19 Mar 2022 |
bobvanderlinden | ah, exactly. that looks similar to what I would've done if the module-reusing is a bit too much 😅 | 10:37:39 |
@elvishjerricco:matrix.org | I do think fully modularizing it would be nice, but definitely not necessary. I think if it hurts eval time at all it's not worth it | 10:37:41 |
bobvanderlinden | btw, initrdServiceConfig ? is that different from serviceConfig ? | 10:37:53 |
@elvishjerricco:matrix.org | But if not, and the code isn't crazy, then cool | 10:38:02 |
@elvishjerricco:matrix.org | bobvanderlinden: Yes. I couldn't think of a really clean way to have the default path option differ | 10:38:20 |
@elvishjerricco:matrix.org | Because we don't want anything in that by default for initrd | 10:38:29 |
@elvishjerricco:matrix.org | If anyone actually uses path , we'll have no sane choice but to add the whole bin directory for those packages to the initrd because that's the only thing it could mean | 10:39:21 |
@elvishjerricco:matrix.org | So anything in there by default is necessarily excessive | 10:39:44 |
@elvishjerricco:matrix.org | Though I definitely wasn't supposed to put the initrdServices line in that config lol. Supposed to be in the commit that actually adds that stuff | 10:41:33 |
@elvishjerricco:matrix.org | * Though I definitely wasn't supposed to put the initrdServices line in that commit lol. Supposed to be in the commit that actually adds that stuff | 10:41:50 |
bobvanderlinden | ah, I think you refer to:
https://github.com/nixos/nixpkgs/blob/9bc093b30a3ab38f9e5b30a132b08a9fd9b27ade/nixos/lib/systemd-lib.nix#L299
That should refer to a new option config.systemd.path , which for boot/systemd.nix and boot/systemd/user.nix should refer to config.path .
| 10:42:36 |
bobvanderlinden | but I guess that'll force serviceConfig to be a function again with its added complexity 😅 | 10:43:15 |
@elvishjerricco:matrix.org | Yea, so I just... made a mkServiceConfig function that takes an argument for the default path and created serviceConfig and initrdServiceConfig to keep it simple | 10:44:05 |
@elvishjerricco:matrix.org | Not exactly clean | 10:44:09 |
@elvishjerricco:matrix.org | but it'll do the trick | 10:44:12 |
@elvishjerricco:matrix.org | And it's at least very simple | 10:44:22 |
bobvanderlinden | thinking about this more. IT could also do in systemd.nix's config section:
systemd.services.*.environment.PATH = mkDefault "${makeBinPath config.path}:${makeSearchPathOutput "bin" "sbin" config.path}";
with some added fiddlyness to handle *
| 10:46:08 |
@elvishjerricco:matrix.org | Yea the fiddlyness for * is the tricky part. I don't know if there's a correct way to do that | 10:47:18 |
@elvishjerricco:matrix.org | There used to be a hack that worked if you defined the option a second time, but I'm pretty sure that stopped working some time ago | 10:47:38 |
@elvishjerricco:matrix.org | and I'm pretty sure it was never intended to work | 10:47:48 |
@janne.hess:helsinki-systems.de | In reply to @elvishjerricco:matrix.org Yea the fiddlyness for * is the tricky part. I don't know if there's a correct way to do that You can iterate over the attrNames and generate a mkMerge | 10:50:56 |
@janne.hess:helsinki-systems.de | * You can iterate over the attrNames and map them to a mkMerge | 10:51:30 |
@elvishjerricco:matrix.org | Janne Heß: No you can't. You can do that to define a different attrsOf in terms of a different attrsOf . But you can't do foo = mapAttrs (...) config.foo because then foo is infinite | 10:52:39 |
@janne.hess:helsinki-systems.de | Oh I see your point now. Pretty sure there was a way somehow that we are using downstream. Maybe Andreas Schrägle remembers? | 10:53:48 |
@elvishjerricco:matrix.org | I've seen this before:
# foo.nix
{
options.foo = mkOption { type = attrsOf (submodule <module>); };
}
#bar.nix
{
options.foo = mkOption { type attrsOf (submodule <more module>); };
}
But I'm pretty sure this wasn't intended to work, and doesn't work anymore (last I checked, like a year ago)
| 10:55:25 |
@elvishjerricco:matrix.org | * I've seen this before:
# foo.nix
{
options.foo = mkOption { type = attrsOf (submodule <module>); };
}
#bar.nix
{
options.foo = mkOption { type = attrsOf (submodule <more module>); };
}
But I'm pretty sure this wasn't intended to work, and doesn't work anymore (last I checked, like a year ago)
| 10:55:44 |
@janne.hess:helsinki-systems.de | That should work fine. There's typesMergable for that so that should do it | 10:56:20 |
@elvishjerricco:matrix.org | typesMergable? | 10:56:33 |
@janne.hess:helsinki-systems.de | Its somewhere in types.nix. I might have an example but I'm only on mobile | 10:56:55 |
bobvanderlinden | It seems we do something similar for timer's startAt:
https://github.com/nixos/nixpkgs/blob/9bc093b30a3ab38f9e5b30a132b08a9fd9b27ade/nixos/modules/system/boot/systemd.nix#L966-L972 | 10:57:04 |