-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tree-wide: fix more warning related to loaOf deprecation #77501
Conversation
Some options do not use
|
Not all modules use name attribute as the name of the submodule, for example, environment.etc uses target. We will need to maintain a list of exceptions.
Improved the warning message. With the last commit cherry-picked my config warns:
cc @worldofpeace @rnhmjoj @petabyteboy |
I inspected the nixos/ directory and saw the following "containers.<name>.bindMounts" = "mountPoint"; # nested inside containers attrsOf so simple attrNames.${option} will not work
"programs.ssh.knownHosts" = "hostNames"; # hostNames is actually a list so we would need to handle it only when singleton
"fileSystems" = "mountPoint";
"boot.specialFileSystems" = "mountPoint";
"services.znapzend.zetup" = "dataset";
"services.znapzend.zetup.<dataset>.destinations" = "label"; # nested inside services.znapzend.zetup loaOf so simple attrNames.${option} will not work
"services.geoclue2.appConfig" = "desktopID"; Not sure if it is worth adding them to the list. |
home-manager also suffers from this but the options are apparently prefixed by something like "<home-manager-prefix>.programs.ssh.matchBlocks" = "host"; # https://github.com/rycee/home-manager/blob/e8dbc3561373b68d12decb3c0d7c1ba245f138f7/modules/programs/ssh.nix#L265
"<home-manager-prefix>.home.file" = "target"; # https://github.com/rycee/home-manager/blob/0e9b7aab3c6c27bf020402e0e2ef20b65c040552/modules/files.nix#L33
"<home-manager-prefix>.xdg.configFile" = "target"; # https://github.com/rycee/home-manager/blob/54de0e1d79a1370e57a8f23bef89f99f9b92ab67/modules/misc/xdg.nix#L41
"<home-manager-prefix>.xdg.dataFile" = "target"; # https://github.com/rycee/home-manager/blob/54de0e1d79a1370e57a8f23bef89f99f9b92ab67/modules/misc/xdg.nix#L58 cc @rycee |
lib/types.nix
Outdated
@@ -340,18 +340,22 @@ rec { | |||
let | |||
padWidth = stringLength (toString (length def.value)); | |||
unnamed = i: unnamedPrefix + fixedWidthNumber padWidth i; | |||
nameAttrs = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat! I didn't think about this.
Why not? It won't hurt.
rycee mentioned they were using |
The matching logic will become more complicated than just
IMHO it would make sense to have home-manager follow the same idioms as NixOS module tree – their options are equivalent to |
The |
Now we suggest correct names for all options in Nixpkgs and also home-manager at the time of writing.
Now we suggest correct names for all options in Nixpkgs and also home-manager at the time of writing. But damn it is ugly. To test, you can use the following {...}: {
containers."foo.boar".bindMounts = [{ mountPoint = "foo"; }];
programs.ssh.knownHosts = [
{ hostNames = ["foo"]; }
{ hostNames = [ "bar" "baz"]; }
];
fileSystems = [
{ mountPoint = "/"; }
{ mountPoint = "/boot"; }
];
boot.initrd.luks.devices = [ { name = "root"; } ];
} and run |
It's complicated but it's not that ugly. I think it's worth it considering it will make it easy for the users to figure out what's going on. Also this code will be removed soon enough (hopefully in 20.09). |
{ path = [ "home-manager" "users" anyString "programs" "ssh" "matchBlocks" ]; | ||
name = "host"; # https://github.com/rycee/home-manager/blob/e8dbc3561373b68d12decb3c0d7c1ba245f138f7/modules/programs/ssh.nix#L265 | ||
} | ||
{ path = [ "home-manager" "users" anyString "home" "file" ]; | ||
name = "target"; # https://github.com/rycee/home-manager/blob/0e9b7aab3c6c27bf020402e0e2ef20b65c040552/modules/files.nix#L33 | ||
} | ||
{ path = [ "home-manager" "users" anyString "xdg" "configFile" ]; | ||
name = "target"; # https://github.com/rycee/home-manager/blob/54de0e1d79a1370e57a8f23bef89f99f9b92ab67/modules/misc/xdg.nix#L41 | ||
} | ||
{ path = [ "home-manager" "users" anyString "xdg" "dataFile" ]; | ||
name = "target"; # https://github.com/rycee/home-manager/blob/54de0e1d79a1370e57a8f23bef89f99f9b92ab67/modules/misc/xdg.nix#L58 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Home-manager isn't a nixos project, and while it would be very nice of us to try to not cause confusion over there it isn't our responsibility to have this in lib/types.nix
. It just seems problematic, even if it isn't a difficult thing to do.
That would be a breaking change then, right? |
Yes. The options will be changed to
Given that our maintenance periods overlap only in immediately successive releases, there will be 6 months to fix this warning on stable and 2 months on unstable. I would call that sufficient. |
Let's just merge this as a stop gap, we can improve it later. |
No problem with that 👍 |
cc #77189