-
-
Save cmacrae/219f16c4eb4493f4c006953ad7f04a45 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ config, lib, pkgs, ... }: | |
with lib; | |
let | |
cfg = config.services.netcat; | |
makeService = n: { | |
name = "netcat${toString n}"; | |
value = { | |
enable = true; | |
description = "Netcat ${toString n}"; | |
serviceConfig = { | |
ExecStart = '' | |
${pkgs.netcat}/bin/nc -l ${toString (config.services.netcat.basePort + n)} | |
''; | |
Restart = "on-failure"; | |
}; | |
}; | |
}; | |
in { | |
options = { | |
services.netcat = { | |
enable = mkOption { | |
type = types.bool; | |
default = false; | |
description = "Whether to start some pointless netcat processes"; | |
}; | |
count = mkOption { | |
type = types.int; | |
default = 1; | |
description = "How many pointless netcat processes to start"; | |
}; | |
basePort = mkOption { | |
type = types.int; | |
default = 999; | |
description = "The base port number"; | |
}; | |
}; | |
}; | |
config = mkIf cfg.enable { | |
systemd.user.services = builtins.listToAttrs (map makeService (lib.range 1 cfg.count)); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment