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

bug: rebuild fails after home manager update #865

Open
awwpotato opened this issue Feb 16, 2025 · 18 comments · May be fixed by #866
Open

bug: rebuild fails after home manager update #865

awwpotato opened this issue Feb 16, 2025 · 18 comments · May be fixed by #866

Comments

@awwpotato
Copy link
Contributor

this commit in home-manager nix-community/home-manager@eb44c16 breaks rebuilding on systems using the home-manager nixos module.

error:
       … while checking flake output 'nixosConfigurations'
         at /nix/store/7chl1krhy0nwq6zbxl5932wikhrswsi0-source/flake.nix:14:7:
           13|     {
           14|       nixosConfigurations = mapAttrs mkNixosConf {
             |       ^
           15|         enceladus.modules = [

       … while checking the NixOS configuration 'nixosConfigurations.enceladus'

       … while calling the 'head' builtin
         at /nix/store/brjzz8wv5k09bq0yrvhc1j4hd8677k21-source/lib/attrsets.nix:1574:11:
         1573|         || pred here (elemAt values 1) (head values) then
         1574|           head values
             |           ^
         1575|         else

       … while evaluating the option `system.build.toplevel':

       … while evaluating definitions from `/nix/store/brjzz8wv5k09bq0yrvhc1j4hd8677k21-source/nixos/modules/system/activation/top-level.nix':

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error:
       Failed assertions:
       - potato profile: `nixpkgs` options are disabled when `home-manager.useGlobalPkgs` is enabled.
@awwpotato
Copy link
Contributor Author

awwpotato commented Feb 16, 2025

it seems like gnome-text-editor is what's causing the issue https://github.com/danth/stylix/blob/master/modules/gnome-text-editor/common.nix#L17
cc: @brckd

@danth
Copy link
Owner

danth commented Feb 16, 2025

There are a few other modules using nixpkgs overlays too.

@brckd
Copy link
Contributor

brckd commented Feb 16, 2025

Yea, we will have to change the functionality of all existing overlays. The problem seems to be that using useGlobalPkgs makes Home Manager use the system packages which it can't override. This should easily be fixable by making Stylix' Home Manager integration disable Home Manager's overrides when that option is set.

@brckd
Copy link
Contributor

brckd commented Feb 16, 2025

@awwpotato A temporary fix could be for you to disable all Home Manager modules that create such overrides.

@panchoh
Copy link
Contributor

panchoh commented Feb 16, 2025

@awwpotato A temporary fix could be for you to disable all Home Manager modules that create such overrides.

Not just disabling them, I’m afraid. I tried setting explicitly targets.gnome-text-editor.enable = lib.mkForce false;, but the assertion kept failing.

My workaround is to actualy prune the three modules that touch overlays in Stylix in a fork, and point to that fork.

I thought of using disabledModules for that, but I’m not sure of what to use instead of modulesPath, which I think will point to nixpkgs (and not Stylix).

EDIT: ah, but in the Stylix docs there is a sample which I can use, muahaha:
disabledModules = [ "${flake.inputs.stylix}/modules/<some-module>/nixos.nix" ];

@Doosty
Copy link

Doosty commented Feb 16, 2025

Even disabling modules doesnt seem to work for me

  imports = [
    inputs.stylix.nixosModules.stylix
  ];
  disabledModules = [
    # disabled all these paths in both hm and nixos module, maybe this isnt the right one when inside hm?
    "${inputs.stylix}/modules/gnome-text-editor/common.nix"
    "${inputs.stylix}/modules/gnome-text-editor/hm.nix"
    "${inputs.stylix}/modules/gnome-text-editor/nixos.nix"
    "${inputs.stylix}/modules/gnome-text-editor/testbed.nix"
  ];
❯ nix eval .#nixosConfigurations.nixos-steamdeck-01.config.home-manager.users.my-user.nixpkgs
{ config = null; overlays = [ «lambda @ /nix/store/88ksghk276aj0ms3ny9q9a993w9cvpfm-source/modules/gnome-text-editor/common.nix:18:12» ]; }
# overlay is still there

❯ nixos-rebuild build --flake .#nixos-steamdeck-01 --show-trace
       error:
       Failed assertions:
       - my-user profile: `nixpkgs` options are disabled when `home-manager.useGlobalPkgs` is enabled.

@panchoh
Copy link
Contributor

panchoh commented Feb 16, 2025

Same here, @Doosty. I had to actually remove the aforementioned gnome-text-editor subdir (and same treatment to the other two modules which refer to nixpkgs.overlays, namely gnome and nix-logos).

@awwpotato
Copy link
Contributor Author

awwpotato commented Feb 16, 2025

There are a few other modules using nixpkgs overlays too.

Gnome text editor is the only one that applies the overlay to home manager, all the other ones are only for nixos. The temporary fix is to fork stylix and delete the Gnome text editor hm module.

@Doosty
Copy link

Doosty commented Feb 16, 2025

Using home-manager from yesterday 2025-02-15 before the useGlobalPkgs assertion commit also works:

# flake.nix
inputs.home-manager = {
  url = "github:nix-community/home-manager/45c07fcf7d28b5fb3ee189c260dee0a2e4d14317";
  inputs.nixpkgs.follows = "nixpkgs";
};

@brckd
Copy link
Contributor

brckd commented Feb 16, 2025

I'd also appreciate if someone can test nix-community/home-manager#6466, which could be another potential temporary fix.

# flake.nix
inputs.home-manager.url = "github:brckd/home-manager/nixpkgs-disabled/warn-instead-of-error";

@brckd
Copy link
Contributor

brckd commented Feb 16, 2025

There are a few other modules using nixpkgs overlays too.

Gnome text editor is the only one that applies the overlay to home manager, all the other ones are only for nixos.

Huh, that's weird. I thought that overrides on home manager and nixos had the same effect, so I included them in both. They should both write to /run/current-system/sw/share/gnome-text-editor.

I completely overlooked that home manager configurations often don't have their own nixpkgs instance. I am of course sorry for the inconvenience my uninformed choice caused.

The temporary fix is to fork stylix and delete the Gnome text editor hm module.

For simplicity, I made one. Haven't tested it though.

# flake.nix
inputs.stylix.url = "github:brckd/stylix/gnome-text-editor/remove-home-module";

nikitawootten added a commit to nikitawootten/infra that referenced this issue Feb 16, 2025
- Workaround for danth/stylix#865
- Use home-manager's git module to configure signing
- Disable zellij's bash integration (was changed to enabled by default in a home-manager update)
- Remove "permitted insecure packages" after sonarr update
- Disable Jellyseerr for now
- Dionysus change to color scheme with more contrast
brckd added a commit to brckd/stylix that referenced this issue Feb 16, 2025
Adds the `stylix.overlays.enable` option which can be disabled to
remove all overlays. This is to handle scenarios where overlays cannot
be set, because the configuration doesn't handle its own nixpkgs
instance. Fixes danth#865.
@brckd brckd linked a pull request Feb 16, 2025 that will close this issue
@brckd
Copy link
Contributor

brckd commented Feb 16, 2025

@awwpotato A temporary fix could be for you to disable all Home Manager modules that create such overrides.

Not just disabling them, I’m afraid. I tried setting explicitly targets.gnome-text-editor.enable = lib.mkForce false;, but the assertion kept failing.

Does anyone know why? Judging from the code this shouldn't be the case.

@awwpotato
Copy link
Contributor Author

awwpotato commented Feb 16, 2025

@awwpotato A temporary fix could be for you to disable all Home Manager modules that create such overrides.

Not just disabling them, I’m afraid. I tried setting explicitly targets.gnome-text-editor.enable = lib.mkForce false;, but the assertion kept failing.

Does anyone know why? Judging from the code this shouldn't be the case.

$ nix repl --expr 'import <nixpkgs>{}'
nix-repl> lib.mkIf false "test"
{
  _type = "if";
  condition = false;
  content = "test";
}
nix-repl> builtins.typeOf (lib.mkIf false "test")
"set"

edit: seems like lib.optionalDrvAttr would give what you expected

nix-repl> lib.optionalDrvAttr false { thing = true; }
null

@awwpotato
Copy link
Contributor Author

Not just disabling them, I’m afraid. I tried setting explicitly targets.gnome-text-editor.enable = lib.mkForce false;, but the assertion kept failing.

apply this inside my home manager config fixes it, not sure why it doesn't work for @panchoh

@sodiboo
Copy link
Contributor

sodiboo commented Feb 17, 2025

There are a lot of workarounds suggested in this thread, but i'd like to point out that instead of trying to workaround the root of the issue (which involves somewhat nasty things like forking stylix, pinning home-manager, or cherrypicking modules to disable), you can just... forcibly satisfy the assertion.

{lib, ...}: {
    nixpkgs.overlays = lib.mkForce null;
}

Since the option never did anything anyways (in configs where this issue occurs), this won't have any affect on your system. It seems much cleaner than most other proposed workarounds.


Literally less than 20 minutes after i posted this, a home-manager-side workaround was merged. The snippet i showed is still a neat way to silence the warning that is now produced.

@niksingh710
Copy link

rn i see overlays being used under nixos-icons,gnome-text-editor,gnome/nixos, these all are nixos dependent stuff and imo their overlays can be moved up to nixosModules instead of being a home-manager module part.

Ig this should resolve this conflict and useGlobalPkgs should let the access of the overlay to home-manager module also.

and in future if an overlay is needed for any package specific to home-manager only not nixos dependent then overrides can be utilised for that.

@brckd
Copy link
Contributor

brckd commented Feb 19, 2025

rn i see overlays being used under nixos-icons,gnome-text-editor,gnome/nixos, these all are nixos dependent stuff and imo their overlays can be moved up to nixosModules instead of being a home-manager module part.

Ig this should resolve this conflict and useGlobalPkgs should let the access of the overlay to home-manager module also.

You're right, the home manager overrides aren't needed most of the time. However, they are needed when one is using Home Manager without useGlobalPkgs and installing a package with home.packages.

Of course, they could just move that package declaration to NixOS. But then they would lose out on the advantage that each user has its own package instance with different overrides. This would be required if say, one user wants to use the gnome-text-editor override and one doesn't. I haven't tested that usecase before, but it would be reasonable from my understanding of user packages.

I'm open to discussion about whether this admittedly niche use case is worth the potential conflicts with NixOS. #866 would automatically disable the duplicate overrides most of the times it's necessary and give the user the option to manually do so.

@awwpotato
Copy link
Contributor Author

Of course, they could just move that package declaration to NixOS. But then they would lose out on the advantage that each user has its own package instance with different overrides.

We should keep the home manager overlay for configs with useGlobalPkgs disabled and standalone home manager configs. It would be undesirable behavior for a package to have stylix theme applied on nixos but not on a standalone home manager config, which is what would happen to my config if this change was made.

rn i see overlays being used under nixos-icons,gnome-text-editor,gnome/nixos, these all are nixos dependent stuff and imo their overlays can be moved up to nixosModules instead of being a home-manager module part.

I don't see how gnome-text-editor is "nixos dependent." There's no reason it can't be used in a home manager standalone setup or enabled for one user but not another in the home manager nixos module as @brckd said.

brckd added a commit to brckd/stylix that referenced this issue Feb 24, 2025
Adds the `stylix.overlays.enable` option which can be disabled to
remove all overlays. This is to handle scenarios where overlays cannot
be set, because the configuration doesn't handle its own nixpkgs
instance. Fixes danth#865.
brckd added a commit to brckd/stylix that referenced this issue Feb 24, 2025
Adds the `stylix.overlays.enable` option which can be disabled to
remove all overlays. This is to handle scenarios where overlays cannot
be set, because the configuration doesn't handle its own nixpkgs
instance. Fixes danth#865.
brckd added a commit to brckd/stylix that referenced this issue Feb 25, 2025
Adds the `stylix.overlays.enable` option which can be disabled to
remove all overlays. This is to handle scenarios where overlays cannot
be set, because the configuration doesn't handle its own nixpkgs
instance. Fixes danth#865.
brckd added a commit to brckd/stylix that referenced this issue Feb 25, 2025
Adds the `stylix.overlays.enable` option which can be disabled to
remove all overlays. This is to handle scenarios where overlays cannot
be set, because the configuration doesn't handle its own nixpkgs
instance. Fixes danth#865.
brckd added a commit to brckd/stylix that referenced this issue Feb 25, 2025
Adds the `stylix.overlays.enable` option which can be disabled to
remove all overlays. This is to handle scenarios where overlays cannot
be set, because the configuration doesn't handle its own nixpkgs
instance. Fixes danth#865.
NovaViper added a commit to NovaViper/NixConfig that referenced this issue Mar 1, 2025
- Add iwd support, switched over to that
- Add back automatic location detection, using beacondb
- Silence nixpkgs.overlays warning with stylix, danth/stylix#865
- Update settings for dracula-tmux, use more nerdfonts
- Remove rio settings in theme module, included in upstream stylix
- Add back wallpaper to lockscreen and make it show all buttons
- Make tmux only launch when not in SSH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants