dhall-kubernetes/nix/dhall-kubernetes.nix
2020-07-23 19:19:21 -07:00

43 lines
1.1 KiB
Nix

{ fetchurl, make-dhall-kubernetes-package, lib, stdenv }:
let
kubernetesDirectory = ./kubernetes;
kubernetesPaths = builtins.readDir kubernetesDirectory;
toKeyValue =
file: _:
let
version = builtins.replaceStrings [ ".txt" ] [ "" ] file;
in
{ name = version;
value =
let
spec =
stdenv.mkDerivation {
name = "kubernetes-${version}";
src =
fetchurl {
url = "https://github.com/kubernetes/kubernetes/archive/release-${version}.tar.gz";
sha256 =
builtins.replaceStrings [ "\n" ] [ "" ]
(builtins.readFile (kubernetesDirectory + "/${file}"));
};
phases = [ "unpackPhase" "installPhase" ];
installPhase = ''
cp api/openapi-spec/swagger.json $out
'';
};
in
make-dhall-kubernetes-package { inherit version spec; };
};
in
lib.mapAttrs' toKeyValue kubernetesPaths