diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..a415272 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,5 @@ +# Generated by soonix, DO NOT EDIT +include: +- component: gitlab.com/TECHNOFAB/nix-gitlab-ci/nix-gitlab-ci@3.0.0-alpha.2 + inputs: + version: 3.0.0-alpha.2 diff --git a/flake.lock b/flake.lock index d988f28..ea0ade9 100644 --- a/flake.lock +++ b/flake.lock @@ -37,11 +37,11 @@ }, "locked": { "dir": "lib", - "lastModified": 1755264589, - "narHash": "sha256-g8KjU4D/nxpMjCLQNP90VAAWUH89yvONRfChyhhzq4c=", + "lastModified": 1756370106, + "narHash": "sha256-l84ojcHuQWBwn4BRxQsMMfQpcq/Az/sHh/hSqFgVtyg=", "owner": "rensa-nix", "repo": "core", - "rev": "9f20f8c94b09a1c85356f8340ebe0a339b0d32e6", + "rev": "9c1a29fa9ba7cbbb78b9e47eb8afbcd29303a3b4", "type": "gitlab" }, "original": { diff --git a/flake.nix b/flake.nix index 7a32ee9..26004fe 100644 --- a/flake.nix +++ b/flake.nix @@ -23,6 +23,7 @@ (simple "tests") (simple "benchmark") (simple "docs") + (simple "ci") ]; } { @@ -30,6 +31,7 @@ ["repo" "tests"] ["repo" "benchmark"] ["repo" "docs"] + ["repo" "ci" "packages"] ]; }; } diff --git a/lib/modules/env.nix b/lib/modules/env.nix index 4332c96..ee5da94 100644 --- a/lib/modules/env.nix +++ b/lib/modules/env.nix @@ -13,7 +13,7 @@ prefix, ... } @ args: let - vals = filter (key: args.${key} != null && args.${key}) [ + vals = filter (key: args.${key} != null && args.${key} != false) [ "eval" "prefix" "unset" diff --git a/nix/repo/benchmark.nix b/nix/repo/benchmark.nix index b80e1d4..9a74e62 100644 --- a/nix/repo/benchmark.nix +++ b/nix/repo/benchmark.nix @@ -6,13 +6,13 @@ in { runtimeInputs = [pkgs.hyperfine]; text = '' echo "Comparison cases first:" - hyperfine -w 3 \ - 'nix-instantiate ${inputs.self}/benchmark/shared.nix' \ - 'nix-instantiate ${inputs.self}/benchmark/empty.nix' + hyperfine -w 5 \ + 'nix-instantiate ${inputs.self}/benchmark/shared.nix --quiet --quiet --quiet' \ + 'nix-instantiate ${inputs.self}/benchmark/empty.nix --quiet --quiet --quiet' echo "Now real benchmark:" - hyperfine -w 3 \ - 'nix-instantiate ${inputs.self}/benchmark/nixpkgs-shell.nix' \ - 'nix-instantiate ${inputs.self}/benchmark/devshell.nix' + hyperfine -w 5 \ + 'nix-instantiate ${inputs.self}/benchmark/nixpkgs-shell.nix --quiet --quiet --quiet' \ + 'nix-instantiate ${inputs.self}/benchmark/devshell.nix --quiet --quiet --quiet' ''; }; } diff --git a/nix/repo/ci.nix b/nix/repo/ci.nix new file mode 100644 index 0000000..e9fe6be --- /dev/null +++ b/nix/repo/ci.nix @@ -0,0 +1,51 @@ +{inputs, ...}: let + inherit (inputs) cilib; +in + cilib.mkCI { + pipelines."default" = { + stages = ["test" "build" "deploy"]; + jobs = { + "test" = { + stage = "test"; + script = [ + "nix run .#tests -- --junit=junit.xml" + ]; + allow_failure = true; + artifacts = { + when = "always"; + reports.junit = "junit.xml"; + }; + }; + "benchmark" = { + stage = "test"; + script = [ + "nix run .#bench" + ]; + }; + "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"; + } + ]; + }; + }; + }; + } diff --git a/nix/repo/devShells.nix b/nix/repo/devShells.nix index 3d59cfc..fd55a79 100644 --- a/nix/repo/devShells.nix +++ b/nix/repo/devShells.nix @@ -1,18 +1,24 @@ -{inputs, ...}: let - inherit (inputs) pkgs devshell treefmt; +{ + inputs, + cell, + ... +}: let + inherit (inputs) pkgs devshell treefmt soonix; + inherit (cell) ci; in { default = devshell.mkShell { + imports = [soonix.devshellModule]; packages = [ pkgs.nil (treefmt.mkWrapper pkgs { programs = { alejandra.enable = true; - statix.enable = true; deadnix.enable = true; mdformat.enable = true; }; }) ]; + soonix.hooks.ci = ci.soonix; meta = { enableMenu = true; showMenu = "always"; diff --git a/nix/repo/flake.lock b/nix/repo/flake.lock index 9b28e91..93bff42 100644 --- a/nix/repo/flake.lock +++ b/nix/repo/flake.lock @@ -1,5 +1,23 @@ { "nodes": { + "nix-gitlab-ci-lib": { + "locked": { + "dir": "lib", + "lastModified": 1756974596, + "narHash": "sha256-KxQj76sUqvPNtrqzNWMZeOWqTitc0aFCYj7UZzToiEA=", + "owner": "TECHNOFAB", + "repo": "nix-gitlab-ci", + "rev": "00cf5b83c6c46698fba12a54b9cc15c6d4e5a4dd", + "type": "gitlab" + }, + "original": { + "dir": "lib", + "owner": "TECHNOFAB", + "ref": "3.0.0-alpha.2", + "repo": "nix-gitlab-ci", + "type": "gitlab" + } + }, "nixmkdocs": { "locked": { "dir": "lib", @@ -36,11 +54,30 @@ }, "root": { "inputs": { + "nix-gitlab-ci-lib": "nix-gitlab-ci-lib", "nixmkdocs": "nixmkdocs", "nixtest-lib": "nixtest-lib", + "soonix-lib": "soonix-lib", "treefmt-nix": "treefmt-nix" } }, + "soonix-lib": { + "locked": { + "dir": "lib", + "lastModified": 1757424411, + "narHash": "sha256-x99obZwqDAhUB+VUhAV9sKH00NnsVi481n/8bdvZCUY=", + "owner": "TECHNOFAB", + "repo": "soonix", + "rev": "add807ef8980197bbd06652a36d937b93b2a31c7", + "type": "gitlab" + }, + "original": { + "dir": "lib", + "owner": "TECHNOFAB", + "repo": "soonix", + "type": "gitlab" + } + }, "treefmt-nix": { "flake": false, "locked": { diff --git a/nix/repo/flake.nix b/nix/repo/flake.nix index 756cc1d..29a15cf 100644 --- a/nix/repo/flake.nix +++ b/nix/repo/flake.nix @@ -2,6 +2,8 @@ inputs = { nixtest-lib.url = "gitlab:TECHNOFAB/nixtest?dir=lib"; nixmkdocs.url = "gitlab:TECHNOFAB/nixmkdocs?dir=lib"; + soonix-lib.url = "gitlab:TECHNOFAB/soonix?dir=lib"; + nix-gitlab-ci-lib.url = "gitlab:TECHNOFAB/nix-gitlab-ci/3.0.0-alpha.2?dir=lib"; treefmt-nix = { url = "github:numtide/treefmt-nix"; flake = false; @@ -12,6 +14,8 @@ // { ntlib = i.nixtest-lib.lib {inherit (i.parent) pkgs;}; doclib = i.nixmkdocs.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;}; devshell = import "${i.parent.self}/lib" {inherit (i.parent) pkgs;}; treefmt = import i.treefmt-nix; };