The pattern of passing inputs
to all modules via specialArgs
seems useful, but I’m not sure the best pattern to “configure” alternate nixpkgs inputs. Unlike other flake inputs, it seems nixpkgs requires some evaluation (import) before it can be used (e.g. for its packages). How can this be configured?
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixpkgs-legacy.url = "github:NixOS/nixpkgs/a3a3dda3bacf61e8a39258a0ed9c924eeca8e293";
};
outputs = inputs@{self, nixpkgs, nixpkgs-unstable, nixpkgs-legacy}:
let
# configure nixpkgs-unstable and nixpkgs-legacy
unstable = import nixpkgs-unstable {
system = "x86_64-linux";
config = {
allowUnfree = true;
};
};
legacy = import nixpkgs-legacy {
system = "x86_64-linux";
config = {
allowUnfree = true;
};
};
# weird hack to try to merge these into inputs
inputs = {
inherit unstable legacy;
};
in
nixosConfigurations.laptop = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit inputs; };
modules = [
./configuration.nix
];
};
Within configuration.nix
,
{ config, lib, inputs, ...}
environment.systemPackages = with pkgs; [
inputs.unstable.obsidian
];
The approach above works, but I’m not sure I understand why. And its cumbersome / unreadable. Trying other approaches in the let block cause infinite recursion
inputs.unstable = import nixpkgs-unstable {
system = "x86_64-linux";
config = {
allowUnfree = true;
};
};
Are there better ways? What’s going on here?