Skip to content

Commit

Permalink
Merge pull request #1524 from adam-gaia/main
Browse files Browse the repository at this point in the history
Add `devenv test` to flake integration wrapper script
  • Loading branch information
domenkozar authored Oct 17, 2024
2 parents f75f4e7 + 1c838f4 commit 7afa57b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/guides/using-with-flakes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions src/devenv-devShell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 7afa57b

Please sign in to comment.