mirror of
https://git.sr.ht/~goorzhel/turboprop
synced 2024-12-15 17:50:52 +00:00
Final refactor
Make flake importable at top level. Move app-template to `./src`, removing `charts` from `./lib`. Clean up unused bits elsewhere.
This commit is contained in:
parent
6907ae7373
commit
3a6246ab83
7 changed files with 24 additions and 96 deletions
|
@ -5,11 +5,12 @@
|
|||
pkgs,
|
||||
# Other names I thought of: data, custom, userLib.
|
||||
# Unsure which one will work best.
|
||||
user ? {},
|
||||
user,
|
||||
} @ inputs: let
|
||||
flakeBuilders = import ./flake-builders.nix inputs;
|
||||
builders = import src/builders.nix inputs;
|
||||
in {
|
||||
inherit (flakeBuilders) mkCharts;
|
||||
inherit (builders) mkCharts;
|
||||
app-template = import src/app-template.nix {inherit charts lib pkgs;};
|
||||
|
||||
mkDerivation = {
|
||||
pname,
|
||||
|
@ -19,18 +20,18 @@ in {
|
|||
kubeVersion,
|
||||
src,
|
||||
}: let
|
||||
services = flakeBuilders.mkServices serviceRoot kubeVersion;
|
||||
services = builders.mkServices serviceRoot kubeVersion;
|
||||
in
|
||||
pkgs.stdenv.mkDerivation {
|
||||
inherit pname version src;
|
||||
derivation_paths = services.paths;
|
||||
namespace_drv = flakeBuilders.mkNamespaces {
|
||||
namespace_drv = builders.mkNamespaces {
|
||||
inherit (services) namespaces;
|
||||
extraMetadata = nsMetadata;
|
||||
};
|
||||
|
||||
buildInputs = [pkgs.kustomize];
|
||||
phases = ["installPhase"];
|
||||
installPhase = builtins.readFile ./output.sh;
|
||||
installPhase = builtins.readFile src/output.sh;
|
||||
};
|
||||
}
|
64
flake.lock
64
flake.lock
|
@ -18,20 +18,6 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "flake-utils",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"haumea": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
|
@ -55,11 +41,11 @@
|
|||
},
|
||||
"nix-kube-generators": {
|
||||
"locked": {
|
||||
"lastModified": 1701094877,
|
||||
"narHash": "sha256-oNY5dO+4bjsMOXC0F1re67O4KpNLZ23fyXZJ3OU/wbI=",
|
||||
"lastModified": 1701188504,
|
||||
"narHash": "sha256-tcD2wJT8i9lxHlCZ/+8BL+Y6B+eJKSG5hlQaScrpQY0=",
|
||||
"owner": "farcaller",
|
||||
"repo": "nix-kube-generators",
|
||||
"rev": "e2f4cd8ed07599afeb6096711ebd652da7ff777c",
|
||||
"rev": "cdb5810a8d5d553cdd0d04fa53378d5105b529b2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -68,50 +54,13 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-kube-generators_2": {
|
||||
"locked": {
|
||||
"lastModified": 1672168242,
|
||||
"narHash": "sha256-HSheOSebNYt5ARW9IRab/aU0HosRE/MJOA3oBO0BKbU=",
|
||||
"owner": "farcaller",
|
||||
"repo": "nix-kube-generators",
|
||||
"rev": "bfdfa01c6723c7adc90e4ddb4dd3c14b05890fa7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "farcaller",
|
||||
"repo": "nix-kube-generators",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixhelm": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nix-kube-generators": "nix-kube-generators_2",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1701046718,
|
||||
"narHash": "sha256-FtFHybdTURFsfKlO5Wjh/cULJe6Q5G5X5r8klfRNX4A=",
|
||||
"owner": "farcaller",
|
||||
"repo": "nixhelm",
|
||||
"rev": "b1c3a947ddf30f5c4801138906fb443cf7da7890",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "farcaller",
|
||||
"repo": "nixhelm",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1701107688,
|
||||
"narHash": "sha256-RP9gjAPfvbdEO9FVT7tgoPoxv/1wzsLaYiwvza2rfXg=",
|
||||
"lastModified": 1701662109,
|
||||
"narHash": "sha256-AYf0CUyAkPQ6d3kI2SM6LmxwEuZSz7D459pKASq3CTA=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "491af1f1cc28df11dfbff049da4134c37d58aee9",
|
||||
"rev": "34deb05e5599997d5685387e4f44376915f1e561",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -125,7 +74,6 @@
|
|||
"flake-utils": "flake-utils",
|
||||
"haumea": "haumea",
|
||||
"nix-kube-generators": "nix-kube-generators",
|
||||
"nixhelm": "nixhelm",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
|
|
26
flake.nix
26
flake.nix
|
@ -10,10 +10,6 @@
|
|||
};
|
||||
|
||||
nix-kube-generators.url = "github:farcaller/nix-kube-generators";
|
||||
nixhelm = {
|
||||
url = "github:farcaller/nixhelm";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = inputs @ {
|
||||
|
@ -22,28 +18,16 @@
|
|||
haumea,
|
||||
flake-utils,
|
||||
nix-kube-generators,
|
||||
nixhelm,
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = import nixpkgs {inherit system;};
|
||||
kubelib = nix-kube-generators.lib {inherit pkgs;};
|
||||
charts = nixhelm.chartsDerivations.${system};
|
||||
lib = import ./lib {inherit charts haumea kubelib pkgs;};
|
||||
|
||||
# TODO: remove after work
|
||||
user = import ./user {
|
||||
inherit pkgs;
|
||||
turboprop = {inherit lib;};
|
||||
};
|
||||
|
||||
lib = import ./lib {inherit kubelib pkgs;};
|
||||
in {
|
||||
packages = {
|
||||
inherit charts lib user;
|
||||
default = user:
|
||||
import ./src {
|
||||
inherit charts haumea lib pkgs user;
|
||||
};
|
||||
};
|
||||
lib = {charts ? {}, user ? {}}:
|
||||
import self {
|
||||
inherit charts haumea lib pkgs user;
|
||||
};
|
||||
# TODO: make a template
|
||||
formatter = pkgs.alejandra;
|
||||
});
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
{
|
||||
charts,
|
||||
haumea,
|
||||
kubelib,
|
||||
pkgs,
|
||||
}: let
|
||||
builders = import ./builders.nix {inherit kubelib pkgs;};
|
||||
fetchers = import ./fetchers.nix {inherit kubelib pkgs;};
|
||||
parseYAMLsFile = p: kubelib.fromYAML (builtins.readFile p);
|
||||
in {
|
||||
inherit builders fetchers;
|
||||
app-template = import ./app-template.nix {inherit builders charts pkgs;};
|
||||
builders = import ./builders.nix {inherit kubelib pkgs;};
|
||||
fetchers = import ./fetchers.nix {inherit kubelib pkgs;};
|
||||
|
||||
inherit parseYAMLsFile;
|
||||
parseYAMLFile = p: builtins.head (parseYAMLsFile p);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
builders,
|
||||
charts,
|
||||
lib,
|
||||
pkgs,
|
||||
}: rec {
|
||||
mkImageAttrs = image:
|
||||
|
@ -42,7 +42,7 @@
|
|||
apiVersions ? [],
|
||||
kubeVersion ? pkgs.kubernetes.version,
|
||||
}:
|
||||
builders.helmChart {
|
||||
lib.builders.helmChart {
|
||||
inherit name namespace apiVersions;
|
||||
chart = charts.bjw-s.app-template;
|
||||
values =
|
|
@ -3,7 +3,7 @@
|
|||
haumea,
|
||||
lib,
|
||||
pkgs,
|
||||
user ? {},
|
||||
user,
|
||||
}: let
|
||||
serviceLoader = {
|
||||
charts,
|
|
@ -5,9 +5,8 @@ set -x
|
|||
# Silence shellcheck SC2154 for these vars but not all others.
|
||||
: "${src:-}"
|
||||
: "${out:-}"
|
||||
# `packages.*.default` environment inputs:
|
||||
# `mkDerivation` environment inputs:
|
||||
: "${derivation_paths:-}"
|
||||
: "${extra_drvs:-}"
|
||||
: "${namespace_drv:-}"
|
||||
|
||||
GLOBIGNORE="*.drv" # don't add symlinks to Kustomizations
|
||||
|
|
Loading…
Reference in a new issue