diff --git a/flake.nix b/flake.nix index 62bc8a09..95d693f5 100644 --- a/flake.nix +++ b/flake.nix @@ -100,31 +100,6 @@ program = pkgs.lib.getExe testScript; }; }; - - checks.alejandra = pkgs.runCommand "check-alejandra" {} '' - ${pkgs.lib.getExe pkgs.alejandra} --check ${self} - touch $out - ''; - - checks.nickel-format = - pkgs.runCommand "check-nickel-format" { - buildInputs = [ - inputs.nickel.packages.${system}.nickel-lang-cli - ]; - } '' - cd ${self} - failed="" - for f in $(find . -name future -prune -or -name '*.ncl' -print); do - if ! diff -u "$f" <(nickel format -f "$f"); then - failed="$failed $f" - fi - done - if [ "$failed" != "" ]; then - echo "Following files need to be formatted: $failed" - exit 1 - fi - touch $out - ''; } ); } diff --git a/lib/builders.ncl b/lib/builders.ncl index ce90c208..ed2f231f 100644 --- a/lib/builders.ncl +++ b/lib/builders.ncl @@ -1,4 +1,4 @@ -let { NickelDerivation, Derivation, NixString, .. } = import "contracts.ncl" in +let { NickelDerivation, Derivation, NixString, NixEnvironmentVariable, .. } = import "contracts.ncl" in let lib = import "lib.ncl" in @@ -56,7 +56,7 @@ in }, structured_env = {}, env = { - stdenv = lib.import_nix "nixpkgs#stdenv" + stdenv | default = lib.import_nix "nixpkgs#stdenv", }, nix_drv = env & structured_env, } diff --git a/project.ncl b/project.ncl index 3616fae8..4a43707c 100644 --- a/project.ncl +++ b/project.ncl @@ -15,5 +15,45 @@ let import_nix = organist.lib.import_nix in nls = import_nix "nickel#lsp-nls", }, }, + + flake.checks + | { + _ | { + version + = "", + env.stdenv + = import_nix "nixpkgs#stdenvNoCC", + .. + } + } + | { _ | organist.builders.NixpkgsPkg } + = { + alejandra = { + name = "check-alejandra", + env.buildCommand = nix-s%" + %{import_nix "nixpkgs#alejandra"}/bin/alejandra --check %{import_nix "self"} + touch $out + "%, + }, + + nickel-format = { + name = "check-nickel-format", + env.buildInputs.nickel = import_nix "nickel#nickel-lang-cli", + env.buildCommand = nix-s%" + cd %{import_nix "self"} + failed="" + for f in $(find . -name future -prune -or -name '*.ncl' -print); do + if ! diff -u "$f" <(nickel format -f "$f"); then + failed="$failed $f" + fi + done + if [ "$failed" != "" ]; then + echo "Following files need to be formatted: $failed" + exit 1 + fi + touch $out + "%, + }, + }, } | organist.contracts.OrganistExpression