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

Per-host home-manager configurations #19

Open
srid opened this issue Apr 20, 2023 · 3 comments
Open

Per-host home-manager configurations #19

srid opened this issue Apr 20, 2023 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@srid
Copy link
Owner

srid commented Apr 20, 2023

cc @bketelsen

Basically add hostname, along with username, to the legacyPackages.homeConfigurations keys.

{
  legacyPackages.homeConfigurations = rec {
    default = ...;
    "srid@macbook1" = default;
    "srid@linux-desktop1" = default;
  };
}

Then nix run .#activate -- --home (see #18) knows which configuration to activate.

@ParetoOptimalDev
Copy link

I tried to temporarily make this work in a somewhat hacky way since:

  • My desktop uses X11
  • My laptop uses wayland
  • I configure X11 and wayland via home-manager
  • Therefore I need per-host home-manager configurations

But it doesn't work for some reason.

If you have any ideas on a quick work-around it would save me the time of having to go back to flake-utils-plus where I know how to do this. Long term I think I want a flake-parts based config... I think :)

Here's my code:

{
  # ...
  outputs = inputs@{ self, ... }:
    inputs.flake-parts.lib.mkFlake { inherit inputs; } {
      # ...
      flake = {
        nixosConfigurations = {
          laptop = self.nixos-flake.lib.mkLinuxSystem {
            imports = [
              self.nixosModules.default
              ./nixos/gui/wayland.nix
              {
                # not ideal, see https://github.com/srid/nixos-flake/issues/19
                home-manager.users.paretoOptimalDev = [
                    ./home/window-manager/sway.nix
                ];
              }
            ];
          };
        };
      };
    };
}

@srid
Copy link
Owner Author

srid commented Nov 13, 2023

Well, this should be straightforward to implement, right?

Look for hostname (fallback to $USER), and then use that to set the attribute here ... all done in the bash script:

nix run \
.#homeConfigurations."\"''${USER}\"".activationPackage \

@srid
Copy link
Owner Author

srid commented Nov 13, 2023

Ideally we want to have that in this repo, but for quick workaround, you can simply add a writeShellApplication based flake app that does this.

@srid srid added the good first issue Good for newcomers label Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants