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

Closed
srid opened this issue Apr 20, 2023 · 4 comments · Fixed by #60
Closed

Per-host home-manager configurations #19

srid opened this issue Apr 20, 2023 · 4 comments · Fixed by #60
Assignees
Labels
enhancement New feature or request

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:

https://github.com/srid/nixos-flake/blob/40010feda1ac1afdcc2571ef550ef3de44926b0e/flake-module.nix#L94-L95

@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
@srid srid mentioned this issue Jun 26, 2024
15 tasks
@srid srid removed the good first issue Good for newcomers label Jun 26, 2024
@srid
Copy link
Owner Author

srid commented Jun 27, 2024

Alright, checkout #60

With it, you can do nix run . $USER@$HOSTNAME

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants