mirror of
https://gitlab.com/TECHNOFAB/nixlets.git
synced 2025-12-12 01:50:05 +01:00
chore: add basic template and lib
This commit is contained in:
parent
c39e29b568
commit
6d7653ff0c
8 changed files with 593 additions and 0 deletions
79
lib/default.nix
Normal file
79
lib/default.nix
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
{
|
||||
inputs,
|
||||
lib,
|
||||
...
|
||||
} @ attrs:
|
||||
with lib; {
|
||||
mkValues = file: {rawValues, ...} @ args:
|
||||
(lib.evalModules {
|
||||
specialArgs = {
|
||||
utils = import ./. attrs;
|
||||
};
|
||||
modules = [
|
||||
file
|
||||
({...}: {
|
||||
# pass through all args to the values.nix module
|
||||
config =
|
||||
rawValues
|
||||
// {
|
||||
_module.args = args;
|
||||
};
|
||||
})
|
||||
];
|
||||
})
|
||||
.config;
|
||||
|
||||
mkNestedOption = options:
|
||||
mkOption {
|
||||
type = types.submodule {
|
||||
inherit options;
|
||||
};
|
||||
default = {};
|
||||
};
|
||||
|
||||
mkNixlet = path: let
|
||||
utils = import ./. attrs;
|
||||
in
|
||||
{
|
||||
rawValues,
|
||||
project,
|
||||
...
|
||||
} @ args: {
|
||||
kubenix,
|
||||
lib,
|
||||
...
|
||||
} @ attrs: let
|
||||
values = utils.mkValues "${path}/values.nix" args;
|
||||
in {
|
||||
imports = [path];
|
||||
# make values accessible from every imported file
|
||||
_module.args = {inherit values;};
|
||||
};
|
||||
|
||||
renderNixlet = {
|
||||
system,
|
||||
project,
|
||||
nixlet,
|
||||
values,
|
||||
overrides ? {...}: {},
|
||||
}:
|
||||
(inputs.kubenix.evalModules.${system} {
|
||||
module = {kubenix, ...}: {
|
||||
imports = with kubenix.modules; [
|
||||
k8s
|
||||
helm
|
||||
docker
|
||||
(nixlet {
|
||||
# all these args are available in values.nix
|
||||
inherit project;
|
||||
rawValues = values;
|
||||
})
|
||||
overrides
|
||||
];
|
||||
kubenix.project = project;
|
||||
};
|
||||
})
|
||||
.config
|
||||
.kubernetes
|
||||
.resultYAML;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue