1 # Experimental flake interface to Nixpkgs.
2 # See https://github.com/NixOS/rfcs/pull/49 for details.
4 description = "A collection of packages for the Nix package manager";
8 libVersionInfoOverlay = import ./lib/flake-version-info.nix self;
9 lib = (import ./lib).extend libVersionInfoOverlay;
11 forAllSystems = lib.genAttrs lib.systems.flakeExposed;
13 jobs = forAllSystems (system: import ./pkgs/top-level/release.nix {
19 lib = lib.extend (final: prev: {
21 nixos = import ./nixos/lib { lib = final; };
24 import ./nixos/lib/eval-config.nix (
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.
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.
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;
43 } // builtins.removeAttrs args [ "modules" ]
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.hostPlatform.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;
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.trivial.release; # DON'T do this in real configs!
70 }).config.system.build.toplevel;
74 nixpkgsManual = builtins.mapAttrs (_: jobSet: jobSet.manual) jobs;
75 nixosManual = (import ./nixos/release-small.nix {
80 devShells = forAllSystems (system: {
81 default = import ./shell.nix { inherit system; };
84 # The "legacy" in `legacyPackages` doesn't imply that the packages exposed
85 # through this attribute are "legacy" packages. Instead, `legacyPackages`
86 # is used here as a substitute attribute name for `packages`. The problem
87 # with `packages` is that it makes operations like `nix flake show
88 # nixpkgs` unusably slow due to the sheer number of packages the Nix CLI
89 # needs to evaluate. But when the Nix CLI sees a `legacyPackages`
90 # attribute it displays `omitted` instead of evaluating all packages,
91 # which keeps `nix flake show` on Nixpkgs reasonably fast, though less
93 legacyPackages = forAllSystems (system:
94 (import ./. { inherit system; }).extend (final: prev: {
95 lib = prev.lib.extend libVersionInfoOverlay;
100 notDetected = ./nixos/modules/installer/scan/not-detected.nix;
103 Make the `nixpkgs.*` configuration read-only. Guarantees that `pkgs`
104 is the way you initialize it.
109 imports = [ nixpkgs.nixosModules.readOnlyPkgs ];
110 nixpkgs.pkgs = nixpkgs.legacyPackages.x86_64-linux;
113 readOnlyPkgs = ./nixos/modules/misc/nixpkgs/read-only.nix;