Commit f08154ac authored by Emily Trau's avatar Emily Trau
Browse files

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

parent ebbc6ea8
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -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";

  # 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.
  rev = "bdd3ee779adb9f4a299059d09e68dfedecfd4226";

  # 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;
  };
+36 −0
Original line number Diff line number Diff line
# 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"
''