Commit 5f4f945c authored by Emily Trau's avatar Emily Trau
Browse files

minimal-bootstrap: refactor out bootstrap-sources.nix

parent c2fd974d
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
rec {
  name = "stage0-posix-${version}-${rev}-source";
  # Pinned from https://github.com/oriansj/stage0-posix/commit/bdd3ee779adb9f4a299059d09e68dfedecfd4226
  version = "unstable-2023-04-24";
  rev = "bdd3ee779adb9f4a299059d09e68dfedecfd4226";

  # This 256 byte seed is the only pre-compiled binary in the bootstrap chain.
  # While it is included in the stage0-posix source bundle and is synced with
  # stage0-posix updates, we have split it out into its own derivation to highlight
  # its unique status as a trusted binary seed.
  hex0-seed = import <nix/fetchurl.nix> {
    name = "hex0-seed-${version}";
    url = "https://github.com/oriansj/bootstrap-seeds/raw/b1263ff14a17835f4d12539226208c426ced4fba/POSIX/x86/hex0-seed";
    hash = "sha256-QU3RPGy51W7M2xnfFY1IqruKzusrSLU+L190ztN6JW8=";
    executable = true;
  };

  # Packaged resources required for the first bootstrapping stage.
  # Contains source code and 256-byte hex0 binary seed.
  #
  # We don't have access to utilities such as fetchgit and fetchzip since this
  # is this is part of the bootstrap process and would introduce a circular
  # dependency. The only tool we have to fetch source trees is `import <nix/fetchurl.nix>`
  # with the unpack option, taking a NAR file as input. This requires source
  # tarballs to be repackaged.
  #
  # To build see `make-bootstrap-sources.nix`
  src = import <nix/fetchurl.nix> {
    inherit name;
    url = "https://github.com/emilytrau/bootstrap-tools-nar-mirror/releases/download/2023-04-25/${name}.nar.xz";
    hash = "sha256-hMLo32yqXiTXPyW1jpR5zprYzZW8lFQy6KMrkNQZ89I=";
    unpack = true;
  };
}
+1 −30
Original line number Diff line number Diff line
@@ -5,36 +5,7 @@
lib.makeScope newScope (self: with self; {
  callPackage = self.callPackage;

  # Pinned from https://github.com/oriansj/stage0-posix/commit/bdd3ee779adb9f4a299059d09e68dfedecfd4226
  version = "unstable-2023-04-24";
  rev = "bdd3ee779adb9f4a299059d09e68dfedecfd4226";

  # This 256 byte seed is the only pre-compiled binary in the bootstrap chain.
  # While it is included in the stage0-posix source bundle and is synced with
  # stage0-posix updates, we have split it out into its own derivation to highlight
  # its unique status as a trusted binary seed.
  hex0-seed = import <nix/fetchurl.nix> {
    name = "hex0-seed-${version}";
    url = "https://github.com/oriansj/bootstrap-seeds/raw/b1263ff14a17835f4d12539226208c426ced4fba/POSIX/x86/hex0-seed";
    hash = "sha256-QU3RPGy51W7M2xnfFY1IqruKzusrSLU+L190ztN6JW8=";
    executable = true;
  };

  # Packaged resources required for the first bootstrapping stage.
  # Contains source code and 256-byte hex0 binary seed.
  #
  # We don't have access to utilities such as fetchgit and fetchzip since this
  # is this is part of the bootstrap process and would introduce a circular
  # dependency. The only tool we have to fetch source trees is `import <nix/fetchurl.nix>`
  # with the unpack option, taking a NAR file as input. This requires source
  # tarballs to be repackaged.
  #
  # To build see `make-bootstrap-sources.nix`
  src = import <nix/fetchurl.nix> {
    url = "https://github.com/emilytrau/bootstrap-tools-nar-mirror/releases/download/2023-04-25/stage0-posix-${builtins.substring 0 7 rev}-source.nar.xz";
    hash = "sha256-hMLo32yqXiTXPyW1jpR5zprYzZW8lFQy6KMrkNQZ89I=";
    unpack = true;
  };
  inherit (import ./bootstrap-sources.nix) version hex0-seed src;

  m2libc = src + "/M2libc";

+7 −8
Original line number Diff line number Diff line
@@ -10,27 +10,26 @@
# To build:
#
#   nix-build pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/make-bootstrap-sources.nix
#   => ./result/stage0-posix-0000000-source.nar.xz
#   => ./result/stage0-posix-$version-$rev-source.nar.xz
#

{ pkgs ? import ../../../../.. {} }:
let
  inherit (pkgs) runCommand fetchFromGitHub nix xz;
  inherit (pkgs) callPackage runCommand fetchFromGitHub nix xz;

  inherit (import ./bootstrap-sources.nix) name rev;

  pname = "stage0-posix";
  rev = "bdd3ee779adb9f4a299059d09e68dfedecfd4226";
  shortHash = builtins.substring 0 7 rev;
  src = fetchFromGitHub {
    owner = "oriansj";
    repo = pname;
    repo = "stage0-posix";
    inherit rev;
    sha256 = "hMLo32yqXiTXPyW1jpR5zprYzZW8lFQy6KMrkNQZ89I=";
    fetchSubmodules = true;
  };
in
runCommand "${pname}-${shortHash}-source" {
runCommand name {
  nativeBuildInputs = [ nix xz ];
} ''
  mkdir $out
  nix-store --dump ${src} | xz -c > "$out/${pname}-${shortHash}-source.nar.xz"
  nix-store --dump ${src} | xz -c > "$out/${name}.nar.xz"
''