feat: switch from flake-parts & devenv to rensa + add nixtest

This commit is contained in:
technofab 2025-12-18 13:32:38 +01:00
parent 6af83809f7
commit 012a3afb2d
Signed by: technofab
SSH key fingerprint: SHA256:bV4h88OqS/AxjbPn66uUdvK9JsgIW4tv3vwJQ8tpMqQ
18 changed files with 553 additions and 611 deletions

18
nix/repo/apps.nix Normal file
View file

@ -0,0 +1,18 @@
{
inputs,
cell,
...
}: let
inherit (inputs) pkgs nixlet-lib;
inherit (cell) nixlets;
in {
upload = {
type = "app";
program =
(pkgs.callPackage nixlet-lib.uploadNixletsToGitlab {
projectId = "55602785";
nixlets = builtins.attrValues nixlets;
})
+ "/bin/nixlets-upload";
};
}

55
nix/repo/ci.nix Normal file
View file

@ -0,0 +1,55 @@
{inputs, ...}: let
inherit (inputs) cilib;
in
cilib.mkCI {
pipelines."default" = {
stages = ["test" "build" "deploy"];
jobs = {
"test" = {
stage = "test";
script = [
# sh
"nix run .#tests -- --junit=junit.xml"
];
allow_failure = true;
artifacts = {
when = "always";
reports.junit = "junit.xml";
};
};
"docs" = {
stage = "build";
script = [
# sh
''
nix build .#docs:default
mkdir -p public
cp -r result/. public/
''
];
artifacts.paths = ["public"];
};
"pages" = {
nix.enable = false;
image = "alpine:latest";
stage = "deploy";
script = ["true"];
artifacts.paths = ["public"];
rules = [
{"if" = "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH";}
];
};
"upload" = {
stage = "deploy";
rules = [
{"if" = "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH";}
];
variables.AUTH_HEADER = "JOB-TOKEN: \${CI_JOB_TOKEN}";
script = [
# sh
"nix run .#upload --impure"
];
};
};
};
}

29
nix/repo/devShells.nix Normal file
View file

@ -0,0 +1,29 @@
{
cell,
inputs,
...
}: let
inherit (inputs) pkgs devshell treefmt;
inherit (cell) soonix;
in {
default = devshell.mkShell {
imports = [soonix.devshellModule];
packages = [
pkgs.nil
(treefmt.mkWrapper pkgs {
programs = {
alejandra.enable = true;
deadnix.enable = true;
statix.enable = true;
mdformat.enable = true;
};
settings.formatter.mdformat.command = let
pkg = pkgs.python3.withPackages (p: [
p.mdformat
p.mdformat-mkdocs
]);
in "${pkg}/bin/mdformat";
})
];
};
}

61
nix/repo/docs.nix Normal file
View file

@ -0,0 +1,61 @@
{
inputs,
cell,
...
}: let
inherit (inputs) doclib;
inherit (cell) nixlets;
in
(doclib.mkDocs {
docs."default" = {
base = "${inputs.self}";
path = "${inputs.self}/docs";
material = {
enable = true;
colors = {
primary = "blue";
accent = "light blue";
};
umami = {
enable = true;
src = "https://analytics.tf/umami";
siteId = "a4181010-317a-45e3-978c-5d07a93e0cd2";
domains = ["nixlets.projects.tf"];
};
};
dynamic-nav = {
enable = true;
files."Nixlets Values" = builtins.map (val: {${val.name} = val.mkDocs {};}) (builtins.attrValues nixlets);
};
config = {
site_name = "Nixlets";
site_url = "https://nixlets.projects.tf";
repo_name = "TECHNOFAB/nixlets";
repo_url = "https://gitlab.com/TECHNOFAB/nixlets";
extra_css = ["style.css"];
theme = {
logo = "images/logo.svg";
icon.repo = "simple/gitlab";
favicon = "images/logo.svg";
};
nav = [
{"Introduction" = "index.md";}
{"Creating Nixlets" = "creation.md";}
{"Packaging" = "packaging.md";}
{"Usage" = "usage.md";}
{"Secrets" = "secrets.md";}
];
markdown_extensions = [
{
"pymdownx.highlight".pygments_lang_class = true;
}
"pymdownx.inlinehilite"
"pymdownx.snippets"
"pymdownx.superfences"
"fenced_code"
"admonition"
];
};
};
})
.packages

118
nix/repo/flake.lock generated Normal file
View file

