diff --git a/.envrc b/.envrc index f990172..565a52a 100644 --- a/.envrc +++ b/.envrc @@ -1 +1,2 @@ -use flake . --impure --accept-flake-config +source $(fetchurl https://gitlab.com/rensa-nix/direnv/-/raw/v0.3.0/direnvrc "sha256-u7+KEz684NnIZ+Vh5x5qLrt8rKdnUNexewBoeTcEVHQ=") +use ren //repo/devShells/default diff --git a/.gitignore b/.gitignore index e1f66c8..f5db43c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ -.direnv/ -.devenv/ result -.pre-commit-config.yaml *.xml cover.* diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6253297..7d70f67 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,5 @@ +# Generated by soonix, DO NOT EDIT include: - - component: gitlab.com/TECHNOFAB/nix-gitlab-ci/nix-gitlab-ci@2.0.0 - inputs: - version: 2.0.0 +- component: gitlab.com/TECHNOFAB/nix-gitlab-ci/nix-gitlab-ci@3.1.2 + inputs: + version: 3.1.2 diff --git a/.gitlab/renovate.json5 b/.gitlab/renovate.json5 new file mode 100644 index 0000000..67d4092 --- /dev/null +++ b/.gitlab/renovate.json5 @@ -0,0 +1,23 @@ +{ + "extends": [ + "config:recommended" + ], + "gitlabci": { + "enabled": false + }, + "lockFileMaintenance": { + "enabled": true, + "extends": [ + "schedule:monthly" + ] + }, + "nix": { + "enabled": true + }, + "postUpgradeTasks": { + "commands": [ + "nix-portable nix run .#update-package", + "nix-portable nix run .#soonix:update" + ] + } +} diff --git a/flake.lock b/flake.lock index 110c517..6d5a6ab 100644 --- a/flake.lock +++ b/flake.lock @@ -1,266 +1,12 @@ { "nodes": { - "cachix": { - "inputs": { - "devenv": [ - "devenv" - ], - "flake-compat": [ - "devenv" - ], - "git-hooks": [ - "devenv" - ], - "nixpkgs": "nixpkgs" - }, - "locked": { - "lastModified": 1742042642, - "narHash": "sha256-D0gP8srrX0qj+wNYNPdtVJsQuFzIng3q43thnHXQ/es=", - "owner": "cachix", - "repo": "cachix", - "rev": "a624d3eaf4b1d225f918de8543ed739f2f574203", - "type": "github" - }, - "original": { - "owner": "cachix", - "ref": "latest", - "repo": "cachix", - "type": "github" - } - }, - "devenv": { - "inputs": { - "cachix": "cachix", - "flake-compat": "flake-compat", - "git-hooks": "git-hooks", - "nix": "nix", - "nixpkgs": "nixpkgs_3" - }, - "locked": { - "lastModified": 1746189866, - "narHash": "sha256-3sTvuSVBFcXbqg26Qcw/ENJ1s36jtzEcZ0mHqLqvWRA=", - "owner": "cachix", - "repo": "devenv", - "rev": "5fc592d45dd056035e0fd5000893a21609c35526", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "devenv", - "type": "github" - } - }, - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1733328505, - "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-parts": { - "inputs": { - "nixpkgs-lib": [ - "devenv", - "nix", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1712014858, - "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "flake-parts_2": { - "inputs": { - "nixpkgs-lib": "nixpkgs-lib" - }, - "locked": { - "lastModified": 1743550720, - "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "c621e8422220273271f52058f618c94e405bb0f5", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "git-hooks": { - "inputs": { - "flake-compat": [ - "devenv" - ], - "gitignore": "gitignore", - "nixpkgs": [ - "devenv", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1742649964, - "narHash": "sha256-DwOTp7nvfi8mRfuL1escHDXabVXFGT1VlPD1JHrtrco=", - "owner": "cachix", - "repo": "git-hooks.nix", - "rev": "dcf5072734cb576d2b0c59b2ac44f5050b5eac82", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "git-hooks.nix", - "type": "github" - } - }, - "gitignore": { - "inputs": { - "nixpkgs": [ - "devenv", - "git-hooks", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1709087332, - "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, - "libgit2": { - "flake": false, - "locked": { - "lastModified": 1697646580, - "narHash": "sha256-oX4Z3S9WtJlwvj0uH9HlYcWv+x1hqp8mhXl7HsLu2f0=", - "owner": "libgit2", - "repo": "libgit2", - "rev": "45fd9ed7ae1a9b74b957ef4f337bc3c8b3df01b5", - "type": "github" - }, - "original": { - "owner": "libgit2", - "repo": "libgit2", - "type": "github" - } - }, - "nix": { - "inputs": { - "flake-compat": [ - "devenv" - ], - "flake-parts": "flake-parts", - "libgit2": "libgit2", - "nixpkgs": "nixpkgs_2", - "nixpkgs-23-11": [ - "devenv" - ], - "nixpkgs-regression": [ - "devenv" - ], - "pre-commit-hooks": [ - "devenv" - ] - }, - "locked": { - "lastModified": 1745930071, - "narHash": "sha256-bYyjarS3qSNqxfgc89IoVz8cAFDkF9yPE63EJr+h50s=", - "owner": "domenkozar", - "repo": "nix", - "rev": "b455edf3505f1bf0172b39a735caef94687d0d9c", - "type": "github" - }, - "original": { - "owner": "domenkozar", - "ref": "devenv-2.24", - "repo": "nix", - "type": "github" - } - }, - "nix-devtools": { - "locked": { - "dir": "lib", - "lastModified": 1739971859, - "narHash": "sha256-DaY11jX7Lraw7mRUIsgPsO+aSkkewQe2D+WMZORTNPE=", - "owner": "technofab", - "repo": "nix-devtools", - "rev": "b4f059657de5ac2569afd69a8f042614d309e6bb", - "type": "gitlab" - }, - "original": { - "dir": "lib", - "owner": "technofab", - "repo": "nix-devtools", - "type": "gitlab" - } - }, - "nix-gitlab-ci": { - "locked": { - "dir": "lib", - "lastModified": 1746973171, - "narHash": "sha256-q/LhPZlhJB2gXZ5BfgU1Wep/1x1y9Sct3/JU8A2fzjg=", - "owner": "technofab", - "repo": "nix-gitlab-ci", - "rev": "dca2d724c155799e537a898cb9f948f8afae4921", - "type": "gitlab" - }, - "original": { - "dir": "lib", - "owner": "technofab", - "ref": "2.0.1", - "repo": "nix-gitlab-ci", - "type": "gitlab" - } - }, - "nix-mkdocs": { - "locked": { - "dir": "lib", - "lastModified": 1757055638, - "narHash": "sha256-KHYSkEreFe4meXzSdEbknC/HwaQSNClQkc8vzHlAsMM=", - "owner": "technofab", - "repo": "nixmkdocs", - "rev": "7840a5febdbeaf2da90babf6c94b3d0929d2bf74", - "type": "gitlab" - }, - "original": { - "dir": "lib", - "owner": "technofab", - "repo": "nixmkdocs", - "type": "gitlab" - } - }, "nixpkgs": { "locked": { - "lastModified": 1733212471, - "narHash": "sha256-M1+uCoV5igihRfcUKrr1riygbe73/dzNnzPsmaLCmpo=", + "lastModified": 1765472234, + "narHash": "sha256-9VvC20PJPsleGMewwcWYKGzDIyjckEz8uWmT0vCDYK0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "55d15ad12a74eb7d4646254e13638ad0c4128776", + "rev": "2fbfb1d73d239d2402a8fe03963e37aab15abe8b", "type": "github" }, "original": { @@ -272,11 +18,11 @@ }, "nixpkgs-lib": { "locked": { - "lastModified": 1743296961, - "narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=", + "lastModified": 1754184128, + "narHash": "sha256-AjhoyBL4eSyXf01Bmc6DiuaMrJRNdWopmdnMY0Pa/M0=", "owner": "nix-community", "repo": "nixpkgs.lib", - "rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa", + "rev": "02e72200e6d56494f4a7c0da8118760736e41b60", "type": "github" }, "original": { @@ -285,113 +31,30 @@ "type": "github" } }, - "nixpkgs_2": { + "ren": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, "locked": { - "lastModified": 1717432640, - "narHash": "sha256-+f9c4/ZX5MWDOuB1rKoWj+lBNm0z0rs4CK47HBLxy1o=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "88269ab3044128b7c2f4c7d68448b2fb50456870", - "type": "github" + "dir": "lib", + "lastModified": 1758738378, + "narHash": "sha256-NjzqdvQCDDdObEBH8x/vdhbdhrIB+N9E570uCdksGHY=", + "owner": "rensa-nix", + "repo": "core", + "rev": "abe19f9f13aff41de2b63304545c87d193d19ef4", + "type": "gitlab" }, "original": { - "owner": "NixOS", - "ref": "release-24.05", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_3": { - "locked": { - "lastModified": 1733477122, - "narHash": "sha256-qamMCz5mNpQmgBwc8SB5tVMlD5sbwVIToVZtSxMph9s=", - "owner": "cachix", - "repo": "devenv-nixpkgs", - "rev": "7bd9e84d0452f6d2e63b6e6da29fe73fac951857", - "type": "github" - }, - "original": { - "owner": "cachix", - "ref": "rolling", - "repo": "devenv-nixpkgs", - "type": "github" - } - }, - "nixpkgs_4": { - "locked": { - "lastModified": 1746152631, - "narHash": "sha256-zBuvmL6+CUsk2J8GINpyy8Hs1Zp4PP6iBWSmZ4SCQ/s=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "032bc6539bd5f14e9d0c51bd79cfe9a055b094c3", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_5": { - "locked": { - "lastModified": 1745377448, - "narHash": "sha256-jhZDfXVKdD7TSEGgzFJQvEEZ2K65UMiqW5YJ2aIqxMA=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "507b63021ada5fee621b6ca371c4fca9ca46f52c", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" + "dir": "lib", + "owner": "rensa-nix", + "repo": "core", + "type": "gitlab" } }, "root": { "inputs": { - "devenv": "devenv", - "flake-parts": "flake-parts_2", - "nix-devtools": "nix-devtools", - "nix-gitlab-ci": "nix-gitlab-ci", - "nix-mkdocs": "nix-mkdocs", - "nixpkgs": "nixpkgs_4", - "systems": "systems", - "treefmt-nix": "treefmt-nix" - } - }, - "systems": { - "locked": { - "lastModified": 1689347949, - "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", - "owner": "nix-systems", - "repo": "default-linux", - "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default-linux", - "type": "github" - } - }, - "treefmt-nix": { - "inputs": { - "nixpkgs": "nixpkgs_5" - }, - "locked": { - "lastModified": 1746216483, - "narHash": "sha256-4h3s1L/kKqt3gMDcVfN8/4v2jqHrgLIe4qok4ApH5x4=", - "owner": "numtide", - "repo": "treefmt-nix", - "rev": "29ec5026372e0dec56f890e50dbe4f45930320fd", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "treefmt-nix", - "type": "github" + "nixpkgs": "nixpkgs", + "ren": "ren" } } }, diff --git a/flake.nix b/flake.nix index 72e77cc..fec8334 100644 --- a/flake.nix +++ b/flake.nix @@ -1,240 +1,39 @@ { + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + ren.url = "gitlab:rensa-nix/core?dir=lib"; + }; + outputs = { - flake-parts, - systems, + ren, + self, ... } @ inputs: - flake-parts.lib.mkFlake {inherit inputs;} { - imports = [ - inputs.devenv.flakeModule - inputs.treefmt-nix.flakeModule - inputs.nix-gitlab-ci.flakeModule - inputs.nix-devtools.flakeModule - inputs.nix-mkdocs.flakeModule + ren.buildWith + { + inherit inputs; + cellsFrom = ./nix; + transformInputs = system: i: + i + // { + pkgs = import i.nixpkgs {inherit system;}; + }; + cellBlocks = with ren.blocks; [ + (simple "devShells") + (simple "ci") + (simple "tests") + (simple "packages") + (simple "docs") + (simple "soonix") + ]; + } + { + packages = ren.select self [ + ["repo" "ci" "packages"] + ["repo" "tests"] + ["packages" "packages"] + ["repo" "docs"] + ["repo" "soonix" "packages"] ]; - systems = import systems; - flake = {}; - perSystem = { - lib, - pkgs, - self', - config, - ... - }: { - treefmt = { - projectRootFile = "flake.nix"; - 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"; - }; - devenv.shells.default = { - containers = pkgs.lib.mkForce {}; - packages = with pkgs; [gore go-junit-report]; - - languages.go = { - enable = true; - enableHardeningWorkaround = true; - }; - - pre-commit.hooks = { - treefmt = { - enable = true; - packageOverrides.treefmt = config.treefmt.build.wrapper; - }; - convco.enable = true; - }; - - task = { - enable = true; - alias = ","; - tasks = { - "test" = { - cmds = [ - "go test -v -coverprofile cover.out ./..." - "go tool cover -html cover.out -o cover.html" - ]; - }; - }; - }; - }; - - docs."default".config = { - path = ./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 self'.packages.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 = { - icon.repo = "simple/gitlab"; - logo = "images/logo.svg"; - 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" - ]; - }; - }; - - ci = { - 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; [go go-junit-report gocover-cobertura]; - variables = { - GOPATH = "$CI_PROJECT_DIR/.go"; - GOCACHE = "$CI_PROJECT_DIR/.go/pkg/mod"; - }; - script = [ - "go test -coverprofile=coverage.out -v 2>&1 ./... | go-junit-report -set-exit-code > report.xml" - "go tool cover -func coverage.out" - "gocover-cobertura < coverage.out > coverage.xml" - ]; - 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"; - }; - }; - }; - }; - "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"; - } - ]; - }; - }; - }; - - packages = let - ntlib = import ./lib {inherit pkgs lib;}; - doclib = inputs.nix-mkdocs.lib {inherit lib pkgs;}; - in rec { - default = pkgs.callPackage ./package.nix {}; - tests = ntlib.mkNixtest { - modules = ntlib.autodiscover {dir = ./tests;}; - args = { - inherit pkgs ntlib; - }; - }; - optionsDoc = doclib.mkOptionDocs { - module = { - _module.args.pkgs = pkgs; - imports = [ - ntlib.module - ]; - }; - roots = [ - { - url = "https://gitlab.com/TECHNOFAB/nixtest/-/blob/main/lib"; - path = toString ./lib; - } - ]; - }; - optionsDocs = pkgs.runCommand "options-docs" {} '' - mkdir -p $out - ln -s ${optionsDoc} $out/options.md - ''; - }; - }; }; - - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - - # flake & devenv related - flake-parts.url = "github:hercules-ci/flake-parts"; - systems.url = "github:nix-systems/default-linux"; - devenv.url = "github:cachix/devenv"; - treefmt-nix.url = "github:numtide/treefmt-nix"; - nix-gitlab-ci.url = "gitlab:technofab/nix-gitlab-ci/2.0.1?dir=lib"; - nix-devtools.url = "gitlab:technofab/nix-devtools?dir=lib"; - nix-mkdocs.url = "gitlab:technofab/nixmkdocs?dir=lib"; - }; - - nixConfig = { - extra-substituters = [ - "https://cache.nixos.org/" - "https://nix-community.cachix.org" - "https://devenv.cachix.org" - ]; - - extra-trusted-public-keys = [ - "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=" - ]; - }; } diff --git a/nix/packages/packages.nix b/nix/packages/packages.nix new file mode 100644 index 0000000..9174657 --- /dev/null +++ b/nix/packages/packages.nix @@ -0,0 +1,8 @@ +{inputs, ...}: let + inherit (inputs) self pkgs; +in { + nixtest = pkgs.callPackage "${self}/package.nix" {}; + update-package = pkgs.writeShellScriptBin "update-package" '' + ${pkgs.nix-update}/bin/nix-update nixtest --flake --version skip + ''; +} diff --git a/nix/repo/ci.nix b/nix/repo/ci.nix new file mode 100644 index 0000000..010c4ad --- /dev/null +++ b/nix/repo/ci.nix @@ -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"; + } + ]; + }; + }; + }; + } diff --git a/nix/repo/devShells.nix b/nix/repo/devShells.nix new file mode 100644 index 0000000..1f425c9 --- /dev/null +++ b/nix/repo/devShells.nix @@ -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 + ]; + }; +} diff --git a/nix/repo/docs.nix b/nix/repo/docs.nix new file mode 100644 index 0000000..f8aea5c --- /dev/null +++ b/nix/repo/docs.nix @@ -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 diff --git a/nix/repo/flake.lock b/nix/repo/flake.lock new file mode 100644 index 0000000..930798e --- /dev/null +++ b/nix/repo/flake.lock @@ -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 +} diff --git a/nix/repo/flake.nix b/nix/repo/flake.nix new file mode 100644 index 0000000..7452c07 --- /dev/null +++ b/nix/repo/flake.nix @@ -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; + }; +} diff --git a/nix/repo/soonix.nix b/nix/repo/soonix.nix new file mode 100644 index 0000000..9eaab59 --- /dev/null +++ b/nix/repo/soonix.nix @@ -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 diff --git a/nix/repo/tests.nix b/nix/repo/tests.nix new file mode 100644 index 0000000..9e2e8fb --- /dev/null +++ b/nix/repo/tests.nix @@ -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; + }; + }; +} diff --git a/package.nix b/package.nix index cce5967..82976d2 100644 --- a/package.nix +++ b/package.nix @@ -4,7 +4,8 @@ ... }: buildGoModule { - name = "nixtest"; + pname = "nixtest"; + version = "latest"; src = # filter everything except for cmd/ and go.mod, go.sum with lib.fileset; diff --git a/snapshots/pretty-snapshot.snap.json b/snapshots/pretty-snapshot.snap.json index d7ee4ed..6349f86 100644 --- a/snapshots/pretty-snapshot.snap.json +++ b/snapshots/pretty-snapshot.snap.json @@ -1 +1 @@ -"{\n example = \u003cfunction\u003e;\n example2 = {\n drv = \u003cderivation hello-2.12.1\u003e;\n };\n}" \ No newline at end of file +"{\n example = \u003cfunction\u003e;\n example2 = {\n drv = \u003cderivation hello-2.12.2\u003e;\n };\n}"