about summary refs log tree commit diff
path: root/nixos/modules/services/misc
diff options
context:
space:
mode:
authorTristan Helmich <tristan.helmich@gmail.com>2017-01-16 12:53:53 +0100
committerRobin Gloster <mail@glob.in>2017-01-16 12:54:43 +0100
commite5f353d5cdaac4a1ad759c53e9358c0880398822 (patch)
treee2f4fbb85006507b10797a2720ba5e80099b2a13 /nixos/modules/services/misc
parentef0f4e70927bfcf00ed53c2015f84a3c862c320b (diff)
downloadnixlib-e5f353d5cdaac4a1ad759c53e9358c0880398822.tar
nixlib-e5f353d5cdaac4a1ad759c53e9358c0880398822.tar.gz
nixlib-e5f353d5cdaac4a1ad759c53e9358c0880398822.tar.bz2
nixlib-e5f353d5cdaac4a1ad759c53e9358c0880398822.tar.lz
nixlib-e5f353d5cdaac4a1ad759c53e9358c0880398822.tar.xz
nixlib-e5f353d5cdaac4a1ad759c53e9358c0880398822.tar.zst
nixlib-e5f353d5cdaac4a1ad759c53e9358c0880398822.zip
couchpotato module: init
Diffstat (limited to 'nixos/modules/services/misc')
-rw-r--r--nixos/modules/services/misc/couchpotato.nix50
1 files changed, 50 insertions, 0 deletions
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;
+      };
+  };
+}