From e5f353d5cdaac4a1ad759c53e9358c0880398822 Mon Sep 17 00:00:00 2001 From: Tristan Helmich Date: Mon, 16 Jan 2017 12:53:53 +0100 Subject: couchpotato module: init --- nixos/modules/services/misc/couchpotato.nix | 50 +++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 nixos/modules/services/misc/couchpotato.nix (limited to 'nixos/modules/services/misc') diff --git a/nixos/modules/services/misc/couchpotato.nix b/nixos/modules/services/misc/couchpotato.nix new file mode 100644 index 000000000000..496487622351 --- /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; + }; + }; +} -- cgit 1.4.1