Skip to content

Commit e877a09

Browse files
authored
Old attempt at generating Nix expressions via aliBuild (#1011)
1 parent dab81d9 commit e877a09

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

templates/alibuild_nix.jnj

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Attempt to generate a nix expression from an aliBuild package instanciation
2+
#
3+
# Run with:
4+
#
5+
# cat alibuild_nix.jnj | python3 alibuild/aliBuild build O2 --defaults o2 --debug --no-system --plugin templating
6+
#
7+
8+
{stdenv, pkgs}:
9+
let
10+
properUnpack = ''
11+
runHook preUnpack;
12+
echo "foo"
13+
env
14+
runHook postUnpack;
15+
'';
16+
{% for name, spec in specs.items() %}
17+
{{name}} = stdenv.mkDerivation {
18+
name = "{{name}}";
19+
version = "{{spec["version"]}}";
20+
{{spec.get("source", None) and "\n src=(builtins.fetchGit {{\n ref=\"refs/tags/{}\";\n url=\"{}\";}});\n".format(spec["tag"], spec["source"]) or "dontUnpack=true;"}}
21+
buildInputs = [{% for build_requires in spec["build_requires"] %}
22+
pkgs.rsync
23+
{{build_requires}}{% endfor %}
24+
];
25+
propagateBuildInputs = [{% for requires in spec["requires"] %}
26+
{{requires}}{% endfor %}
27+
];
28+
29+
unpackPhase = properUnpack;
30+
31+
dontConfigure = true;
32+
dontBuild = true;
33+
installPhase = ''
34+
runHook preInstall
35+
set -x
36+
PKGNAME={{name}}
37+
PKGVERSION={{spec["version"]}}
38+
PKGREVISION=1
39+
PKGHASH=1
40+
INSTALLROOT=$out
41+
mkdir -p $INSTALLROOT
42+
ARCHITECTURE={{args.architecture}}
43+
JOBS=10
44+
SOURCEDIR=$src
45+
mkdir -p $PWD
46+
{{spec["recipe"].replace("\n", "\n ").replace("\n \n", "\n\n").replace("${", "''${")}}
47+
runHook postInstall
48+
'';
49+
};
50+
{% endfor %}
51+
in
52+
{
53+
inherit{% for name, spec in specs.items() %} {{name}}{% endfor %};
54+
}

0 commit comments

Comments
 (0)