/
devenv.nix
82 lines (73 loc) · 2.3 KB
/
devenv.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
{ pkgs, nix, lib, config, ... }:
{
packages = [
(import ./src/devenv.nix { inherit pkgs nix; })
pkgs.python3Packages.virtualenv
pkgs.python3Packages.cairocffi
pkgs.yaml2json
];
# bin/mkdocs serve --config-file mkdocs.insiders.yml
processes.docs.exec = "bin/mkdocs serve";
processes.build.exec = "${pkgs.watchexec}/bin/watchexec -e nix nix build";
enterShell = ''
echo "To Install:"
echo
echo "virtualenv ."
echo "bin/pip install -r requirements.txt"
'';
scripts.devenv-bump-version.exec = ''
# TODO: ask for the new version
# TODO: update the version in the mkdocs.yml
echo assuming you bumped the version in mkdocs.yml, populating src/modules/latest-version
cat mkdocs.yml | yaml2json | jq '.extra.devenv.version' > src/modules/latest-version
'';
scripts.devenv-run-tests.exec = ''
set -xe
pushd examples/simple
# this should fail since files already exist
devenv init && exit 1
rm devenv.nix devenv.yaml .envrc
devenv init
popd
# TODO: test direnv integration
# TODO: test DIRENV_ACTIVE
'';
scripts.devenv-test-all-examples.exec = ''
for dir in $(ls examples); do
devenv-run-example-test $dir
done
'';
scripts.devenv-test-example.exec = ''
pushd examples/$1
devenv ci
devenv shell ls
popd
'';
scripts."generate-doc-options".exec = ''
options=$(nix build --extra-experimental-features 'flakes nix-command' --print-out-paths --no-link '.#devenv-docs-options')
echo "# devenv.nix options" > docs/reference/options.md
echo >> docs/reference/options.md
cat $options >> docs/reference/options.md
'';
scripts."generate-languages-example".exec = ''
cat > examples/supported-languages/devenv.nix <<EOF
{ pkgs, ... }: {
# Enable all languages tooling!
${lib.concatStringsSep "\n " (map (lang: "languages.${lang}.enable = true;") (builtins.attrNames config.languages))}
# If you're missing a language, please contribute it by following examples of other languages <3
}
EOF
'';
pre-commit.hooks = {
nixpkgs-fmt.enable = true;
shellcheck.enable = true;
#markdownlint.enable = true;
};
pre-commit.settings.markdownlint.config = {
MD013 = {
line_length = 120;
};
MD033 = false;
MD034 = false;
};
}