From 17866268eff538a242e3b4f6ca06b02a1a1ac032 Mon Sep 17 00:00:00 2001 From: rasmus-kirk Date: Thu, 7 Mar 2024 09:54:17 +0100 Subject: [PATCH] Added tools to manage hard linking --- nixarr/nixarr.nix | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/nixarr/nixarr.nix b/nixarr/nixarr.nix index 1519abe..87799af 100644 --- a/nixarr/nixarr.nix +++ b/nixarr/nixarr.nix @@ -6,6 +6,14 @@ }: with lib; let cfg = config.nixarr; + list-unlinked = pkgs.writeShellApplication { + name = "list-unlinked"; + runtimeInputs = with pkgs; [util-linux]; + text = '' + find "$1" -type f -links 1 -exec du -h {} + | sort -h + ''; + }; + in { imports = [ ./jellyfin @@ -56,6 +64,15 @@ in { ''; }; + mediaUsers = mkOption { + type = with types; listOf str; + default = []; + example = [ "user" ]; + description = '' + Extra users to add to the media group. + ''; + }; + mediaDir = mkOption { type = types.path; default = "/data/media"; @@ -147,7 +164,7 @@ in { ]; users.groups = { - media = {}; + media.members = cfg.mediaUsers; streamer = {}; torrenter = {}; }; @@ -180,6 +197,11 @@ in { "d '${cfg.mediaDir}/torrents/readarr' 0755 torrenter media - -" ]; + environment.systemPackages = with pkgs; [ + jdupes + list-unlinked + ]; + # TODO: wtf to do about openports vpnnamespaces.wg = { enable = cfg.vpn.enable ;