44 lines
882 B
Nix
44 lines
882 B
Nix
{ dhall, dhall-nix, stdenvNoCC, lndir }:
|
|
|
|
{ name
|
|
|
|
# Expressions to add to the cache before interpreting the code
|
|
, dependencies ? []
|
|
# The root path of the expression
|
|
, src
|
|
, ...
|
|
}:
|
|
|
|
let
|
|
cache = ".cache";
|
|
|
|
data = ".local/share";
|
|
|
|
cacheDhall = "${cache}/dhall";
|
|
|
|
dataDhall = "${data}/dhall";
|
|
|
|
sourceFile = "source.dhall";
|
|
|
|
in
|
|
stdenvNoCC.mkDerivation {
|
|
name = "${name}.nix";
|
|
inherit src;
|
|
nativeBuildInputs = [lndir dhall dhall-nix];
|
|
buildInputs = dependencies;
|
|
configurePhase = ''
|
|
mkdir -p ${cacheDhall}
|
|
|
|
for dependency in $buildInputs; do
|
|
lndir -silent $dependency/${cacheDhall} ${cacheDhall}
|
|
done
|
|
|
|
export XDG_CACHE_HOME=$PWD/${cache}
|
|
'';
|
|
buildPhase = ''
|
|
cat package.dhall | dhall resolve | dhall normalize > resolved.dhall
|
|
'';
|
|
installPhase = ''
|
|
dhall-to-nix < resolved.dhall > $out
|
|
'';
|
|
}
|