Skip to content

Commit

Permalink
separate minimal-bootstrap-sources from make-minimal-bootstrap-sources
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Adam Joseph committed Jun 26, 2023
1 parent df720da commit c8080b0
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
3 changes: 0 additions & 3 deletions pkgs/os-specific/linux/minimal-bootstrap/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
, hostPlatform
, fetchurl
, checkMeta
, make-minimal-bootstrap-sources
}:

lib.makeScope
Expand Down Expand Up @@ -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 { };

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{ make-minimal-bootstrap-sources
{
}:

rec {
name = "stage0-posix-${version}-${rev}-source";
# 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 <nix/fetchurl.nix> {
Expand Down Expand Up @@ -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 '<nixpkgs>' -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`.
#
'';
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 { };
Expand Down

0 comments on commit c8080b0

Please sign in to comment.