diff --git a/docs/guides/using-with-flakes.md b/docs/guides/using-with-flakes.md index d3bd21fb5..f39eb9832 100644 --- a/docs/guides/using-with-flakes.md +++ b/docs/guides/using-with-flakes.md @@ -62,6 +62,7 @@ Here's a minimal `flake.nix` file that includes: in { packages.${system}.devenv-up = self.devShells.${system}.default.config.procfileScript; + packages.${system}.devenv-test = self.devShells.${system}.default.config.test; devShells.${system}.default = devenv.lib.mkShell { inherit inputs pkgs; @@ -91,6 +92,21 @@ $ devenv up 17:34:37 system | run.1 stopped (rc=0) ``` +And run [tests with `devenv test`](/tests). +```console +$ devenv test +Running tasks devenv:enterShell +Succeeded devenv:pre-commit:install 10ms +Succeeded devenv:enterShell 4ms +2 Succeeded 14.75ms +• Testing ... +Running tasks devenv:enterTest +Succeeded devenv:pre-commit:run 474ms +Not implemented devenv:enterTest +1 Skipped, 1 Succeeded 474.62ms +``` + + ## Automatic shell switching with direnv Install [nix-direnv](https://github.com/nix-community/nix-direnv) for direnv to work with flakes. diff --git a/src/devenv-devShell.nix b/src/devenv-devShell.nix index 2be3a85bc..4e0b791b9 100644 --- a/src/devenv-devShell.nix +++ b/src/devenv-devShell.nix @@ -27,9 +27,16 @@ pkgs.writeScriptBin "devenv" '' exec $procfilescript "$@" fi ;; + + test) + testscript=$(nix build '.#${shellPrefix (config._module.args.name or "default")}devenv-test' --no-link --print-out-paths --no-pure-eval) + exec $testscript "$@" + ;; + version) echo "devenv: ${version}" ;; + *) echo "https://devenv.sh (version ${version}): Fast, Declarative, Reproducible, and Composable Developer Environments" echo @@ -39,6 +46,7 @@ pkgs.writeScriptBin "devenv" '' echo echo "Commands:" echo + echo "test Runs tests" echo "up Starts processes in foreground. See http://devenv.sh/processes" echo "version Display devenv version" echo