set overlays through modules
This changes how the templates use nixpkgs. Before, we instantiated nixpkgs in the flake and passd it directly to the configs; this was good for consistency, but silently ignored `nixpkgs.*` options, generating confusion among users. We now use modules to configure nixpkgs. This should help avoid cases such as: https://discourse.nixos.org/t/allowunfree-doesnt-work-with-flake-managed-system/21798/17 The drawback is that we can no longer test overlayed packages like so: `nix build .#foo`, you can do it like so instead: `nix build .#nixosConfigurations.your-system.pkgs.foo`. Personally, I've been avoiding override packages globally in my own config.
This commit is contained in:
parent
b8e3385f6b
commit
3face7eddd
|
@ -2,11 +2,11 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"hardware": {
|
"hardware": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1665040200,
|
"lastModified": 1667585378,
|
||||||
"narHash": "sha256-glqL6yj3aUm40y92inzRmowGt9aIrUrpBX7eBAMic4I=",
|
"narHash": "sha256-cvOwucrjBaAkaGk3FunG+MQiwiSBeIVTtO5n/YavpC0=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixos-hardware",
|
"repo": "nixos-hardware",
|
||||||
"rev": "47fd70289491c1f0c0d9a1f44fb5a9e2801120c9",
|
"rev": "6b35a59c19ddbbeb229fcd1d3dcd422dcc0fa927",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -23,11 +23,11 @@
|
||||||
"utils": "utils"
|
"utils": "utils"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1665119273,
|
"lastModified": 1667574732,
|
||||||
"narHash": "sha256-neL/ZRrwk47Ke1nfjk8ltlIm+NRZyA3MBcNbqEGSBeE=",
|
"narHash": "sha256-73TVk3uSQOja6Q/5OuNcpcqwo6+SMzJPRtYAjU0rBx4=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "9fcae11ff29ca5f959b05c206f3724486c28ff07",
|
"rev": "b764068a506c6f70dba998efa0e7fcb99cb4deb2",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -38,11 +38,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1664989420,
|
"lastModified": 1667482890,
|
||||||
"narHash": "sha256-Q8IxomUjjmewsoJgO3htkXLfCckQ7HkDJ/ZhdYVf/fA=",
|
"narHash": "sha256-pua0jp87iwN7NBY5/ypx0s9L9CG49Ju/NI4wGwurHc4=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "37bd39839acf99c5b738319f42478296f827f274",
|
"rev": "a2a777538d971c6b01c6e54af89ddd6567c055e8",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -61,11 +61,11 @@
|
||||||
},
|
},
|
||||||
"utils": {
|
"utils": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1659877975,
|
"lastModified": 1667077288,
|
||||||
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
"narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
"rev": "6ee9ebb6b1ee695d2cacc4faa053a7b9baa76817",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -4,38 +4,24 @@
|
||||||
inputs = {
|
inputs = {
|
||||||
# Nixpkgs
|
# Nixpkgs
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
hardware.url = "github:nixos/nixos-hardware";
|
|
||||||
|
|
||||||
# Home manager
|
# Home manager
|
||||||
home-manager.url = "github:nix-community/home-manager";
|
home-manager.url = "github:nix-community/home-manager";
|
||||||
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
# TODO: Add any other flake you might need
|
# TODO: Add any other flake you might need
|
||||||
|
hardware.url = "github:nixos/nixos-hardware";
|
||||||
|
|
||||||
# Shameless plug: looking for a way to nixify your themes and make
|
# Shameless plug: looking for a way to nixify your themes and make
|
||||||
# everything match nicely? Try nix-colors!
|
# everything match nicely? Try nix-colors!
|
||||||
# nix-colors.url = "github:misterio77/nix-colors";
|
# nix-colors.url = "github:misterio77/nix-colors";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { nixpkgs, home-manager, ... }@inputs: rec {
|
outputs = { nixpkgs, home-manager, ... }@inputs: {
|
||||||
# This instantiates nixpkgs for each system listed
|
|
||||||
# Allowing you to configure it (e.g. allowUnfree)
|
|
||||||
# Our configurations will use these instances
|
|
||||||
legacyPackages = nixpkgs.lib.genAttrs [ "x86_64-linux" "x86_64-darwin" ] (system:
|
|
||||||
import inputs.nixpkgs {
|
|
||||||
inherit system;
|
|
||||||
|
|
||||||
# NOTE: Using `nixpkgs.config` in your NixOS config won't work
|
|
||||||
# Instead, you should set nixpkgs configs here
|
|
||||||
# (https://nixos.org/manual/nixpkgs/stable/#idm140737322551056)
|
|
||||||
config.allowUnfree = true;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
nixosConfigurations = {
|
nixosConfigurations = {
|
||||||
# FIXME replace with your hostname
|
# FIXME replace with your hostname
|
||||||
your-hostname = nixpkgs.lib.nixosSystem {
|
your-hostname = nixpkgs.lib.nixosSystem {
|
||||||
pkgs = legacyPackages.x86_64-linux;
|
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
specialArgs = { inherit inputs; }; # Pass flake inputs to our config
|
specialArgs = { inherit inputs; }; # Pass flake inputs to our config
|
||||||
# > Our main nixos configuration file <
|
# > Our main nixos configuration file <
|
||||||
modules = [ ./nixos/configuration.nix ];
|
modules = [ ./nixos/configuration.nix ];
|
||||||
|
@ -45,7 +31,7 @@
|
||||||
homeConfigurations = {
|
homeConfigurations = {
|
||||||
# FIXME replace with your username@hostname
|
# FIXME replace with your username@hostname
|
||||||
"your-username@your-hostname" = home-manager.lib.homeManagerConfiguration {
|
"your-username@your-hostname" = home-manager.lib.homeManagerConfiguration {
|
||||||
pkgs = legacyPackages.x86_64-linux;
|
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
extraSpecialArgs = { inherit inputs; }; # Pass flake inputs to our config
|
extraSpecialArgs = { inherit inputs; }; # Pass flake inputs to our config
|
||||||
# > Our main home-manager configuration file <
|
# > Our main home-manager configuration file <
|
||||||
modules = [ ./home-manager/home.nix ];
|
modules = [ ./home-manager/home.nix ];
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
# TODO: You can set an initial password for your user.
|
# TODO: You can set an initial password for your user.
|
||||||
# If you do, you can skip setting a root password by passing '--no-root-passwd' to nixos-install.
|
# If you do, you can skip setting a root password by passing '--no-root-passwd' to nixos-install.
|
||||||
# Be sure to change it (using passwd) after rebooting!
|
# Be sure to change it (using passwd) after rebooting!
|
||||||
# initialPassword = "correcthorsebatterystaple";
|
initialPassword = "correcthorsebatterystaple";
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
openssh.authorizedKeys.keys = [
|
openssh.authorizedKeys.keys = [
|
||||||
# TODO: Add your SSH public key(s) here, if you plan on using SSH to connect
|
# TODO: Add your SSH public key(s) here, if you plan on using SSH to connect
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"hardware": {
|
"hardware": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1665040200,
|
"lastModified": 1667585378,
|
||||||
"narHash": "sha256-glqL6yj3aUm40y92inzRmowGt9aIrUrpBX7eBAMic4I=",
|
"narHash": "sha256-cvOwucrjBaAkaGk3FunG+MQiwiSBeIVTtO5n/YavpC0=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixos-hardware",
|
"repo": "nixos-hardware",
|
||||||
"rev": "47fd70289491c1f0c0d9a1f44fb5a9e2801120c9",
|
"rev": "6b35a59c19ddbbeb229fcd1d3dcd422dcc0fa927",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -23,11 +23,11 @@
|
||||||
"utils": "utils"
|
"utils": "utils"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1665119273,
|
"lastModified": 1667574732,
|
||||||
"narHash": "sha256-neL/ZRrwk47Ke1nfjk8ltlIm+NRZyA3MBcNbqEGSBeE=",
|
"narHash": "sha256-73TVk3uSQOja6Q/5OuNcpcqwo6+SMzJPRtYAjU0rBx4=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "9fcae11ff29ca5f959b05c206f3724486c28ff07",
|
"rev": "b764068a506c6f70dba998efa0e7fcb99cb4deb2",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -38,11 +38,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1664989420,
|
"lastModified": 1667482890,
|
||||||
"narHash": "sha256-Q8IxomUjjmewsoJgO3htkXLfCckQ7HkDJ/ZhdYVf/fA=",
|
"narHash": "sha256-pua0jp87iwN7NBY5/ypx0s9L9CG49Ju/NI4wGwurHc4=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "37bd39839acf99c5b738319f42478296f827f274",
|
"rev": "a2a777538d971c6b01c6e54af89ddd6567c055e8",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -61,11 +61,11 @@
|
||||||
},
|
},
|
||||||
"utils": {
|
"utils": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1659877975,
|
"lastModified": 1667077288,
|
||||||
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
"narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
"rev": "6ee9ebb6b1ee695d2cacc4faa053a7b9baa76817",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -4,13 +4,13 @@
|
||||||
inputs = {
|
inputs = {
|
||||||
# Nixpkgs
|
# Nixpkgs
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
hardware.url = "github:nixos/nixos-hardware";
|
|
||||||
|
|
||||||
# Home manager
|
# Home manager
|
||||||
home-manager.url = "github:nix-community/home-manager";
|
home-manager.url = "github:nix-community/home-manager";
|
||||||
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
# TODO: Add any other flake you might need
|
# TODO: Add any other flake you might need
|
||||||
|
hardware.url = "github:nixos/nixos-hardware";
|
||||||
|
|
||||||
# Shameless plug: looking for a way to nixify your themes and make
|
# Shameless plug: looking for a way to nixify your themes and make
|
||||||
# everything match nicely? Try nix-colors!
|
# everything match nicely? Try nix-colors!
|
||||||
|
@ -28,11 +28,23 @@
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
# Your custom packages and modifications
|
# Your custom packages
|
||||||
overlays = {
|
# Acessible through 'nix build', 'nix shell', etc
|
||||||
default = import ./overlay { inherit inputs; };
|
packages = forAllSystems (system:
|
||||||
};
|
let pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
in
|
||||||
|
import ./pkgs { inherit pkgs; }
|
||||||
|
);
|
||||||
|
# Devshell for bootstrapping
|
||||||
|
# Acessible through 'nix develop' or 'nix-shell' (legacy)
|
||||||
|
devShells = forAllSystems (system:
|
||||||
|
let pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
in
|
||||||
|
import ./shell.nix { inherit pkgs; }
|
||||||
|
);
|
||||||
|
|
||||||
|
# Your custom packages and modifications, exported as overlays
|
||||||
|
overlays = import ./overlays;
|
||||||
# Reusable nixos modules you might want to export
|
# Reusable nixos modules you might want to export
|
||||||
# These are usually stuff you would upstream into nixpkgs
|
# These are usually stuff you would upstream into nixpkgs
|
||||||
nixosModules = import ./modules/nixos;
|
nixosModules = import ./modules/nixos;
|
||||||
|
@ -40,37 +52,15 @@
|
||||||
# These are usually stuff you would upstream into home-manager
|
# These are usually stuff you would upstream into home-manager
|
||||||
homeManagerModules = import ./modules/home-manager;
|
homeManagerModules = import ./modules/home-manager;
|
||||||
|
|
||||||
# Devshell for bootstrapping
|
|
||||||
# Accessible through 'nix develop' or 'nix-shell' (legacy)
|
|
||||||
devShells = forAllSystems (system: {
|
|
||||||
default = nixpkgs.legacyPackages.${system}.callPackage ./shell.nix { };
|
|
||||||
});
|
|
||||||
|
|
||||||
# This instantiates nixpkgs for each system listed above
|
|
||||||
# Allowing you to add overlays and configure it (e.g. allowUnfree)
|
|
||||||
# Our configurations will use these instances
|
|
||||||
# Your flake will also let you access your package set through nix build, shell, run, etc.
|
|
||||||
legacyPackages = forAllSystems (system:
|
|
||||||
import inputs.nixpkgs {
|
|
||||||
inherit system;
|
|
||||||
# This adds our overlays to pkgs
|
|
||||||
overlays = builtins.attrValues overlays;
|
|
||||||
|
|
||||||
# NOTE: Using `nixpkgs.config` in your NixOS config won't work
|
|
||||||
# Instead, you should set nixpkgs configs here
|
|
||||||
# (https://nixos.org/manual/nixpkgs/stable/#idm140737322551056)
|
|
||||||
config.allowUnfree = true;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
nixosConfigurations = {
|
nixosConfigurations = {
|
||||||
# FIXME replace with your hostname
|
# FIXME replace with your hostname
|
||||||
your-hostname = nixpkgs.lib.nixosSystem {
|
your-hostname = nixpkgs.lib.nixosSystem {
|
||||||
pkgs = legacyPackages.x86_64-linux;
|
|
||||||
specialArgs = { inherit inputs; }; # Pass flake inputs to our config
|
specialArgs = { inherit inputs; }; # Pass flake inputs to our config
|
||||||
modules = (builtins.attrValues nixosModules) ++ [
|
modules = (builtins.attrValues nixosModules) ++ [
|
||||||
# > Our main nixos configuration file <
|
# > Our main nixos configuration file <
|
||||||
./nixos/configuration.nix
|
./nixos/configuration.nix
|
||||||
|
# Our common nixpkgs config (unfree, overlays, etc)
|
||||||
|
(import ./nixpkgs-config.nix { inherit overlays; })
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -78,11 +68,13 @@
|
||||||
homeConfigurations = {
|
homeConfigurations = {
|
||||||
# FIXME replace with your username@hostname
|
# FIXME replace with your username@hostname
|
||||||
"your-username@your-hostname" = home-manager.lib.homeManagerConfiguration {
|
"your-username@your-hostname" = home-manager.lib.homeManagerConfiguration {
|
||||||
pkgs = legacyPackages.x86_64-linux;
|
pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
|
||||||
extraSpecialArgs = { inherit inputs; }; # Pass flake inputs to our config
|
extraSpecialArgs = { inherit inputs; }; # Pass flake inputs to our config
|
||||||
modules = (builtins.attrValues homeManagerModules) ++ [
|
modules = (builtins.attrValues homeManagerModules) ++ [
|
||||||
# > Our main home-manager configuration file <
|
# > Our main home-manager configuration file <
|
||||||
./home-manager/home.nix
|
./home-manager/home.nix
|
||||||
|
# Our common nixpkgs config (unfree, overlays, etc)
|
||||||
|
(import ./nixpkgs-config.nix { inherit overlays; })
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
10
standard/nixpkgs-config.nix
Normal file
10
standard/nixpkgs-config.nix
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{ overlays, ... }:
|
||||||
|
{
|
||||||
|
nixpkgs = {
|
||||||
|
config = {
|
||||||
|
allowUnfree = true;
|
||||||
|
};
|
||||||
|
# Overlays is an attrset, convert to a list
|
||||||
|
overlays = builtins.attrValues overlays;
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
# This file defines two overlays and composes them
|
# This file defines overlays
|
||||||
{ inputs, ... }:
|
{
|
||||||
let
|
|
||||||
# This one brings our custom packages from the 'pkgs' directory
|
# This one brings our custom packages from the 'pkgs' directory
|
||||||
additions = final: _prev: import ../pkgs { pkgs = final; };
|
additions = final: _prev: import ../pkgs { pkgs = final; };
|
||||||
|
|
||||||
|
@ -12,5 +11,4 @@ let
|
||||||
# ...
|
# ...
|
||||||
# });
|
# });
|
||||||
};
|
};
|
||||||
in
|
}
|
||||||
inputs.nixpkgs.lib.composeManyExtensions [ additions modifications ]
|
|
Loading…
Reference in a new issue