Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add devenv test to flake integration wrapper script #1524

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading