mirror of
https://gitlab.com/TECHNOFAB/nixtest.git
synced 2025-12-16 20:13:53 +01:00
refactor: replace flake-parts, devenv etc. with rensa
This commit is contained in:
parent
5a7053afcb
commit
0414493963
16 changed files with 443 additions and 602 deletions
85
nix/repo/ci.nix
Normal file
85
nix/repo/ci.nix
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
{inputs, ...}: let
|
||||
inherit (inputs) pkgs cilib;
|
||||
in
|
||||
cilib.mkCI {
|
||||
pipelines."default" = {
|
||||
stages = ["test" "build" "deploy"];
|
||||
jobs = {
|
||||
"test:lib" = {
|
||||
stage = "test";
|
||||
script = [
|
||||
"nix run .#tests -- --junit=junit.xml"
|
||||
];
|
||||
allow_failure = true;
|
||||
artifacts = {
|
||||
when = "always";
|
||||
reports.junit = "junit.xml";
|
||||
};
|
||||
};
|
||||
"test:go" = {
|
||||
stage = "test";
|
||||
nix.deps = with pkgs; [gcc go go-junit-report gocover-cobertura];
|
||||
variables = {
|
||||
GOPATH = "$CI_PROJECT_DIR/.go";
|
||||
GOCACHE = "$CI_PROJECT_DIR/.go/pkg/mod";
|
||||
};
|
||||
script = [
|
||||
# sh
|
||||
''
|
||||
set +e
|
||||
go test -coverprofile=coverage.out -v 2>&1 ./... | go-junit-report -set-exit-code > report.xml
|
||||
TEST_EXIT_CODE=$?
|
||||
go tool cover -func coverage.out
|
||||
gocover-cobertura < coverage.out > coverage.xml
|
||||
|
||||
exit $TEST_EXIT_CODE
|
||||
''
|
||||
];
|
||||
allow_failure = true;
|
||||
coverage = "/\(statements\)(?:\s+)?(\d+(?:\.\d+)?%)/";
|
||||
cache.paths = [".go/pkg/mod/"];
|
||||
artifacts = {
|
||||
when = "always";
|
||||
reports = {
|
||||
junit = "report.xml";
|
||||
coverage_report = {
|
||||
coverage_format = "cobertura";
|
||||
path = "coverage.xml";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
"build" = {
|
||||
stage = "build";
|
||||
script = [
|
||||
# sh
|
||||
"nix build .#nixtest"
|
||||
];
|
||||
};
|
||||
"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";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
33
nix/repo/devShells.nix
Normal file
33
nix/repo/devShells.nix
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
inputs,
|
||||
cell,
|
||||
...
|
||||
}: let
|
||||
inherit (inputs) pkgs devshell treefmt;
|
||||
inherit (cell) soonix;
|
||||
in {
|
||||
default = devshell.mkShell {
|
||||
imports = [soonix.devshellModule];
|
||||
packages = with pkgs; [
|
||||
(treefmt.mkWrapper pkgs {
|
||||
programs = {
|
||||
alejandra.enable = true;
|
||||
mdformat.enable = true;
|
||||
gofmt.enable = true;
|
||||
};
|
||||
settings.formatter.mdformat.command = let
|
||||
pkg = pkgs.python3.withPackages (p: [
|
||||
p.mdformat
|
||||
p.mdformat-mkdocs
|
||||
]);
|
||||
in "${pkg}/bin/mdformat";
|
||||
})
|
||||
gcc
|
||||
go
|
||||
gopls
|
||||
delve
|
||||
go-junit-report
|
||||
gocover-cobertura
|
||||
];
|
||||
};
|
||||
}
|
||||
64
nix/repo/docs.nix
Normal file
64
nix/repo/docs.nix
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
{inputs, ...}: let
|
||||
inherit (inputs) pkgs doclib ntlib;
|
||||
|
||||
optionsDoc = doclib.mkOptionDocs {
|
||||
module = ntlib.module;
|
||||
roots = [
|
||||
{
|
||||
url = "https://gitlab.com/TECHNOFAB/nixtest/-/blob/main/lib";
|
||||
path = "${inputs.self}/lib";
|
||||
}
|
||||
];
|
||||
};
|
||||
optionsDocs = pkgs.runCommand "options-docs" {} ''
|
||||
mkdir -p $out
|
||||
ln -s ${optionsDoc} $out/options.md
|
||||
'';
|
||||
in
|
||||
(doclib.mkDocs {
|
||||
docs."default" = {
|
||||
base = "${inputs.self}";
|
||||
path = "${inputs.self}/docs";
|
||||
material = {
|
||||
enable = true;
|
||||
colors = {
|
||||
primary = "green";
|
||||
accent = "light green";
|
||||
};
|
||||
umami = {
|
||||
enable = true;
|
||||
src = "https://analytics.tf/umami";
|
||||
siteId = "716d1869-9342-4b62-a770-e15d2d5c807d";
|
||||
domains = ["nixtest.projects.tf"];
|
||||
};
|
||||
};
|
||||
macros = {
|
||||
enable = true;
|
||||
includeDir = toString optionsDocs;
|
||||
};
|
||||
config = {
|
||||
site_name = "Nixtest";
|
||||
site_url = "https://nixtest.projects.tf";
|
||||
repo_name = "TECHNOFAB/nixtest";
|
||||
repo_url = "https://gitlab.com/TECHNOFAB/nixtest";
|
||||
extra_css = ["style.css"];
|
||||
theme = {
|
||||
logo = "images/logo.svg";
|
||||
icon.repo = "simple/gitlab";
|
||||
favicon = "images/logo.svg";
|
||||
};
|
||||
nav = [
|
||||
{"Introduction" = "index.md";}
|
||||
{"Usage" = "usage.md";}
|
||||
{"Reference" = "reference.md";}
|
||||
{"CLI" = "cli.md";}
|
||||
{"Example Configs" = "examples.md";}
|
||||
{"Options" = "options.md";}
|
||||
];
|
||||
markdown_extensions = [
|
||||
"pymdownx.superfences"
|
||||
"admonition"
|
||||
];
|
||||
};
|
||||
};
|
||||
}).packages
|
||||
100
nix/repo/flake.lock
generated
Normal file
100
nix/repo/flake.lock
generated
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
{
|
||||
"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": 1763481845,
|
||||
"narHash": "sha256-Bp0+9rDmlPWMcnKqGx+BG4+o5KO8FuDAOvXRnXrm3Fo=",
|
||||
"owner": "TECHNOFAB",
|
||||
"repo": "nixmkdocs",
|
||||
"rev": "73d59093df94a894d25bc4bf71880b6f00faa62f",
|
||||
"type": "gitlab"
|
||||
},
|
||||
"original": {
|
||||
"dir": "lib",
|
||||
"owner": "TECHNOFAB",
|
||||
"repo": "nixmkdocs",
|
||||
"type": "gitlab"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"devshell-lib": "devshell-lib",
|
||||
"nix-gitlab-ci-lib": "nix-gitlab-ci-lib",
|
||||
"nixmkdocs-lib": "nixmkdocs-lib",
|
||||
"soonix-lib": "soonix-lib",
|
||||
"treefmt-nix": "treefmt-nix"
|
||||
}
|
||||
},
|
||||
"soonix-lib": {
|
||||
"locked": {
|
||||
"dir": "lib",
|
||||
"lastModified": 1763323017,
|
||||
"narHash": "sha256-MJyg37d+VMfRoFiVUj16FW+zkEwQXbgK9LoFF/SHoxA=",
|
||||
"owner": "TECHNOFAB",
|
||||
"repo": "soonix",
|
||||
"rev": "078034b01e4eaf1f9436d46721f7cbe0d96eb8b4",
|
||||
"type": "gitlab"
|
||||
},
|
||||
"original": {
|
||||
"dir": "lib",
|
||||
"owner": "TECHNOFAB",
|
||||
"repo": "soonix",
|
||||
"type": "gitlab"
|
||||
}
|
||||
},
|
||||
"treefmt-nix": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1762938485,
|
||||
"narHash": "sha256-AlEObg0syDl+Spi4LsZIBrjw+snSVU4T8MOeuZJUJjM=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "5b4ee75aeefd1e2d5a1cc43cf6ba65eba75e83e4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
22
nix/repo/flake.nix
Normal file
22
nix/repo/flake.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
inputs = {
|
||||
devshell-lib.url = "gitlab:rensa-nix/devshell?dir=lib";
|
||||
soonix-lib.url = "gitlab:TECHNOFAB/soonix?dir=lib";
|
||||
nix-gitlab-ci-lib.url = "gitlab:TECHNOFAB/nix-gitlab-ci/3.1.2?dir=lib";
|
||||
nixmkdocs-lib.url = "gitlab:TECHNOFAB/nixmkdocs?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;};
|
||||
cilib = i.nix-gitlab-ci-lib.lib {inherit (i.parent) pkgs;};
|
||||
doclib = i.nixmkdocs-lib.lib {inherit (i.parent) pkgs;};
|
||||
ntlib = import "${i.parent.self}/lib" {inherit (i.parent) pkgs;};
|
||||
treefmt = import i.treefmt-nix;
|
||||
};
|
||||
}
|
||||
34
nix/repo/soonix.nix
Normal file
34
nix/repo/soonix.nix
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
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 .#update-package"
|
||||
"nix-portable nix run .#soonix:update"
|
||||
];
|
||||
lockFileMaintenance = {
|
||||
enabled = true;
|
||||
extends = ["schedule:monthly"];
|
||||
};
|
||||
nix.enabled = true;
|
||||
gitlabci.enabled = false;
|
||||
};
|
||||
hook = {
|
||||
mode = "copy";
|
||||
gitignore = false;
|
||||
};
|
||||
opts.format = "json";
|
||||
};
|
||||
};
|
||||
}).config
|
||||
10
nix/repo/tests.nix
Normal file
10
nix/repo/tests.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{inputs, ...}: let
|
||||
inherit (inputs) pkgs ntlib;
|
||||
in {
|
||||
tests = ntlib.mkNixtest {
|
||||
modules = ntlib.autodiscover {dir = "${inputs.self}/tests";};
|
||||
args = {
|
||||
inherit pkgs ntlib;
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue