on master help sign in
Inline default.nix stuff

Makes things easier to work with.

commit80a769483f33a48b101e6bf8a93dc47cabd52a4a authorMatthew Bauer <mjbauer95@gmail.com> dateWed 26 Apr 2017, 01:31 (9 years ago) parent06dab77
8 files changed+61−91
Makefile+6 arx.nix−11 default.nix+52−20 makebootstrap.nix−9 maketar.nix−17 nix-bootstrap.nix−8 nix-bundle.sh+3−1 nix-user-chroot.nix−25
Makefilenew file+6
@@ -0,0 +1,6 @@
1+PREFIX ?= /usr
2+
3+install: nix-bundle.sh default.nix
4+ mkdir -p ${PREFIX}/share/nix-bundle/
5+ install $^ ${PREFIX}/share/nix-bundle/
6+ mkdir -p ${PREFIX}/bin
arx.nixdeleted−11
@@ -1,11 +0,0 @@
1−{ stdenv, arx }:
2−{ name, archive, startup}:
3−
4−stdenv.mkDerivation {
5− inherit name;
6− nativeBuildInputs = [ arx ];
7− buildCommand = ''
8− ${arx}/bin/arx tmpx ${archive} -o $out // ${startup}
9− chmod +x $out
10− '';
11−}
default.nix+52−20
@@ -3,32 +3,64 @@
33with nixpkgs;
44
55rec {
6+ arx = { archive, startup}:
7+ stdenv.mkDerivation {
8+ name = "arx";
9+ buildCommand = ''
10+ ${haskellPackages.arx}/bin/arx tmpx ${archive} -o $out // ${startup}
11+ chmod +x $out
12+ '';
13+ };
614
7− arx = callPackage ./arx.nix {
8− inherit (haskellPackages) arx;
9− };
10−
11− maketar = callPackage ./maketar.nix {};
12−
13− nix-installer = callPackage ./nix-installer.nix {};
15+ maketar = { targets }:
16+ stdenv.mkDerivation {
17+ name = "maketar";
18+ exportReferencesGraph = map (x: [("closure-" + baseNameOf x) x]) targets;
19+ buildCommand = ''
20+ storePaths=$(${perl}/bin/perl ${pathsFromGraph} ./closure-*)
1421
15− makebootstrap = callPackage ./makebootstrap.nix {
16− inherit arx maketar;
17− };
18−
19− nix-user-chroot = callPackage ./nix-user-chroot.nix {};
22+ # printRegistration=1 ${perl}/bin/perl ${pathsFromGraph} ./closure-* > .reginfo
23+ tar cfj $out \
24+ --owner=0 --group=0 --mode=u+rw,uga+r \
25+ --hard-dereference \
26+ $storePaths
27+ '';
28+ };
2029
21− nix-bootstrap = callPackage ./nix-bootstrap.nix {
22− inherit nix-user-chroot makebootstrap;
23− };
30+ nix-user-chroot = stdenv.mkDerivation {
31+ name = "nix-user-chroot-2b144e";
32+ src = fetchFromGitHub {
33+ owner = "matthewbauer";
34+ repo = "nix-user-chroot";
35+ rev = "2b144ee89568ba40b66317da261ce889fbda3674";
36+ sha256 = "16bmshhvk6941w04rx78i5a1305876qni2n2rvm7rkziz49j158n";
37+ };
2438
25− appimagetool = callPackage ./appimagetool.nix {};
39+ postFixup = ''
40+ exe=$out/bin/nix-user-chroot
41+ patchelf \
42+ --set-interpreter .$(patchelf --print-interpreter $exe) \
43+ --set-rpath $(patchelf --print-rpath $exe | sed 's|/nix/store/|./nix/store/|g') \
44+ $exe
45+ '';
2646
27− appimage = callPackage ./appimage.nix {
28− inherit appimagetool;
47+ installPhase = ''
48+ mkdir -p $out/bin/
49+ cp nix-user-chroot $out/bin/nix-user-chroot
50+ '';
2951 };
3052
31− appdir = callPackage ./appdir.nix {};
53+ makebootstrap = { targets, startup }:
54+ arx {
55+ inherit startup;
56+ archive = maketar {
57+ inherit targets;
58+ };
59+ };
3260
33− closure = callPackage ./closure.nix {};
61+ nix-bootstrap = { target, run }:
62+ makebootstrap {
63+ startup = ".${nix-user-chroot}/bin/nix-user-chroot ./nix ${target}${run}";
64+ targets = [ nix-user-chroot target ];
65+ };
3466}
makebootstrap.nixdeleted−9
@@ -1,9 +0,0 @@
1−{ arx, maketar }:
2−{ name, targets, startup }:
3−
4−arx {
5− inherit name startup;
6− archive = maketar {
7− inherit name targets;
8− };
9−}
maketar.nixdeleted−17
@@ -1,17 +0,0 @@
1−{ stdenv, gcc, perl, pathsFromGraph }:
2−{ name, targets }:
3−
4−stdenv.mkDerivation {
5− inherit name;
6− exportReferencesGraph = map (x: [("closure-" + baseNameOf x) x]) targets;
7− nativeBuildInputs = [ perl ];
8− buildCommand = ''
9− storePaths=$(${perl}/bin/perl ${pathsFromGraph} ./closure-*)
10−
11− # printRegistration=1 ${perl}/bin/perl ${pathsFromGraph} ./closure-* > .reginfo
12− tar cfj $out \
13− --owner=0 --group=0 --mode=u+rw,uga+r \
14− --hard-dereference \
15− $storePaths
16− '';
17−}
nix-bootstrap.nixdeleted−8
@@ -1,8 +0,0 @@
1−{ stdenv, writeText, nix-user-chroot, makebootstrap }:
2−{ name, target, run }:
3−
4−makebootstrap {
5− inherit name;
6− startup = ".${nix-user-chroot}/bin/nix-user-chroot ./nix ${target}${run}";
7− targets = [ nix-user-chroot target ];
8−}
nix-bundle.sh+3−1
@@ -23,7 +23,9 @@ target="$1"
2323exec="$2"
2424filename=$(basename $exec)
2525
26−expr="with import <nixpkgs> {}; with import ./. {}; nix-bootstrap { name = \"$filename\"; target = $target; run = \"$exec\"; }"
26+nix_file=./default.nix
27+
28+expr="with import <nixpkgs> {}; with import $nix_file {}; nix-bootstrap { target = $target; run = \"$exec\"; }"
2729
2830out=$(nix-store --no-gc-warning -r $(nix-instantiate --no-gc-warning -E "$expr"))
2931
nix-user-chroot.nixdeleted−25
@@ -1,25 +0,0 @@
1−{ stdenv, fetchFromGitHub }:
2−
3−stdenv.mkDerivation {
4− name = "nix-user-chroot-2b144e";
5−
6− src = fetchFromGitHub {
7− owner = "matthewbauer";
8− repo = "nix-user-chroot";
9− rev = "2b144ee89568ba40b66317da261ce889fbda3674";
10− sha256 = "16bmshhvk6941w04rx78i5a1305876qni2n2rvm7rkziz49j158n";
11− };
12−
13− postFixup = ''
14− exe=$out/bin/nix-user-chroot
15− patchelf \
16− --set-interpreter .$(patchelf --print-interpreter $exe) \
17− --set-rpath $(patchelf --print-rpath $exe | sed 's|/nix/store/|./nix/store/|g') \
18− $exe
19− '';
20−
21− installPhase = ''
22− mkdir -p $out/bin/
23− cp nix-user-chroot $out/bin/nix-user-chroot
24− '';
25−}