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 jobs = import ./pkgs/top-level/release.nix {
9 nixpkgs = self;
10 };
11
12 lib = import ./lib;
13
14 forAllSystems = lib.genAttrs lib.systems.flakeExposed;
15 in
16 {
17 lib = lib.extend (final: prev: {
18
19 nixos = import ./nixos/lib { lib = final; };
20
21 nixosSystem = args:
22 import ./nixos/lib/eval-config.nix (
23 args // {
24 modules = args.modules ++ [{
25 system.nixos.versionSuffix =
26 ".${final.substring 0 8 (self.lastModifiedDate or self.lastModified or "19700101")}.${self.shortRev or "dirty"}";
27 system.nixos.revision = final.mkIf (self ? rev) self.rev;
28 }];
29 } // lib.optionalAttrs (! args?system) {
30 # Allow system to be set modularly in nixpkgs.system.
31 # We set it to null, to remove the "legacy" entrypoint's
32 # non-hermetic default.
33 system = null;
34 }
35 );
36 });
37
38 checks.x86_64-linux.tarball = jobs.tarball;
39
40 htmlDocs = {
41 nixpkgsManual = jobs.manual;
42 nixosManual = (import ./nixos/release-small.nix {
43 nixpkgs = self;
44 }).nixos.manual.x86_64-linux;
45 };
46
47 # The "legacy" in `legacyPackages` doesn't imply that the packages exposed
48 # through this attribute are "legacy" packages. Instead, `legacyPackages`
49 # is used here as a substitute attribute name for `packages`. The problem
50 # with `packages` is that it makes operations like `nix flake show
51 # nixpkgs` unusably slow due to the sheer number of packages the Nix CLI
52 # needs to evaluate. But when the Nix CLI sees a `legacyPackages`
53 # attribute it displays `omitted` instead of evaluating all packages,
54 # which keeps `nix flake show` on Nixpkgs reasonably fast, though less
55 # information rich.
56 legacyPackages = forAllSystems (system: import ./. { inherit system; });
57
58 nixosModules = {
59 notDetected = ./nixos/modules/installer/scan/not-detected.nix;
60
61 /*
62 Make the `nixpkgs.*` configuration read-only. Guarantees that `pkgs`
63 is the way you initialize it.
64
65 Example:
66
67 {
68 imports = [ nixpkgs.nixosModules.readOnlyPkgs ];
69 nixpkgs.pkgs = nixpkgs.legacyPackages.x86_64-linux;
70 }
71 */
72 readOnlyPkgs = ./nixos/modules/misc/nixpkgs/read-only.nix;
73 };
74 };
75}