Add support for the same username across multiple targets #144
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hopefully fixes #124
In the v3 migration docs, it says that a file containing home manager configuration at
homes/<target>/ <username>/default.nixwill make the corresponding homeConfiguration available asoutputs.homeConfigurations."<username>@<target>". In reality, it is available atoutputs.homeConfigurations.<username>. It seems thatx86_64-linuxhas precedence overaarch64-darwin(edit: I think because of the order of variables inflake-utils'sdefaultSystems), so when I have bothhomes/aarch64-darwin/james/default.nixandhomes/x86_64-linux/james/default.nix, only thex86_64-linuxconfiguration actually makes it to theoutputs(and importantly,darwinConfigurations.myMachine.home-manager.users).This PR does 3 things:
Makes
homeConfigurationswork like the migration guide says it should (for the systems inoutputs.pkgs- only systems ending in-linuxor-darwincan make usablehomeConfigurations, but other systems will still add tohomeConfigurations. By usingattrNames pkgs, we only makepackages.<system>.homeConfigurationsforsystemswhich can make usablehomeConfigurations.Uses
<username>@<target>for homes defined at./homes/<target>/<username>/default.nixwhen checking which homes to apply todarwinConfigurationsandnixosConfigurations.Adds
packages.<target>.homeConfigurationsas an output ofmkFlakeso thathome-manager switch --flake .(or".#<username>") works. In order to do this, we reconstructhomeConfigurationsfor eachdefaultSystem, 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 byhomes/<system>/<username>/default.nixcan be seen byhome-manageratpackages.<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.