diff options
author | Aaron Andersen <aaron@fosslib.net> | 2019-08-25 10:47:40 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-25 10:47:40 -0400 |
commit | 5b8c2295b00a3de9dce0953e5e550b267ca54110 (patch) | |
tree | fc4b6a5a7665411f371d47286f282baf8ca4fe8b /nixos | |
parent | 1859271a4b8dc0e7be43a9f61c6dae3ccae2a3b9 (diff) | |
parent | c3e93d5ad4b72225fbd7c938379058e238ab8779 (diff) | |
download | nixlib-5b8c2295b00a3de9dce0953e5e550b267ca54110.tar nixlib-5b8c2295b00a3de9dce0953e5e550b267ca54110.tar.gz nixlib-5b8c2295b00a3de9dce0953e5e550b267ca54110.tar.bz2 nixlib-5b8c2295b00a3de9dce0953e5e550b267ca54110.tar.lz nixlib-5b8c2295b00a3de9dce0953e5e550b267ca54110.tar.xz nixlib-5b8c2295b00a3de9dce0953e5e550b267ca54110.tar.zst nixlib-5b8c2295b00a3de9dce0953e5e550b267ca54110.zip |
Merge pull request #67393 from c0deaddict/feature/transmission-user-configurable
nixos/transmission: make user configurable
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/torrent/transmission.nix | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/nixos/modules/services/torrent/transmission.nix b/nixos/modules/services/torrent/transmission.nix index f544928fb6b1..a94a471361ef 100644 --- a/nixos/modules/services/torrent/transmission.nix +++ b/nixos/modules/services/torrent/transmission.nix @@ -84,6 +84,18 @@ in The directory where transmission will create files. ''; }; + + user = mkOption { + type = types.str; + default = "transmission"; + description = "User account under which Transmission runs."; + }; + + group = mkOption { + type = types.str; + default = "transmission"; + description = "Group account under which Transmission runs."; + }; }; }; @@ -99,7 +111,8 @@ in serviceConfig.ExecStartPre = preStart; serviceConfig.ExecStart = "${pkgs.transmission}/bin/transmission-daemon -f --port ${toString config.services.transmission.port}"; serviceConfig.ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; - serviceConfig.User = "transmission"; + serviceConfig.User = cfg.user; + serviceConfig.Group = cfg.group; # NOTE: transmission has an internal umask that also must be set (in settings.json) serviceConfig.UMask = "0002"; }; @@ -107,14 +120,19 @@ in # It's useful to have transmission in path, e.g. for remote control environment.systemPackages = [ pkgs.transmission ]; - users.groups.transmission.gid = config.ids.gids.transmission; - users.users.transmission = { - group = "transmission"; - uid = config.ids.uids.transmission; - description = "Transmission BitTorrent user"; - home = homeDir; - createHome = true; - }; + users.users = optionalAttrs (cfg.user == "transmission") (singleton + { name = "transmission"; + group = cfg.group; + uid = config.ids.uids.transmission; + description = "Transmission BitTorrent user"; + home = homeDir; + createHome = true; + }); + + users.groups = optionalAttrs (cfg.group == "transmission") (singleton + { name = "transmission"; + gid = config.ids.gids.transmission; + }); # AppArmor profile security.apparmor.profiles = mkIf apparmor [ |