Hi, firstly, thanks for all the resources, I've got a nixos-flake based setup (essentially copied from srid/nixos-config) for my desktop and macbook.
I want to extend my flake to some servers and was reading about per-host configs here: https://github.com/srid/nixos-flake/issues/19, but didn't quite grasp the workaround mentioned in the last 2 comments. I want to avoid pulling-in the gui related home-manager configs for the servers obviously. (as an aside, some of my gui configs like for wayland are split across the nixos/ and home/ folders, is there a way to unify them?)
Has anyone got per-home config with a similar setup? here's my config for reference if needed: https://github.com/arulagrawal/nix.
@Arul Agrawal I suggest forking nixos-flake
and modifying this writeShellApplication.
Make it so that it uses HOSTNAME
instead of USER
(but still fallback to USER
if the former doesn't exist in homeConfigurations
). You may first have to do a nix flake show --json
on the flake, so as to see if homeConfigurations.$HOSTNAME
does in fact exist.
Once you get something working to satisfaction, open a PR on nixos-flake repo!
Happy to help through your contribution here.
so the idea is, instead of doing this, the home-manager config would instead be called in flake.nix under flake -> homeConfigurations (where the darwinConfigurations and nixosConfigurations currently reside)?
No, the idea is to fork nixos-flake and do the aforementioned change.
Then change this line in your flake to point to your fork, and run nix run
.
https://github.com/arulagrawal/nixos-flake/commit/2b8fc0f521db121d1f48d32e1cbc57732ede91a4
Something like this? (will cleanup the commit message)
I did this and pointed my flake to the branch and ran nix run
. The question I asked now was to ask where to put the per-host config.
legacyPackages.homeConfigurations.HOSTNAME
And run nix run .#activate-home
I'm assuming you are doing this in non-NixOS, since that issue is all about home-manager only config.
So, try to get this working on macOS first.
One little step at a time.
You can put the config in homeModules
, and import if from two places (to as to share between nixos & macos)
Srid said:
You can put the config in
homeModules
, and import if from two places (to as to share between nixos & macos)
Example, https://github.com/srid/nixos-flake/blob/master/examples/both/flake.nix
Okay I think I was going about this the wrong way (for what I need). I didn't test the server config yet (the device I was going to use died on me or smth) but I think something like this suffices: https://github.com/arulagrawal/nix/compare/main...separate-linux-configs
apologies for the confusion
@Arul Agrawal this post prompted me to write #nix > Dynamic NixOS configuration, using flakes. Feel free to "take inspiration" from it ;)
Last updated: Nov 15 2024 at 13:04 UTC