2016-06-15 19:23:19 +03:00
|
|
|
{nixpkgs ? import <nixpkgs> {}}:
|
|
|
|
|
|
|
|
with nixpkgs;
|
|
|
|
|
2016-11-26 10:05:43 +03:00
|
|
|
rec {
|
2017-04-26 09:31:01 +03:00
|
|
|
arx = { archive, startup}:
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "arx";
|
|
|
|
buildCommand = ''
|
2017-04-27 07:03:01 +03:00
|
|
|
${haskellPackages.arx}/bin/arx tmpx ${archive} -rm! -o $out // ${startup}
|
2017-04-26 09:31:01 +03:00
|
|
|
chmod +x $out
|
|
|
|
'';
|
|
|
|
};
|
2016-06-15 19:23:19 +03:00
|
|
|
|
2017-04-26 09:31:01 +03:00
|
|
|
maketar = { targets }:
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "maketar";
|
2017-04-27 07:03:01 +03:00
|
|
|
buildInputs = [gnutar perl bzip2];
|
2017-04-26 09:31:01 +03:00
|
|
|
exportReferencesGraph = map (x: [("closure-" + baseNameOf x) x]) targets;
|
|
|
|
buildCommand = ''
|
2017-04-27 07:03:01 +03:00
|
|
|
storePaths=$(perl ${pathsFromGraph} ./closure-*)
|
2016-06-15 19:23:19 +03:00
|
|
|
|
2017-04-26 09:31:01 +03:00
|
|
|
tar cfj $out \
|
|
|
|
--owner=0 --group=0 --mode=u+rw,uga+r \
|
|
|
|
--hard-dereference \
|
|
|
|
$storePaths
|
|
|
|
'';
|
|
|
|
};
|
2016-11-18 19:53:30 +03:00
|
|
|
|
2017-04-27 07:03:01 +03:00
|
|
|
# TODO: eventually should this go in nixpkgs?
|
2017-04-26 09:31:01 +03:00
|
|
|
nix-user-chroot = stdenv.mkDerivation {
|
|
|
|
name = "nix-user-chroot-2b144e";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "matthewbauer";
|
|
|
|
repo = "nix-user-chroot";
|
|
|
|
rev = "2b144ee89568ba40b66317da261ce889fbda3674";
|
|
|
|
sha256 = "16bmshhvk6941w04rx78i5a1305876qni2n2rvm7rkziz49j158n";
|
|
|
|
};
|
2016-06-15 19:23:19 +03:00
|
|
|
|
2017-04-26 09:31:01 +03:00
|
|
|
postFixup = ''
|
|
|
|
exe=$out/bin/nix-user-chroot
|
|
|
|
patchelf \
|
|
|
|
--set-interpreter .$(patchelf --print-interpreter $exe) \
|
|
|
|
--set-rpath $(patchelf --print-rpath $exe | sed 's|/nix/store/|./nix/store/|g') \
|
|
|
|
$exe
|
|
|
|
'';
|
2017-02-07 01:17:20 +03:00
|
|
|
|
2017-04-26 09:31:01 +03:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin/
|
|
|
|
cp nix-user-chroot $out/bin/nix-user-chroot
|
|
|
|
'';
|
2017-02-07 01:17:20 +03:00
|
|
|
};
|
|
|
|
|
2017-04-26 09:31:01 +03:00
|
|
|
makebootstrap = { targets, startup }:
|
|
|
|
arx {
|
|
|
|
inherit startup;
|
|
|
|
archive = maketar {
|
|
|
|
inherit targets;
|
|
|
|
};
|
|
|
|
};
|
2017-02-13 03:21:51 +03:00
|
|
|
|
2017-04-26 09:31:01 +03:00
|
|
|
nix-bootstrap = { target, run }:
|
|
|
|
makebootstrap {
|
2017-04-26 22:03:45 +03:00
|
|
|
startup = ''.${nix-user-chroot}/bin/nix-user-chroot ./nix ${target}${run} \$@'';
|
2017-04-26 09:31:01 +03:00
|
|
|
targets = [ nix-user-chroot target ];
|
|
|
|
};
|
2016-06-15 19:23:19 +03:00
|
|
|
}
|