diff options
Diffstat (limited to 'modules/containers/pinchflat')
-rw-r--r-- | modules/containers/pinchflat/default.nix | 66 |
1 files changed, 55 insertions, 11 deletions
diff --git a/modules/containers/pinchflat/default.nix b/modules/containers/pinchflat/default.nix index 6f9c825..6b5df23 100644 --- a/modules/containers/pinchflat/default.nix +++ b/modules/containers/pinchflat/default.nix @@ -1,18 +1,62 @@ -{ ... }: +{ + config, + lib, + ... +}: +with lib; let - directory = "/opt/pinchflat"; + service = "pinchflat"; + cfg = config.modules.containers.${service}; in { - systemd.tmpfiles.rules = builtins.map (x: "d ${x} 0755 share share - -") [ directory ]; + options.modules.containers.${service} = { + enable = mkEnableOption service; + user = mkOption { + default = "share"; + type = types.str; + }; + group = mkOption { + default = "share"; + type = types.str; + }; + port = mkOption { + default = 8945; + type = types.int; + }; + url = mkOption { + default = null; + type = types.str; + }; + mediaDir = mkOption { + type = types.str; + }; + configDir = mkOption { + default = "/opt/${service}"; + type = types.str; + }; + }; + + config = mkIf cfg.enable { + users.users.${cfg.user} = { + isSystemUser = true; + group = cfg.group; + }; - virtualisation.oci-containers.containers.pinchflat = { - image = "keglin/pinchflat:latest"; - autoStart = true; - ports = [ "8945:8945" ]; - volumes = [ - "${directory}:/config" - "/tank/media/yt:/downloads" + users.groups.${cfg.group} = { }; + + systemd.tmpfiles.rules = builtins.map (f: "d ${f} 0755 ${cfg.user} ${cfg.group} - -") [ + cfg.configDir ]; - environment.TZ = "America/Detroit"; + + virtualisation.oci-containers.containers.${service} = { + image = "keglin/pinchflat:latest"; + autoStart = true; + ports = [ "${builtins.toString cfg.port}:${builtins.toString cfg.port}" ]; + volumes = [ + "${cfg.configDir}:/config" + "${cfg.mediaDir}:/downloads" + ]; + environment.TZ = "America/Detroit"; + }; }; } |