forked from hercules-ci/devenv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
devenv.nix
103 lines (90 loc) · 2.76 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
{ inputs, pkgs, lib, config, ... }:
{
packages = [
(import ./src/devenv.nix { inherit pkgs; nix = inputs.nix; })
pkgs.python3Packages.virtualenv
pkgs.python3Packages.cairocffi
pkgs.yaml2json
];
languages.python.enable = true;
devcontainer.enable = true;
difftastic.enable = true;
# 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 -r '.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
popd
tmp="$(mktemp -d)"
devenv init "$tmp"
pushd "$tmp"
devenv ci
popd
rm -rf "$tmp"
# Test devenv integrated into Nix flake
tmp="$(mktemp -d)"
pushd "$tmp"
nix flake init --template ''${DEVENV_ROOT}#simple
nix flake update \
--override-input devenv ''${DEVENV_ROOT}
nix develop --command echo nix-develop started succesfully
popd
rm -rf "$tmp"
# TODO: test DIRENV_ACTIVE
'';
scripts.devenv-test-all-examples.exec = ''
for dir in $(ls examples); do
devenv-test-example $dir
done
'';
scripts.devenv-test-example.exec = ''
set -e
pushd examples/$1
devenv ci
devenv shell ls
popd
'';
scripts."devenv-generate-doc-options".exec = ''
set -e
options=$(nix build --extra-experimental-features 'flakes nix-command' --show-trace --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."devenv-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;
};
}