diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d12327c809..d2d75cb4b8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,33 +27,10 @@ Adapted from the [Contributor Covenant] and [The Carpentries Code of Conduct]: With the current setup, the Nix manual hosted on nix.dev does not get updated automatically with new releases. The following manual steps are required: -- Regularly update the inputs to use the latest versions of the Nix release branches with `nix shell --run "niv update"` - - To avoid long build times, make sure Nix can be fetched from the cache. - If it doesn't, find the latest commit that is [built by Hydra](https://hydra.nixos.org/project/nix). For example, to pin Nix 2.18: - - ```bash - niv update nix_2-18 -r f5f4de6a550327b4b1a06123c2e450f1b92c73b6 - ``` - -- On each new Nix release: - - 1. Add the latest version in [`default.nix`](./default.nix). - For example, to add Nix 2.19: - - ```bash - niv add nixos/nix -n nix_2-19 -b 2.19-maintenance - ``` - - 2. Reference the latest version in [`source/reference/nix-manual.md`](./source/reference/nix-manual.md). - -- If an unstable or stable release of Nixpkgs adopt a new version of Nix, update the corresponding references here. - - Also update URLs to the the Nix manual to the version used by Nixpkgs unstable. - For example, if one wants to move from 2.18 to 2.19: - ```bash - sed -i 's#https://nix.dev/manual/nix/2.18/#https://nix.dev/manual/nix/2.19/#g' $(ls **/*.md) - ``` +```shell-session +nix-shell --run update-nixpkgs-releases +nix-shell --run update-nix-releases +``` ## Contributor guides diff --git a/default.nix b/default.nix index 1cb0ec9401..314f4e5031 100644 --- a/default.nix +++ b/default.nix @@ -1,67 +1,68 @@ -{ inputs ? import ./nix/sources.nix +{ inputs ? import ./nix/inputs.nix , system ? builtins.currentSystem , }: let - pkgs = import inputs.nixpkgs { + pkgs = import inputs.nixpkgs."23.05" { config = { }; - overlays = [ (import ./overlay.nix) ]; + overlays = [ (import ./nix/overlay.nix) ]; inherit system; }; - nix-dev = pkgs.stdenv.mkDerivation { - name = "nix-dev"; - src = ./.; - nativeBuildInputs = with pkgs.python310.pkgs; [ - linkify-it-py - myst-parser - sphinx - sphinx-book-theme - sphinx-copybutton - sphinx-design - sphinx-notfound-page - sphinx-sitemap - ]; - buildPhase = '' - make html - ''; - installPhase = - let - # Various versions of the Nix manuals, grep for (nix-manual)= to find where they are displayed - # FIXME: This requires human interaction to update! See ./CONTRIBUTING.md for details. - releases = { - latest = "2.19"; - rolling = "2.18"; - stable = "2.18"; - prev-stable = "2.13"; - }; - inputName = version: pkgs.lib.strings.replaceStrings [ "." ] [ "-" ] version; - src = version: inputs."nix_${inputName version}"; - manual = version: (import (src version)).default.doc; - copy = version: '' - cp -Rf ${manual version}/share/doc/nix/manual/* $out/manual/nix/${version} - ''; - # add upstream page redirects of the form ` `, excluding comment lines and empty - redirects = version: '' - sed '/^#/d;/^$/d;s#^\(.*\) \(.*\) #/manual/nix/${version}\1 /manual/nix/${version}\2 #g' ${src version}/doc/manual/_redirects >> $out/_redirects + lib = pkgs.lib; + releases = import ./nix/releases.nix { inherit lib inputs system; }; + + nix-dev = + pkgs.stdenv.mkDerivation { + name = "nix-dev"; + src = ./.; + nativeBuildInputs = with pkgs.python310.pkgs; [ + linkify-it-py + myst-parser + sphinx + sphinx-book-theme + sphinx-copybutton + sphinx-design + sphinx-notfound-page + sphinx-sitemap + pkgs.perl + ]; + buildPhase = + let + substitutedNixManualReference = pkgs.substitute { + src = ./source/reference/nix-manual.md; + replacements = lib.concatLists (lib.mapAttrsToList (from: to: [ "--subst-var-by" from to ]) releases.substitutions); + }; + in + '' + cp -f ${substitutedNixManualReference} source/reference/nix-manual.md + make html ''; - shortlink = release: version: '' - echo /manual/nix/${release} /manual/nix/${version}/ 302 >> $out/_redirects + installPhase = + let + # Various versions of the Nix manuals, grep for (nix-manual)= to find where they are displayed. + # FIXME: This requires human interaction to update! See ./CONTRIBUTING.md for details. + release = version: nix: '' + cp -R --no-preserve=mode ${nix.doc}/share/doc/nix/manual $out/manual/nix/${version} + + # add upstream page redirects of the form ` `, excluding comments and empty lines + # not all releases have that though + if [[ -f ${nix.doc}/share/doc/nix/manual/_redirects ]]; then + sed '/^#/d;/^$/d;s#^\(.*\) \(.*\) #/manual/nix/${version}\1 /manual/nix/${version}\2 #g' ${nix.doc}/share/doc/nix/manual/_redirects >> $out/_redirects + fi + ''; + # Redirects from mutable URLs like /manual/nix/latest/... to /manual/nix/2.21/... + mutableRedirect = mutable: immutable: '' + echo "/manual/nix/${mutable}/* /manual/nix/${immutable}/:splat 302" >> $out/_redirects + ''; + in + '' + mkdir -p $out/manual/nix + cp -R build/html/* $out/ + ${lib.concatStringsSep "\n" (lib.mapAttrsToList release releases.nixReleases)} + ${lib.concatStringsSep "\n" (lib.mapAttrsToList mutableRedirect releases.mutableNixManualRedirects)} ''; - versions = with pkgs.lib; lists.unique (attrsets.attrValues releases); - in - with pkgs.lib.attrsets; - with pkgs.lib.strings; - '' - mkdir -p $out - cp -R build/html/* $out/ - # NOTE: the comma in the shell expansion makes it also work for singleton lists - mkdir -p $out/manual/nix/{${concatStringsSep "," versions},} - ${concatStringsSep "\n" (map copy versions)} - ${concatStringsSep "\n" (map redirects versions)} - ${concatStringsSep "\n" (mapAttrsToList shortlink releases)} - ''; - }; + }; devmode = let @@ -104,6 +105,8 @@ let python ${pkgs.writeText "live.py" script} ''; }; + update-nix-releases = pkgs.callPackage ./nix/update-nix-releases.nix { }; + update-nixpkgs-releases = pkgs.callPackage ./nix/update-nixpkgs-releases.nix { }; in { # build with `nix-build -A build` @@ -113,6 +116,8 @@ in inputsFrom = [ nix-dev ]; packages = [ devmode + update-nix-releases + update-nixpkgs-releases pkgs.niv pkgs.python310.pkgs.black pkgs.vale diff --git a/nix/inputs.nix b/nix/inputs.nix new file mode 100644 index 0000000000..bb275750a1 --- /dev/null +++ b/nix/inputs.nix @@ -0,0 +1,36 @@ +# An abstraction over the different source pins in this directory +{ + + # The main niv pins, these are without any standard names: + # { + # = ; + # } + main = import ./sources.nix { + sourcesFile = ./sources.json; + }; + + # Sources for Nix releases, the attribute name is the release version. + # These are done specially because updating these is non-trivial. + # See ./update-nix-releases.nix + # { + # = ; + # } + nix = + builtins.mapAttrs (name: value: + # This matches the nix-prefetch-url --unpack --name source call in ./update-nix-releases.nix + fetchTarball { + name = "source"; + url = value.url; + sha256 = value.sha256; + } + ) (builtins.fromJSON (builtins.readFile ./nix-versions.json)); + + # Sources for Nixpkgs releases, the attribute name is the release name. + # These can be updated with the standard niv tooling, but are tracked separately to avoid having to filter them out during processing. + # See ./update-nixpkgs-releases.nix + nixpkgs = + import ./sources.nix { + sourcesFile = ./nixpkgs-versions.json; + }; + +} diff --git a/nix/nix-versions.json b/nix/nix-versions.json new file mode 100644 index 0000000000..aaec2d963f --- /dev/null +++ b/nix/nix-versions.json @@ -0,0 +1,92 @@ +{ + "2.21": { + "url": "https://github.com/nixos/nix/tarball/92e38fe30ccd7ca7e872b5da3b0fc138fed3b438", + "version": "2.21.2", + "sha256": "1wdaq3iv4dkajnvp4mn6ykq1f3pb24kgls3vggch3h08aadd2nj6" + }, + "2.20": { + "url": "https://github.com/nixos/nix/tarball/7bc4af7301df34ea4e157338ac3792c1a9ae35b7", + "version": "2.20.6", + "sha256": "17mpp5s3045zmilhvysa29g44clcfi5wn41sslkhxm7a50k7qa85" + }, + "2.19": { + "url": "https://github.com/nixos/nix/tarball/82f44d8633c849497d64980b5705d09ddbb01164", + "version": "2.19.5", + "sha256": "03vwahd1v8vq580cksr2grspj7iibdh5adyxdff8gq32scxahqzz" + }, + "2.18": { + "url": "https://github.com/nixos/nix/tarball/76364a847dd39e77ad5eebfcfa86df25f518ab1f", + "version": "2.18.3", + "sha256": "1d7b3khvkrmq3m34vw75l52a83rc7f2c4al7c5nyggwclkmnh11w" + }, + "2.17": { + "url": "https://github.com/nixos/nix/tarball/27c8b92f31fc4fb1d5be28d5196dc5ac0da58aee", + "version": "2.17.3", + "sha256": "1v1nw39j67y34hjnh9126975j1l1ha4ysfr70mnvpvsl3zb6mjvv" + }, + "2.16": { + "url": "https://github.com/nixos/nix/tarball/d9c204fafcbb5a05aef5c36fc83f4c3d6cc4749d", + "version": "2.16.4", + "sha256": "0m3x4qgp2m61d1dd5mfqwxw5r0dgy7pzdc7zg0z9x9l7slghx3ma" + }, + "2.15": { + "url": "https://github.com/nixos/nix/tarball/b59275b4417afd459dcf08a097fbd659f63161c2", + "version": "2.15.4", + "sha256": "0wx0z9b8abhdxcdm10mahx9dqqmwm63yrpmb5ax8ykzl7ij58wgv" + }, + "2.14": { + "url": "https://github.com/nixos/nix/tarball/9e19aca31bc9237d699b86bce1d31aa099f09121", + "version": "2.14.1", + "sha256": "1wnaah9bpycl89bjv85b967vxvgrppfl1a8f1h7vvavhb2fcgxkb" + }, + "2.13": { + "url": "https://github.com/nixos/nix/tarball/17e5d0325d0d7bb108d35f678622e3c237ca9fe9", + "version": "2.13.7", + "sha256": "1brlmfm2ab37hzsi5p6m13gpfhqzqkr1nvwkg2ks8ij1mcz7dh67" + }, + "2.12": { + "url": "https://github.com/nixos/nix/tarball/3c1f09ca492f5ec2252b511c9b627eddd2e98f88", + "version": "2.12.2", + "sha256": "14bjd85i3qm8jzzyafv1jcsdq5ylrp96563141dimc7p2085jczs" + }, + "2.11": { + "url": "https://github.com/nixos/nix/tarball/1aac1884c5d5976cc74a0a4e193e0b0ca3f25dbf", + "version": "2.11.2", + "sha256": "0ivcvz7g838sbh05vgzirz0agbr1dbr3gw1ywmxzmm3bh75hw2gs" + }, + "2.10": { + "url": "https://github.com/nixos/nix/tarball/73b3ba878a86e9a4d5e46fb16ce735b7dea4c929", + "version": "2.10.3", + "sha256": "0s7i6mj3x9l5l3b73fp4jq0cl1sjah7lq11gkymzb2jrqhxc681z" + }, + "2.9": { + "url": "https://github.com/nixos/nix/tarball/338418790adac11a4e73218e40fa109c4cfbc86d", + "version": "2.9.3", + "sha256": "0kl36c365dd9mzjcr5py52lgm78hj81cvw7lws9f16zkj64hcy9v" + }, + "2.8": { + "url": "https://github.com/nixos/nix/tarball/4555784afb613247563896273dad7887c1a2a0a3", + "version": "2.8.2", + "sha256": "0zg7y4c1fjz241fspzmba3acjw1qbigvkngp7q2xb5mdm5sl6swp" + }, + "2.7": { + "url": "https://github.com/nixos/nix/tarball/5ed3a9db6add8b28bdb484c00f45033f50ccb853", + "version": "2.7.0", + "sha256": "03y59yxc32ghkfrfkrrjkhpnksyp5q29mlhq1ssxia29wjmv5mz3" + }, + "2.6": { + "url": "https://github.com/nixos/nix/tarball/e044ccb67ce38d11059de32515306f5f1bd2f04f", + "version": "2.6.1", + "sha256": "0pfx87zgyhhhf4mnrknzq0pgry8i2d5pxvsbf52sqrxxzznr1n0k" + }, + "2.5": { + "url": "https://github.com/nixos/nix/tarball/16b3e41ed0e4b6c2ceffcbe8956acdd8b0cde71d", + "version": "2.5.1", + "sha256": "1px45lab0yb9gx6bysr296w3bc6cv1cm3x3lik1hhi3k5fpfc3pn" + }, + "2.4": { + "url": "https://github.com/nixos/nix/tarball/fbe3b09248feb251f7baf24dc5cd6d675ec0cb2c", + "version": "2.4.1", + "sha256": "0kzn3ggmir8iv1nk4yds6676x8y4q72xv06ks5p2nrvazhdarl8y" + } +} diff --git a/nix/nixpkgs-versions.json b/nix/nixpkgs-versions.json new file mode 100644 index 0000000000..bb865145c8 --- /dev/null +++ b/nix/nixpkgs-versions.json @@ -0,0 +1,134 @@ +{ + "18.09": { + "branch": "nixos-18.09", + "description": "Nix Packages collection & NixOS", + "homepage": "", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "a7e559a5504572008567383c3dc8e142fa7a8633", + "sha256": "16j95q58kkc69lfgpjkj76gw5sx8rcxwi3civm0mlfaxxyw9gzp6", + "type": "tarball", + "url": "https://github.com/nixos/nixpkgs/archive/a7e559a5504572008567383c3dc8e142fa7a8633.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "19.03": { + "branch": "nixos-19.03", + "description": "Nix Packages collection & NixOS", + "homepage": "", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "34c7eb7545d155cc5b6f499b23a7cb1c96ab4d59", + "sha256": "11z6ajj108fy2q5g8y4higlcaqncrbjm3dnv17pvif6avagw4mcb", + "type": "tarball", + "url": "https://github.com/nixos/nixpkgs/archive/34c7eb7545d155cc5b6f499b23a7cb1c96ab4d59.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "19.09": { + "branch": "nixos-19.09", + "description": "Nix Packages collection & NixOS", + "homepage": "", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "75f4ba05c63be3f147bcc2f7bd4ba1f029cedcb1", + "sha256": "157c64220lf825ll4c0cxsdwg7cxqdx4z559fdp7kpz0g6p8fhhr", + "type": "tarball", + "url": "https://github.com/nixos/nixpkgs/archive/75f4ba05c63be3f147bcc2f7bd4ba1f029cedcb1.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "20.03": { + "branch": "nixos-20.03", + "description": "Nix Packages collection & NixOS", + "homepage": "", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "1db42b7fe3878f3f5f7a4f2dc210772fd080e205", + "sha256": "05k9y9ki6jhaqdhycnidnk5zrdzsdammbk5lsmsbz249hjhhgcgh", + "type": "tarball", + "url": "https://github.com/nixos/nixpkgs/archive/1db42b7fe3878f3f5f7a4f2dc210772fd080e205.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "20.09": { + "branch": "nixos-20.09", + "description": "Nix Packages collection & NixOS", + "homepage": "", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "1c1f5649bb9c1b0d98637c8c365228f57126f361", + "sha256": "0f2nvdijyxfgl5kwyb4465pppd5vkhqxddx6v40k2s0z9jfhj0xl", + "type": "tarball", + "url": "https://github.com/nixos/nixpkgs/archive/1c1f5649bb9c1b0d98637c8c365228f57126f361.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "21.05": { + "branch": "nixos-21.05", + "description": "Nix Packages collection & NixOS", + "homepage": "", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "022caabb5f2265ad4006c1fa5b1ebe69fb0c3faf", + "sha256": "12q00nbd7fb812zchbcnmdg3pw45qhxm74hgpjmshc2dfmgkjh4n", + "type": "tarball", + "url": "https://github.com/nixos/nixpkgs/archive/022caabb5f2265ad4006c1fa5b1ebe69fb0c3faf.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "21.11": { + "branch": "nixos-21.11", + "description": "Nix Packages collection & NixOS", + "homepage": "", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "eabc38219184cc3e04a974fe31857d8e0eac098d", + "sha256": "04ffwp2gzq0hhz7siskw6qh9ys8ragp7285vi1zh8xjksxn1msc5", + "type": "tarball", + "url": "https://github.com/nixos/nixpkgs/archive/eabc38219184cc3e04a974fe31857d8e0eac098d.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "22.05": { + "branch": "nixos-22.05", + "description": "Nix Packages collection & NixOS", + "homepage": "", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "380be19fbd2d9079f677978361792cb25e8a3635", + "sha256": "154x9swf494mqwi4z8nbq2f0sp8pwp4fvx51lqzindjfbb9yxxv5", + "type": "tarball", + "url": "https://github.com/nixos/nixpkgs/archive/380be19fbd2d9079f677978361792cb25e8a3635.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "22.11": { + "branch": "nixos-22.11", + "description": "Nix Packages collection & NixOS", + "homepage": "", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b", + "sha256": "1xi53rlslcprybsvrmipm69ypd3g3hr7wkxvzc73ag8296yclyll", + "type": "tarball", + "url": "https://github.com/nixos/nixpkgs/archive/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "23.05": { + "branch": "nixos-23.05", + "description": "Nix Packages collection & NixOS", + "homepage": "", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "70bdadeb94ffc8806c0570eb5c2695ad29f0e421", + "sha256": "05cbl1k193c9la9xhlz4y6y8ijpb2mkaqrab30zij6z4kqgclsrd", + "type": "tarball", + "url": "https://github.com/nixos/nixpkgs/archive/70bdadeb94ffc8806c0570eb5c2695ad29f0e421.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "23.11": { + "branch": "nixos-23.11", + "description": "Nix Packages collection & NixOS", + "homepage": "", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "219951b495fc2eac67b1456824cc1ec1fd2ee659", + "sha256": "065jy7qivlbdqmbvd7r9h97b23f21axmc4r7sqmq2h0j82rmymxv", + "type": "tarball", + "url": "https://github.com/nixos/nixpkgs/archive/219951b495fc2eac67b1456824cc1ec1fd2ee659.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + } +} diff --git a/overlay.nix b/nix/overlay.nix similarity index 100% rename from overlay.nix rename to nix/overlay.nix diff --git a/nix/releases.nix b/nix/releases.nix new file mode 100644 index 0000000000..2d6742db5c --- /dev/null +++ b/nix/releases.nix @@ -0,0 +1,90 @@ +{ lib, inputs, system }: +let + # Import Nixpkgs, get the pkgs set back + pkgsFor = source: + import source { + inherit system; + config = { }; + overlays = [ ]; + }; + + # The pkgs for nixpkgs rolling release + pkgsRolling = pkgsFor inputs.main.nixpkgs-rolling; + + # The pkgs for each release: + # { + # "23.11" = pkgs...; + # "23.05" = pkgs...; + # } + pkgsReleases = lib.mapAttrs (release: source: + pkgsFor source + ) inputs.nixpkgs; + + # Information on Nixpkgs versions + nixpkgsVersions = rec { + # List of sorted version strings, e.g. [ "22.11" "23.05" "23.11" ] + sorted = lib.sort lib.versionOlder (lib.attrNames pkgsReleases); + # Number of versions, e.g. 3 + count = lib.length sorted; + # String for the latest version, e.g. "23.11" + latest = lib.elemAt sorted (count - 1); + # String for the version before the latest one, e.g. "23.05" + prevLatest = lib.elemAt sorted (count - 2); + }; + + # The Nix version string for a pkgs, e.g. "2.18" + nixVersionForPkgs = pkgs: + # XXX: We ignore the patch version here, which means that we may show a different (slightly more up-to-date) version than what's actually in Nixpkgs. + # This is not a big issue, and simplifies the setup a lot. + lib.versions.majorMinor pkgs.nix.version; + + # The build for each Nix version: + # { + # "2.18" = { outPath = ...; ... }; + # "2.19" = { outPath = ...; ... }; + # ... + # } + nixReleases = lib.mapAttrs (release: source: + # XXX: Unfortunately, the use of flake-compat prevents passing `system` with stable Nix... + (import source).default + ) inputs.nix; + + # Information on Nix versions + nixVersions = rec { + # List of sorted version strings, e.g. [ "2.18" "2.19" "2.20" ] + sorted = lib.sort lib.versionOlder (lib.attrNames nixReleases); + # Number of versions, e.g. 3 + count = lib.length sorted; + # String for the latest version, e.g. "2.20" + latest = lib.elemAt sorted (count - 1); + }; + + # Mutable link redirects to set up for the Nix manual + # E.g. /manual/nix/latest redirects to /manual/nix/2.20, which is encoded as: + # { + # "latest" = "2.20"; + # ... + # } + mutableNixManualRedirects = { + latest = nixVersions.latest; + rolling = nixVersionForPkgs pkgsRolling; + stable = nixVersionForPkgs pkgsReleases.${nixpkgsVersions.latest}; + prev-stable = nixVersionForPkgs pkgsReleases.${nixpkgsVersions.prevLatest}; + }; + + # Substitutions to perform on ../source/reference/nix-manual.md + # E.g. @nix-latest@ gets replaced with 2.20, which is encoded as: + # { + # "nix-latest" = "2.20"; + # ... + # } + substitutions = { + nixpkgs-stable = nixpkgsVersions.latest; + nixpkgs-prev-stable = nixpkgsVersions.prevLatest; + } // lib.mapAttrs' (name: value: + lib.nameValuePair "nix-${name}" value + ) mutableNixManualRedirects; +in +{ + inherit nixReleases mutableNixManualRedirects substitutions; +} diff --git a/nix/sources.json b/nix/sources.json index af08ddd2ef..260a931df6 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -1,50 +1,14 @@ { - "nix_2-13": { - "branch": "2.13-maintenance", - "description": "Nix, the purely functional package manager", - "homepage": "https://nixos.org/", - "owner": "nixos", - "repo": "nix", - "rev": "25f2dfc6e41d8c30e7abc443a7b262e34e49253b", - "sha256": "0lbp6yq92wpzi7kihbbma8d1c6q33msw95y0kmirfiikd8yvpvs7", - "type": "tarball", - "url": "https://github.com/nixos/nix/archive/25f2dfc6e41d8c30e7abc443a7b262e34e49253b.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "nix_2-18": { - "branch": "2.18-maintenance", - "description": "Nix, the purely functional package manager", - "homepage": "https://nixos.org/", - "owner": "nixos", - "repo": "nix", - "rev": "60eb80593f3a18aebc7672ad7007cb23c14db061", - "sha256": "0nyssab6skn9qd7mz4v0y3ycnhck7is6agm0i26l1anrgs90x37l", - "type": "tarball", - "url": "https://github.com/nixos/nix/archive/60eb80593f3a18aebc7672ad7007cb23c14db061.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "nix_2-19": { - "branch": "2.19-maintenance", - "description": "Nix, the purely functional package manager", - "homepage": "https://nixos.org/", - "owner": "nixos", - "repo": "nix", - "rev": "dc09e6193bffcab37d3d43107eae9464395ab51d", - "sha256": "0n117h0jz3aih41mg0kns8v6rjhmrg7r6p8azl55p32zrj02zyvm", - "type": "tarball", - "url": "https://github.com/nixos/nix/archive/dc09e6193bffcab37d3d43107eae9464395ab51d.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "nixpkgs": { - "branch": "nixos-23.05", + "nixpkgs-rolling": { + "branch": "nixpkgs-unstable", "description": "Nix Packages collection & NixOS", "homepage": "", - "owner": "NixOS", + "owner": "nixos", "repo": "nixpkgs", - "rev": "898cb2064b6e98b8c5499f37e81adbdf2925f7c5", - "sha256": "0ha53gbglrcnpzfc4lwzgyvlsagvm1m2q9z5i5b4nfahplnqpsbj", + "rev": "e976fa8f49c35cf28496301a1ef2aa23ad576b56", + "sha256": "1kq9wkwaf4kfv2p29jdqwfkbadmx1isbkaryqcrrjah4wskwa1rw", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/898cb2064b6e98b8c5499f37e81adbdf2925f7c5.tar.gz", + "url": "https://github.com/nixos/nixpkgs/archive/e976fa8f49c35cf28496301a1ef2aa23ad576b56.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "poetry2nix": { diff --git a/nix/update-nix-releases.nix b/nix/update-nix-releases.nix new file mode 100644 index 0000000000..5ac812abf6 --- /dev/null +++ b/nix/update-nix-releases.nix @@ -0,0 +1,86 @@ +{ writeShellApplication +, git +, nix +, ripgrep +, coreutils +, jq +}: +# Custom update mechanism for Nix releases in ./nix-versions.json +writeShellApplication { + name = "update-nix-releases"; + runtimeInputs = [ git nix ripgrep coreutils jq ]; + text = '' + tmp=$(mktemp -d) + trap 'rm -rf "$tmp"' EXIT + + echo >&2 "Fetching the Nix git history" + # We only need the Git history of the repo, the contents we download directly into the Nix store. + # --filter=tree:0 prevents downloading any contents and --bare prevents creating a working tree + git clone --quiet --filter=tree:0 --bare https://github.com/nixos/nix "$tmp/nix" + + echo >&2 "Going through all *-maintenance branches" + git -C "$tmp/nix" branch --list '*-maintenance' --format '%(refname)' \ + | rg 'refs/heads/(.*)-maintenance' -or '$1' \ + | sort --reverse --version-sort \ + | while read -r version; do + + rev=$(git -C "$tmp/nix" rev-parse "$version-maintenance") + echo >&2 "Version $version on branch $version-maintenance is at $rev" + + # Try to find a cached build by iterating back through the Git history + # This is necessary because the maintenance branches are pushed to directly and Hydra will take a while to build it + cached=false + steps=0 + while true; do + # We fetch Nix the same as `fetchTarball { name = "source"; ... }`, such that we should definitely get the same hashes and co. + # Though older versions of Nix didn't pin flake-compat, but this doesn't appear to be a problem in this case + # See https://github.com/NixOS/nix.dev/pull/830#issuecomment-1922672937 + url=https://github.com/nixos/nix/tarball/"$rev" + readarray -t sha256Source < <(nix-prefetch-url --unpack --name source --print-path "$url") + sha256=''${sha256Source[0]} + source=''${sha256Source[1]} + + if [[ ! -f "$source"/.version ]]; then + # Not having a .version indicates that we're not in the release anymore + break + fi + fullVersion="$(<"$source"/.version)" + + # Only try versions recent enough to have the same structure, this filter out versions before 2.4 + if ! drvPath=$(nix-instantiate "$source" --argstr system "x86_64-linux" -A default 2> /dev/null); then + echo >&2 "No default.nix supporting -A default" + break + fi + # We need a doc output, this is always the case for >= 2.4 + if ! docOutput=$(nix-store --query --binding doc "$drvPath"); then + echo >&2 "No doc output" + break + fi + # Check if the path is cached; `--size` is needed because without it, no query to the cache would be made + if nix-store --query --size "$docOutput" --store https://cache.nixos.org > /dev/null 2>&1; then + cached=true + break + fi + # If it's not cached, try the parent commit, usually only a couple steps are required at most + rev=$(git -C "$tmp/nix" rev-parse "$rev~") + steps=$(( steps + 1 )) + done + + if [ "$cached" = false ]; then + echo >&2 "Could not find a cached version for release $version" + continue + fi + + echo >&2 "Found a cached version, $steps steps away from the latest commit" + + jq -n \ + --arg key "$version" \ + --arg url "$url" \ + --arg version "$fullVersion" \ + --arg sha256 "$sha256" \ + '$ARGS.named' + done \ + | jq -s 'map({ key: .key, value: del(.key) }) | from_entries' \ + > nix/nix-versions.json + ''; +} diff --git a/nix/update-nixpkgs-releases.nix b/nix/update-nixpkgs-releases.nix new file mode 100644 index 0000000000..1613361cd3 --- /dev/null +++ b/nix/update-nixpkgs-releases.nix @@ -0,0 +1,31 @@ +{ writeShellApplication +, git +, niv +, nix +, ripgrep +, coreutils +, jq +}: +# add or update Nixpkgs releases using `niv` +writeShellApplication { + name = "update-nixpkgs-releases"; + runtimeInputs = [ git niv nix ripgrep jq coreutils ]; + text = '' + echo >&2 "Updating rolling" + niv update nixpkgs-rolling + echo >&2 "Updating stable releases" + niv -s nix/nixpkgs-versions.json update + + echo >&2 "Adding any new releases" + # get release branches + git ls-remote https://github.com/nixos/nixpkgs "refs/heads/*" \ + | rg '^([0-9a-f]+)\trefs/heads/nixos-(\d\d\.\d\d)$' -or '$2' \ + | sort --reverse --version-sort \ + | while read -r version; do + + if ! jq -e --arg version "$version" 'has($ARGS.named.version)' nix/nixpkgs-versions.json >/dev/null; then + niv -s nix/nixpkgs-versions.json add nixos/nixpkgs -n "$version" -b "nixos-$version" + fi + done + ''; +} diff --git a/source/reference/nix-manual.md b/source/reference/nix-manual.md index 7e67a08cfe..0c8359094a 100644 --- a/source/reference/nix-manual.md +++ b/source/reference/nix-manual.md @@ -1,35 +1,50 @@ +--- +myst: + html_meta: + "description lang=en": "Nix reference manual version overview" + "keywords": "Nix, reference, manual, documentation" +--- + (nix-manual)= # Nix reference manual + + ```{toctree} :hidden: Nix pre-release (development) -Nix 2.19 (latest) -Nix 2.18 (rolling) -Nix 2.18 (stable 23.11) -Nix 2.13 (stable 23.05) +Nix @nix-latest@ (latest) +Nix @nix-rolling@ (in Nixpkgs rolling) +Nix @nix-stable@ (in Nixpkgs @nixpkgs-stable@) +Nix @nix-prev-stable@ (in Nixpkgs @nixpkgs-prev-stable@) ``` +The Nix reference manual is available for multiple versions: + - [Nix pre-release](https://hydra.nixos.org/job/nix/master/build.x86_64-linux/latest/download) - Reference documentation for the latest build from the `master` branch of the [Nix repository](https://github.com/NixOS/nix) + Development build from the `master` branch of the [Nix repository](https://github.com/NixOS/nix) -- [Nix 2.19](https://nix.dev/manual/nix/2.19/) +- [Nix @nix-latest@](https://nix.dev/manual/nix/latest/) - Reference documentation for the latest Nix release + Latest Nix release -- [Nix 2.18](https://nix.dev/manual/nix/2.18/) +- [Nix @nix-rolling@](https://nix.dev/manual/nix/rolling/) - Reference documentation for the Nix version shipped with the {term}`Nixpkgs` and {term}`NixOS` rolling release + Shipped with the rolling release of {term}`Nixpkgs` and {term}`NixOS` -- [Nix 2.18](https://nix.dev/manual/nix/2.18/) +- [Nix @nix-stable@](https://nix.dev/manual/nix/stable/) - Reference documentation for the Nix version shipped with the current {term}`Nixpkgs` and {term}`NixOS` stable release + Shipped with the latest stable release of {term}`Nixpkgs` and {term}`NixOS`: @nixpkgs-stable@ -- [Nix 2.13](https://nix.dev/manual/nix/2.13/) +- [Nix @nix-prev-stable@](https://nix.dev/manual/nix/prev-stable/) - Reference documentation for the Nix version shipped with the previous {term}`Nixpkgs` and {term}`NixOS` stable release + Shipped with the previous stable release of {term}`Nixpkgs` and {term}`NixOS`: @nixpkgs-prev-stable@ :::{tip} More information on Nixpkgs and NixOS releases: [](channel-branches)