Bootstrap busybox from binaries

This commit is contained in:
clerie 2023-06-27 18:09:35 +02:00
commit e2d6b08c5a
3 changed files with 51 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
result

29
busybox.nix Normal file
View File

@ -0,0 +1,29 @@
let
busybox = import ./fetchurl.nix {
url = "https://www.busybox.net/downloads/binaries/1.35.0-x86_64-linux-musl/busybox";
outputHash = "sha256-mVOoYPn3r9NYiZjQf5AF2p7hXy1Q4kN5RSscc/PGpiY=";
executable = true;
};
busybox_ash = import ./fetchurl.nix {
url = "https://www.busybox.net/downloads/binaries/1.35.0-x86_64-linux-musl/busybox_ASH";
outputHash = "sha256-cgXsXhZxOE62NM2uYD4tkw4IA6vsiwolJjhw7zTyiIQ=";
executable = true;
};
busybox_cp = import ./fetchurl.nix {
url = "https://www.busybox.net/downloads/binaries/1.35.0-x86_64-linux-musl/busybox_CP";
outputHash = "sha256-SohMSgXijkdN8Y7LE522obQ0QUAs8xBEQl+p0w8iAVc=";
executable = true;
};
busybox_mkdir = import ./fetchurl.nix {
url = "https://www.busybox.net/downloads/binaries/1.35.0-x86_64-linux-musl/busybox_MKDIR";
outputHash = "sha256-knwWrnrCqxv52cM78VW/00Zqju6YI0+kXo/ZPLzJb18=";
executable = true;
};
in {
busybox = builtins.derivation {
system = "x86_64-linux";
name = "busybox";
builder = busybox_ash;
args = [ "-c" "${busybox_mkdir} $out; ${busybox_cp} ${busybox} $out/busybox" ];
};
}

21
fetchurl.nix Normal file
View File

@ -0,0 +1,21 @@
{ url
, outputHash
, executable ? false
, unpack ? false
, name ? baseNameOf (toString url)
}:
derivation ({
builder = "builtin:fetchurl";
outputHashMode = "recursive";
inherit name url executable unpack outputHash;
outputHashAlgo = if outputHash == "" then "sha256" else "";
system = "builtin";
# No need to double the amount of network traffic
preferLocalBuild = true;
})