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

Switch home configuration without rebuilding the system #138

Open
Nikola-Milovic opened this issue Nov 16, 2024 · 2 comments
Open

Switch home configuration without rebuilding the system #138

Nikola-Milovic opened this issue Nov 16, 2024 · 2 comments

Comments

@Nikola-Milovic
Copy link

I was wondering, what is the dynamic of home-manager with snowfall v3? I've read that in #7 standalone home manager is possible, my question is, how do I achieve this, and do I need to change anything in the modules themselves?

I currently have a system that enables option X. Then in my home manager modules depending on the osConfig.x i do different things, will this still work as indended? Since my system is systemA, and my home config is user@systemA I guess it should resolve correctly?

I have no issues with the current setup, it works wonderfully, I just dislike having to rebuild my entire system to get CSS change into my waybar, seems redundant. Are there any drawbacks to switching to standalone HM with snowfall?

@Nikola-Milovic
Copy link
Author

It seems not possible at least with nh home switch

.dotfiles on  gammastep [+] ➜ nh home switch
warning: Git tree '/home/nikola/.dotfiles' is dirty
> Building home configuration
warning: Git tree '/home/nikola/.dotfiles' is dirty
error:
       … while evaluating a branch condition
         at /nix/store/ly4s3hw35dd1c2vsd694y2715pc1d2c1-source/lib/lists.nix:125:9:
          124|       fold' = n:
          125|         if n == len
             |         ^
          126|         then nul

       … while calling the 'length' builtin
         at /nix/store/ly4s3hw35dd1c2vsd694y2715pc1d2c1-source/lib/lists.nix:123:13:
          122|     let
          123|       len = length list;
             |             ^
          124|       fold' = n:

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

       error: function 'anonymous lambda' called without required argument 'osConfig'
       at /nix/store/l76yhqhh85m3vw99xm438h4dfjvfvpb6-3wbl663mrnsi7fvdrqbyw7hizlspzgkj-source/modules/home/desktop/bars/waybar/default.nix:1:1:
            1| {
             | ^
            2|   config,
┏━ 1 Errors: 
┃ error:
┃        … while evaluating a branch condition
┃          at /nix/store/ly4s3hw35dd1c2vsd694y2715pc1d2c1-source/lib/lists.nix:125:9:
┃           124|       fold' = n:
┃           125|         if n == len
┃              |         ^
┃           126|         then nul
┃ 
┃        … while calling the 'length' builtin
┃          at /nix/store/ly4s3hw35dd1c2vsd694y2715pc1d2c1-source/lib/lists.nix:123:13:
┃           122|     let
┃           123|       len = length list;
┃              |             ^
┃           124|       fold' = n:
┃ 
┃        (stack trace truncated; use '--show-trace' to show the full, detailed trace)
┃ 
┃        error: function 'anonymous lambda' called without required argument 'osConfig'
┃        at /nix/store/l76yhqhh85m3vw99xm438h4dfjvfvpb6-3wbl663mrnsi7fvdrqbyw7hizlspzgkj-source/modules/home/desktop/bars/way…
┃             1| {
┃              | ^
┃             2|   config,
┣━━━                                                            
┗━ ∑ ⚠ Exited with 1 errors reported by nix at 08:22:53 after 0s
Error: 
   0: Command exited with status Exited(1)

Location:
   src/commands.rs:151

@jameslounds
Copy link

jameslounds commented Dec 10, 2024

I've had a quick look at your nix-tmp repo, I think if you change your osConfig arguments to osConfig ? {}s (using an empty attest as the default argument), standalone should work - it works for my config at least.

Regarding the issue itself, I know home-manager switch accepts --options NAME VALUE, so maybe the nixos configuration could include a shell script which wraps home-manager switch to include certain values in an attrset at say config.${namespace}.osConfig using --option. No idea if this will work

For example in the nixosConfiguration somewhere

environment.systemPackages = [
  pkgs.writeShellScriptBin "hm-switch" ''
    home-manager switch --flake <path_to_your_flake> \ 
     --option ${namespace}.osConfig.services.myService.enable ${config.${namespace}.services.myService.enable}
     # and so on
  '';
];

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

No branches or pull requests

2 participants