feat: rewrite how nixlets work

This commit is contained in:
TECHNOFAB 2024-05-08 17:09:17 +00:00
parent ba81fba6b2
commit 0cde19e51f
36 changed files with 494 additions and 125 deletions

View file

@ -1,4 +1,5 @@
{values, ...}: {
{nixlet, ...}:
with nixlet; {
kubernetes.resources = {
configMaps."${values.uniqueName}-config" = {
data = {

View file

@ -1,8 +1,9 @@
{
values,
nixlet,
lib,
...
}: {
}:
with nixlet; {
kubernetes.resources = let
# switch to a StatefulSet if we don't use an external storage configuration
type =

6
nixlets/attic/nixlet.nix Normal file
View file

@ -0,0 +1,6 @@
{
name = "attic";
version = "0.0.1";
description = "Multi-tenant Nix Binary Cache";
defaultProject = "attic";
}

View file

@ -1,8 +1,9 @@
{
values,
nixlet,
lib,
...
}: {
}:
with nixlet; {
kubernetes.resources = {
persistentVolumeClaims."${values.uniqueName}-data".spec = lib.mkIf (!values.externalStorage) {
accessModes = ["ReadWriteOnce"];

View file

@ -1,4 +1,5 @@
{values, ...}: {
{nixlet, ...}:
with nixlet; {
kubernetes.resources = {
services."${values.uniqueName}" = {
spec = {

View file

@ -1,10 +1,11 @@
{
lib,
utils,
project,
nixlet,
...
}:
with lib; {
with lib;
with nixlet; {
# for some basic values see https://github.com/helm/examples/blob/4888ba8fb8180dd0c36d1e84c1fcafc6efd81532/charts/hello-world/values.yaml
options = {
replicaCount = mkOption {

View file

@ -1,4 +1,5 @@
{values, ...}: {
{nixlet, ...}:
with nixlet; {
kubernetes.resources = {
configMaps."${values.uniqueName}-config" = {
data = {

View file

@ -0,0 +1,6 @@
{
name = "mosquitto";
version = "0.0.1";
description = "An open source MQTT broker";
defaultProject = "mosquitto";
}

View file

@ -1,4 +1,5 @@
{values, ...}: {
{nixlet, ...}:
with nixlet; {
kubernetes.resources = {
persistentVolumeClaims."${values.uniqueName}-data".spec = {
accessModes = ["ReadWriteOnce"];

View file

@ -1,4 +1,5 @@
{values, ...}: {
{nixlet, ...}:
with nixlet; {
kubernetes.resources = {
services."${values.uniqueName}" = {
spec = {

View file

@ -1,4 +1,5 @@
{values, ...}: {
{nixlet, ...}:
with nixlet; {
kubernetes.resources = {
statefulSets."${values.uniqueName}".spec = {
replicas = values.replicaCount;

View file

@ -1,17 +1,19 @@
{
lib,
utils,
project,
nixlet,
...
}:
with lib; {
with lib;
with utils;
with nixlet; {
# for some basic values see https://github.com/helm/examples/blob/4888ba8fb8180dd0c36d1e84c1fcafc6efd81532/charts/hello-world/values.yaml
options = {
replicaCount = mkOption {
type = types.int;
default = 1;
};
image = utils.mkNestedOption {
image = mkNestedOption {
repository = mkOption {
type = types.str;
default = "eclipse-mosquitto";
@ -25,7 +27,7 @@ with lib; {
default = "IfNotPresent";
};
};
service = utils.mkNestedOption {
service = mkNestedOption {
port = mkOption {
type = types.int;
default = 1883;

View file

@ -0,0 +1,6 @@
{
name = "postgres";
version = "0.0.1";
description = "The world's most advanced open source database";
defaultProject = "postgres";
}

View file

@ -1,4 +1,5 @@
{values, ...}: {
{nixlet, ...}:
with nixlet; {
kubernetes.resources = {
persistentVolumeClaims."${values.uniqueName}-data".spec = {
accessModes = ["ReadWriteOnce"];

View file

@ -1,4 +1,5 @@
{values, ...}: {
{nixlet, ...}:
with nixlet; {
kubernetes.resources = {
services."${values.uniqueName}" = {
spec = {

View file

@ -1,4 +1,5 @@
{values, ...}: {
{nixlet, ...}:
with nixlet; {
kubernetes.resources = {
statefulSets."${values.uniqueName}".spec = {
replicas = values.replicaCount;

View file

@ -1,17 +1,19 @@
{
lib,
utils,
project,
nixlet,
...
}:
with lib; {
with lib;
with utils;
with nixlet; {
# for some basic values see https://github.com/helm/examples/blob/4888ba8fb8180dd0c36d1e84c1fcafc6efd81532/charts/hello-world/values.yaml
options = {
replicaCount = mkOption {
type = types.int;
default = 1;
};
image = utils.mkNestedOption {
image = mkNestedOption {
repository = mkOption {
type = types.str;
default = "postgres";
@ -25,7 +27,7 @@ with lib; {
default = "IfNotPresent";
};
};
service = utils.mkNestedOption {
service = mkNestedOption {
port = mkOption {
type = types.int;
default = 5432;

View file

@ -1,8 +1,9 @@
{
values,
nixlet,
lib,
...
}: {
}:
with nixlet; {
kubernetes.resources = {
deployments."${values.uniqueName}" = {
spec = {

View file

@ -0,0 +1,6 @@
{
name = "surrealdb";
version = "0.0.1";
description = "As a multi-model database, SurrealDB enables developers to use multiple techniques to store and model data, without having to choose a method in advance";
defaultProject = "surrealdb";
}

View file

@ -1,4 +1,5 @@
{values, ...}: {
{nixlet, ...}:
with nixlet; {
kubernetes.resources = {
services."${values.uniqueName}" = {
spec = {

View file

@ -1,17 +1,19 @@
{
lib,
utils,
project,
nixlet,
...
}:
with lib; {
with lib;
with utils;
with nixlet; {
# for some basic values see https://github.com/helm/examples/blob/4888ba8fb8180dd0c36d1e84c1fcafc6efd81532/charts/hello-world/values.yaml
options = {
replicaCount = mkOption {
type = types.int;
default = 1;
};
image = utils.mkNestedOption {
image = mkNestedOption {
repository = mkOption {
type = types.str;
default = "surrealdb/surrealdb";
@ -25,7 +27,7 @@ with lib; {
default = "latest";
};
};
service = utils.mkNestedOption {
service = mkNestedOption {
port = mkOption {
type = types.int;
default = 8000;
@ -35,7 +37,7 @@ with lib; {
default = "ClusterIP";
};
};
surrealdb = utils.mkNestedOption {
surrealdb = mkNestedOption {
log = mkOption {
type = types.str;
default = "info";

View file

@ -1,8 +1,9 @@
{
values,
nixlet,
pkgs,
...
}: let
}:
with nixlet; let
tomlFormat = pkgs.formats.toml {};
in {
kubernetes.resources = {

6
nixlets/tikv/nixlet.nix Normal file
View file

@ -0,0 +1,6 @@
{
name = "tikv";
version = "0.0.1";
description = "TiKV is an open-source, distributed, and transactional key-value database";
defaultProject = "tikv";
}

View file

@ -1,4 +1,5 @@
{values, ...}: {
{nixlet, ...}:
with nixlet; {
kubernetes.resources = {
services = {
/*

View file

@ -1,4 +1,5 @@
{values, ...}: {
{nixlet, ...}:
with nixlet; {
kubernetes.resources = {
/*
Placement Driver

View file

@ -1,10 +1,12 @@
{
lib,
utils,
project,
nixlet,
...
}:
with lib; {
with lib;
with utils;
with nixlet; {
# for some basic values see https://github.com/helm/examples/blob/4888ba8fb8180dd0c36d1e84c1fcafc6efd81532/charts/hello-world/values.yaml
options = {
pd = utils.mkNestedOption {