at 25.11-pre 1.6 kB view raw
1{ 2 config, 3 pkgs, 4 lib, 5 ... 6}: 7let 8 cfg = config.services.leaps; 9 stateDir = "/var/lib/leaps/"; 10in 11{ 12 options = { 13 services.leaps = { 14 enable = lib.mkEnableOption "leaps, a pair programming service"; 15 port = lib.mkOption { 16 type = lib.types.port; 17 default = 8080; 18 description = "A port where leaps listens for incoming http requests"; 19 }; 20 address = lib.mkOption { 21 default = ""; 22 type = lib.types.str; 23 example = "127.0.0.1"; 24 description = "Hostname or IP-address to listen to. By default it will listen on all interfaces."; 25 }; 26 path = lib.mkOption { 27 default = "/"; 28 type = lib.types.path; 29 description = "Subdirectory used for reverse proxy setups"; 30 }; 31 }; 32 }; 33 34 config = lib.mkIf cfg.enable { 35 users = { 36 users.leaps = { 37 uid = config.ids.uids.leaps; 38 description = "Leaps server user"; 39 group = "leaps"; 40 home = stateDir; 41 createHome = true; 42 }; 43 44 groups.leaps = { 45 gid = config.ids.gids.leaps; 46 }; 47 }; 48 49 systemd.services.leaps = { 50 description = "leaps service"; 51 wantedBy = [ "multi-user.target" ]; 52 after = [ "network.target" ]; 53 54 serviceConfig = { 55 User = "leaps"; 56 Group = "leaps"; 57 Restart = "on-failure"; 58 WorkingDirectory = stateDir; 59 PrivateTmp = true; 60 ExecStart = "${pkgs.leaps}/bin/leaps -path ${toString cfg.path} -address ${cfg.address}:${toString cfg.port}"; 61 }; 62 }; 63 }; 64}