-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
54 lines (49 loc) · 2.11 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{
description = "Nix-based Kubernetes management";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixpkgs-unstable";
systems.url = "github:nix-systems/default";
};
outputs = { self, nixpkgs, systems }:
let
withLib = fn: pkgs: fn pkgs self.lib.${pkgs.system};
forAllSystems = fn: nixpkgs.lib.genAttrs
(import systems)
(system: withLib fn nixpkgs.legacyPackages.${system});
in
{
lib = forAllSystems (pkgs: transpire: rec {
buildDocs = pkgs.callPackage ./lib/build-docs.nix { inherit transpire; };
buildHelmChart = pkgs.callPackage ./lib/build-helm-chart.nix { };
buildKustomization = pkgs.callPackage ./lib/build-kustomization.nix { };
evalModules = pkgs.callPackage ./lib/eval-modules.nix { inherit transpire; };
fetchFromHelm = pkgs.callPackage ./lib/fetch-from-helm.nix { };
# Shortcuts for the most common use cases
build = {
__functor = args: (evalModules args).config.build;
cluster = args: (evalModules args).config.build.cluster;
clusterFile = args: (evalModules args).config.build.clusterFile;
};
});
packages = forAllSystems (pkgs: transpire: {
docs = transpire.buildDocs { };
} // import ./generated-openapi-pkgs.nix pkgs);
apps = forAllSystems (pkgs: transpire: {
generate-openapi-pkgs = {
type = "app";
program = toString (pkgs.writers.writeBash "generate-openapi-pkgs" ''
git ls-remote --tags --refs --sort="-version:refname" https://github.com/kubernetes/kubernetes |
awk '{print $2}' |
while read -r ref; do
if [[ $ref =~ ^refs/tags/(v[0-9]+\.[0-9]+\.[0-9])+$ ]]; then
rev="''${BASH_REMATCH[1]}"
url="https://raw.githubusercontent.com/kubernetes/kubernetes/$rev/api/openapi-spec/swagger.json"
sha256=$(nix store prefetch-file $url --json | ${pkgs.jq}/bin/jq -r .hash)
echo "\"openapi-$rev\" = fetchOpenApi \"$rev\" \"$sha256\";"
fi
done
'');
};
});
};
}