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

How to configure multiple overlays to different hosts? #139

Open
ghost opened this issue Apr 19, 2023 · 3 comments
Open

How to configure multiple overlays to different hosts? #139

ghost opened this issue Apr 19, 2023 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@ghost
Copy link

ghost commented Apr 19, 2023

I have two overlays, two hosts.
Host 1 needs to use overlay1 Host 2 needs to use overlay1 overlay2.

{ self, inputs, ... }: {
  flake.overlays.default = import ../pkgs;

  perSystem = { system, ... }: {
    _module.args.pkgs = import self.inputs.nixpkgs {
      inherit system;
      overlays =
        [ self.overlays.default 2.overlays.default ];
      config.allowUnfree = true;
    };
  };
}

IMG_5789

@roberth
Copy link
Member

roberth commented Apr 19, 2023

Flake evaluation is designed not to depend on external factors, such as which host is evaluating the flake.

I would recommend something like NixOS or home-manager to configure host environments. These each have their own ways of initializing the pkgs module argument.

Alternatively, if you do not want to manage significant portions of your host environment declaratively, you could declare the relevant packages for each host using distinct package names. Instead of just _module.args.pkgs, you could also add _module.args.pkgs2 or any other name. pkgs is only "special" because it is implicitly expected by some modules. flake-parts itself does not come with such an expectation though.

@akirak
Copy link

akirak commented Apr 19, 2023

@nuusers In your case, you won't specify those host-specific overlays under perSystem though? You can specify overlays for a NixOS system as part of the configuration:

nixpkgs.lib.nixosSystem {
  inherit system specialArgs;
  modules = [
   {
      # Specify overlays for the system
      nixpkgs.overlays = overlays;
   }
   ...
  ];
}

@roberth roberth added the documentation Improvements or additions to documentation label May 9, 2023
@kekeqwq
Copy link

kekeqwq commented May 13, 2023

@roberth Sorry I lost my account, here is my solution:
https://github.com/kekeqwq/flakes/blob/3916883f74fbcd924f5679526a7bcea996c486ea/flake-parts/nixos.nix#LL30C32-L30C32
You can close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants