diff --git a/Makefile b/Makefile index 0e46956..813c209 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ PREFIX ?= /usr -install: nix-bundle.sh nix-run.sh appdir.nix appimagetool.nix appimage.nix AppRun.c appimage-top.nix default.nix appdir.sh nix2appimage.sh nix-user-chroot/ +install: nix-bundle.sh nix-run.sh appdir.nix appimagetool.nix appimage.nix AppRun.c appimage-top.nix default.nix appdir.sh nix2appimage.sh nix-user-chroot/ top.nix mkdir -p ${PREFIX}/share/nix-bundle/ cp -r $^ ${PREFIX}/share/nix-bundle/ diff --git a/appimage.nix b/appimage.nix index 49bfe6c..693f982 100644 --- a/appimage.nix +++ b/appimage.nix @@ -5,7 +5,9 @@ stdenv.mkDerivation { name = "appimage"; buildInputs = [ appimagetool ]; buildCommand = '' - ARCH=x86_64 appimagetool ${dir}/*.AppDir + cp -r ${dir}/* . + chmod +w *.AppDir + ARCH=x86_64 appimagetool *.AppDir mkdir $out cp *.AppImage $out ''; diff --git a/default.nix b/default.nix index 4d628c6..3b90c89 100644 --- a/default.nix +++ b/default.nix @@ -1,4 +1,4 @@ -{nixpkgs ? import {}}: +{nixpkgs ? import ./top.nix}: with nixpkgs; @@ -7,7 +7,7 @@ rec { stdenv.mkDerivation { name = "arx"; buildCommand = '' - ${haskellPackages.arx}/bin/arx tmpx ${archive} -o $out // ${startup} + ${nixpkgs.haskellPackages.arx}/bin/arx tmpx -rm! ${archive} -o $out // ${startup} chmod +x $out ''; }; @@ -38,7 +38,7 @@ rec { postFixup = '' exe=$out/bin/nix-user-chroot patchelf \ - --set-interpreter .$(patchelf --print-interpreter $exe) \ + --set-interpreter .${musl}/lib/libc.so \ --set-rpath $(patchelf --print-rpath $exe | sed 's|/nix/store/|./nix/store/|g') \ $exe ''; @@ -74,12 +74,6 @@ rec { targets = [ "${script}" ] ++ extraTargets; }; - nix-bootstrap-nix = {target, run, extraTargets ? []}: - nix-bootstrap-path { - inherit target run; - extraTargets = [ gnutar bzip2 xz gzip coreutils bash ]; - }; - # special case adding path to the environment before launch nix-bootstrap-path = let nix-user-chroot'' = targets: nix-user-chroot.overrideDerivation (o: { diff --git a/nix-bundle.sh b/nix-bundle.sh index 8bece2a..2207195 100755 --- a/nix-bundle.sh +++ b/nix-bundle.sh @@ -42,8 +42,9 @@ elif ! [ -z "$extraTargets" ]; then bootstrap=nix-bootstrap-path fi -expr="with import {}; with import $nix_file {}; $bootstrap { target = $target; extraTargets = [ $extraTargets ]; run = \"$exec\"; }" +expr="with import ./top.nix; with import $nix_file {}; $bootstrap { target = ($target); extraTargets = [ $extraTargets ]; run = \"$exec\"; }" +echo "$expr" out=$(nix-store --no-gc-warning -r $(nix-instantiate --no-gc-warning -E "$expr")) if [ -z "$out" ]; then diff --git a/nix.nix b/nix.nix new file mode 100644 index 0000000..475b702 --- /dev/null +++ b/nix.nix @@ -0,0 +1,17 @@ +with import ./top.nix; +with import ./default.nix {}; + +nix-bootstrap-path { + run = "/bin/nix"; + target = (nix.overrideAttrs (o: { + buildInputs = [ curl openssl sqlite libseccomp libsodium ]; + doCheck = false; + doInstallCheck = false; + preConfigure = (o.preConfigure or "") + '' + NIX_CFLAGS_COMPILE+=" -g0" + configureFlagsArray+=(--with-sandbox-shell=${bash}/bin/bash) + ''; + propagatedBuildInputs = [gnutar bzip2 xz gzip coreutils bash boehmgc]; + })); + extraTargets = [coreutils bzip2 xz gzip gnutar bash]; +} diff --git a/top.nix b/top.nix new file mode 100644 index 0000000..0a1d0d4 --- /dev/null +++ b/top.nix @@ -0,0 +1 @@ +import { localSystem = { config = "x86_64-unknown-linux-musl"; }; }