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

Add support for the same username across multiple targets #144

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

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.

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
1 participant