lib/flake-utils: update mkHost

The NixOS system is now made overridable as a workaround for
nixos-generators.

See https://github.com/nix-community/nixos-generators/issues/110
for more details.
This commit is contained in:
Gabriel Arazas 2022-02-04 20:45:24 +08:00
parent d5c914f127
commit 73c98916a5
2 changed files with 15 additions and 10 deletions

View File

@ -66,7 +66,7 @@
(system: f system);
libExtended = nixpkgs.lib.extend (final: prev:
(import ./lib { lib = final; }) // {
(import ./lib { lib = prev; }) // {
flakeUtils = (import ./lib/flake-utils.nix {
inherit inputs;
lib = final;
@ -74,9 +74,17 @@
});
# The default configuration for our NixOS systems.
hostDefaultConfig = {
# Default architecture.
hostDefaultConfig = let
system = "x86_64-linux";
in {
inherit system;
specialArgs = {
inherit system inputs self;
lib = nixpkgs.lib.extend (final: prev:
import ./lib { lib = prev; });
};
# The default configuration for a NixOS system STARTS HERE.
# I want to capture the usual flakes to its exact version so we're
# making them available to our system. This will also prevent the

View File

@ -26,13 +26,10 @@ in rec {
=> { ... } # NixOS configuration attrset
*/
mkHost = file:
attrs@{ system ? sys, ... }:
inputs.nixpkgs.lib.nixosSystem {
attrs@{ system ? sys, specialArgs ? { inherit lib system inputs; }, ... }:
(lib.makeOverridable inputs.nixpkgs.lib.nixosSystem) {
# The system of the NixOS system.
inherit system;
# Additional attributes to be referred to our modules.
specialArgs = { inherit lib system inputs; };
inherit system specialArgs;
# We also set the following in order for priority.
# Later modules will override previously imported modules.
@ -43,7 +40,7 @@ in rec {
}
# Put the given attribute set (except for the system).
(lib.filterAttrs (n: v: !lib.elem n [ "system" ]) attrs)
(lib.filterAttrs (n: v: !lib.elem n [ "system" "specialArgs" ]) attrs)
# The entry point of the module.
file