disnix
disnix copied to clipboard
Defining services is punishingly complicated
Not sure whether to file that against disnix
or dysnomia
. Also I should warn in advance that I'm only one week into the Nix world and clearly not Nix-minded enough yet.
If one wants to use Disnix to run a process that requires even a single command line argument, e.g. iperf -s
, one must jump through so many hoops it's not even funny.
If I understood correctly, launching it without the -s would've required just iperf = { name = "iperf"; pkg = pkgs.iperf; type = "process"; };
. But in order to add that little -s
one must:
0. Specify type = "wrapper";
.
- Write a wrapper for it (your way seems to be: create a directory, write a wrapper, reuse a templating Makefile, compile (!) it)
- Override a derivation and build it with the wrapper baked in (I can't even grasp how at the moment).
Am I wrong? Can the process be streamlined somehow? At the moment it's easier to overrideAttrs on the package and patch the sources to imply that '-s' than to make a wrapper.
Ideally I'd like to specify type = "process"; args = ["-s"];
for this trivial operation and something like
baseDir = "/var/lib/service";
type = modularWrapper {
collectGarbage = ''
rm -r $baseDir
'';
systemdUnit = ''
[Unit]
After=disnix.service
[Install]
WantedBy=dysnomia.target
[Service]
Environment=PATH=${dysnomia.systemdPath}
Type=simple;
'';
};
for more complex ones. Is this possible?