From 41e81a16f16fdc375c62cc212be2548ac50e04fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikodem=20Rabuli=C5=84ski?= Date: Tue, 1 Apr 2025 19:13:17 +0200 Subject: [PATCH] nilla: add ci.check --- .forgejo/workflows/build.yaml | 2 +- default.nix | 8 ++++++++ nilla.nix | 36 +++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 default.nix diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 89693ab..ee97846 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -8,4 +8,4 @@ jobs: runs-on: native steps: - uses: actions/checkout@v4 - - run: nix flake check --all-systems + - run: nix-build -A ci.check diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..bb13b3b --- /dev/null +++ b/default.nix @@ -0,0 +1,8 @@ +let + nilla = import ./nilla.nix { }; + getPackage = name: nilla.packages.${name}.result.${builtins.currentSystem}; +in +{ + ci.check = getPackage "ci-check"; + formatter = getPackage "formatter"; +} diff --git a/nilla.nix b/nilla.nix index bc20103..4379f29 100644 --- a/nilla.nix +++ b/nilla.nix @@ -76,6 +76,42 @@ in eval.config.build.wrapper; }; + ci-check = + let + all-packages = builtins.attrValues (builtins.removeAttrs config.packages [ "ci-check" ]); + all-packages' = lib.lists.flatten (map (pkg: builtins.attrValues pkg.result) all-packages); + + nixos-systems = builtins.attrValues config.systems.nixos; + nixos-systems' = map (system: system.result.config.system.build.toplevel) nixos-systems; + + darwin-systems = builtins.attrValues config.systems.darwin; + darwin-systems' = map (system: system.result.config.system.build.toplevel) darwin-systems; + + all-drvs = all-packages' ++ nixos-systems' ++ darwin-systems'; + all-drvs' = lib.strings.concatMapSep "\n" builtins.unsafeDiscardStringContext all-drvs; + in + mkPackage ( + { + lib, + stdenvNoCC, + system, + }: + stdenvNoCC.mkDerivation { + name = "nilla-eval-check"; + src = lib.cleanSource ./.; + doCheck = true; + + allDerivations = all-drvs'; + formatter = lib.getExe config.packages.formatter.result.${system}; + + passAsFile = [ "allDerivations" ]; + + installPhase = ''touch "$out"''; + checkPhase = '' + "$formatter" --ci + ''; + } + ); }; config.shells.default = {