@ -0,0 +1,118 @@
{
"nodes": {
"devshell-lib": {
"locked": {
"dir": "lib",
"lastModified": 1758204313,
"narHash": "sha256-ainbY0Oajb1HMdvy+A8QxF/P5qwcbEzJGEY5pzKdDdc=",
"owner": "rensa-nix",
"repo": "devshell",
"rev": "7d0c4bc78d9f017a739b0c7eb2f4e563118353e6",
"type": "gitlab"
},
"original": {
"dir": "lib",
"owner": "rensa-nix",
"repo": "devshell",
"type": "gitlab"
}
},
"nix-gitlab-ci-lib": {
"locked": {
"dir": "lib",
"lastModified": 1765444672,
"narHash": "sha256-B0cMjRs9P50ym9Le0VUcRN69Yy6tbV13MXq81tTTEus=",
"owner": "TECHNOFAB",
"repo": "nix-gitlab-ci",
"rev": "8f88a53b5479773cd626420362631bc1da99e677",
"type": "gitlab"
},
"original": {
"dir": "lib",
"owner": "TECHNOFAB",
"ref": "3.1.2",
"repo": "nix-gitlab-ci",
"type": "gitlab"
}
},
"nixmkdocs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1766000281,
"narHash": "sha256-rtQKu/snzEjZBCyTkZMWUIuvCThtjmVEwBXb6T1mm40=",
"owner": "TECHNOFAB",
"repo": "nixmkdocs",
"rev": "6999c026457d7dee3a7ab336cd4d1b38bae77957",
"type": "gitlab"
},
"original": {
"dir": "lib",
"owner": "TECHNOFAB",
"repo": "nixmkdocs",
"type": "gitlab"
}
},
"nixtest-lib": {
"locked": {
"dir": "lib",
"lastModified": 1765788390,
"narHash": "sha256-CwICjxGzu43jLaF+Ez6veRW1rEOvkT9zm46X0YrqdYc=",
"owner": "TECHNOFAB",
"repo": "nixtest",
"rev": "fc2b64839c97bca96d4b03d0c1d6ea6ec847c84b",
"type": "gitlab"
},
"original": {
"dir": "lib",
"owner": "TECHNOFAB",
"repo": "nixtest",
"type": "gitlab"
}
},
"root": {
"inputs": {
"devshell-lib": "devshell-lib",
"nix-gitlab-ci-lib": "nix-gitlab-ci-lib",
"nixmkdocs-lib": "nixmkdocs-lib",
"nixtest-lib": "nixtest-lib",
"soonix-lib": "soonix-lib",
"treefmt-nix": "treefmt-nix"
}
},
"soonix-lib": {
"locked": {
"dir": "lib",
"lastModified": 1766044966,
"narHash": "sha256-VB8PgA5QYmehFCGGz8YmlmuhCG43ab9rK9ufdKmfjao=",
"owner": "TECHNOFAB",
"repo": "soonix",
"rev": "e9860d65a0123af948c1a2da65664a6d481efe05",
"type": "gitlab"
},
"original": {
"dir": "lib",
"owner": "TECHNOFAB",
"repo": "soonix",
"type": "gitlab"
}
},
"treefmt-nix": {
"flake": false,
"locked": {
"lastModified": 1766000401,
"narHash": "sha256-+cqN4PJz9y0JQXfAK5J1drd0U05D5fcAGhzhfVrDlsI=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "42d96e75aa56a3f70cab7e7dc4a32868db28e8fd",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

27
nix/repo/flake.nix Normal file
View file

@ -0,0 +1,27 @@
{
inputs = {
devshell-lib.url = "gitlab:rensa-nix/devshell?dir=lib";
nixtest-lib.url = "gitlab:TECHNOFAB/nixtest?dir=lib";
soonix-lib.url = "gitlab:TECHNOFAB/soonix?dir=lib";
nixmkdocs-lib.url = "gitlab:TECHNOFAB/nixmkdocs?dir=lib";
nix-gitlab-ci-lib.url = "gitlab:TECHNOFAB/nix-gitlab-ci/3.1.2?dir=lib";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
flake = false;
};
};
outputs = i:
i
// {
devshell = i.devshell-lib.lib {inherit (i.parent) pkgs;};
soonix = i.soonix-lib.lib {inherit (i.parent) pkgs;};
ntlib = i.nixtest-lib.lib {inherit (i.parent) pkgs;};
cilib = i.nix-gitlab-ci-lib.lib {inherit (i.parent) pkgs;};
doclib = i.nixmkdocs-lib.lib {inherit (i.parent) pkgs;};
nixlet-lib = import "${i.parent.self}/lib" {
inherit (i.parent) kubenix;
inherit (i.parent.pkgs) lib;
};
treefmt = import i.treefmt-nix;
};
}

4
nix/repo/nixlets.nix Normal file
View file

@ -0,0 +1,4 @@
{inputs, ...}: let
inherit (inputs) self nixlet-lib;
in
import "${self}/nixlets" {inherit nixlet-lib;}

37
nix/repo/soonix.nix Normal file
View file

@ -0,0 +1,37 @@
{
inputs,
cell,
...
}: let
inherit (inputs) soonix;
inherit (cell) ci;
in
(soonix.make {
hooks = {
ci = ci.soonix;
renovate = {
output = ".gitlab/renovate.json5";
data = {
extends = ["config:recommended"];
postUpgradeTasks = {
commands = [
"nix-portable nix run .#soonix:update"
];
executionMode = "branch";
};
lockFileMaintenance = {
enabled = true;
extends = ["schedule:monthly"];
};
nix.enabled = true;
gitlabci.enabled = false;
};
hook = {
mode = "copy";
gitignore = false;
};
opts.format = "json";
};
};
})
.config

16
nix/repo/tests.nix Normal file
View file

@ -0,0 +1,16 @@
{
inputs,
cell,
system,
...
}: let
inherit (inputs) pkgs ntlib nixlet-lib;
inherit (cell) nixlets;
in {
tests = ntlib.mkNixtest {
modules = ntlib.autodiscover {dir = "${inputs.self}/tests";};
args = {
inherit pkgs ntlib nixlet-lib nixlets system;
};
};
}