mirror of
https://git.sr.ht/~goorzhel/turboprop
synced 2024-12-15 17:50:52 +00:00
1b63b4bda1
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.
44 lines
885 B
Nix
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
|
|
'';
|
|
});
|
|
}
|