From c8080b06a9458f8c898ea4537dab82d32e71d06c Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Mon, 26 Jun 2023 00:52:22 -0700 Subject: [PATCH] separate minimal-bootstrap-sources from make-minimal-bootstrap-sources Ericson2314 observed that although FODs break the build-time cycle, they don't break the eval-time cycle. This cycle must be broken in order to compute the derivation hash. make-minimal-bootstrap-sources does and always has depended on the full nixpkgs (including fetchFromGitHub). This commit completely separates minimal-bootstrap-sources from it, so that minimal-bootstrap-sources now does not depend on make-minimal-bootstrap-sources (or nixpkgs) in any way. minimal-bootstrap-sources is now a "bare Nix" derivation. It is an FOD whose builder always fails with an error message. --- .../linux/minimal-bootstrap/default.nix | 3 -- .../stage0-posix/bootstrap-sources.nix | 37 +++++++++++++++++-- .../stage0-posix/default.nix | 2 +- .../stage0-posix/make-bootstrap-sources.nix | 2 +- pkgs/top-level/all-packages.nix | 2 +- 5 files changed, 36 insertions(+), 10 deletions(-) diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index 3c1746716f06..3e4e9e7f5cb8 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -4,7 +4,6 @@ , hostPlatform , fetchurl , checkMeta -, make-minimal-bootstrap-sources }: lib.makeScope @@ -61,8 +60,6 @@ lib.makeScope ln-boot = callPackage ./ln-boot { }; - inherit make-minimal-bootstrap-sources; - mes = lib.recurseIntoAttrs (callPackage ./mes { }); mes-libc = callPackage ./mes/libc.nix { }; diff --git a/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/bootstrap-sources.nix b/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/bootstrap-sources.nix index 4aa5d32f7498..65b052c44569 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/bootstrap-sources.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/bootstrap-sources.nix @@ -1,4 +1,4 @@ -{ make-minimal-bootstrap-sources +{ }: rec { @@ -6,6 +6,7 @@ rec { # Pinned from https://github.com/oriansj/stage0-posix/commit/3189b5f325b7ef8b88e3edec7c1cde4fce73c76c version = "unstable-2023-05-02"; rev = "3189b5f325b7ef8b88e3edec7c1cde4fce73c76c"; + outputHashAlgo = "sha256"; # This 256 byte seed is the only pre-compiled binary in the bootstrap chain. hex0-seed = import { @@ -69,9 +70,37 @@ rec { specifically designed for bit-exact reproducibility, none of the requirements above apply to `minimal-bootstrap-sources`. */ - minimal-bootstrap-sources = make-minimal-bootstrap-sources.overrideAttrs(_: { + minimal-bootstrap-sources = derivation { + name = "${name}.nar.xz"; + system = builtins.currentSystem; outputHashMode = "flat"; - outputHashAlgo = "sha256"; + inherit outputHashAlgo; outputHash = "sha256-ig988BiRTz92hhZZgKQW1tVPoV4aQ2D69Cq3wHvVgHg="; - }); + + # This builder always fails, but fortunately Nix will print the + # "builder", which is really the error message that we want the + # user to see. + builder = '' + # + # + # Neither your store nor your substituters seems to have: + # + # ${name}.nar.xz + # + # Please obtain or create this file, give it exactly the name + # shown above, and then run the following command: + # + # nix-store --add-fixed ${outputHashAlgo} ${name}.nar.xz + # + # You can create this file from an already-bootstrapped nixpkgs + # using the following command: + # + # nix-build '' -A make-minimal-bootstrap-sources + # + # Or, if you prefer, you can create this file using only `git`, + # `nix`, and `xz`. For the commands needed in order to do this, + # see `make-bootstrap-sources.nix`. + # + ''; + }; } diff --git a/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/default.nix index 8e0900100aed..c15223a43d48 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/default.nix @@ -3,7 +3,7 @@ }: lib.makeScope newScope (self: with self; { - inherit (self.callPackage ./bootstrap-sources.nix) + inherit (self.callPackage ./bootstrap-sources.nix {}) version hex0-seed minimal-bootstrap-sources; src = minimal-bootstrap-sources; diff --git a/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/make-bootstrap-sources.nix b/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/make-bootstrap-sources.nix index 4fe9a9be7881..8951cc9ddbc4 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/make-bootstrap-sources.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/make-bootstrap-sources.nix @@ -18,7 +18,7 @@ , xz }: let - inherit (import ./bootstrap-sources.nix { make-minimal-bootstrap-sources = null; }) name rev; + inherit (import ./bootstrap-sources.nix { }) name rev; src = fetchFromGitHub { owner = "oriansj"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 55d5131553ca..e68f4669541f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -27440,8 +27440,8 @@ with pkgs; inherit (stdenv.buildPlatform) system; }; checkMeta = callPackage ../stdenv/generic/check-meta.nix { }; - inherit make-minimal-bootstrap-sources; }); + minimal-bootstrap-sources = callPackage ../os-specific/linux/minimal-bootstrap/stage0-posix/bootstrap-sources.nix { }; make-minimal-bootstrap-sources = callPackage ../os-specific/linux/minimal-bootstrap/stage0-posix/make-bootstrap-sources.nix { }; mingetty = callPackage ../os-specific/linux/mingetty { };