minimal-bootrap: init make-bootstrap-sources.nix

This commit is contained in:
Emily Trau 2023-05-01 17:54:29 +10:00
parent ebbc6ea8b3
commit f08154ac04
2 changed files with 48 additions and 5 deletions

View file

@ -7,13 +7,20 @@ lib.makeScope newScope (self: with self; {
# Pinned from https://github.com/oriansj/stage0-posix/commit/bdd3ee779adb9f4a299059d09e68dfedecfd4226
version = "unstable-2023-04-24";
rev = "bdd3ee779adb9f4a299059d09e68dfedecfd4226";
# We don't have access to utilities such as fetchgit and fetchzip since they
# 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 (Nix ARchive) file as input. This requires source tarballs to be repackaged.
# 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-${version}-source.nar.xz";
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;
};

View file

@ -0,0 +1,36 @@
# 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:
#
# nix-build pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/make-bootstrap-sources.nix
# => ./result/stage0-posix-0000000-source.nar.xz
#
{ pkgs ? import ../../../../.. {} }:
let
inherit (pkgs) runCommand fetchFromGitHub nix xz;
pname = "stage0-posix";
rev = "bdd3ee779adb9f4a299059d09e68dfedecfd4226";
shortHash = builtins.substring 0 7 rev;
src = fetchFromGitHub {
owner = "oriansj";
repo = pname;
inherit rev;
sha256 = "hMLo32yqXiTXPyW1jpR5zprYzZW8lFQy6KMrkNQZ89I=";
fetchSubmodules = true;
};
in
runCommand "${pname}-${shortHash}-source" {
nativeBuildInputs = [ nix xz ];
} ''
mkdir $out
nix-store --dump ${src} | xz -c > "$out/${pname}-${shortHash}-source.nar.xz"
''