diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix index 6ab4b24a349..de69ada5bfe 100644 --- a/nixos/modules/misc/ids.nix +++ b/nixos/modules/misc/ids.nix @@ -282,6 +282,7 @@ infinoted = 264; keystone = 265; glance = 266; + couchpotato = 267; # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399! @@ -534,6 +535,7 @@ infinoted = 264; keystone = 265; glance = 266; + couchpotato = 267; # When adding a gid, make sure it doesn't match an existing # uid. Users and groups with the same name should have equal diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index f76852793d4..395d2ecb93c 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -242,6 +242,7 @@ ./services/misc/cpuminer-cryptonight.nix ./services/misc/cgminer.nix ./services/misc/confd.nix + ./services/misc/couchpotato.nix ./services/misc/devmon.nix ./services/misc/dictd.nix ./services/misc/dysnomia.nix diff --git a/nixos/modules/services/misc/couchpotato.nix b/nixos/modules/services/misc/couchpotato.nix new file mode 100644 index 00000000000..49648762235 --- /dev/null +++ b/nixos/modules/services/misc/couchpotato.nix @@ -0,0 +1,50 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.services.couchpotato; + +in +{ + options = { + services.couchpotato = { + enable = mkEnableOption "CouchPotato Server"; + }; + }; + + config = mkIf cfg.enable { + systemd.services.couchpotato = { + description = "CouchPotato Server"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + + preStart = '' + mkdir -p /var/lib/couchpotato + chown -R couchpotato:couchpotato /var/lib/couchpotato + ''; + + serviceConfig = { + Type = "simple"; + User = "couchpotato"; + Group = "couchpotato"; + PermissionsStartOnly = "true"; + ExecStart = "${pkgs.couchpotato}/bin/couchpotato"; + Restart = "on-failure"; + }; + }; + + users.extraUsers = singleton + { name = "couchpotato"; + group = "couchpotato"; + home = "/var/lib/couchpotato/"; + description = "CouchPotato daemon user"; + uid = config.ids.uids.couchpotato; + }; + + users.extraGroups = singleton + { name = "couchpotato"; + gid = config.ids.gids.couchpotato; + }; + }; +}