aboutsummaryrefslogtreecommitdiffhomepage
path: root/release-bundle.nix
diff options
context:
space:
mode:
authorFrédéric Menou <frederic.menou@fretlink.com>2016-12-08 10:19:15 +0200
committerIsmaël Bouya <ismael.bouya@fretlink.com>2022-05-17 18:01:51 +0200
commita9d77a20008efe82862cc1adbfa7a6d4f09f8ff7 (patch)
treeadf3186fdccaeef19151026cdfbd38a530cf9ecb /release-bundle.nix
downloadedi-parser-a9d77a20008efe82862cc1adbfa7a6d4f09f8ff7.tar.gz
edi-parser-a9d77a20008efe82862cc1adbfa7a6d4f09f8ff7.tar.zst
edi-parser-a9d77a20008efe82862cc1adbfa7a6d4f09f8ff7.zip
Release code as open sourceHEADmaster
Diffstat (limited to 'release-bundle.nix')
-rw-r--r--release-bundle.nix48
1 files changed, 48 insertions, 0 deletions
diff --git a/release-bundle.nix b/release-bundle.nix
new file mode 100644
index 0000000..cf6b097
--- /dev/null
+++ b/release-bundle.nix
@@ -0,0 +1,48 @@
1{ pkgs, toExeName ? (e: if pkgs.lib.hasInfix "/" e.exeName then e.exeName else "bin/${e.exeName}") }:
2let
3 nix-bundle = import (builtins.fetchTarball "https://github.com/matthewbauer/nix-bundle/archive/master.tar.gz") {};
4 toNixBundle = e: if pkgs.lib.isDerivation e then
5 nix-bundle.nix-bootstrap {
6 target = e;
7 run = "/${toExeName e}";
8 nixUserChrootFlags = "-m /builds:/builds";
9 } else e;
10in
11 {
12 # This function takes an (possibly deep) attrset of derivations and
13 # turns those derivations into bundles, returning the same attrset
14 bundled-derivations = pkgs.lib.mapAttrsRecursiveCond
15 (f: !builtins.isBool f && !(pkgs.lib.isDerivation f))
16 (_: toNixBundle);
17 # This function collects all the derivations of an attrset, and
18 # turns them into a directory of executable bundles.
19 bundled-dist = derivations: pkgs.runCommand "dist" {} ''
20 mkdir -p $out/bin
21 ${builtins.concatStringsSep "\n"
22 (map
23 (b: "cp ${toNixBundle b} $out/${toExeName b}")
24 (pkgs.lib.collect pkgs.lib.isDerivation derivations)
25 )}
26 '';
27 bundled-documentation = derivations: pkgs.runCommand "documentation" {} ''
28 mkdir -p $out/share/doc
29 ${builtins.concatStringsSep "\n"
30 (map
31 (b: ''
32 for f in ${b}/share/doc/*; do
33 cp -a "$f/html" $out/share/doc/$(basename "$f")
34 done
35 '')
36 (pkgs.lib.collect pkgs.lib.isDerivation derivations)
37 )}
38 '';
39 # This function collects all the derivations of an attrset, and
40 # turns them into a tarball of executable bundles.
41 tarball = derivations: pkgs.runCommand "bundled.tar.gz" {} ''
42 tar -Pczf $out ${builtins.concatStringsSep " "
43 (map
44 (b: "--transform=s@${toNixBundle b}@${toExeName b}@ ${toNixBundle b}")
45 (pkgs.lib.collect pkgs.lib.isDerivation derivations)
46 )}
47 '';
48 }