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

Switching NixOS config does not apply home-manager together #680

Closed
kachick opened this issue Jul 15, 2024 · 13 comments · Fixed by #788 or #796
Closed

Switching NixOS config does not apply home-manager together #680

kachick opened this issue Jul 15, 2024 · 13 comments · Fixed by #788 or #796
Labels
bug Something isn't working

Comments

@kachick
Copy link
Owner

kachick commented Jul 15, 2024

🤷‍♂️

dotfiles/flake.nix

Lines 136 to 150 in ca54fdd

modules = [
./nixos/configuration.nix
home-manager.nixosModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
backupFileExtension = "backup";
users.kachick = import ./home-manager/kachick.nix;
extraSpecialArgs = {
inherit homemade-pkgs edge-pkgs;
};
};
}

@kachick kachick added the bug Something isn't working label Jul 15, 2024
@kachick kachick changed the title Switching NixOS config does not apply home-manager togather Switching NixOS config does not apply home-manager together Jul 15, 2024
@kachick
Copy link
Owner Author

kachick commented Jul 29, 2024

@kachick
Copy link
Owner Author

kachick commented Jul 29, 2024

@kachick
Copy link
Owner Author

kachick commented Sep 16, 2024

Ah, I have faced similar issue again. Then looked same command in both /home/kachick/.nix-profile and /etc/profiles/per-user/kachick

Since uninstalling home-manager with nix run home-manager/release-24.05 -- uninstall and re-apply with sudo nixos-rebuild switch --flake .#moss --show-trace looks fixed. Now cmds are only in /etc/profiles/per-user/kachick

💭 I would keep useUserPackages = true; to respect home-manager manual, written as it might be default...

@kachick
Copy link
Owner Author

kachick commented Sep 17, 2024

Same as in algae and it blocked by existing files
I manually removed them and fixed.

[kachick@algae:~/repos/github.com/kachick/dotfiles]$ sudo nixos-rebuild switch --flake '.#algae' --show-trace
warning: Git tree '/home/kachick/repos/github.com/kachick/dotfiles' is dirty
building the system configuration...
warning: Git tree '/home/kachick/repos/github.com/kachick/dotfiles' is dirty
activating the configuration...
setting up /etc...
reloading user units for kachick...
restarting sysinit-reactivation.target
warning: the following units failed: home-manager-kachick.service

