1
0
Fork 0
mirror of https://git.sr.ht/~goorzhel/turboprop synced 2024-12-15 17:50:52 +00:00
Commit graph

61 commits

Author SHA1 Message Date
Antonio Gurgel
61c040df2c Revert silly name for import flake-builders
Also, clean out unused variables.
2023-11-23 10:22:34 -08:00
Antonio Gurgel
ef94817a55 Stop relying on ns/name in derivation path
I've changed release modules' signatures from:
`{lib} -> ... -> <drv>`
to:
`{lib} -> ... -> {out=<drv>; extra=<drv>;}`
Which makes individual derivations more easily findable.

Now, instead of picking them out from a soup of paths in `output.sh`
with a specially-crafted needle (`${ns}-${name}`), I map derivations
directly to paths and use the result as a sort of index. In other words,
I spent some ingenuity in `flake-builders.sh` to save a _lot_ of
ingenuity in `output.sh`.

This affords me the extra convenience, previously spurned because of
the very limitation I've overcome, of symlinking derivations in the
output flake.
2023-11-23 10:07:19 -08:00
Antonio Gurgel
e8016e5bc5 Reflow comments
I try to insert line breaks where a thought fragment ends (a habit
learnt from writing subtitles), but in comments and Git commit
messages it doesn't make as much sense.
2023-11-22 17:54:27 -08:00
Antonio Gurgel
05a3f2bef0 Build extras from system releases too 2023-11-21 23:19:46 -08:00
Antonio Gurgel
6aff849da7 Add kyverno
I have my answer to 2638113, and it's what I was suspecting: the
flake-builder was never using clusterData until I added a release
that needs it, at which point I got the dreaded "error: attribute
'apiVersions' missing".

Remediation was simple: realize the wrongheadedness of passing
an empty attrset when the values are already well-known.
2023-11-21 20:58:13 -08:00
Antonio Gurgel
dc3060aa30 Pass charts into releases, and restore variadity
It doesn't pay to be strict about release module arity.
2023-11-21 20:46:32 -08:00
Antonio Gurgel
1a44fbafd5 Refactor output script to deal with both trees 2023-11-20 23:49:01 -08:00
Antonio Gurgel
b4deb0b258 Implement clusterData
kubelib.buildHelmChart can take the target Kubernetes version and
a list of custom APIs, so I'll bind them both up in an attrset
and pass them to `flake-builder.releases`.

