{ options , lib , config , pkgs , ... }: let cfg = config.services.devalloc; in { options.services.devalloc = { enable = lib.mkEnableOption "Enable the devalloc service"; port = lib.mkOption { type = lib.types.int; default = 3000; description = '' The port on which devalloc will listen for incoming HTTP traffic. ''; }; keep = lib.mkOption { type = lib.types.path; default = "/var/devalloc/keep"; description = "Keep location"; }; depo = lib.mkOption { type = lib.types.path; default = "/var/devalloc/depo"; description = "depo location"; }; package = lib.mkOption { type = lib.types.package; description = "devalloc package to use"; }; }; config = lib.mkIf cfg.enable { systemd.services.devalloc = { path = [ cfg.package pkgs.git ]; wantedBy = [ "multi-user.target" ]; preStart = '' mkdir -p ${cfg.keep} mkdir -p ${cfg.depo} ''; script = '' ${cfg.package}/bin/devalloc ''; description = '' Devalloc ''; serviceConfig = { Environment = [ "PORT=${toString cfg.port}" "AREA=Live" "DEPO=${cfg.depo}" "KEEP=${cfg.keep}" ]; EnvironmentFile="/run/devalloc/env"; KillSignal = "INT"; Type = "simple"; Restart = "on-abort"; RestartSec = "1"; }; }; }; }