diff --git a/flake.nix b/flake.nix index 06cd3fd..505eb2a 100644 --- a/flake.nix +++ b/flake.nix @@ -4,19 +4,26 @@ inputs.flake-utils.url = "github:numtide/flake-utils"; outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: let - pkgs = nixpkgs.legacyPackages.${system}; - in { - packages = { - default = pkgs.callPackage ./default.nix { }; - test-runner = pkgs.callPackage ./run-tests.nix {}; - }; - devShells.default = pkgs.callPackage ./shell.nix { }; - apps.test-runner = { - type = "app"; - program = "${self.packages.${system}.test-runner}"; - }; - }) // { + flake-utils.lib.eachDefaultSystem + (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + packages = { + default = pkgs.callPackage ./default.nix { }; + test-runner = pkgs.callPackage ./test-runner.nix { }; + test-runner-unstable = pkgs.callPackage ./test-runner.nix { }; + }; + devShells.default = pkgs.callPackage ./shell.nix { }; + apps.test-runner = { + type = "app"; + program = "${self.packages.${system}.test-runner}"; + }; + checks = { + lint = pkgs.callPackage ./lint.nix { }; + }; + }) // { overlay = final: prev: { nix-direnv = final.callPackage ./default.nix { }; }; diff --git a/lint.nix b/lint.nix new file mode 100644 index 0000000..1223cb3 --- /dev/null +++ b/lint.nix @@ -0,0 +1,24 @@ +{ shellcheck +, mypy +, python3 +, lib +, ruff +, runCommand +}: +runCommand "lint" {} '' + set -e + mkdir source + cp -r ${./.}/* source + chmod +w source + cd source + + echo run shellcheck + ${shellcheck}/bin/shellcheck direnvrc + echo run black + ${lib.getExe python3.pkgs.black} --check . + echo run ruff + ${lib.getExe ruff} tests + echo run mypy + ${lib.getExe mypy} tests + touch $out +'' diff --git a/run-tests.nix b/run-tests.nix deleted file mode 100644 index ae908cc..0000000 --- a/run-tests.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ - writeScript, - shellcheck, - direnv, - mypy, - python3, - lib, - ruff -}: -writeScript "run-tests" '' - set -e - PATH="''${PATH}''${PATH:+":"}${direnv}/bin" - echo run shellcheck - ${shellcheck}/bin/shellcheck direnvrc - echo run black - LC_ALL=en_US.utf-8 ${lib.getExe python3.pkgs.black} --check . - echo run ruff - ${lib.getExe ruff} tests - echo run mypy - ${lib.getExe mypy} tests - - echo run unittest - ${lib.getExe python3.pkgs.pytest} . -'' diff --git a/test-runner.nix b/test-runner.nix new file mode 100644 index 0000000..53374a6 --- /dev/null +++ b/test-runner.nix @@ -0,0 +1,15 @@ +{ writeScript +, direnv +, python3 +, lib +, nix +, coreutils +, gnugrep +}: +writeScript "test-runner" '' + set -e + export PATH=${lib.makeBinPath [ direnv nix coreutils gnugrep ]} + + echo run unittest + ${lib.getExe python3.pkgs.pytest} . +''