minimal-bootstrap.stage0-posix: remove mkKaemDerivation0 abstration
This commit is contained in:
parent
59e11ad4e4
commit
60ebcafd47
@ -27,27 +27,6 @@ lib.makeScope newScope (self: with self; {
|
||||
|
||||
inherit (callPackage ./stage0-posix-x86.nix { }) blood-elf-0 hex2 kaem-unwrapped M1 M2;
|
||||
|
||||
mkKaemDerivation0 = args@{
|
||||
script,
|
||||
...
|
||||
}:
|
||||
derivationWithMeta ({
|
||||
inherit system;
|
||||
builder = kaem-unwrapped;
|
||||
args = [
|
||||
"--verbose"
|
||||
"--strict"
|
||||
"--file"
|
||||
script
|
||||
];
|
||||
|
||||
ARCH = "x86";
|
||||
OPERATING_SYSTEM = "linux";
|
||||
BLOOD_FLAG = " ";
|
||||
BASE_ADDRESS = "0x8048000";
|
||||
ENDIAN_FLAG = "--little-endian";
|
||||
} // (builtins.removeAttrs args [ "script" ]));
|
||||
|
||||
mescc-tools = callPackage ./mescc-tools { };
|
||||
|
||||
mescc-tools-extra = callPackage ./mescc-tools-extra { };
|
||||
@ -56,15 +35,21 @@ lib.makeScope newScope (self: with self; {
|
||||
|
||||
# Now that mescc-tools-extra is available we can install kaem at /bin/kaem
|
||||
# to make it findable in environments
|
||||
kaem = mkKaemDerivation0 {
|
||||
kaem = derivationWithMeta {
|
||||
inherit system version kaem-unwrapped;
|
||||
pname = "kaem";
|
||||
script = builtins.toFile "kaem-wrapper.kaem" ''
|
||||
mkdir -p ''${out}/bin
|
||||
cp ''${kaem-unwrapped} ''${out}/bin/kaem
|
||||
chmod 555 ''${out}/bin/kaem
|
||||
'';
|
||||
builder = kaem-unwrapped;
|
||||
args = [
|
||||
"--verbose"
|
||||
"--strict"
|
||||
"--file"
|
||||
(builtins.toFile "kaem-wrapper.kaem" ''
|
||||
mkdir -p ''${out}/bin
|
||||
cp ''${kaem-unwrapped} ''${out}/bin/kaem
|
||||
chmod 555 ''${out}/bin/kaem
|
||||
'')
|
||||
];
|
||||
PATH = lib.makeBinPath [ mescc-tools-extra ];
|
||||
inherit version kaem-unwrapped;
|
||||
|
||||
meta = with lib; {
|
||||
description = "Minimal build tool for running scripts on systems that lack any shell";
|
||||
|
@ -1,13 +1,24 @@
|
||||
{ lib
|
||||
, mkKaemDerivation0
|
||||
, src
|
||||
, system
|
||||
, derivationWithMeta
|
||||
, kaem-unwrapped
|
||||
, mescc-tools
|
||||
, src
|
||||
, version
|
||||
}:
|
||||
mkKaemDerivation0 {
|
||||
inherit version src mescc-tools;
|
||||
derivationWithMeta {
|
||||
inherit system version src mescc-tools;
|
||||
pname = "mescc-tools-extra";
|
||||
script = ./build.kaem;
|
||||
builder = kaem-unwrapped;
|
||||
args = [
|
||||
"--verbose"
|
||||
"--strict"
|
||||
"--file"
|
||||
./build.kaem
|
||||
];
|
||||
|
||||
ARCH = "x86";
|
||||
OPERATING_SYSTEM = "linux";
|
||||
|
||||
meta = with lib; {
|
||||
description = "Collection of tools written for use in bootstrapping";
|
||||
|
@ -1,5 +1,7 @@
|
||||
{ lib
|
||||
, mkKaemDerivation0
|
||||
, system
|
||||
, derivationWithMeta
|
||||
, kaem-unwrapped
|
||||
, M1
|
||||
, M2
|
||||
, blood-elf-0
|
||||
@ -10,55 +12,74 @@
|
||||
}:
|
||||
|
||||
let
|
||||
ARCH = "x86";
|
||||
BLOOD_FLAG = " ";
|
||||
BASE_ADDRESS = "0x8048000";
|
||||
ENDIAN_FLAG = "--little-endian";
|
||||
|
||||
# We need a few tools from mescc-tools-extra to assemble the output folder
|
||||
buildMesccToolsExtraUtil = name:
|
||||
mkKaemDerivation0 {
|
||||
derivationWithMeta {
|
||||
pname = "mescc-tools-extra-${name}";
|
||||
script = builtins.toFile "build-${name}.kaem" ''
|
||||
''${M2} --architecture ''${ARCH} \
|
||||
-f ''${m2libc}/sys/types.h \
|
||||
-f ''${m2libc}/stddef.h \
|
||||
-f ''${m2libc}/''${ARCH}/linux/fcntl.c \
|
||||
-f ''${m2libc}/fcntl.c \
|
||||
-f ''${m2libc}/''${ARCH}/linux/unistd.c \
|
||||
-f ''${m2libc}/''${ARCH}/linux/sys/stat.c \
|
||||
-f ''${m2libc}/stdlib.c \
|
||||
-f ''${m2libc}/stdio.h \
|
||||
-f ''${m2libc}/stdio.c \
|
||||
-f ''${m2libc}/string.c \
|
||||
-f ''${m2libc}/bootstrappable.c \
|
||||
-f ''${src}/mescc-tools-extra/${name}.c \
|
||||
--debug \
|
||||
-o ${name}.M1
|
||||
builder = kaem-unwrapped;
|
||||
args = [
|
||||
"--verbose"
|
||||
"--strict"
|
||||
"--file"
|
||||
(builtins.toFile "build-${name}.kaem" ''
|
||||
''${M2} --architecture ''${ARCH} \
|
||||
-f ''${m2libc}/sys/types.h \
|
||||
-f ''${m2libc}/stddef.h \
|
||||
-f ''${m2libc}/''${ARCH}/linux/fcntl.c \
|
||||
-f ''${m2libc}/fcntl.c \
|
||||
-f ''${m2libc}/''${ARCH}/linux/unistd.c \
|
||||
-f ''${m2libc}/''${ARCH}/linux/sys/stat.c \
|
||||
-f ''${m2libc}/stdlib.c \
|
||||
-f ''${m2libc}/stdio.h \
|
||||
-f ''${m2libc}/stdio.c \
|
||||
-f ''${m2libc}/string.c \
|
||||
-f ''${m2libc}/bootstrappable.c \
|
||||
-f ''${src}/mescc-tools-extra/${name}.c \
|
||||
--debug \
|
||||
-o ${name}.M1
|
||||
|
||||
''${blood-elf-0} ''${ENDIAN_FLAG} -f ${name}.M1 -o ${name}-footer.M1
|
||||
''${blood-elf-0} ''${ENDIAN_FLAG} -f ${name}.M1 -o ${name}-footer.M1
|
||||
|
||||
''${M1} --architecture ''${ARCH} \
|
||||
''${ENDIAN_FLAG} \
|
||||
-f ''${m2libc}/''${ARCH}/''${ARCH}_defs.M1 \
|
||||
-f ''${m2libc}/''${ARCH}/libc-full.M1 \
|
||||
-f ${name}.M1 \
|
||||
-f ${name}-footer.M1 \
|
||||
-o ${name}.hex2
|
||||
|
||||
''${hex2} --architecture ''${ARCH} \
|
||||
''${ENDIAN_FLAG} \
|
||||
-f ''${m2libc}/''${ARCH}/ELF-''${ARCH}-debug.hex2 \
|
||||
-f ${name}.hex2 \
|
||||
--base-address ''${BASE_ADDRESS} \
|
||||
-o ''${out}
|
||||
'')
|
||||
];
|
||||
inherit system version M1 M2 blood-elf-0 hex2 m2libc src ARCH BLOOD_FLAG BASE_ADDRESS ENDIAN_FLAG;
|
||||
|
||||
''${M1} --architecture ''${ARCH} \
|
||||
''${ENDIAN_FLAG} \
|
||||
-f ''${m2libc}/''${ARCH}/''${ARCH}_defs.M1 \
|
||||
-f ''${m2libc}/''${ARCH}/libc-full.M1 \
|
||||
-f ${name}.M1 \
|
||||
-f ${name}-footer.M1 \
|
||||
-o ${name}.hex2
|
||||
|
||||
''${hex2} --architecture ''${ARCH} \
|
||||
''${ENDIAN_FLAG} \
|
||||
-f ''${m2libc}/''${ARCH}/ELF-''${ARCH}-debug.hex2 \
|
||||
-f ${name}.hex2 \
|
||||
--base-address ''${BASE_ADDRESS} \
|
||||
-o ''${out}
|
||||
'';
|
||||
inherit version M1 M2 blood-elf-0 hex2 m2libc src;
|
||||
};
|
||||
mkdir = buildMesccToolsExtraUtil "mkdir";
|
||||
cp = buildMesccToolsExtraUtil "cp";
|
||||
chmod = buildMesccToolsExtraUtil "chmod";
|
||||
replace = buildMesccToolsExtraUtil "replace";
|
||||
in
|
||||
mkKaemDerivation0 {
|
||||
derivationWithMeta {
|
||||
pname = "mescc-tools";
|
||||
script = ./build.kaem;
|
||||
inherit version M1 M2 blood-elf-0 hex2 mkdir cp chmod replace m2libc src;
|
||||
builder = kaem-unwrapped;
|
||||
args = [
|
||||
"--verbose"
|
||||
"--strict"
|
||||
"--file"
|
||||
./build.kaem
|
||||
];
|
||||
inherit system version M1 M2 blood-elf-0 hex2 mkdir cp chmod replace m2libc src ARCH BLOOD_FLAG BASE_ADDRESS ENDIAN_FLAG;
|
||||
|
||||
meta = with lib; {
|
||||
description = "Collection of tools written for use in bootstrapping";
|
||||
|
@ -2,9 +2,9 @@
|
||||
, stdenv
|
||||
, system
|
||||
, callPackage
|
||||
, mkKaemDerivation0
|
||||
, fetchurl
|
||||
, kaem
|
||||
, kaem-unwrapped
|
||||
, mescc-tools
|
||||
, mescc-tools-extra
|
||||
}:
|
||||
@ -35,21 +35,28 @@ rec {
|
||||
, allowSubstitutes ? false
|
||||
, preferLocalBuild ? true
|
||||
}:
|
||||
mkKaemDerivation0 {
|
||||
inherit name text executable allowSubstitutes preferLocalBuild;
|
||||
derivationWithMeta {
|
||||
inherit system name text executable allowSubstitutes preferLocalBuild;
|
||||
passAsFile = [ "text" ];
|
||||
|
||||
builder = kaem-unwrapped;
|
||||
args = [
|
||||
"--verbose"
|
||||
"--strict"
|
||||
"--file"
|
||||
(builtins.toFile "write-text-file.kaem" ''
|
||||
target=''${out}${destination}
|
||||
if match x${if builtins.dirOf destination == "" then "0" else "1"} x1; then
|
||||
mkdir -p ''${out}${builtins.dirOf destination}
|
||||
fi
|
||||
cp ''${textPath} ''${target}
|
||||
if match x''${executable} x1; then
|
||||
chmod 555 ''${target}
|
||||
fi
|
||||
'')
|
||||
];
|
||||
|
||||
PATH = lib.makeBinPath [ mescc-tools-extra ];
|
||||
script = builtins.toFile "write-text-file.kaem" ''
|
||||
target=''${out}${destination}
|
||||
if match x${if builtins.dirOf destination == "" then "0" else "1"} x1; then
|
||||
mkdir -p ''${out}${builtins.dirOf destination}
|
||||
fi
|
||||
cp ''${textPath} ''${target}
|
||||
if match x''${executable} x1; then
|
||||
chmod 555 ''${target}
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
writeText = name: text: writeTextFile {inherit name text;};
|
||||
|
Loading…
Reference in New Issue
Block a user