diff --git a/lib/default.nix b/lib/default.nix index 45b9fc5..d3e2daf 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,45 +1,18 @@ system: { nixpkgs, ... } @ args: rec { - pkgs = import nixpkgs { inherit system; }; inherit (builtins) toFile; - runCommandBasic = script: builtins.derivation { - inherit system; - name = "runCommandBasic"; - builder = "${pkgs.busybox}/bin/sh"; - args = [ (toFile "builder.sh" script) ]; - }; - - writeTextFile = - { name - , text - , executable ? false - , destination ? "" - , checkPhase ? "" - }: runCommandBasic '' - target=$out${destination} - mkdir -p "$(dirname "$target")" - - if [ -e "$textPath" ]; then - mv "$textPath" "$target" - else - echo -n "$text" > "$target" - fi - - eval "$checkPhase" - (test -n "$executable" && chmod +x "$target") || true - ''; - writeText = name: text: writeTextFile { inherit name text; }; - writeTextDir = path: text: writeTextFile { - inherit text; - name = builtins.baseNameOf path; - destination = "/${path}"; - }; - writeScript = name: text: writeTextFile { inherit name text; executable = true; }; - writeScriptBin = name: text: writeTextFile { inherit name text; executable = true; destination = "/bin/${name}"; }; - baseDerivation = { script, ... } @args: builtins.derivation (args // { inherit system; - builder = "${pkgs.busybox}/bin/sh"; - args = [ (writeScript "${args.name}-builder.sh" script) ]; + builder = ./. + "/../prebuilt/${system}/busybox"; + args = [ + "sh" + (toFile "${args.name}-builder.sh" ( + '' + set -ex + export PATH=${./. + "/../prebuilt/${system}"} + eval "$script" + '' + )) + ]; }); } diff --git a/prebuilt/armv7l-linux/busybox b/prebuilt/armv7l-linux/busybox new file mode 100755 index 0000000..081d211 Binary files /dev/null and b/prebuilt/armv7l-linux/busybox differ diff --git a/prebuilt/armv7l-linux/cp b/prebuilt/armv7l-linux/cp new file mode 120000 index 0000000..c3fa810 --- /dev/null +++ b/prebuilt/armv7l-linux/cp @@ -0,0 +1 @@ +busybox \ No newline at end of file diff --git a/prebuilt/armv7l-linux/dirname b/prebuilt/armv7l-linux/dirname new file mode 120000 index 0000000..c3fa810 --- /dev/null +++ b/prebuilt/armv7l-linux/dirname @@ -0,0 +1 @@ +busybox \ No newline at end of file diff --git a/prebuilt/armv7l-linux/echo b/prebuilt/armv7l-linux/echo new file mode 120000 index 0000000..c3fa810 --- /dev/null +++ b/prebuilt/armv7l-linux/echo @@ -0,0 +1 @@ +busybox \ No newline at end of file diff --git a/prebuilt/armv7l-linux/mkdir b/prebuilt/armv7l-linux/mkdir new file mode 120000 index 0000000..c3fa810 --- /dev/null +++ b/prebuilt/armv7l-linux/mkdir @@ -0,0 +1 @@ +busybox \ No newline at end of file diff --git a/prebuilt/armv7l-linux/mv b/prebuilt/armv7l-linux/mv new file mode 120000 index 0000000..c3fa810 --- /dev/null +++ b/prebuilt/armv7l-linux/mv @@ -0,0 +1 @@ +busybox \ No newline at end of file