Skip to content

musl wip #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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/
4 changes: 3 additions & 1 deletion appimage.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
'';
Expand Down
12 changes: 3 additions & 9 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{nixpkgs ? import <nixpkgs> {}}:
{nixpkgs ? import ./top.nix}:

with nixpkgs;

Expand All @@ -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
'';
};
Expand Down Expand Up @@ -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
'';
Expand Down Expand Up @@ -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: {
Expand Down
3 changes: 2 additions & 1 deletion nix-bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ elif ! [ -z "$extraTargets" ]; then
bootstrap=nix-bootstrap-path
fi

expr="with import <nixpkgs> {}; 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
Expand Down
17 changes: 17 additions & 0 deletions nix.nix
Original file line number Diff line number Diff line change
@@ -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];
}
1 change: 1 addition & 0 deletions top.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import <nixpkgs> { localSystem = { config = "x86_64-unknown-linux-musl"; }; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and similarly, accept a nixpkgs path as an input, so it doesnt rely on the current value of $NIX_PATH