Accordingly, the other release-builders will have to become variadic.
2023-11-20 23:31:11 -08:00
Antonio Gurgel
aa1ec7d842 Don't do readFile twice
Also, I had a brief temptation to move `gatherApis` to `flake-builders`,
but apart from being used in the flake's let-in, it has little in common
with the other builders. I need to lose a direct dependency on kubelib
to try the concept out, though (`flake-builders` doesn't take `kubelib`),
and I ended up keeping the result.
2023-11-20 23:02:54 -08:00
Antonio Gurgel
3e7a376329 Start messy refactor
Release trees are now split into API-producing and API-using ones.
Namespace rake must now take a list of roots of release trees.
2023-11-20 22:46:06 -08:00
Antonio Gurgel
5ec509e3b6 Add packages.*.lib as output (useful for debugging) 2023-11-20 21:52:23 -08:00
Antonio Gurgel
3b5168fdc0 Identify another messy refactor on the horizon
Packages can either output new APIs or expect them in the cluster.

Examples of packages which
- output APIs: Gateway API, which installs various versions of
  gateway.networking.k8s.io resources.
- take APIs as input: app-template, which queries the cluster to
  choose v1a2, v1b1, or v1 for its HTTPRoute (etc.) objects.

("Packages" here collectively refers to Helm charts and YAML bundles.)

I will have to impose strict ordering on them, i.e., build the former
before the latter.
2023-11-20 21:46:44 -08:00
Antonio Gurgel
e5ff9ec805 Factor out pname from main derivation 2023-11-19 14:24:35 -08:00
Antonio Gurgel
708e537c7c Remove verbs from lib.{build,fetch}ers.*
Reading things like `lib.builders.buildHelmChart` got exhausting.
2023-11-19 14:24:24 -08:00
Antonio Gurgel
d0f61ec7de Add Makefile and helper for decrypting SOPS secrets 2023-11-19 13:44:34 -08:00
Antonio Gurgel
33433a953e Build namespaces
I initially thought this would be just another release in
`releases/common/namespaces`, but there's a lot more potential
than that.
2023-11-19 13:21:41 -08:00
Antonio Gurgel
6e09298a02 Tidy up 2023-11-19 11:46:27 -08:00
Antonio Gurgel
408befb503 Decouple homelab idiosyncrasies
My long-term vision for this flake is to use it as a control flake:
plug it into your homelab ("data-plane") flake and avail yourself
of its `lib.builders`, et cetera.

In short, I want this flake to be useful to many people, and that
means not shipping my homelab with it.
2023-11-19 11:35:35 -08:00
Antonio Gurgel
a74676d5f8 Factor out derivation-collecting 2023-11-18 23:22:51 -08:00
Antonio Gurgel
2c213d6222 Factor out (and document exhaustively) flake-builders 2023-11-18 23:13:11 -08:00
Antonio Gurgel
f62420754a Lower all of lib's imports into named attrs
The namespace was getting a bit crowded.
2023-11-18 22:38:17 -08:00
Antonio Gurgel
18b3cbfe84 Remove kubelib as release input; rm buildYAMLStream synonym
Everything I need directly from nix-kube-generators is now
handled in `lib/`. Additionally, now that I know buildYAMLStream always
takes a namespace and name, there's no need for the longer-winded name.
2023-11-18 22:21:08 -08:00
Antonio Gurgel
367851267f Split fetchers and builders; create NamespacedYAML builder
The reason I struggled with genericBuilders, and again when I replaced
`remoteYAML`'s NS-name `pname` with `url`, is that I was confusing the
following two things:
1. Things that fetch a resource (a Helm chart, a YAML stream, etc.)
without naming or namespacing it.
2. Things that create a release _by_ giving it a name and namespace
so that lib/output.sh can sort the resultant files into directories.

Additionally, I was questioning the good sense of releases/svc/gateway:
a release with no release, but only extra objects? Turns out I
needlessly bound the concept of JIT namespace injection to that
`extraObjects` feature. Once I abstracted that builder, the more general
solution became clear.
2023-11-18 22:01:43 -08:00
Antonio Gurgel
b97c0cd007 Don't use dir name in .#packages.*.default
https://nix.dev/guides/best-practices#reproducible-source-paths
2023-11-18 19:22:25 -08:00
Antonio Gurgel
8d355af50d Convert releases/svc/gateway to extraObjects
Now that I have the auto-namespace thing I can skip passing `namespace`
into this module too.
2023-11-18 19:22:25 -08:00
Antonio Gurgel
b51bcafdaf Implement attaching extra k8s objects to releases
No more tossing YAMLs into release dirs. All is Nix.
2023-11-18 19:22:25 -08:00
Antonio Gurgel
11a3fcb002 Refactor modules
By declaring builders at the module level, only to call them in
flake.nix, I give myself the opportunity to inject `{name, namespace}`
there and need no longer pass these args into every module myself.
2023-11-18 19:22:25 -08:00
Antonio Gurgel
05604660ea Factor out app-template HTTPRoutes 2023-11-18 02:09:30 -08:00
Antonio Gurgel
f5b9d92e0f Devise way to retrieve Helm values as YAML
Even though I've refactored the values into Nix, I'd like them easily
available as YAML. This is impossible to do inside the flake, because
it requires `nix derivation show`, so I made do with a helper script.
2023-11-18 00:52:31 -08:00
Antonio Gurgel
8a53be1d9f Have devshell follow root nixpkgs; update deps 2023-11-17 23:22:32 -08:00
Antonio Gurgel
1ab0281d9d Build top- and namespace-level Kustomizations
For `kubectl apply -k result`.
2023-11-17 23:09:06 -08:00
Antonio Gurgel
430b576766 Withdraw releases from output
I only needed it for debugging before I finished the default output.
Charts are still available for anyone using this flake as an input.
2023-11-16 22:11:43 -08:00
Antonio Gurgel
afb5aeea36 Truck in dev niceties from previous k8s repo 2023-11-16 21:29:59 -08:00
Antonio Gurgel
7d912d6ba4 Add Kustomizations for each release in output 2023-11-16 20:34:15 -08:00
Antonio Gurgel
1ade63a493 Pull packages.*.default's installPhase out into lib/ 2023-11-16 20:11:09 -08:00
Antonio Gurgel
60cab327ed Finally build the envisioned output 2023-11-16 19:50:44 -08:00
Antonio Gurgel
a90896c0b9 Finally build the whole flake 2023-11-16 18:16:27 -08:00
Antonio Gurgel
46b20e720d Fumble more with gathering releases for .#default 2023-11-15 18:36:31 -08:00
Antonio Gurgel
1826882c13 Factor out values-gathering 2023-11-15 18:34:32 -08:00
Antonio Gurgel
59116a7f13 Flail at creating default output
I envision the derivation output to be a directory with nested namespace
directories with each release as a single YAML inside.

But I'm currently stuck at the `nix build` part.
2023-11-15 17:36:29 -08:00
Antonio Gurgel
bef2c80e9f Make release tree itself an output
I was puzzling over how to cobble all these derivations into one
mega-derivation, but I might not have to.
2023-11-15 16:44:34 -08:00
Antonio Gurgel
771aeccb54 Simplify leaf derivations
An attrset with a single attr named `out`? Nah, pull it all up one level
and make the _module_ the derivation.
2023-11-15 16:43:54 -08:00
Antonio Gurgel
d26e1356de Create lib.yamlBundle
rakeLeaves moved to a separate module so that it still won't require
`pkgs`, which would pull it into `eachDefaultSystem`.
2023-11-15 15:37:28 -08:00
Antonio Gurgel
c2c860d613 Figure out how to install YAML bundle 2023-11-15 15:20:39 -08:00
Antonio Gurgel
da5b6c0336 wip gw 2023-11-15 10:58:06 -08:00
Antonio Gurgel
08cd7f8082 Simplify buildReleases 2023-11-15 10:57:46 -08:00
Antonio Gurgel
caa0f0b3b2 Increase godlike genericness
Now releases can be built with a single function, be they Helm releases
or YAML bundles copied from Git.
2023-11-15 09:12:40 -08:00
Antonio Gurgel
581ad284dd Trim bogusVersion check
YAGNI (yet).
2023-11-15 08:44:05 -08:00
Antonio Gurgel
b645542f8a Fix last vestige of copy-pasta 2023-11-15 08:43:46 -08:00
Antonio Gurgel
a2abba2889 Ascend to godlike levels of genericness
charts/ and src/ both have two levels of children:
- charts/$repo/$chart
- src/$ns/$release

So, why not use one function to rake them both?

Also, the leaf-raking doesn't require nixpkgs or nix-kube-generators so
I moved everything that does (e.g.: `downloadCharts`) into the
`eachDefaultSystem` part of the output, following the example of
nixhelm's flake.
2023-11-15 01:36:46 -08:00