mirror of
https://gitlab.com/TECHNOFAB/nixlets.git
synced 2025-12-12 01:50:05 +01:00
feat: rewrite how nixlets work
This commit is contained in:
parent
ba81fba6b2
commit
0cde19e51f
36 changed files with 494 additions and 125 deletions
18
ci.nix
18
ci.nix
|
|
@ -4,7 +4,7 @@
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
ci = {
|
ci = {
|
||||||
stages = ["check"];
|
stages = ["check" "upload"];
|
||||||
default = {
|
default = {
|
||||||
retry = {
|
retry = {
|
||||||
max = 2;
|
max = 2;
|
||||||
|
|
@ -14,10 +14,26 @@
|
||||||
jobs = {
|
jobs = {
|
||||||
"check" = {
|
"check" = {
|
||||||
stage = "check";
|
stage = "check";
|
||||||
|
before_script = [
|
||||||
|
"nix flake prefetch path:lib"
|
||||||
|
];
|
||||||
script = [
|
script = [
|
||||||
"nix flake check --impure"
|
"nix flake check --impure"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
"upload" = {
|
||||||
|
stage = "upload";
|
||||||
|
rules = [
|
||||||
|
{"if" = ''$CI_COMMIT_REF_NAME == "main"'';}
|
||||||
|
];
|
||||||
|
variables.AUTH_HEADER = "JOB-TOKEN: \${CI_JOB_TOKEN}";
|
||||||
|
before_script = [
|
||||||
|
"nix flake prefetch path:lib"
|
||||||
|
];
|
||||||
|
script = [
|
||||||
|
"nix run .#upload --impure"
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
123
flake.lock
generated
123
flake.lock
generated
|
|
@ -172,6 +172,22 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"flake-compat_6": {
|
"flake-compat_6": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1673956053,
|
||||||
|
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-compat_7": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1696426674,
|
"lastModified": 1696426674,
|
||||||
|
|
@ -258,7 +274,7 @@
|
||||||
},
|
},
|
||||||
"flake-utils_3": {
|
"flake-utils_3": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"systems": "systems_4"
|
"systems": "systems_5"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1701680307,
|
"lastModified": 1701680307,
|
||||||
|
|
@ -340,6 +356,30 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"kubenix_2": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-compat": "flake-compat_6",
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixlet-lib",
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"systems": "systems_4",
|
||||||
|
"treefmt": "treefmt_2"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1709908607,
|
||||||
|
"narHash": "sha256-cG5PftryvQT5vTtRJGGsnfFgdobaUmD2klVVhzddFiU=",
|
||||||
|
"owner": "TECHNOFAB11",
|
||||||
|
"repo": "kubenix",
|
||||||
|
"rev": "ddfdd8d0903acff4a0a52b84e4395da1778dcc4c",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "TECHNOFAB11",
|
||||||
|
"repo": "kubenix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"lowdown-src": {
|
"lowdown-src": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
|
@ -444,6 +484,22 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"nixlet-lib": {
|
||||||
|
"inputs": {
|
||||||
|
"kubenix": "kubenix_2",
|
||||||
|
"nixpkgs": "nixpkgs_6"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1,
|
||||||
|
"narHash": "sha256-DPYdVXcXcHnC9Js4ff28Pbux/uPE8eBqHGrmBaYMhmg=",
|
||||||
|
"path": "lib",
|
||||||
|
"type": "path"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"path": "lib",
|
||||||
|
"type": "path"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1678875422,
|
"lastModified": 1678875422,
|
||||||
|
|
@ -641,6 +697,22 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs_6": {
|
"nixpkgs_6": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1715037484,
|
||||||
|
"narHash": "sha256-OUt8xQFmBU96Hmm4T9tOWTu4oCswCzoVl+pxSq/kiFc=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "ad7efee13e0d216bf29992311536fce1d3eefbef",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixpkgs-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_7": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1709386671,
|
"lastModified": 1709386671,
|
||||||
"narHash": "sha256-VPqfBnIJ+cfa78pd4Y5Cr6sOWVW8GYHRVucxJGmRf8Q=",
|
"narHash": "sha256-VPqfBnIJ+cfa78pd4Y5Cr6sOWVW8GYHRVucxJGmRf8Q=",
|
||||||
|
|
@ -656,7 +728,7 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs_7": {
|
"nixpkgs_8": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1704842529,
|
"lastModified": 1704842529,
|
||||||
"narHash": "sha256-OTeQA+F8d/Evad33JMfuXC89VMetQbsU4qcaePchGr4=",
|
"narHash": "sha256-OTeQA+F8d/Evad33JMfuXC89VMetQbsU4qcaePchGr4=",
|
||||||
|
|
@ -696,10 +768,10 @@
|
||||||
},
|
},
|
||||||
"pre-commit-hooks_2": {
|
"pre-commit-hooks_2": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-compat": "flake-compat_6",
|
"flake-compat": "flake-compat_7",
|
||||||
"flake-utils": "flake-utils_3",
|
"flake-utils": "flake-utils_3",
|
||||||
"gitignore": "gitignore_2",
|
"gitignore": "gitignore_2",
|
||||||
"nixpkgs": "nixpkgs_7",
|
"nixpkgs": "nixpkgs_8",
|
||||||
"nixpkgs-stable": "nixpkgs-stable_3"
|
"nixpkgs-stable": "nixpkgs-stable_3"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
|
|
@ -722,9 +794,10 @@
|
||||||
"flake-parts": "flake-parts",
|
"flake-parts": "flake-parts",
|
||||||
"kubenix": "kubenix",
|
"kubenix": "kubenix",
|
||||||
"nix-gitlab-ci": "nix-gitlab-ci",
|
"nix-gitlab-ci": "nix-gitlab-ci",
|
||||||
"nixpkgs": "nixpkgs_6",
|
"nixlet-lib": "nixlet-lib",
|
||||||
|
"nixpkgs": "nixpkgs_7",
|
||||||
"pre-commit-hooks": "pre-commit-hooks_2",
|
"pre-commit-hooks": "pre-commit-hooks_2",
|
||||||
"systems": "systems_5"
|
"systems": "systems_6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems": {
|
"systems": {
|
||||||
|
|
@ -772,6 +845,20 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems_4": {
|
"systems_4": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "systems",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems_5": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1681028828,
|
"lastModified": 1681028828,
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
|
@ -786,7 +873,7 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems_5": {
|
"systems_6": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1689347949,
|
"lastModified": 1689347949,
|
||||||
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
|
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
|
||||||
|
|
@ -821,6 +908,28 @@
|
||||||
"repo": "treefmt-nix",
|
"repo": "treefmt-nix",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"treefmt_2": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixlet-lib",
|
||||||
|
"kubenix",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1688026376,
|
||||||
|
"narHash": "sha256-qJmkr9BWDpqblk4E9/rCsAEl39y2n4Ycw6KRopvpUcY=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"rev": "df3f32b0cc253dfc7009b7317e8f0e7ccd70b1cf",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|
|
||||||
51
flake.nix
51
flake.nix
|
|
@ -2,6 +2,7 @@
|
||||||
outputs = {
|
outputs = {
|
||||||
self,
|
self,
|
||||||
flake-parts,
|
flake-parts,
|
||||||
|
nixlet-lib,
|
||||||
systems,
|
systems,
|
||||||
...
|
...
|
||||||
} @ inputs:
|
} @ inputs:
|
||||||
|
|
@ -11,24 +12,19 @@
|
||||||
inputs.nix-gitlab-ci.flakeModule
|
inputs.nix-gitlab-ci.flakeModule
|
||||||
];
|
];
|
||||||
systems = import systems;
|
systems = import systems;
|
||||||
flake = rec {
|
flake = {
|
||||||
utils = import ./lib {
|
# █▄ █ █ ▀▄▀ █ █▀▀ ▀█▀ █▀
|
||||||
inherit (inputs.nixpkgs) lib;
|
# █ ▀█ █ █ █ █▄▄ ██▄ █ ▄█
|
||||||
inherit inputs;
|
nixlets = with nixlet-lib; {
|
||||||
};
|
mosquitto = mkNixlet ./nixlets/mosquitto;
|
||||||
|
attic = mkNixlet ./nixlets/attic;
|
||||||
# █▄░█ █ ▀▄▀ █░░ █▀▀ ▀█▀ █▀
|
postgres = mkNixlet ./nixlets/postgres;
|
||||||
# █░▀█ █ █░█ █▄▄ ██▄ ░█░ ▄█
|
tikv = mkNixlet ./nixlets/tikv;
|
||||||
nixlets = {
|
surrealdb = mkNixlet ./nixlets/surrealdb;
|
||||||
# <name> = utils.mkNixlet ./nixlets/<name>;
|
|
||||||
mosquitto = utils.mkNixlet ./nixlets/mosquitto;
|
|
||||||
attic = utils.mkNixlet ./nixlets/attic;
|
|
||||||
postgres = utils.mkNixlet ./nixlets/postgres;
|
|
||||||
tikv = utils.mkNixlet ./nixlets/tikv;
|
|
||||||
surrealdb = utils.mkNixlet ./nixlets/surrealdb;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
perSystem = {
|
perSystem = {
|
||||||
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
system,
|
system,
|
||||||
inputs',
|
inputs',
|
||||||
|
|
@ -54,11 +50,9 @@
|
||||||
# check if every nixlet successfully renders with default values
|
# check if every nixlet successfully renders with default values
|
||||||
checks =
|
checks =
|
||||||
builtins.mapAttrs (
|
builtins.mapAttrs (
|
||||||
name: nixlet:
|
_: nixlet:
|
||||||
self.utils.renderNixlet {
|
nixlet.render {
|
||||||
inherit system nixlet;
|
inherit system;
|
||||||
project = name;
|
|
||||||
values = {};
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.nixlets;
|
self.nixlets;
|
||||||
|
|
@ -66,14 +60,20 @@
|
||||||
# allow directly building every nixlet with default values
|
# allow directly building every nixlet with default values
|
||||||
packages =
|
packages =
|
||||||
builtins.mapAttrs (
|
builtins.mapAttrs (
|
||||||
name: nixlet:
|
_: nixlet:
|
||||||
self.utils.renderNixlet {
|
nixlet.render {
|
||||||
inherit system nixlet;
|
inherit system;
|
||||||
project = name;
|
|
||||||
values = {};
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.nixlets;
|
self.nixlets;
|
||||||
|
|
||||||
|
apps.upload = {
|
||||||
|
type = "app";
|
||||||
|
program = pkgs.callPackage nixlet-lib.uploadNixletsToGitlab {
|
||||||
|
projectId = "55602785";
|
||||||
|
nixlets = lib.attrValues self.nixlets;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -94,5 +94,6 @@
|
||||||
url = "github:TECHNOFAB11/kubenix";
|
url = "github:TECHNOFAB11/kubenix";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
nixlet-lib.url = "path:lib";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
151
lib/default.nix
151
lib/default.nix
|
|
@ -3,11 +3,11 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
} @ attrs:
|
} @ attrs:
|
||||||
with lib; {
|
with lib; rec {
|
||||||
mkValues = file: {rawValues, ...} @ args:
|
mkValues = file: {rawValues, ...} @ args:
|
||||||
(lib.evalModules {
|
(lib.evalModules {
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
utils = import ./. attrs;
|
utils = import ./utils.nix attrs;
|
||||||
};
|
};
|
||||||
modules = [
|
modules = [
|
||||||
file
|
file
|
||||||
|
|
@ -23,58 +23,103 @@ with lib; {
|
||||||
})
|
})
|
||||||
.config;
|
.config;
|
||||||
|
|
||||||
mkNestedOption = options:
|
# wraps mkNixletInner to allow passing either a path or an attrset
|
||||||
mkOption {
|
mkNixlet = arg:
|
||||||
type = types.submodule {
|
mkNixletInner (
|
||||||
inherit options;
|
if (builtins.typeOf arg) == "set"
|
||||||
};
|
then arg
|
||||||
default = {};
|
else
|
||||||
};
|
{path = arg;}
|
||||||
|
// (
|
||||||
|
if builtins.pathExists "${arg}/nixlet.nix"
|
||||||
|
then (import "${arg}/nixlet.nix")
|
||||||
|
else throw "Nixlet at '${arg}' does not contain nixlet.nix and mkNixlet was called with just a path"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
mkNixlet = path: let
|
mkNixletInner = {
|
||||||
utils = import ./. attrs;
|
path,
|
||||||
in
|
name,
|
||||||
{
|
version ? null,
|
||||||
rawValues,
|
description ? "",
|
||||||
project,
|
defaultProject ? null,
|
||||||
...
|
...
|
||||||
} @ args: {
|
}: let
|
||||||
kubenix,
|
# TODO: just like with the values check the args here with the options system?
|
||||||
lib,
|
in {
|
||||||
...
|
inherit name version description path;
|
||||||
} @ attrs: let
|
render = {
|
||||||
values = utils.mkValues "${path}/values.nix" args;
|
system,
|
||||||
in {
|
project ? defaultProject,
|
||||||
imports = [path];
|
overrides ? ({...}: {}),
|
||||||
# make values accessible from every imported file
|
values ? {},
|
||||||
_module.args = {inherit values;};
|
}:
|
||||||
};
|
assert lib.assertMsg (project != null) "No default project set, please pass a project to the render method"; let
|
||||||
|
# every nixlet gets "nixlet" as arg with some useful data about itself
|
||||||
|
nixletArg = {
|
||||||
|
inherit name project version description;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
(inputs.kubenix.evalModules.${system} {
|
||||||
|
module = {kubenix, ...}: {
|
||||||
|
imports = with kubenix.modules; [
|
||||||
|
k8s
|
||||||
|
helm
|
||||||
|
docker
|
||||||
|
files
|
||||||
|
({...}: let
|
||||||
|
finalValues = mkValues "${path}/values.nix" {
|
||||||
|
rawValues = values;
|
||||||
|
nixlet = nixletArg;
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
imports = [path];
|
||||||
|
_module.args.nixlet =
|
||||||
|
{
|
||||||
|
values = finalValues;
|
||||||
|
}
|
||||||
|
// nixletArg;
|
||||||
|
})
|
||||||
|
overrides
|
||||||
|
];
|
||||||
|
kubenix.project = project;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.config
|
||||||
|
.kubernetes
|
||||||
|
.resultYAML;
|
||||||
|
};
|
||||||
|
|
||||||
renderNixlet = {
|
fetchNixlet = url: sha256: mkNixlet (builtins.fetchTarball {inherit url sha256;});
|
||||||
system,
|
|
||||||
project,
|
uploadNixletsToGitlab = {
|
||||||
nixlet,
|
pkgs,
|
||||||
values ? {},
|
projectId,
|
||||||
overrides ? {...}: {},
|
nixlets,
|
||||||
|
...
|
||||||
}:
|
}:
|
||||||
(inputs.kubenix.evalModules.${system} {
|
pkgs.writeShellScriptBin "nixlets-upload" (
|
||||||
module = {kubenix, ...}: {
|
''
|
||||||
imports = with kubenix.modules; [
|
if [[ -z "$AUTH_HEADER" ]]; then
|
||||||
k8s
|
echo "Must provide AUTH_HEADER environment variable!" 1>&2
|
||||||
helm
|
exit 1
|
||||||
docker
|
fi
|
||||||
files
|
''
|
||||||
(nixlet {
|
+ lib.concatStringsSep "\n" (
|
||||||
# all these args are available in values.nix
|
builtins.map (nixlet:
|
||||||
inherit project;
|
with nixlet; ''
|
||||||
rawValues = values;
|
URL="https://gitlab.com/api/v4/projects/${projectId}/packages/generic/${name}/${version}/${name}.tar.gz"
|
||||||
})
|
if curl --output /dev/null --silent --head --fail --header "$AUTH_HEADER" $URL; then
|
||||||
overrides
|
echo "> Skipped ${name}@${version} because it already exists in the Package Registry"
|
||||||
];
|
else
|
||||||
kubenix.project = project;
|
echo "> Uploading new version ${name}@${version}"
|
||||||
};
|
${pkgs.gnutar}/bin/tar -czf /tmp/${name}.tar.gz --mode='u+rwX' -C ${path} .
|
||||||
})
|
${pkgs.curl}/bin/curl --header "$AUTH_HEADER" --upload-file "/tmp/${name}.tar.gz" "$URL"; echo;
|
||||||
.config
|
${pkgs.coreutils}/bin/rm -f /tmp/${nixlet.name}.tar.gz
|
||||||
.kubernetes
|
echo "> Finished ${name}@${version}, see above"
|
||||||
.resultYAML;
|
fi
|
||||||
|
'')
|
||||||
|
nixlets
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
102
lib/flake.lock
generated
Normal file
102
lib/flake.lock
generated
Normal file
|
|
@ -0,0 +1,102 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-compat": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1673956053,
|
||||||
|
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"kubenix": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-compat": "flake-compat",
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"systems": "systems",
|
||||||
|
"treefmt": "treefmt"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1709908607,
|
||||||
|
"narHash": "sha256-cG5PftryvQT5vTtRJGGsnfFgdobaUmD2klVVhzddFiU=",
|
||||||
|
"owner": "TECHNOFAB11",
|
||||||
|
"repo": "kubenix",
|
||||||
|
"rev": "ddfdd8d0903acff4a0a52b84e4395da1778dcc4c",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "TECHNOFAB11",
|
||||||
|
"repo": "kubenix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1715037484,
|
||||||
|
"narHash": "sha256-OUt8xQFmBU96Hmm4T9tOWTu4oCswCzoVl+pxSq/kiFc=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "ad7efee13e0d216bf29992311536fce1d3eefbef",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixpkgs-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"kubenix": "kubenix",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "systems",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"treefmt": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"kubenix",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1688026376,
|
||||||
|
"narHash": "sha256-qJmkr9BWDpqblk4E9/rCsAEl39y2n4Ycw6KRopvpUcY=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"rev": "df3f32b0cc253dfc7009b7317e8f0e7ccd70b1cf",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
22
lib/flake.nix
Normal file
22
lib/flake.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
description = "Nixlets lib";
|
||||||
|
|
||||||
|
outputs = {
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
kubenix,
|
||||||
|
...
|
||||||
|
} @ inputs:
|
||||||
|
import ./. {
|
||||||
|
inherit (nixpkgs) lib;
|
||||||
|
inherit inputs;
|
||||||
|
};
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||||
|
kubenix = {
|
||||||
|
url = "github:TECHNOFAB11/kubenix";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
10
lib/utils.nix
Normal file
10
lib/utils.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
{lib, ...}:
|
||||||
|
with lib; {
|
||||||
|
mkNestedOption = options:
|
||||||
|
mkOption {
|
||||||
|
type = types.submodule {
|
||||||
|
inherit options;
|
||||||
|
};
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{values, ...}: {
|
{nixlet, ...}:
|
||||||
|
with nixlet; {
|
||||||
kubernetes.resources = {
|
kubernetes.resources = {
|
||||||
configMaps."${values.uniqueName}-config" = {
|
configMaps."${values.uniqueName}-config" = {
|
||||||
data = {
|
data = {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
{
|
{
|
||||||
values,
|
nixlet,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: {
|
}:
|
||||||
|
with nixlet; {
|
||||||
kubernetes.resources = let
|
kubernetes.resources = let
|
||||||
# switch to a StatefulSet if we don't use an external storage configuration
|
# switch to a StatefulSet if we don't use an external storage configuration
|
||||||
type =
|
type =
|
||||||
|
|
|
||||||
6
nixlets/attic/nixlet.nix
Normal file
6
nixlets/attic/nixlet.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
name = "attic";
|
||||||
|
version = "0.0.1";
|
||||||
|
description = "Multi-tenant Nix Binary Cache";
|
||||||
|
defaultProject = "attic";
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
{
|
{
|
||||||
values,
|
nixlet,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: {
|
}:
|
||||||
|
with nixlet; {
|
||||||
kubernetes.resources = {
|
kubernetes.resources = {
|
||||||
persistentVolumeClaims."${values.uniqueName}-data".spec = lib.mkIf (!values.externalStorage) {
|
persistentVolumeClaims."${values.uniqueName}-data".spec = lib.mkIf (!values.externalStorage) {
|
||||||
accessModes = ["ReadWriteOnce"];
|
accessModes = ["ReadWriteOnce"];
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{values, ...}: {
|
{nixlet, ...}:
|
||||||
|
with nixlet; {
|
||||||
kubernetes.resources = {
|
kubernetes.resources = {
|
||||||
services."${values.uniqueName}" = {
|
services."${values.uniqueName}" = {
|
||||||
spec = {
|
spec = {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
utils,
|
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
|
# for some basic values see https://github.com/helm/examples/blob/4888ba8fb8180dd0c36d1e84c1fcafc6efd81532/charts/hello-world/values.yaml
|
||||||
options = {
|
options = {
|
||||||
replicaCount = mkOption {
|
replicaCount = mkOption {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{values, ...}: {
|
{nixlet, ...}:
|
||||||
|
with nixlet; {
|
||||||
kubernetes.resources = {
|
kubernetes.resources = {
|
||||||
configMaps."${values.uniqueName}-config" = {
|
configMaps."${values.uniqueName}-config" = {
|
||||||
data = {
|
data = {
|
||||||
|
|
|
||||||
6
nixlets/mosquitto/nixlet.nix
Normal file
6
nixlets/mosquitto/nixlet.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
name = "mosquitto";
|
||||||
|
version = "0.0.1";
|
||||||
|
description = "An open source MQTT broker";
|
||||||
|
defaultProject = "mosquitto";
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{values, ...}: {
|
{nixlet, ...}:
|
||||||
|
with nixlet; {
|
||||||
kubernetes.resources = {
|
kubernetes.resources = {
|
||||||
persistentVolumeClaims."${values.uniqueName}-data".spec = {
|
persistentVolumeClaims."${values.uniqueName}-data".spec = {
|
||||||
accessModes = ["ReadWriteOnce"];
|
accessModes = ["ReadWriteOnce"];
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{values, ...}: {
|
{nixlet, ...}:
|
||||||
|
with nixlet; {
|
||||||
kubernetes.resources = {
|
kubernetes.resources = {
|
||||||
services."${values.uniqueName}" = {
|
services."${values.uniqueName}" = {
|
||||||
spec = {
|
spec = {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{values, ...}: {
|
{nixlet, ...}:
|
||||||
|
with nixlet; {
|
||||||
kubernetes.resources = {
|
kubernetes.resources = {
|
||||||
statefulSets."${values.uniqueName}".spec = {
|
statefulSets."${values.uniqueName}".spec = {
|
||||||
replicas = values.replicaCount;
|
replicas = values.replicaCount;
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,19 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
utils,
|
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
|
# for some basic values see https://github.com/helm/examples/blob/4888ba8fb8180dd0c36d1e84c1fcafc6efd81532/charts/hello-world/values.yaml
|
||||||
options = {
|
options = {
|
||||||
replicaCount = mkOption {
|
replicaCount = mkOption {
|
||||||
type = types.int;
|
type = types.int;
|
||||||
default = 1;
|
default = 1;
|
||||||
};
|
};
|
||||||
image = utils.mkNestedOption {
|
image = mkNestedOption {
|
||||||
repository = mkOption {
|
repository = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "eclipse-mosquitto";
|
default = "eclipse-mosquitto";
|
||||||
|
|
@ -25,7 +27,7 @@ with lib; {
|
||||||
default = "IfNotPresent";
|
default = "IfNotPresent";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
service = utils.mkNestedOption {
|
service = mkNestedOption {
|
||||||
port = mkOption {
|
port = mkOption {
|
||||||
type = types.int;
|
type = types.int;
|
||||||
default = 1883;
|
default = 1883;
|
||||||
|
|
|
||||||
6
nixlets/postgres/nixlet.nix
Normal file
6
nixlets/postgres/nixlet.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
name = "postgres";
|
||||||
|
version = "0.0.1";
|
||||||
|
description = "The world's most advanced open source database";
|
||||||
|
defaultProject = "postgres";
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{values, ...}: {
|
{nixlet, ...}:
|
||||||
|
with nixlet; {
|
||||||
kubernetes.resources = {
|
kubernetes.resources = {
|
||||||
persistentVolumeClaims."${values.uniqueName}-data".spec = {
|
persistentVolumeClaims."${values.uniqueName}-data".spec = {
|
||||||
accessModes = ["ReadWriteOnce"];
|
accessModes = ["ReadWriteOnce"];
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{values, ...}: {
|
{nixlet, ...}:
|
||||||
|
with nixlet; {
|
||||||
kubernetes.resources = {
|
kubernetes.resources = {
|
||||||
services."${values.uniqueName}" = {
|
services."${values.uniqueName}" = {
|
||||||
spec = {
|
spec = {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{values, ...}: {
|
{nixlet, ...}:
|
||||||
|
with nixlet; {
|
||||||
kubernetes.resources = {
|
kubernetes.resources = {
|
||||||
statefulSets."${values.uniqueName}".spec = {
|
statefulSets."${values.uniqueName}".spec = {
|
||||||
replicas = values.replicaCount;
|
replicas = values.replicaCount;
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,19 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
utils,
|
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
|
# for some basic values see https://github.com/helm/examples/blob/4888ba8fb8180dd0c36d1e84c1fcafc6efd81532/charts/hello-world/values.yaml
|
||||||
options = {
|
options = {
|
||||||
replicaCount = mkOption {
|
replicaCount = mkOption {
|
||||||
type = types.int;
|
type = types.int;
|
||||||
default = 1;
|
default = 1;
|
||||||
};
|
};
|
||||||
image = utils.mkNestedOption {
|
image = mkNestedOption {
|
||||||
repository = mkOption {
|
repository = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "postgres";
|
default = "postgres";
|
||||||
|
|
@ -25,7 +27,7 @@ with lib; {
|
||||||
default = "IfNotPresent";
|
default = "IfNotPresent";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
service = utils.mkNestedOption {
|
service = mkNestedOption {
|
||||||
port = mkOption {
|
port = mkOption {
|
||||||
type = types.int;
|
type = types.int;
|
||||||
default = 5432;
|
default = 5432;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
{
|
{
|
||||||
values,
|
nixlet,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: {
|
}:
|
||||||
|
with nixlet; {
|
||||||
kubernetes.resources = {
|
kubernetes.resources = {
|
||||||
deployments."${values.uniqueName}" = {
|
deployments."${values.uniqueName}" = {
|
||||||
spec = {
|
spec = {
|
||||||
|
|
|
||||||
6
nixlets/surrealdb/nixlet.nix
Normal file
6
nixlets/surrealdb/nixlet.nix
Normal 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";
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{values, ...}: {
|
{nixlet, ...}:
|
||||||
|
with nixlet; {
|
||||||
kubernetes.resources = {
|
kubernetes.resources = {
|
||||||
services."${values.uniqueName}" = {
|
services."${values.uniqueName}" = {
|
||||||
spec = {
|
spec = {
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,19 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
utils,
|
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
|
# for some basic values see https://github.com/helm/examples/blob/4888ba8fb8180dd0c36d1e84c1fcafc6efd81532/charts/hello-world/values.yaml
|
||||||
options = {
|
options = {
|
||||||
replicaCount = mkOption {
|
replicaCount = mkOption {
|
||||||
type = types.int;
|
type = types.int;
|
||||||
default = 1;
|
default = 1;
|
||||||
};
|
};
|
||||||
image = utils.mkNestedOption {
|
image = mkNestedOption {
|
||||||
repository = mkOption {
|
repository = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "surrealdb/surrealdb";
|
default = "surrealdb/surrealdb";
|
||||||
|
|
@ -25,7 +27,7 @@ with lib; {
|
||||||
default = "latest";
|
default = "latest";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
service = utils.mkNestedOption {
|
service = mkNestedOption {
|
||||||
port = mkOption {
|
port = mkOption {
|
||||||
type = types.int;
|
type = types.int;
|
||||||
default = 8000;
|
default = 8000;
|
||||||
|
|
@ -35,7 +37,7 @@ with lib; {
|
||||||
default = "ClusterIP";
|
default = "ClusterIP";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
surrealdb = utils.mkNestedOption {
|
surrealdb = mkNestedOption {
|
||||||
log = mkOption {
|
log = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "info";
|
default = "info";
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
{
|
{
|
||||||
values,
|
nixlet,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}:
|
||||||
|
with nixlet; let
|
||||||
tomlFormat = pkgs.formats.toml {};
|
tomlFormat = pkgs.formats.toml {};
|
||||||
in {
|
in {
|
||||||
kubernetes.resources = {
|
kubernetes.resources = {
|
||||||
|
|
|
||||||
6
nixlets/tikv/nixlet.nix
Normal file
6
nixlets/tikv/nixlet.nix
Normal 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";
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{values, ...}: {
|
{nixlet, ...}:
|
||||||
|
with nixlet; {
|
||||||
kubernetes.resources = {
|
kubernetes.resources = {
|
||||||
services = {
|
services = {
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{values, ...}: {
|
{nixlet, ...}:
|
||||||
|
with nixlet; {
|
||||||
kubernetes.resources = {
|
kubernetes.resources = {
|
||||||
/*
|
/*
|
||||||
Placement Driver
|
Placement Driver
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
utils,
|
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
|
# for some basic values see https://github.com/helm/examples/blob/4888ba8fb8180dd0c36d1e84c1fcafc6efd81532/charts/hello-world/values.yaml
|
||||||
options = {
|
options = {
|
||||||
pd = utils.mkNestedOption {
|
pd = utils.mkNestedOption {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
{values, ...}: {
|
{nixlet, ...}: {
|
||||||
imports = [
|
imports = [
|
||||||
# import other files here
|
# import other files here
|
||||||
];
|
];
|
||||||
|
|
|
||||||
6
template/nixlet.nix
Normal file
6
template/nixlet.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
name = "";
|
||||||
|
version = "0.0.1";
|
||||||
|
description = "";
|
||||||
|
defaultProject = "";
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,12 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
utils,
|
utils,
|
||||||
|
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
|
# for some basic values see https://github.com/helm/examples/blob/4888ba8fb8180dd0c36d1e84c1fcafc6efd81532/charts/hello-world/values.yaml
|
||||||
options = {
|
options = {
|
||||||
# define values here
|
# define values here
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue