Skip to content

Is there a way to specify different nixpkgs for different hosts? #51

@akavel

Description

@akavel

Currently, I am trying to track nixpkgs versions separately for different hosts. My old flake.nix had the following:

{
  inputs = {
    # To update nixpkgs (and thus NixOS), pick the nixos-20.09 rev from
    # https://status.nixos.org/
    # (Or, alternatively, nixos-unstable rev.)
    # 
    # 22.05 @21.11.2022
    nixpkgs.url = "github:nixos/nixpkgs/cf63ade6f74bbc9d2a017290f1b2e33e8fbfa70a";
    # 23.11 @07.05.2024
    nixpkgs2.url = "github:nixos/nixpkgs/27c13997bf450a01219899f5a83bd6ffbfc70d3c";
    nixos-wsl.url = "github:nix-community/NixOS-WSL/main";
  };

  outputs = { self, nixpkgs, nixpkgs2, nixos-wsl }: {
    # choice will be done "automatically" based on hostname
    nixosConfigurations.myhost1 = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [ ./myhost1.nix ];
    };
    nixosConfigurations.myhost2 = nixpkgs2.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [
        nixos-wsl.nixosModules.default
        ./myhost2.nix
      ];
    };
  };
}

I'm trying to port this config to nixos-flake, to let me unify it with my home-manager configs. However, I noticed that nixos-flake seems to be hardcoded to use inputs.nixpkgs, and inputs are passed via flake-parts.lib.mkFlake { inherit inputs; }, so I don't see a clear way to use different nixpkgs between different nixosConfigurations inside nixos-flake. Do you have any suggestions how I could try doing this? I am ok to try modifying nixos-flake code, but I'd be grateful for suggestions how to try approaching that in such case; currently flake-parts is still quite confusing to me; and also you know nixos-flake better, so may have better ideas what approach could be better suited to it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions