minimal-bootstrap.stage0-posix: remove builtins.fetchTarball

This commit is contained in:
Emily Trau 2023-04-25 18:46:33 +10:00
parent 71dcd60557
commit ba346eb8ac
9 changed files with 95 additions and 127 deletions

View file

@ -6,7 +6,20 @@
lib.makeScope newScope (self: with self; {
callPackage = self.callPackage;
inherit (callPackage ./sources.nix { }) version bootstrap-seeds-src m2-mesoplanet-src m2-planet-src m2libc mescc-tools-src mescc-tools-extra-src stage0-posix-x86-src;
# 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.
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";
hash = "sha256-hMLo32yqXiTXPyW1jpR5zprYzZW8lFQy6KMrkNQZ89I=";
unpack = true;
};
m2libc = src + "/M2libc";
hex0 = callPackage ./hex0.nix { };

View file

@ -1,5 +1,5 @@
{ system
, bootstrap-seeds-src
, src
, version
}:
let
@ -8,15 +8,15 @@ let
i686-linux = "x86";
}.${system} or throwSystem;
seed = "${bootstrap-seeds-src}/POSIX/${arch}/hex0-seed";
src = "${bootstrap-seeds-src}/POSIX/${arch}/hex0_${arch}.hex0";
seed = "${src}/bootstrap-seeds/POSIX/${arch}/hex0-seed";
source = "${src}/bootstrap-seeds/POSIX/${arch}/hex0_${arch}.hex0";
in
derivation {
inherit system;
name = "hex0-${version}";
builder = seed;
args = [
src
source
(placeholder "out")
];
}

View file

@ -1,5 +1,5 @@
{ system
, bootstrap-seeds-src
, src
, hex0
, version
}:
@ -9,14 +9,14 @@ let
i686-linux = "x86";
}.${system} or throwSystem;
src = "${bootstrap-seeds-src}/POSIX/${arch}/kaem-minimal.hex0";
source = "${src}/bootstrap-seeds/POSIX/${arch}/kaem-minimal.hex0";
in
derivation {
inherit system;
name = "kaem-minimal-${version}";
builder = hex0;
args = [
src
source
(placeholder "out")
];
}

View file

@ -2,19 +2,20 @@
# https://github.com/oriansj/mescc-tools-extra/blob/ec53af69d6d2119b47b369cd0ec37ac806e7ad60/mescc-tools-extra.kaem
alias CC="${mescc-tools}/bin/M2-Mesoplanet --operating-system ${OPERATING_SYSTEM} --architecture ${ARCH} -f"
cd ${src}/mescc-tools-extra
# Create output folder
CC ${src}/mkdir.c -o ./mkdir
./mkdir -p ${out}/bin
CC mkdir.c -o ${TMP}/mkdir
${TMP}/mkdir -p ${out}/bin
CC ${src}/sha256sum.c -o ${out}/bin/sha256sum
CC ${src}/match.c -o ${out}/bin/match
CC ${src}/mkdir.c -o ${out}/bin/mkdir
CC ${src}/untar.c -o ${out}/bin/untar
CC ${src}/ungz.c -o ${out}/bin/ungz
CC ${src}/unbz2.c -o ${out}/bin/unbz2
CC ${src}/catm.c -o ${out}/bin/catm
CC ${src}/cp.c -o ${out}/bin/cp
CC ${src}/chmod.c -o ${out}/bin/chmod
CC ${src}/rm.c -o ${out}/bin/rm
CC ${src}/replace.c -o ${out}/bin/replace
CC sha256sum.c -o ${out}/bin/sha256sum
CC match.c -o ${out}/bin/match
CC mkdir.c -o ${out}/bin/mkdir
CC untar.c -o ${out}/bin/untar
CC ungz.c -o ${out}/bin/ungz
CC unbz2.c -o ${out}/bin/unbz2
CC catm.c -o ${out}/bin/catm
CC cp.c -o ${out}/bin/cp
CC chmod.c -o ${out}/bin/chmod
CC rm.c -o ${out}/bin/rm
CC replace.c -o ${out}/bin/replace

View file

@ -1,5 +1,5 @@
{ mkKaemDerivation0
, mescc-tools-extra-src
, src
, mescc-tools
, version
}:
@ -7,6 +7,5 @@ mkKaemDerivation0 {
name = "mescc-tools-extra-${version}";
script = ./build.kaem;
src = mescc-tools-extra-src;
inherit mescc-tools;
inherit src mescc-tools;
}

View file

@ -12,12 +12,12 @@ ${chmod} 0555 ${out}/bin/hex2
# M2-Mesoplanet searches for runtime dependencies in environment variables
# We can hardcode them with the "replace" utility from mescc-tools-extra
${replace} \
--file ${m2-mesoplanet-src}/cc.c \
--file ${src}/M2-Mesoplanet/cc.c \
--output ./cc_patched.c \
--match-on "env_lookup(\"M2LIBC_PATH\")" \
--replace-with "\"${m2libc}\""
${replace} \
--file ${m2-mesoplanet-src}/cc_spawn.c \
--file ${src}/M2-Mesoplanet/cc_spawn.c \
--output ./cc_spawn_patched.c \
--match-on "env_lookup(\"PATH\")" \
--replace-with "\"${out}/bin:\""
@ -38,13 +38,13 @@ ${M2} --architecture ${ARCH} \
-f ${m2libc}/stdio.c \
-f ${m2libc}/string.c \
-f ${m2libc}/bootstrappable.c \
-f ${m2-mesoplanet-src}/cc.h \
-f ${m2-mesoplanet-src}/cc_globals.c \
-f ${m2-mesoplanet-src}/cc_env.c \
-f ${m2-mesoplanet-src}/cc_reader.c \
-f ${src}/M2-Mesoplanet/cc.h \
-f ${src}/M2-Mesoplanet/cc_globals.c \
-f ${src}/M2-Mesoplanet/cc_env.c \
-f ${src}/M2-Mesoplanet/cc_reader.c \
-f ./cc_spawn_patched.c \
-f ${m2-mesoplanet-src}/cc_core.c \
-f ${m2-mesoplanet-src}/cc_macro.c \
-f ${src}/M2-Mesoplanet/cc_core.c \
-f ${src}/M2-Mesoplanet/cc_macro.c \
-f ./cc_patched.c \
--debug \
-o ./M2-Mesoplanet-1.M1
@ -80,8 +80,8 @@ ${M2} --architecture ${ARCH} \
-f ${m2libc}/stdio.h \
-f ${m2libc}/stdio.c \
-f ${m2libc}/bootstrappable.c \
-f ${mescc-tools-src}/stringify.c \
-f ${mescc-tools-src}/blood-elf.c \
-f ${src}/mescc-tools/stringify.c \
-f ${src}/mescc-tools/blood-elf.c \
--debug \
-o ./blood-elf-1.M1
@ -119,7 +119,7 @@ ${M2} --architecture ${ARCH} \
-f ${m2libc}/stdio.h \
-f ${m2libc}/stdio.c \
-f ${m2libc}/bootstrappable.c \
-f ${mescc-tools-src}/get_machine.c \
-f ${src}/mescc-tools/get_machine.c \
--debug \
-o get_machine.M1
@ -154,14 +154,14 @@ ${M2} --architecture ${ARCH} \
-f ${m2libc}/stdio.h \
-f ${m2libc}/stdio.c \
-f ${m2libc}/bootstrappable.c \
-f ${m2-planet-src}/cc.h \
-f ${m2-planet-src}/cc_globals.c \
-f ${m2-planet-src}/cc_reader.c \
-f ${m2-planet-src}/cc_strings.c \
-f ${m2-planet-src}/cc_types.c \
-f ${m2-planet-src}/cc_core.c \
-f ${m2-planet-src}/cc_macro.c \
-f ${m2-planet-src}/cc.c \
-f ${src}/M2-Planet/cc.h \
-f ${src}/M2-Planet/cc_globals.c \
-f ${src}/M2-Planet/cc_reader.c \
-f ${src}/M2-Planet/cc_strings.c \
-f ${src}/M2-Planet/cc_types.c \
-f ${src}/M2-Planet/cc_core.c \
-f ${src}/M2-Planet/cc_macro.c \
-f ${src}/M2-Planet/cc.c \
--debug \
-o ./M2-1.M1

View file

@ -5,10 +5,7 @@
, blood-elf-0
, hex2
, m2libc
, m2-mesoplanet-src
, m2-planet-src
, mescc-tools-src
, mescc-tools-extra-src
, src
, version
}:
@ -30,7 +27,7 @@ let
-f ''${m2libc}/stdio.c \
-f ''${m2libc}/string.c \
-f ''${m2libc}/bootstrappable.c \
-f ''${mescc-tools-extra-src}/${name}.c \
-f ''${src}/mescc-tools-extra/${name}.c \
--debug \
-o ${name}.M1
@ -51,7 +48,7 @@ let
--base-address ''${BASE_ADDRESS} \
-o ''${out}
'';
inherit M1 M2 blood-elf-0 hex2 m2libc mescc-tools-extra-src;
inherit M1 M2 blood-elf-0 hex2 m2libc src;
};
mkdir = buildMesccToolsExtraUtil "mkdir";
cp = buildMesccToolsExtraUtil "cp";
@ -62,5 +59,5 @@ mkKaemDerivation0 {
name = "mescc-tools-${version}";
script = ./build.kaem;
inherit M1 M2 blood-elf-0 hex2 mkdir cp chmod replace m2libc m2-mesoplanet-src m2-planet-src mescc-tools-src;
inherit M1 M2 blood-elf-0 hex2 mkdir cp chmod replace m2libc src;
}

View file

@ -1,40 +0,0 @@
{}:
{
# Pinned from https://github.com/oriansj/stage0-posix/commit/4ad489ffc261ee036cfd33f20d939d7c5b05844e
version = "unstable-2023-04-16";
bootstrap-seeds-src = builtins.fetchTarball {
url = "https://github.com/oriansj/bootstrap-seeds/archive/e4974affa1934274a8b8c29f19c87e758e650f52.tar.gz";
sha256 = "0f325x9sixbv35b5s6cjd2qi41n84kmzia11n6w4r6rrldw6wci2";
};
m2-mesoplanet-src = builtins.fetchTarball {
url = "https://github.com/oriansj/M2-Mesoplanet/archive/4bf3e2eded821cf9b69fd63a033272197a8703f7.tar.gz";
sha256 = "0db13grmxg5hp1jj8vss2ms9c7znk319pkhmnd1ygzg5w8i2v0cj";
};
m2-planet-src = builtins.fetchTarball {
url = "https://github.com/oriansj/M2-Planet/archive/f02aaaf67bf004eccd5fd0efb33ced481a0d8346.tar.gz";
sha256 = "0bysizqr8nffzzjq6m59gs1m5z2smwfbymijjkxr3l8rxx819vck";
};
m2libc = builtins.fetchTarball {
url = "https://github.com/oriansj/M2libc/archive/1139b2bbf5f9c2618e52298917460ec75c345451.tar.gz";
sha256 = "113bsmpas8iwflnyjh34ap0p0y23bgdkca9viz9l87kwjbag5y4p";
};
mescc-tools-src = builtins.fetchTarball {
url = "https://github.com/oriansj/mescc-tools/archive/3f941824677d74b30d80de08436d63b783adc17f.tar.gz";
sha256 = "0cl5934giah2hdzi5q3w3qmkhpm7gx9qjc7nhbwvs3gbmq10nk36";
};
mescc-tools-extra-src = builtins.fetchTarball {
url = "https://github.com/oriansj/mescc-tools-extra/archive/ec53af69d6d2119b47b369cd0ec37ac806e7ad60.tar.gz";
sha256 = "1kn8mpx104ij9gxifl10dbyalizyn3ifszj5i3msidvr5k7ciay1";
};
stage0-posix-x86-src = builtins.fetchTarball {
url = "https://github.com/oriansj/stage0-posix-x86/archive/56e6b8df3e95f4bc04f8b420a4cd8c82c70b9efa.tar.gz";
sha256 = "0fih58js6kpflbx9bkl3ikpmbxljlfpg36s78dnaiy6nim36aw7d";
};
}

View file

@ -6,10 +6,8 @@
{ system
, hex0
, stage0-posix-x86-src
, m2libc
, m2-planet-src
, mescc-tools-src
, src
, version
}:
rec {
@ -24,7 +22,7 @@ rec {
# Phase-1 Build hex1 from hex0 #
################################
hex1 = run "hex1" hex0 ["${stage0-posix-x86-src}/hex1_x86.hex0" out];
hex1 = run "hex1" hex0 ["${src}/x86/hex1_x86.hex0" out];
# hex1 adds support for single character labels and is available in various forms
# in mescc-tools/x86_bootstrap to allow you various ways to verify correctness
@ -33,7 +31,7 @@ rec {
# Phase-2 Build hex2 from hex1 #
################################
hex2-0 = run "hex2" hex1 ["${stage0-posix-x86-src}/hex2_x86.hex1" out];
hex2-0 = run "hex2" hex1 ["${src}/x86/hex2_x86.hex1" out];
# hex2 adds support for long labels and absolute addresses thus allowing it
# to function as an effective linker for later stages of the bootstrap
@ -44,7 +42,7 @@ rec {
# Phase-2b Build catm from hex2 #
#################################
catm = run "catm" hex2-0 ["${stage0-posix-x86-src}/catm_x86.hex2" out];
catm = run "catm" hex2-0 ["${src}/x86/catm_x86.hex2" out];
# catm removes the need for cat or shell support for redirection by providing
# equivalent functionality via catm output_file input1 input2 ... inputN
@ -53,7 +51,7 @@ rec {
# Phase-3 Build M0 from hex2 #
##############################
M0_hex2 = run "M0.hex2" catm [out "${stage0-posix-x86-src}/ELF-i386.hex2" "${stage0-posix-x86-src}/M0_x86.hex2"];
M0_hex2 = run "M0.hex2" catm [out "${src}/x86/ELF-i386.hex2" "${src}/x86/M0_x86.hex2"];
M0 = run "M0" hex2-0 [M0_hex2 out];
# M0 is the architecture specific version of M1 and is by design single
@ -63,8 +61,8 @@ rec {
# Phase-4 Build cc_x86 from M0 #
################################
cc_x86-0_hex2 = run "cc_x86-0.hex2" M0 ["${stage0-posix-x86-src}/cc_x86.M1" out];
cc_x86-1_hex2 = run "cc_x86-1.hex2" catm [out "${stage0-posix-x86-src}/ELF-i386.hex2" cc_x86-0_hex2];
cc_x86-0_hex2 = run "cc_x86-0.hex2" M0 ["${src}/x86/cc_x86.M1" out];
cc_x86-1_hex2 = run "cc_x86-1.hex2" catm [out "${src}/x86/ELF-i386.hex2" cc_x86-0_hex2];
cc_x86 = run "cc_x86" hex2-0 [cc_x86-1_hex2 out];
#######################################
@ -74,20 +72,20 @@ rec {
M2-0_c = run "M2-0.c" catm [
out
"${m2libc}/x86/linux/bootstrap.c"
"${m2-planet-src}/cc.h"
"${src}/M2-Planet/cc.h"
"${m2libc}/bootstrappable.c"
"${m2-planet-src}/cc_globals.c"
"${m2-planet-src}/cc_reader.c"
"${m2-planet-src}/cc_strings.c"
"${m2-planet-src}/cc_types.c"
"${m2-planet-src}/cc_core.c"
"${m2-planet-src}/cc_macro.c"
"${m2-planet-src}/cc.c"
"${src}/M2-Planet/cc_globals.c"
"${src}/M2-Planet/cc_reader.c"
"${src}/M2-Planet/cc_strings.c"
"${src}/M2-Planet/cc_types.c"
"${src}/M2-Planet/cc_core.c"
"${src}/M2-Planet/cc_macro.c"
"${src}/M2-Planet/cc.c"
];
M2-0_M1 = run "M2-0.M1" cc_x86 [M2-0_c out];
M2-0-0_M1 = run "M2-0-0.M1" catm [out "${stage0-posix-x86-src}/x86_defs.M1" "${stage0-posix-x86-src}/libc-core.M1" M2-0_M1];
M2-0-0_M1 = run "M2-0-0.M1" catm [out "${src}/x86/x86_defs.M1" "${src}/x86/libc-core.M1" M2-0_M1];
M2-0_hex2 = run "M2-0.hex2" M0 [M2-0-0_M1 out];
M2-0-0_hex2 = run "M2-0-0.hex2" catm [out "${stage0-posix-x86-src}/ELF-i386.hex2" M2-0_hex2];
M2-0-0_hex2 = run "M2-0-0.hex2" catm [out "${src}/x86/ELF-i386.hex2" M2-0_hex2];
M2 = run "M2" hex2-0 [M2-0-0_hex2 out];
############################################
@ -98,8 +96,8 @@ rec {
"--architecture" "x86"
"-f" "${m2libc}/x86/linux/bootstrap.c"
"-f" "${m2libc}/bootstrappable.c"
"-f" "${mescc-tools-src}/stringify.c"
"-f" "${mescc-tools-src}/blood-elf.c"
"-f" "${src}/mescc-tools/stringify.c"
"-f" "${src}/mescc-tools/blood-elf.c"
"--bootstrap-mode"
"-o" out
];
@ -120,8 +118,8 @@ rec {
"--architecture" "x86"
"-f" "${m2libc}/x86/linux/bootstrap.c"
"-f" "${m2libc}/bootstrappable.c"
"-f" "${mescc-tools-src}/stringify.c"
"-f" "${mescc-tools-src}/M1-macro.c"
"-f" "${src}/mescc-tools/stringify.c"
"-f" "${src}/mescc-tools/M1-macro.c"
"--bootstrap-mode"
"--debug"
"-o" out
@ -153,10 +151,10 @@ rec {
"-f" "${m2libc}/stdio.h"
"-f" "${m2libc}/stdio.c"
"-f" "${m2libc}/bootstrappable.c"
"-f" "${mescc-tools-src}/hex2.h"
"-f" "${mescc-tools-src}/hex2_linker.c"
"-f" "${mescc-tools-src}/hex2_word.c"
"-f" "${mescc-tools-src}/hex2.c"
"-f" "${src}/mescc-tools/hex2.h"
"-f" "${src}/mescc-tools/hex2_linker.c"
"-f" "${src}/mescc-tools/hex2_word.c"
"-f" "${src}/mescc-tools/hex2.c"
"--debug"
"-o" out
];
@ -196,8 +194,8 @@ rec {
"-f" "${m2libc}/stdio.h"
"-f" "${m2libc}/stdio.c"
"-f" "${m2libc}/bootstrappable.c"
"-f" "${mescc-tools-src}/stringify.c"
"-f" "${mescc-tools-src}/M1-macro.c"
"-f" "${src}/mescc-tools/stringify.c"
"-f" "${src}/mescc-tools/M1-macro.c"
"--debug"
"-o" out
];
@ -239,10 +237,10 @@ rec {
"-f" "${m2libc}/stdio.h"
"-f" "${m2libc}/stdio.c"
"-f" "${m2libc}/bootstrappable.c"
"-f" "${mescc-tools-src}/hex2.h"
"-f" "${mescc-tools-src}/hex2_linker.c"
"-f" "${mescc-tools-src}/hex2_word.c"
"-f" "${mescc-tools-src}/hex2.c"
"-f" "${src}/mescc-tools/hex2.h"
"-f" "${src}/mescc-tools/hex2_linker.c"
"-f" "${src}/mescc-tools/hex2_word.c"
"-f" "${src}/mescc-tools/hex2.c"
"--debug"
"-o" out
];
@ -284,10 +282,10 @@ rec {
"-f" "${m2libc}/stdio.h"
"-f" "${m2libc}/stdio.c"
"-f" "${m2libc}/bootstrappable.c"
"-f" "${mescc-tools-src}/Kaem/kaem.h"
"-f" "${mescc-tools-src}/Kaem/variable.c"
"-f" "${mescc-tools-src}/Kaem/kaem_globals.c"
"-f" "${mescc-tools-src}/Kaem/kaem.c"
"-f" "${src}/mescc-tools/Kaem/kaem.h"
"-f" "${src}/mescc-tools/Kaem/variable.c"
"-f" "${src}/mescc-tools/Kaem/kaem_globals.c"
"-f" "${src}/mescc-tools/Kaem/kaem.c"
"--debug"
"-o" out
];