about summary refs log tree commit diff
path: root/nixpkgs/flake.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2024-01-06 02:12:23 +0100
committerAlyssa Ross <hi@alyssa.is>2024-01-06 02:12:23 +0100
commitf34a1b70eb86e4a63cfb88ea460345bb1aed88e3 (patch)
tree32834d23912250e0c4b86aa4420baacf8091c0fe /nixpkgs/flake.nix
parent003ab91dd67b093890db1dd0bab564345db6e496 (diff)
parent7a7cfff8915e06365bc2365ff33d4d413184fa9f (diff)
downloadnixlib-f34a1b70eb86e4a63cfb88ea460345bb1aed88e3.tar
nixlib-f34a1b70eb86e4a63cfb88ea460345bb1aed88e3.tar.gz
nixlib-f34a1b70eb86e4a63cfb88ea460345bb1aed88e3.tar.bz2
nixlib-f34a1b70eb86e4a63cfb88ea460345bb1aed88e3.tar.lz
nixlib-f34a1b70eb86e4a63cfb88ea460345bb1aed88e3.tar.xz
nixlib-f34a1b70eb86e4a63cfb88ea460345bb1aed88e3.tar.zst
nixlib-f34a1b70eb86e4a63cfb88ea460345bb1aed88e3.zip
Merge branch 'nixos-unstable-small' of https://github.com/NixOS/nixpkgs
Conflicts:
	nixpkgs/pkgs/build-support/go/module.nix
Diffstat (limited to 'nixpkgs/flake.nix')
-rw-r--r--nixpkgs/flake.nix28
1 files changed, 25 insertions, 3 deletions
diff --git a/nixpkgs/flake.nix b/nixpkgs/flake.nix
index f16bc7d05fce..580f572ff32c 100644
--- a/nixpkgs/flake.nix
+++ b/nixpkgs/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;