Skip to content
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

mkRenamedOptionModule doesn't work in submodules #96006

Open
jD91mZM2 opened this issue Aug 22, 2020 · 9 comments · Fixed by #97023
Open

mkRenamedOptionModule doesn't work in submodules #96006

jD91mZM2 opened this issue Aug 22, 2020 · 9 comments · Fixed by #97023
Assignees
Labels
6.topic: module system About "NixOS" module system internals

Comments

@jD91mZM2
Copy link
Member

jD91mZM2 commented Aug 22, 2020

Describe the bug

I'm working on a home-manager module, where I now want to rename

programs.firefox.profiles.<name>.privacy.enableSettings

to

programs.firefox.profiles.<name>.privacy.settings.enable

The problem is, that list of submodules.

I tried to add

imports = [
  (mkRenamedOptionModule
    [ "privacy" "enableSettings" ]
    [ "privacy" "settings" "enable" ])
];

to the programs.firefox.profiles.<name> module, but that causes the error

warning: Git tree '/home/user/dotfiles' is dirty
warning: Git tree '/home/user/dotfiles' is dirty
error: --- ThrownError ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ nix-build
The option `programs.firefox.profiles.main.warnings' defined in `/home/user/dotfiles/nur-packages/hm-modules/programs/firefox-privacy.nix' does not exist.
(use '--show-trace' to show detailed location information)

There are 135 unread and relevant news items.
Read them by running the command 'home-manager news'.

because each submodule doesn't have a separate warning system.

Obviously doing

imports = [
  (mkRenamedOptionModule
    [ "programs" "firefox" "profiles" "privacy" "enableSettings" ]
    [ "programs" "firefox" "profiles" "privacy" "settings" "enable" ])
];

doesn't work either, because it's missing the profile name.

To Reproduce

Try to rename a suboption in an option of type types.attrsOf (types.submodule ({ config, ... }: {.

The error I got can be seen on my nur-packages' GitLab (on tag nixpkgs-issue-96006 which I created for this occasion).

Expected behavior

Unclear. I guess warnings would be propagated upwards, somehow, using magic?

Metadata
Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

  • system: "x86_64-linux"
  • host os: Linux 5.7.16, NixOS, 20.09.20200821.4a87da1 (Nightingale)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.4pre20200721_ff314f1
  • channels(user): ""
  • channels(root): "nixos-20.09pre237781.32b46dd897a"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos
@jD91mZM2 jD91mZM2 added 0.kind: bug Something is broken 6.topic: module system About "NixOS" module system internals and removed 0.kind: bug Something is broken labels Aug 22, 2020
@aanderse
Copy link
Member

cc @infinisil

@infinisil
Copy link
Member

I've got a plan for fixing this! Will work on this soon probably :)

@infinisil
Copy link
Member

See PR above ^ :)

@chkno
Copy link
Member

chkno commented Feb 5, 2021

This was marked resolved with #97023 , but #97023 was reverted in #107159

@chkno chkno reopened this Feb 5, 2021
@stale
Copy link

stale bot commented Aug 4, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 4, 2021
@infinisil
Copy link
Member

Still needed!

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 4, 2021
@stale
Copy link

stale bot commented Apr 29, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 29, 2022
@infinisil
Copy link
Member

.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 30, 2022
@ncfavier
Copy link
Member

ncfavier commented May 18, 2022

For the record, this would be useful in https://github.com/nix-community/home-manager/blob/master/modules/misc/xdg-desktop-entries.nix where assertions are currently extracted from the submodules and shoved into top-level assertions.

I wonder if the right solution would be to desugar mkRenamedOptionModule [ "xdg" "desktopEntries" "<name>" "extraConfig" ] into the right thing. That way errors could show the full option path.

This probably overlaps with the more general discussion around submodule syntax, e.g. #146882 (comment)

Maroka-chan added a commit to Maroka-chan/VPN-Confinement that referenced this issue Sep 8, 2024
`mkRenamedOptionModule` has been used to throw warnings if the old
option names are used, while still allowing for the old names to work.
A warning is only thrown for 'vpnnamespaces' as the warnings apparently
do not work for submodules. This might have something to do with
NixOS/nixpkgs#96006
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: module system About "NixOS" module system internals
Projects
None yet
5 participants