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 jobs = import ./pkgs/top-level/release.nix {
12 libVersionInfoOverlay = import ./lib/flake-version-info.nix self;
13 lib = (import ./lib).extend libVersionInfoOverlay;
15 forAllSystems = lib.genAttrs lib.systems.flakeExposed;
18 lib = lib.extend (final: prev: {
20 nixos = import ./nixos/lib { lib = final; };
23 import ./nixos/lib/eval-config.nix (
26 # Allow system to be set modularly in nixpkgs.system.
27 # We set it to null, to remove the "legacy" entrypoint's
28 # non-hermetic default.
31 modules = args.modules ++ [
32 # This module is injected here since it exposes the nixpkgs self-path in as
33 # constrained of contexts as possible to avoid more things depending on it and
34 # introducing unnecessary potential fragility to changes in flakes itself.
36 # See: failed attempt to make pkgs.path not copy when using flakes:
37 # https://github.com/NixOS/nixpkgs/pull/153594#issuecomment-1023287913
38 ({ config, pkgs, lib, ... }: {
39 config.nixpkgs.flake.source = self.outPath;
42 } // builtins.removeAttrs args [ "modules" ]
46 checks.x86_64-linux = {
47 tarball = jobs.tarball;
48 # Test that ensures that the nixosSystem function can accept a lib argument
49 # Note: prefer not to extend or modify `lib`, especially if you want to share reusable modules
50 # alternatives include: `import` a file, or put a custom library in an option or in `_module.args.<libname>`
51 nixosSystemAcceptsLib = (self.lib.nixosSystem {
52 lib = self.lib.extend (final: prev: {
53 ifThisFunctionIsMissingTheTestFails = final.id;
56 ./nixos/modules/profiles/minimal.nix
57 ({ lib, ... }: lib.ifThisFunctionIsMissingTheTestFails {
58 # Define a minimal config without eval warnings
59 nixpkgs.hostPlatform = "x86_64-linux";
60 boot.loader.grub.enable = false;
61 fileSystems."/".device = "nodev";
62 # See https://search.nixos.org/options?show=system.stateVersion&query=stateversion
63 system.stateVersion = lib.versions.majorMinor lib.version; # DON'T do this in real configs!
66 }).config.system.build.toplevel;
70 nixpkgsManual = jobs.manual;
71 nixosManual = (import ./nixos/release-small.nix {
73 }).nixos.manual.x86_64-linux;
76 # The "legacy" in `legacyPackages` doesn't imply that the packages exposed
77 # through this attribute are "legacy" packages. Instead, `legacyPackages`
78 # is used here as a substitute attribute name for `packages`. The problem
79 # with `packages` is that it makes operations like `nix flake show
80 # nixpkgs` unusably slow due to the sheer number of packages the Nix CLI
81 # needs to evaluate. But when the Nix CLI sees a `legacyPackages`
82 # attribute it displays `omitted` instead of evaluating all packages,
83 # which keeps `nix flake show` on Nixpkgs reasonably fast, though less
85 legacyPackages = forAllSystems (system:
86 (import ./. { inherit system; }).extend (final: prev: {
87 lib = prev.lib.extend libVersionInfoOverlay;
92 notDetected = ./nixos/modules/installer/scan/not-detected.nix;
95 Make the `nixpkgs.*` configuration read-only. Guarantees that `pkgs`
96 is the way you initialize it.
101 imports = [ nixpkgs.nixosModules.readOnlyPkgs ];
102 nixpkgs.pkgs = nixpkgs.legacyPackages.x86_64-linux;
105 readOnlyPkgs = ./nixos/modules/misc/nixpkgs/read-only.nix;