1
0
Fork 0
mirror of https://git.sr.ht/~goorzhel/turboprop synced 2024-12-15 17:50:52 +00:00
turboprop/lib/builders.nix
Antonio Gurgel 1b63b4bda1 Refactor lib/
NixOS configs taught me wrong; `imports=[]` is not a magic sequence.
But because `lib/default.nix` returns an attrset, I can use attrset
mechanics on it.
2023-11-18 01:55:21 -08:00

44 lines
885 B
Nix

{pkgs}: let
genericBuilder = {
namespace,
name,
version,
url,
hash,
src,
installPhase,
...
}:
pkgs.stdenv.mkDerivation {
inherit version installPhase src;
pname = "${namespace}-${name}";
phases = ["installPhase"];
};
in {
yamlFile = attrs:
genericBuilder (attrs
// {
src = pkgs.fetchurl {inherit (attrs) url hash;};
installPhase = "cp -v $src $out";
});
gitChart = {
chartPath,
vPrefixInRef ? false,
...
} @ attrs:
genericBuilder (attrs
// {
src = pkgs.fetchgit {
inherit (attrs) url hash;
rev =
if vPrefixInRef
then "v${attrs.version}"
else attrs.version;
sparseCheckout = [chartPath];
};
installPhase = ''
cp -rv $src/${chartPath} $out
'';
});
}