forked from cachix/devenv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevenv-devShell.nix
55 lines (48 loc) · 1.7 KB
/
devenv-devShell.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{ config, pkgs }:
let
lib = pkgs.lib;
version = lib.fileContents ./modules/latest-version;
shellPrefix = shellName: if shellName == "default" then "" else "${shellName}-";
in
pkgs.writeScriptBin "devenv" ''
#!/usr/bin/env bash
# we want subshells to fail the program
set -e
NIX_FLAGS="--show-trace --extra-experimental-features nix-command --extra-experimental-features flakes"
command=$1
if [[ ! -z $command ]]; then
shift
fi
case $command in
up)
procfilescript=$(nix build '.#${shellPrefix (config._module.args.name or "default")}devenv-up' --no-link --print-out-paths --override-input devenv-root path:.devenv/state/pwd)
if [ "$(cat $procfilescript|tail -n +2)" = "" ]; then
echo "No 'processes' option defined: https://devenv.sh/processes/"
exit 1
else
exec $procfilescript "$@"
fi
;;
test)
testscript=$(nix build '.#${shellPrefix (config._module.args.name or "default")}devenv-test' --no-link --print-out-paths --override-input devenv-root path:.devenv/state/pwd)
exec $testscript "$@"
;;
version)
echo "devenv: ${version}"
;;
*)
echo "https://devenv.sh (version ${version}): Fast, Declarative, Reproducible, and Composable Developer Environments"
echo
echo "This is a flake integration wrapper that comes with a subset of functionality from the flakeless devenv CLI."
echo
echo "Usage: devenv command"
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
exit 1
esac
''