commit e2d6b08c5a749cf4e1a448c2bf524a7dbc7ce630
Author: clerie <git@clerie.de>
Date:   Tue Jun 27 18:09:35 2023 +0200

    Bootstrap busybox from binaries

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b2be92b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+result
diff --git a/busybox.nix b/busybox.nix
new file mode 100644
index 0000000..b1e4aa9
--- /dev/null
+++ b/busybox.nix
@@ -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" ];
+  };
+}
diff --git a/fetchurl.nix b/fetchurl.nix
new file mode 100644
index 0000000..83ccfeb
--- /dev/null
+++ b/fetchurl.nix
@@ -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;
+
+})