summary refs log tree commit diff
path: root/nixos/modules/services/misc/couchpotato.nix
blob: f5163cf86cf5f09f3331df8eef064b42642b3a1c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{ 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" ];

      serviceConfig = {
        Type = "simple";
        User = "couchpotato";
        Group = "couchpotato";
        StateDirectory = "couchpotato";
        ExecStart = "${pkgs.couchpotato}/bin/couchpotato";
        Restart = "on-failure";
      };
    };

    users.users.couchpotato =
      { group = "couchpotato";
        home = "/var/lib/couchpotato/";
        description = "CouchPotato daemon user";
        uid = config.ids.uids.couchpotato;
      };

    users.groups.couchpotato =
      { gid = config.ids.gids.couchpotato; };
  };
}