Skip to content

Commit 393f415

Browse files
authored
Merge pull request #28 from dtzWill/dtz-fixups
Misc fixups that may be of interest (don't merge as-is)
2 parents dcbfa1a + ff4c7ed commit 393f415

File tree

5 files changed

+40
-20
lines changed

5 files changed

+40
-20
lines changed

AppRun.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static void add_path(const char* name, const char* rootdir) {
9292
}
9393

9494
#define SAVE_ENV_VAR(x) char *x = getenv(#x)
95-
#define LOAD_ENV_VAR(x) setenv(#x, x, 1)
95+
#define LOAD_ENV_VAR(x) do { if (x != NULL) setenv(#x, x, 1); } while(0)
9696

9797
int main(int argc, char *argv[]) {
9898
char *appdir = dirname(realpath("/proc/self/exe", NULL));

appdir.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
{ stdenv, fetchurl, perl, pathsFromGraph, fetchFromGitHub, musl, coreutils, bash }:
1+
{ stdenv, fetchurl, muslPkgs, perl, pathsFromGraph, fetchFromGitHub, coreutils, bash }:
22

33
let
4-
AppRun = targets: stdenv.mkDerivation {
4+
AppRun = targets: muslPkgs.stdenv.mkDerivation {
55
name = "AppRun";
66

77
phases = [ "buildPhase" "installPhase" "fixupPhase" ];
88

99
buildPhase = ''
10-
CC="${musl}/bin/musl-gcc -O2 -Wall -Wno-deprecated-declarations -Wno-unused-result -static"
10+
CC="$CC -O2 -Wall -Wno-deprecated-declarations -Wno-unused-result -static"
1111
$CC ${./AppRun.c} -o AppRun -DENV_PATH='"${stdenv.lib.makeBinPath targets}"'
1212
'';
1313

appimage-top.nix

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
{nixpkgs ? import <nixpkgs> {}}:
1+
{ nixpkgs' ? <nixpkgs> }:
22

3-
with nixpkgs;
3+
let
4+
pkgs = import nixpkgs' { };
5+
muslPkgs = import nixpkgs' {
6+
localSystem.config = "x86_64-unknown-linux-musl";
7+
};
48

5-
rec {
6-
appimagetool = callPackage ./appimagetool.nix {};
9+
in rec {
10+
appimagetool = pkgs.callPackage ./appimagetool.nix {};
711

8-
appimage = callPackage ./appimage.nix {
12+
appimage = pkgs.callPackage ./appimage.nix {
913
inherit appimagetool;
1014
};
1115

12-
appdir = callPackage ./appdir.nix {};
16+
appdir = pkgs.callPackage ./appdir.nix { inherit muslPkgs; };
1317
}

appimagetool.nix

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
# Ideally, this should be source based,
66
# but I can't get it to build from GitHub
77

8-
stdenv.mkDerivation rec {
8+
let
9+
inherit (stdenv.cc.bintools) dynamicLinker;
10+
in stdenv.mkDerivation rec {
911
name = "appimagekit";
1012

1113
src = fetchurl {
12-
url = "https://github.com/probonopd/AppImageKit/releases/download/7/appimagetool-x86_64.AppImage";
13-
sha256 = "1irvbf0xnya16cyzpvr43jviq5ly3wl7b9753rji7d1hhxwb7b9r";
14+
url = "https://github.com/AppImage/AppImageKit/releases/download/10/appimagetool-x86_64.AppImage";
15+
sha256 = "03zbiblj8a1yk1xsb5snxi4ckwn3diyldg1jh5hdjjhsmpw652ig";
1416
};
1517

1618
buildInputs = [
@@ -22,7 +24,7 @@ stdenv.mkDerivation rec {
2224
unpackPhase = ''
2325
cp $src appimagetool-x86_64.AppImage
2426
chmod u+wx appimagetool-x86_64.AppImage
25-
patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
27+
patchelf --set-interpreter ${dynamicLinker} \
2628
--set-rpath ${fuse}/lib:${zlib}/lib \
2729
appimagetool-x86_64.AppImage
2830
./appimagetool-x86_64.AppImage --appimage-extract
@@ -32,12 +34,12 @@ stdenv.mkDerivation rec {
3234
mkdir -p $out
3335
cp -r usr/* $out
3436
35-
patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
36-
--set-rpath ${stdenv.glibc.out}/lib:${fuse}/lib:${zlib}/lib:${glib}/lib \
37-
$out/bin/appimagetool
38-
patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
39-
--set-rpath ${zlib}/lib \
40-
$out/bin/mksquashfs
37+
for x in $out/bin/*; do
38+
patchelf \
39+
--set-interpreter ${dynamicLinker} \
40+
--set-rpath ${stdenv.lib.makeLibraryPath [ zlib stdenv.glibc.out fuse glib ]} \
41+
$x
42+
done
4143
'';
4244

4345
dontStrip = true;

test-appimage.nix

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{ appimagefile, nixpkgs' ? <nixpkgs> }:
2+
3+
# nix build -f test-appimage.nix --arg appimagefile ./VLC*AppImage
4+
5+
with import nixpkgs' {};
6+
7+
runCommand "patchelf" {} ''
8+
cp ${appimagefile} $out
9+
chmod +w $out
10+
patchelf \
11+
--set-interpreter ${stdenv.cc.bintools.dynamicLinker} \
12+
--set-rpath ${stdenv.glibc.out}/lib:${fuse}/lib:${zlib}/lib:${glib}/lib \
13+
$out
14+
''

0 commit comments

Comments
 (0)