Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1# Experimental flake interface to Nixpkgs. 2# See https://github.com/NixOS/rfcs/pull/49 for details. 3{ 4 description = "A collection of packages for the Nix package manager"; 5 6 outputs = { self }: 7 let 8 libVersionInfoOverlay = import ./lib/flake-version-info.nix self; 9 lib = (import ./lib).extend libVersionInfoOverlay; 10 11 forAllSystems = lib.genAttrs lib.systems.flakeExposed; 12 13 jobs = forAllSystems (system: import ./pkgs/top-level/release.nix { 14 nixpkgs = self; 15 inherit system; 16 }); 17 in 18 { 19 lib = lib.extend (final: prev: { 20 21 nixos = import ./nixos/lib { lib = final; }; 22 23 nixosSystem = args: 24 import ./nixos/lib/eval-config.nix ( 25 { 26 lib = final; 27 # Allow system to be set modularly in nixpkgs.system. 28 # We set it to null, to remove the "legacy" entrypoint's 29 # non-hermetic default. 30 system = null; 31 32 modules = args.modules ++ [ 33 # This module is injected here since it exposes the nixpkgs self-path in as 34 # constrained of contexts as possible to avoid more things depending on it and 35 # introducing unnecessary potential fragility to changes in flakes itself. 36 # 37 # See: failed attempt to make pkgs.path not copy when using flakes: 38 # https://github.com/NixOS/nixpkgs/pull/153594#issuecomment-1023287913 39 ({ config, pkgs, lib, ... }: { 40 config.nixpkgs.flake.source = self.outPath; 41 }) 42 ]; 43 } // builtins.removeAttrs args [ "modules" ] 44 ); 45 }); 46 47 checks = forAllSystems (system: { 48 tarball = jobs.${system}.tarball; 49 # Exclude power64 due to "libressl is not available on the requested hostPlatform" with hostPlatform being power64 50 } // lib.optionalAttrs (self.legacyPackages.${system}.stdenv.isLinux && !self.legacyPackages.${system}.targetPlatform.isPower64) { 51 # Test that ensures that the nixosSystem function can accept a lib argument 52 # Note: prefer not to extend or modify `lib`, especially if you want to share reusable modules 53 # alternatives include: `import` a file, or put a custom library in an option or in `_module.args.<libname>` 54 nixosSystemAcceptsLib = (self.lib.nixosSystem { 55 pkgs = self.legacyPackages.${system}; 56 lib = self.lib.extend (final: prev: { 57 ifThisFunctionIsMissingTheTestFails = final.id; 58 }); 59 modules = [ 60 ./nixos/modules/profiles/minimal.nix 61 ({ lib, ... }: lib.ifThisFunctionIsMissingTheTestFails { 62 # Define a minimal config without eval warnings 63 nixpkgs.hostPlatform = "x86_64-linux"; 64 boot.loader.grub.enable = false; 65 fileSystems."/".device = "nodev"; 66 # See https://search.nixos.org/options?show=system.stateVersion&query=stateversion 67 system.stateVersion = lib.versions.majorMinor lib.version; # DON'T do this in real configs! 68 }) 69 ]; 70 }).config.system.build.toplevel; 71 }); 72 73 htmlDocs = { 74 nixpkgsManual = builtins.mapAttrs (_: jobSet: jobSet.manual) jobs; 75 nixosManual = (import ./nixos/release-small.nix { 76 nixpkgs = self; 77 }).nixos.manual; 78 }; 79 80 # The "legacy" in `legacyPackages` doesn't imply that the packages exposed 81 # through this attribute are "legacy" packages. Instead, `legacyPackages` 82 # is used here as a substitute attribute name for `packages`. The problem 83 # with `packages` is that it makes operations like `nix flake show 84 # nixpkgs` unusably slow due to the sheer number of packages the Nix CLI 85 # needs to evaluate. But when the Nix CLI sees a `legacyPackages` 86 # attribute it displays `omitted` instead of evaluating all packages, 87 # which keeps `nix flake show` on Nixpkgs reasonably fast, though less 88 # information rich. 89 legacyPackages = forAllSystems (system: 90 (import ./. { inherit system; }).extend (final: prev: { 91 lib = prev.lib.extend libVersionInfoOverlay; 92 }) 93 ); 94 95 nixosModules = { 96 notDetected = ./nixos/modules/installer/scan/not-detected.nix; 97 98 /* 99 Make the `nixpkgs.*` configuration read-only. Guarantees that `pkgs` 100 is the way you initialize it. 101 102 Example: 103 104 { 105 imports = [ nixpkgs.nixosModules.readOnlyPkgs ]; 106 nixpkgs.pkgs = nixpkgs.legacyPackages.x86_64-linux; 107 } 108 */ 109 readOnlyPkgs = ./nixos/modules/misc/nixpkgs/read-only.nix; 110 }; 111 }; 112}