on master help sign in
Add some scripts to deal with closures.

To be documented later.

commit43f167eb0d27d805d266b9963a6a83795aa54536 authorMatthew Bauer <mjbauer95@gmail.com> dateSun 12 Feb 2017, 18:21 (10 years ago) parente66fdf7
4 files changed+72
appdir.sh+27 closure.nix+16 closure.sh+27 default.nix+2
appdir.shnew file+27
@@ -0,0 +1,27 @@
1+#!/usr/bin/env sh
2+
3+if [ "$#" -lt 1 ]; then
4+ cat <<EOF
5+
6+Usage: $0 TARGET
7+
8+Create an appdir from the nixpkgs attribute "TARGET".
9+EOF
10+
11+ exit 1
12+fi
13+
14+target="$1"
15+
16+expr="with import <nixpkgs> {}; with import ./. {}; appdir { name = \"$target\"; target = $target; }"
17+
18+out=$(nix-store --no-gc-warning -r $(nix-instantiate --no-gc-warning -E "$expr"))
19+
20+if [ -z "$out" ]; then
21+ echo "$0 failed. Exiting."
22+ exit 1
23+else
24+ rm -f result
25+ ln -sf $out/*.AppDir result
26+ echo "AppImage created at result"
27+fi
closure.nixnew file+16
@@ -0,0 +1,16 @@
1+{ stdenv, perl, pathsFromGraph }:
2+{ targets }:
3+
4+# everything in the closure linked together for inspection
5+
6+stdenv.mkDerivation {
7+ name = "closure";
8+ exportReferencesGraph = map (x: [("closure-" + baseNameOf x) x]) targets;
9+ nativeBuildInputs = [ perl ];
10+ buildCommand = ''
11+ storePaths=$(${perl}/bin/perl ${pathsFromGraph} ./closure-*)
12+
13+ mkdir $out
14+ ln -s $storePaths $out
15+ '';
16+}
closure.shnew file+27
@@ -0,0 +1,27 @@
1+#!/usr/bin/env sh
2+
3+if [ "$#" -lt 1 ]; then
4+ cat <<EOF
5+
6+Usage: $0 TARGET
7+
8+Create a closure from the nixpkgs attribute "TARGET".
9+EOF
10+
11+ exit 1
12+fi
13+
14+target="$1"
15+
16+expr="with import <nixpkgs> {}; with import ./. {}; closure { targets = [$target]; }"
17+
18+out=$(nix-store --no-gc-warning -r $(nix-instantiate --no-gc-warning -E "$expr"))
19+
20+if [ -z "$out" ]; then
21+ echo "$0 failed. Exiting."
22+ exit 1
23+else
24+ rm -f result
25+ ln -sf $out result
26+ echo "Dir created at result"
27+fi
default.nix+2
@@ -29,4 +29,6 @@ rec {
2929 };
3030
3131 appdir = callPackage ./appdir.nix {};
32+
33+ closure = callPackage ./closure.nix {};
3234}