1 Feb 2024 |
infinisil | Currying function arguments :) | 20:22:12 |
guangtao | that makes sense; set all attrts of default to having order. | 20:23:54 |
@djacu:matrix.org | What is this deep magic!? It works | 20:26:24 |
@djacu:matrix.org | Oh did you just apply mkDefault to all the values set in default ?? | 20:27:02 |
infinisil | Indeed :) | 20:27:18 |
@djacu:matrix.org | Cool man. Thanks!
What is really nice is that I can use ({...}: {user = {b = 3;};}) and it overrides. Which provides a nice API for end users (i.e. not having to use mkForce).
So this partially makes sense. But why didn't having a user config with ({...}: {user = {b = lib.mkForce 3;};}) work before? It should have a really high priority.
Without your fix, does the config.default have... no priority? What was the failure mechanism before the fix?
| 20:31:17 |
infinisil | Before, config.user and config.default had the same priority. The conflict happened one level above | 20:32:25 |
infinisil | You could've fixed this with { user = lib.mkForce { b = 3; }; } | 20:32:49 |
infinisil | So putting the mkForce also on the same level where the conflict happened | 20:33:01 |
@djacu:matrix.org | In reply to @infinisil:matrix.org Before, config.user and config.default had the same priority. The conflict happened one level above I tried that! You can see it is the last thing under the # NONE OF THESE WORK; conflicting definitions section. line 56 | 20:34:06 |
infinisil | Oh um.... | 20:34:36 |
infinisil | Ahh! The problem is that config.user doesn't contain any mkForce anymore. It's an evaluated option, so all of those modifiers are gone | 20:39:01 |
infinisil | So the input to user is lib.mkForce { b = 3; } , but it outputs just { b = 3; } , no conflict there, since there's just one definition | 20:39:48 |
infinisil | Similarly the input to defaults is just that one default = { a = 1; b = 2; } (which is actually defaults = lib.mkOptionDefault { ... } but that's not relevant here), it outputs { a = 1; b = 2; } | 20:40:38 |
infinisil | Finally, you have effectively
{
out = lib.mkMerge [
config.default
config.user
];
}
| 20:41:10 |
infinisil | * Finally, you have effectively
{
out = lib.mkMerge [
{ a = 1; b = 2; }
{ b = 3; }
];
}
Both of which are without priority, so it recurses into the attrs and conflicts because two b s
| 20:41:59 |
infinisil | Instead if you want to actually copy the definitions from one option to another, the mkAlias function suite is what you need: https://github.com/NixOS/nixpkgs/blob/master/lib/modules.nix#L1039-L1073 | 20:43:19 |
infinisil | * Instead if you want to actually copy the definitions from one option to another, the mkAlias function suite is what you need: https://github.com/NixOS/nixpkgs/blob/a0d3f10c751b6b2642b44d327470f68ad6bc7952/lib/modules.nix#L1039-L1073 | 20:43:32 |
2 Feb 2024 |
@djacu:matrix.org | Ah that's a pretty sweet suite. Just so I understanding you completely, you're just mentioning this for other use cases. Not suggesting that it could be used in the example I provided? | 00:45:43 |
infinisil | That alias stuff is pretty messy, I wouldn't recommend that myself, but sometimes it is needed. In this case the simpler mapAttrs (name: mkDefault) works though | 02:53:43 |
| ibizaman joined the room. | 05:25:20 |
| sarcasticadmin joined the room. | 20:01:14 |
5 Feb 2024 |
| hexa joined the room. | 01:34:42 |
8 Feb 2024 |
| zrsk joined the room. | 10:38:02 |
15 Feb 2024 |
| a-kenji joined the room. | 19:15:14 |
16 Feb 2024 |
| @qyriad:matrix.org joined the room. | 14:56:15 |
| mr-qubo joined the room. | 14:59:24 |
mr-qubo | I recently stumbled upon similar issue when working on home-manager. https://discourse.nixos.org/t/is-it-possible-to-define-systemd-services-in-a-submodule/39538/5
The idea is that enabling https://nix-community.github.io/home-manager/options.xhtml#opt-programs.bash.enableCompletion should set environment.pathsToLink = [ "/share/bash-completion" ]; .
I think that module system is missing an option to pass config options recursively up to all ancestors.
| 15:06:01 |
mr-qubo | My idea is that nixos config could have a property extraNixosChildConfig and in home-manager bash module I could set _recurseAncestors = { extraNixosChildConfig = { environment.pathsToLink = [ ... ]; }; } . | 15:07:22 |
mr-qubo | wdyt? | 15:07:26 |