on master help sign in
Merge pull request #28 from dtzWill/dtz-fixups

Misc fixups that may be of interest (don't merge as-is)

commit393f4153e9abd338523fb253b6fdbf9da3ae704c authorMatthew Justin Bauer <mjbauer95@gmail.com> dateSat 3 Mar 2018, 19:09 (9 years ago) parentdcbfa1aff4c7ed
5 files changed+40−20
AppRun.c+1−1 appdir.nix+3−3 appimage-top.nix+10−6 appimagetool.nix+12−10 test-appimage.nix+14
AppRun.c+1−1
@@ -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
9797int main(int argc, char *argv[]) {
9898 char *appdir = dirname(realpath("/proc/self/exe", NULL));
appdir.nix+3−3
@@ -1,13 +1,13 @@
1−{ stdenv, fetchurl, perl, pathsFromGraph, fetchFromGitHub, musl, coreutils, bash }:
1+{ stdenv, fetchurl, muslPkgs, perl, pathsFromGraph, fetchFromGitHub, coreutils, bash }:
22
33let
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+10−6
@@ -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+12−10
@@ -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.nixnew file+14
@@ -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+''