× home-manager-kachick.service - Home Manager environment for kachick
     Loaded: loaded (/etc/systemd/system/home-manager-kachick.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Tue 2024-09-17 14:10:08 JST; 83ms ago
    Process: 13082 ExecStart=/nix/store/18kq72xw0nnmzqaj40x9p0j76ymbzb7k-hm-setup-env /nix/store/kc5ybrcbz7qkmvmi6i9695j4ycjb4ady-home-manager-generation (code=exited, status=1/FAILURE)
   Main PID: 13082 (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
        CPU: 105ms

 9月 17 14:10:08 algae hm-activate-kachick[13173]: Please do one of the following:
 9月 17 14:10:08 algae hm-activate-kachick[13173]: - Move or remove the above files and try again.
 9月 17 14:10:08 algae hm-activate-kachick[13173]: - In standalone mode, use 'home-manager switch -b backup' to back up
 9月 17 14:10:08 algae hm-activate-kachick[13173]:   files automatically.
 9月 17 14:10:08 algae hm-activate-kachick[13173]: - When used as a NixOS or nix-darwin module, set
 9月 17 14:10:08 algae hm-activate-kachick[13173]:     'home-manager.backupFileExtension'
 9月 17 14:10:08 algae hm-activate-kachick[13173]:   to, for example, 'backup' and rebuild.
 9月 17 14:10:08 algae systemd[1]: home-manager-kachick.service: Main process exited, code=exited, status=1/FAILURE
 9月 17 14:10:08 algae systemd[1]: home-manager-kachick.service: Failed with result 'exit-code'.
 9月 17 14:10:08 algae systemd[1]: Failed to start Home Manager environment for kachick.
warning: error(s) occurred while switching to the new configuration

[kachick@algae:~/repos/github.com/kachick/dotfiles]$ systemctl status "home-manager-$USER.service"
× home-manager-kachick.service - Home Manager environment for kachick
     Loaded: loaded (/etc/systemd/system/home-manager-kachick.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Tue 2024-09-17 14:10:08 JST; 12s ago
    Process: 13082 ExecStart=/nix/store/18kq72xw0nnmzqaj40x9p0j76ymbzb7k-hm-setup-env /nix/store/kc5ybrcbz7qkmvmi6i9695j4ycjb4ady-home-manager-generation>
   Main PID: 13082 (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
        CPU: 105ms

 9月 17 14:10:08 algae hm-activate-kachick[13173]: Please do one of the following:
 9月 17 14:10:08 algae hm-activate-kachick[13173]: - Move or remove the above files and try again.
 9月 17 14:10:08 algae hm-activate-kachick[13173]: - In standalone mode, use 'home-manager switch -b backup' to back up
 9月 17 14:10:08 algae hm-activate-kachick[13173]:   files automatically.
 9月 17 14:10:08 algae hm-activate-kachick[13173]: - When used as a NixOS or nix-darwin module, set
 9月 17 14:10:08 algae hm-activate-kachick[13173]:     'home-manager.backupFileExtension'
 9月 17 14:10:08 algae hm-activate-kachick[13173]:   to, for example, 'backup' and rebuild.
 9月 17 14:10:08 algae systemd[1]: home-manager-kachick.service: Main process exited, code=exited, status=1/FAILURE
 9月 17 14:10:08 algae systemd[1]: home-manager-kachick.service: Failed with result 'exit-code'.
 9月 17 14:10:08 algae systemd[1]: Failed to start Home Manager environment for kachick.


[kachick@algae:~/repos/github.com/kachick/dotfiles]$ journalctl --unit home-manager-kachick.service
 9月 17 14:09:05 algae systemd[1]: home-manager-kachick.service: Failed with result 'exit-code'.
 9月 17 14:09:05 algae systemd[1]: Failed to start Home Manager environment for kachick.
 9月 17 14:10:08 algae systemd[1]: Starting Home Manager environment for kachick...
 9月 17 14:10:08 algae hm-activate-kachick[13082]: Home Managerの有効化を開始しました
 9月 17 14:10:08 algae hm-activate-kachick[13082]: checkFilesChanged を有効化しています
 9月 17 14:10:08 algae hm-activate-kachick[13082]: checkLinkTargets を有効化しています
 9月 17 14:10:08 algae hm-activate-kachick[13173]: Existing file '/home/kachick/.mozilla/firefox/profiles.ini' is in the way of '/nix/store/gz9ah4irysrxfwxcp7l344v9i0kf4adv-home-manager-files/.mozilla/firefox/profiles.ini'
 9月 17 14:10:08 algae hm-activate-kachick[13173]: Existing file '/home/kachick/.config/fcitx5/profile' is in the way of '/nix/store/gz9ah4irysrxfwxcp7l344v9i0kf4adv-home-manager-files/.config/fcitx5/profile', will be skipped since they are the same
 9月 17 14:10:08 algae hm-activate-kachick[13173]: Existing file '/home/kachick/.config/zed/settings.json' is in the way of '/nix/store/gz9ah4irysrxfwxcp7l344v9i0kf4adv-home-manager-files/.config/zed/settings.json'
 9月 17 14:10:08 algae hm-activate-kachick[13173]: Existing file '/home/kachick/.config/user-dirs.dirs' is in the way of '/nix/store/gz9ah4irysrxfwxcp7l344v9i0kf4adv-home-manager-files/.config/user-dirs.dirs'
 9月 17 14:10:08 algae hm-activate-kachick[13173]: Please do one of the following:
 9月 17 14:10:08 algae hm-activate-kachick[13173]: - Move or remove the above files and try again.
 9月 17 14:10:08 algae hm-activate-kachick[13173]: - In standalone mode, use 'home-manager switch -b backup' to back up
 9月 17 14:10:08 algae hm-activate-kachick[13173]:   files automatically.
 9月 17 14:10:08 algae hm-activate-kachick[13173]: - When used as a NixOS or nix-darwin module, set
 9月 17 14:10:08 algae hm-activate-kachick[13173]:     'home-manager.backupFileExtension'
 9月 17 14:10:08 algae hm-activate-kachick[13173]:   to, for example, 'backup' and rebuild.
 9月 17 14:10:08 algae systemd[1]: home-manager-kachick.service: Main process exited, code=exited, status=1/FAILURE
 9月 17 14:10:08 algae systemd[1]: home-manager-kachick.service: Failed with result 'exit-code'.
 9月 17 14:10:08 algae systemd[1]: Failed to start Home Manager environment for kachick.
~

[kachick@algae:~/repos/github.com/kachick/dotfiles]$ rm '/home/kachick/.mozilla/firefox/profiles.ini'

[kachick@algae:~/repos/github.com/kachick/dotfiles]$ rm '/home/kachick/.config/fcitx5/profile'

[kachick@algae:~/repos/github.com/kachick/dotfiles]$ rm '/home/kachick/.config/zed/settings.json'

[kachick@algae:~/repos/github.com/kachick/dotfiles]$ rm '/home/kachick/.config/user-dirs.dirs'

[kachick@algae:~/repos/github.com/kachick/dotfiles]$ sudo nixos-rebuild switch --flake '.#algae' --show-trace
warning: Git tree '/home/kachick/repos/github.com/kachick/dotfiles' is dirty
building the system configuration...
warning: Git tree '/home/kachick/repos/github.com/kachick/dotfiles' is dirty
activating the configuration...
setting up /etc...
reloading user units for kachick...
restarting sysinit-reactivation.target

@kachick
Copy link
Owner Author

kachick commented Sep 17, 2024

Now packages will be updated in nixos-rebuild, but files are not. Might be related to nix-community/home-manager#5519

@kachick
Copy link
Owner Author

kachick commented Sep 17, 2024

@kachick
Copy link
Owner Author

kachick commented Sep 17, 2024

I don't know why it generates only when first execution... 🤔

> nix run home-manager/release-24.05 -- generations
2024-09-17 16:21 : id 1 -> /nix/store/a56h6xklsjg0cd0qyxw4vbj3g1wy77cv-home-manager-generation

@kachick
Copy link
Owner Author

kachick commented Sep 17, 2024

> nix run home-manager/release-24.05 -- uninstallnix run home-manager/release-24.05 -- generations
ls: cannot access 'home-manager-*-link': No such file or directorysudo nixos-rebuild switch --flake .#algae
building the system configuration...
activating the configuration...
setting up /etc...
reloading user units for kachick...
restarting sysinit-reactivation.target
restarting the following units: home-manager-kachick.service
> nix run home-manager/release-24.05 -- generations
2024-09-17 18:15 : id 1 -> /nix/store/rbsvdvcjlnpsf7020pzl3bcqkc0dld03-home-manager-generation

So uninstall home-manager as standalone version and rebuild nixos at everytime is the only one of the solution... 🙄

@kachick
Copy link
Owner Author

kachick commented Sep 17, 2024

My fcitx5/profile is always conflicting in NixOS

nix-community/home-manager#3090 (comment)

xdg.configFile."fcitx5/config" = {
source = ../config/fcitx5/config;
};
xdg.configFile."fcitx5/profile" = {
source = ../config/fcitx5/profile;
};

i18n = {
inputMethod = {
enabled = "fcitx5";
fcitx5.addons = [
pkgs.fcitx5-mozc
pkgs.fcitx5-gtk
];
fcitx5.waylandFrontend = true;
};
};

@phanirithvij
Copy link

phanirithvij commented Sep 17, 2024

Have you read https://ayats.org/blog/no-home-manager, seems like you might find it relevant.
I read it but didn't find any solution inside it.

@kachick
Copy link
Owner Author

kachick commented Sep 17, 2024

Thank you for sharing! This post sounds interesting...
Hmm, but if dropping home-manager, I also need another solution 🤔
To sync dotfiles for each app, and using nix store absolute path in it...

@kachick
Copy link
Owner Author

kachick commented Sep 17, 2024

@kachick
Copy link
Owner Author

kachick commented Sep 18, 2024

nix-community/home-manager#5495 much helps to check collisions than now, but it is not all for my case...

If no collisions, systemctl status "home-manager-$USER.service" displays correct /nix/store/...-home-manager-generation, but actually not applied the xdg file managers like nix-community/home-manager#5519

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment