Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1let 2 pinned = (builtins.fromJSON (builtins.readFile ./pinned.json)).pins; 3in 4{ 5 system ? builtins.currentSystem, 6 7 nixpkgs ? null, 8}: 9let 10 nixpkgs' = 11 if nixpkgs == null then 12 fetchTarball { 13 inherit (pinned.nixpkgs) url; 14 sha256 = pinned.nixpkgs.hash; 15 } 16 else 17 nixpkgs; 18 19 pkgs = import nixpkgs' { 20 inherit system; 21 config = { 22 permittedInsecurePackages = [ "nix-2.3.18" ]; 23 }; 24 overlays = [ ]; 25 }; 26 27 fmt = 28 let 29 treefmtNixSrc = fetchTarball { 30 inherit (pinned.treefmt-nix) url; 31 sha256 = pinned.treefmt-nix.hash; 32 }; 33 treefmtEval = (import treefmtNixSrc).evalModule pkgs { 34 # Important: The auto-rebase script uses `git filter-branch --tree-filter`, 35 # which creates trees within the Git repository under `.git-rewrite/t`, 36 # notably without having a `.git` themselves. 37 # So if this projectRootFile were the default `.git/config`, 38 # having the auto-rebase script use treefmt on such a tree would make it 39 # format all files in the _parent_ Git tree as well. 40 projectRootFile = ".git-blame-ignore-revs"; 41 42 # Be a bit more verbose by default, so we can see progress happening 43 settings.verbose = 1; 44 45 # By default it's info, which is too noisy since we have many unmatched files 46 settings.on-unmatched = "debug"; 47 48 programs.actionlint.enable = true; 49 50 programs.keep-sorted.enable = true; 51 52 # This uses nixfmt underneath, 53 # the default formatter for Nix code. 54 # See https://github.com/NixOS/nixfmt 55 programs.nixfmt.enable = true; 56 57 programs.yamlfmt = { 58 enable = true; 59 settings.formatter = { 60 retain_line_breaks = true; 61 }; 62 }; 63 settings.formatter.yamlfmt.excludes = [ 64 # Breaks helm templating 65 "nixos/tests/k3s/k3s-test-chart/templates/*" 66 # Aligns comments with whitespace 67 "pkgs/development/haskell-modules/configuration-hackage2nix/main.yaml" 68 # TODO: Fix formatting for auto-generated file 69 "pkgs/development/haskell-modules/configuration-hackage2nix/transitive-broken.yaml" 70 ]; 71 72 settings.formatter.editorconfig-checker = { 73 command = "${pkgs.lib.getExe pkgs.editorconfig-checker}"; 74 options = [ "-disable-indent-size" ]; 75 includes = [ "*" ]; 76 priority = 1; 77 }; 78 79 # TODO: Upstream this into treefmt-nix eventually: 80 # https://github.com/numtide/treefmt-nix/issues/387 81 settings.formatter.markdown-code-runner = { 82 command = pkgs.lib.getExe pkgs.markdown-code-runner; 83 options = 84 let 85 config = pkgs.writers.writeTOML "markdown-code-runner-config" { 86 presets.nixfmt = { 87 language = "nix"; 88 command = [ (pkgs.lib.getExe pkgs.nixfmt) ]; 89 }; 90 }; 91 in 92 [ "--config=${config}" ]; 93 includes = [ "*.md" ]; 94 }; 95 }; 96 fs = pkgs.lib.fileset; 97 nixFilesSrc = fs.toSource { 98 root = ../.; 99 fileset = fs.difference ../. (fs.maybeMissing ../.git); 100 }; 101 in 102 { 103 shell = treefmtEval.config.build.devShell; 104 pkg = treefmtEval.config.build.wrapper; 105 check = treefmtEval.config.build.check nixFilesSrc; 106 }; 107 108in 109rec { 110 inherit pkgs fmt; 111 requestReviews = pkgs.callPackage ./request-reviews { }; 112 codeownersValidator = pkgs.callPackage ./codeowners-validator { }; 113 114 # FIXME(lf-): it might be useful to test other Nix implementations 115 # (nixVersions.stable and Lix) here somehow at some point to ensure we don't 116 # have eval divergence. 117 eval = pkgs.callPackage ./eval { 118 nix = pkgs.nixVersions.latest; 119 }; 120 121 # CI jobs 122 lib-tests = import ../lib/tests/release.nix { inherit pkgs; }; 123 manual-nixos = (import ../nixos/release.nix { }).manual.${system} or null; 124 manual-nixpkgs = (import ../doc { }); 125 manual-nixpkgs-tests = (import ../doc { }).tests; 126 nixpkgs-vet = pkgs.callPackage ./nixpkgs-vet.nix { }; 127 parse = pkgs.lib.recurseIntoAttrs { 128 latest = pkgs.callPackage ./parse.nix { nix = pkgs.nixVersions.latest; }; 129 lix = pkgs.callPackage ./parse.nix { nix = pkgs.lix; }; 130 # TODO: Raise nixVersions.minimum to 2.24 and flip back to it. 131 minimum = pkgs.callPackage ./parse.nix { nix = pkgs.nixVersions.nix_2_24; }; 132 }; 133 shell = import ../shell.nix { inherit nixpkgs system; }; 134 tarball = import ../pkgs/top-level/make-tarball.nix { 135 # Mirrored from top-level release.nix: 136 nixpkgs = { 137 outPath = pkgs.lib.cleanSource ../.; 138 revCount = 1234; 139 shortRev = "abcdef"; 140 revision = "0000000000000000000000000000000000000000"; 141 }; 142 officialRelease = false; 143 inherit pkgs lib-tests; 144 nix = pkgs.nixVersions.latest; 145 }; 146}