diff options
-rw-r--r-- | flake.nix | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/flake.nix b/flake.nix index f16bc7d05fce2..580f572ff32c6 100644 --- a/flake.nix +++ b/flake.nix @@ -21,16 +21,38 @@ nixosSystem = args: import ./nixos/lib/eval-config.nix ( - args // { inherit (self) lib; } // lib.optionalAttrs (! args?system) { + { + lib = final; # Allow system to be set modularly in nixpkgs.system. # We set it to null, to remove the "legacy" entrypoint's # non-hermetic default. system = null; - } + } // args ); }); - checks.x86_64-linux.tarball = jobs.tarball; + checks.x86_64-linux = { + tarball = jobs.tarball; + # Test that ensures that the nixosSystem function can accept a lib argument + # Note: prefer not to extend or modify `lib`, especially if you want to share reusable modules + # alternatives include: `import` a file, or put a custom library in an option or in `_module.args.<libname>` + nixosSystemAcceptsLib = (self.lib.nixosSystem { + lib = self.lib.extend (final: prev: { + ifThisFunctionIsMissingTheTestFails = final.id; + }); + modules = [ + ./nixos/modules/profiles/minimal.nix + ({ lib, ... }: lib.ifThisFunctionIsMissingTheTestFails { + # Define a minimal config without eval warnings + nixpkgs.hostPlatform = "x86_64-linux"; + boot.loader.grub.enable = false; + fileSystems."/".device = "nodev"; + # See https://search.nixos.org/options?show=system.stateVersion&query=stateversion + system.stateVersion = lib.versions.majorMinor lib.version; # DON'T do this in real configs! + }) + ]; + }).config.system.build.toplevel; + }; htmlDocs = { nixpkgsManual = jobs.manual; |