1let
2 pinnedNixpkgs = builtins.fromJSON (builtins.readFile ./pinned-nixpkgs.json);
3in
4{
5 system ? builtins.currentSystem,
6
7 nixpkgs ? null,
8}:
9let
10 nixpkgs' =
11 if nixpkgs == null then
12 fetchTarball {
13 url = "https://github.com/NixOS/nixpkgs/archive/${pinnedNixpkgs.rev}.tar.gz";
14 sha256 = pinnedNixpkgs.sha256;
15 }
16 else
17 nixpkgs;
18
19 pkgs = import nixpkgs' {
20 inherit system;
21 config = { };
22 overlays = [ ];
23 };
24
25 fmt =
26 let
27 treefmtNixSrc = fetchTarball {
28 # Master at 2025-02-12
29 url = "https://github.com/numtide/treefmt-nix/archive/4f09b473c936d41582dd744e19f34ec27592c5fd.tar.gz";
30 sha256 = "051vh6raskrxw5k6jncm8zbk9fhbzgm1gxpq9gm5xw1b6wgbgcna";
31 };
32 treefmtEval = (import treefmtNixSrc).evalModule pkgs {
33 # Important: The auto-rebase script uses `git filter-branch --tree-filter`,
34 # which creates trees within the Git repository under `.git-rewrite/t`,
35 # notably without having a `.git` themselves.
36 # So if this projectRootFile were the default `.git/config`,
37 # having the auto-rebase script use treefmt on such a tree would make it
38 # format all files in the _parent_ Git tree as well.
39 projectRootFile = ".git-blame-ignore-revs";
40
41 # Be a bit more verbose by default, so we can see progress happening
42 settings.verbose = 1;
43
44 # By default it's info, which is too noisy since we have many unmatched files
45 settings.on-unmatched = "debug";
46
47 programs.actionlint.enable = true;
48
49 programs.keep-sorted.enable = true;
50
51 # This uses nixfmt-rfc-style underneath,
52 # the default formatter for Nix code.
53 # See https://github.com/NixOS/nixfmt
54 programs.nixfmt.enable = true;
55
56 settings.formatter.editorconfig-checker = {
57 command = "${pkgs.lib.getExe pkgs.editorconfig-checker}";
58 options = [ "-disable-indent-size" ];
59 includes = [ "*" ];
60 priority = 1;
61 };
62 };
63 fs = pkgs.lib.fileset;
64 nixFilesSrc = fs.toSource {
65 root = ../.;
66 fileset = fs.difference ../. (fs.maybeMissing ../.git);
67 };
68 in
69 {
70 shell = treefmtEval.config.build.devShell;
71 pkg = treefmtEval.config.build.wrapper;
72 check = treefmtEval.config.build.check nixFilesSrc;
73 };
74
75in
76{
77 inherit pkgs fmt;
78 requestReviews = pkgs.callPackage ./request-reviews { };
79 codeownersValidator = pkgs.callPackage ./codeowners-validator { };
80 eval = pkgs.callPackage ./eval { };
81
82 # CI jobs
83 lib-tests = import ../lib/tests/release.nix { inherit pkgs; };
84 manual-nixos = (import ../nixos/release.nix { }).manual.${system} or null;
85 manual-nixpkgs = (import ../pkgs/top-level/release.nix { }).manual;
86 manual-nixpkgs-tests = (import ../pkgs/top-level/release.nix { }).manual.tests;
87 parse = pkgs.lib.recurseIntoAttrs {
88 latest = pkgs.callPackage ./parse.nix { nix = pkgs.nixVersions.latest; };
89 lix = pkgs.callPackage ./parse.nix { nix = pkgs.lix; };
90 minimum = pkgs.callPackage ./parse.nix { nix = pkgs.nixVersions.minimum; };
91 };
92 shell = import ../shell.nix { inherit nixpkgs system; };
93}