Skip to content

Conversation

@jameslounds
Copy link

@jameslounds jameslounds commented Dec 8, 2024

Hopefully fixes #124
In the v3 migration docs, it says that a file containing home manager configuration at homes/<target>/ <username>/default.nix will make the corresponding homeConfiguration available as outputs.homeConfigurations."<username>@<target>". In reality, it is available at outputs.homeConfigurations.<username>. It seems that x86_64-linux has precedence over aarch64-darwin (edit: I think because of the order of variables in flake-utils's defaultSystems ), so when I have both homes/aarch64-darwin/james/default.nix and homes/x86_64-linux/james/default.nix, only the x86_64-linux configuration actually makes it to the outputs (and importantly, darwinConfigurations.myMachine.home-manager.users).

This PR does 3 things:

  • Makes homeConfigurations work like the migration guide says it should (for the systems in outputs.pkgs - only systems ending in -linux or -darwin can make usable homeConfigurations, but other systems will still add to homeConfigurations. By using attrNames pkgs, we only make packages.<system>.homeConfigurations for systems which can make usable homeConfigurations.

  • Uses <username>@<target> for homes defined at ./homes/<target>/<username>/default.nix when checking which homes to apply to darwinConfigurations and nixosConfigurations.

  • Adds packages.<target>.homeConfigurations as an output of mkFlake so that home-manager switch --flake . (or ".#<username>") works. In order to do this, we reconstruct homeConfigurations for each defaultSystem, including only the homes for that system. We then rename any homes whose name ends with @<system>, and remove that @<system> suffix. This ensures that a home declared by homes/<system>/<username>/default.nix can be seen by home-manager at packages.<system>.homeConfigurations.<username>

I'm not the happiest about the changes I've made to snowfall-lib/flake/default.nix - I'm sure there's a much nicer way of doing this, but my nix skills aren't there yet.

KyleKrein added a commit to KyleKrein/snowfall-lib that referenced this pull request Aug 9, 2025
@anntnzrb
Copy link

anntnzrb commented Oct 9, 2025

Adopted

This fix has been implemented to enable the same username across multiple targets.

Changes

1. Unique home naming - Prevents collisions:

  • homes/x86_64-linux/james/default.nixhomeConfigurations."james@x86_64-linux"
  • homes/aarch64-darwin/james/default.nixhomeConfigurations."james@aarch64-darwin"

2. Per-system packages output - Convenient access:

  • packages.x86_64-linux.homeConfigurations.james (without @)
  • packages.aarch64-darwin.homeConfigurations.james (without @)

3. Updated host matching - Uses full user@system format

Benefits

✅ Fixes home configuration collision
✅ Matches documentation behavior
✅ Enables home-manager switch --flake .#james to work
✅ Backward compatible for single-target setups

Verification

nix flake check passes
✅ Home configurations properly namespaced per-system

Commit: anntnzrb/snowfall-lib@012761f

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 this pull request may close these issues.

Target Wide Home-Manager not working as expected

2 participants