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 Terraform Nix template #1

Closed
wants to merge 62 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
9de5bd8
Support unfree attribute in devenv.yaml
domenkozar Feb 8, 2023
17111e2
Allow wiring up overlays
domenkozar Feb 9, 2023
4430eb1
add an example for overlays
domenkozar Feb 9, 2023
b0f22d7
Validate devenv.yaml schema and move overlays to inputs
domenkozar Feb 9, 2023
eb7eb2c
raku.nix: fixed description to not break web documentation
theesm Feb 8, 2023
3a86f30
Auto generate docs/reference/options.md
github-actions[bot] Feb 8, 2023
00c8dc4
add devenv specific direnv integration
domenkozar Feb 10, 2023
b6fdef5
use devenv-direnv
domenkozar Feb 10, 2023
a0e1ad3
write down also the imports as CSV
domenkozar Feb 11, 2023
e5dd4d8
Update direnvrc
domenkozar Feb 12, 2023
785f6c7
Update src/devenv-yaml.nix
domenkozar Feb 13, 2023
55d1428
Added mkcert as integration
Feb 13, 2023
c71c96c
correct hostctl integration
Feb 13, 2023
f9fe71f
added a complete mkcert example
Feb 13, 2023
78d20ff
added a fallback for the hostctl hosts option
Feb 13, 2023
a01eca8
Update src/devenv-yaml.nix
domenkozar Feb 14, 2023
580d2c2
revert hostctl config changes
Feb 14, 2023
d93bcc3
rename certificates option
Feb 14, 2023
9980067
remove wildcard from example
Feb 14, 2023
670b983
Add wildcard domain to option example
jochenmanz Feb 15, 2023
9845109
feat: Add Ansible support
sestrella Feb 23, 2023
eb66af8
Merge pull request #432 from stackbuilders/add_ansible_support
domenkozar Feb 24, 2023
1aa3dbb
Auto generate docs/reference/options.md
github-actions[bot] Feb 24, 2023
cbff56d
feat(go): use correct go version for tools
shyim Feb 25, 2023
c19bec5
Merge pull request #437 from shyim/patch-3
domenkozar Feb 26, 2023
d0c5490
chore(deps): bump cachix/install-nix-action from 18 to 19
dependabot[bot] Feb 27, 2023
9684443
Merge pull request #438 from cachix/dependabot/github_actions/cachix/…
domenkozar Feb 27, 2023
9698a12
Update src/devenv-yaml.nix
domenkozar Feb 28, 2023
332ea80
Merge pull request #406 from jochenmanz/feature/mkcert-basics
domenkozar Feb 28, 2023
5c1daec
Auto generate docs/reference/options.md
github-actions[bot] Feb 28, 2023
1b7ea64
Merge pull request #383 from cachix/unfree-and-overlays
domenkozar Feb 28, 2023
ecbbfd1
Merge pull request #387 from cachix/devenv-direnv
domenkozar Feb 28, 2023
ae8f940
docs/github-actions: use devenv version 0.5.1
bobvanderlinden Mar 1, 2023
252f996
Merge pull request #443 from bobvanderlinden/patch-2
domenkozar Mar 1, 2023
61250a0
chore(deps): bump cachix/install-nix-action from 19 to 20
dependabot[bot] Mar 2, 2023
8454b85
Merge pull request #446 from cachix/dependabot/github_actions/cachix/…
sandydoo Mar 2, 2023
ac80069
ignore documentation warnings for now
domenkozar Feb 22, 2023
43442e5
Make it easy to create containers out of the environment.
domenkozar Feb 11, 2023
a8cfd5a
format
domenkozar Feb 28, 2023
983f9b6
Update docs/containers.md
domenkozar Mar 2, 2023
42773ac
Auto generate docs/reference/options.md
github-actions[bot] Mar 2, 2023
8c824ea
bump direnv integration
domenkozar Mar 2, 2023
50606d4
fix --help
domenkozar Mar 2, 2023
68e8b87
fix link
domenkozar Mar 2, 2023
784e68a
Auto generate docs/reference/options.md
github-actions[bot] Mar 2, 2023
90007a9
v0.6 release post
domenkozar Feb 28, 2023
2cae5ec
v0.6
domenkozar Mar 2, 2023
25196b5
Auto generate docs/reference/options.md
github-actions[bot] Mar 2, 2023
ab2222f
v0.6 post: rename subsection
domenkozar Mar 2, 2023
7976b7a
Auto generate docs/reference/options.md
github-actions[bot] Mar 2, 2023
6fa448d
Fix indentation in the devenv script
madjar Mar 2, 2023
1707e89
Merge pull request #448 from madjar/main
domenkozar Mar 2, 2023
8489b4d
Auto generate docs/reference/options.md
github-actions[bot] Mar 2, 2023
8f7ea93
Enable the escapeall pymdown extension
sandydoo Feb 6, 2023
7b84c36
Fix links to source in reference docs
sandydoo Mar 2, 2023
ef6d9ef
Ignore .direnv folder for cached builds
thenonameguy Mar 2, 2023
2660787
Remove override from process-compose config as it's not supported
thenonameguy Mar 2, 2023
36d4851
Merge pull request #454 from thenonameguy/fix/process-compose-yaml
domenkozar Mar 3, 2023
268070c
Merge pull request #451 from cachix/fix-reference-docs
domenkozar Mar 3, 2023
93796e5
Auto generate docs/reference/options.md
github-actions[bot] Mar 3, 2023
dbb6788
Add terraform template
sestrella Mar 3, 2023
f206e2f
Add template to flake.nix
sestrella Mar 3, 2023
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
13 changes: 6 additions & 7 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
watch_file devenv.nix
watch_file devenv.yaml
watch_file devenv.lock
watch_file result/bin/devenv
watch_dir src
nix-build
eval "$(./result/bin/devenv print-dev-env)"
source_url "https://raw.githubusercontent.com/cachix/devenv/5811f4817ba24da923506d134fff2610b8f95ff2/direnvrc" "sha256-IN2rc7pbaBxxjcdIpYOe9lkpiyjSr2V2AwF6KwlnWYQ="

# use our own last built devenv/nix in CLI
PATH_add result/bin

use devenv
6 changes: 3 additions & 3 deletions .github/workflows/buildtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v19
- uses: cachix/install-nix-action@v20
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v19
- uses: cachix/install-nix-action@v20
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v19
- uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v12
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v18
- uses: cachix/install-nix-action@v20
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ result
/include
/lib
pyvenv.cfg
/.direnv
12 changes: 6 additions & 6 deletions devenv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1676549890,
"narHash": "sha256-sq/WcOEAl7gWrrfGkWdnyYazRyTf+enEim/o6LOQzI8=",
"lastModified": 1677534593,
"narHash": "sha256-PuZSAHeq4/9pP/uYH1FcagQ3nLm/DrDrvKi/xC9glvw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "8c66bd1b68f4708c90dcc97c6f7052a5a7b33257",
"rev": "3ad64d9e2d5bf80c877286102355b1625891ae9a",
"type": "github"
},
"original": {
Expand Down Expand Up @@ -161,11 +161,11 @@
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1676513100,
"narHash": "sha256-MK39nQV86L2ag4TmcK5/+r1ULpzRLPbbfvWbPvIoYJE=",
"lastModified": 1677160285,
"narHash": "sha256-tBzpCjMP+P3Y3nKLYvdBkXBg3KvTMo3gvi8tLQaqXVY=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "5f0cba88ac4d6dd8cad5c6f6f1540b3d6a21a798",
"rev": "2bd861ab81469428d9c823ef72c4bb08372dd2c4",
"type": "github"
},
"original": {
Expand Down
7 changes: 4 additions & 3 deletions devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@
];

languages.python.enable = true;
languages.python.venv.enable = true;

devcontainer.enable = true;
difftastic.enable = true;

# bin/mkdocs serve --config-file mkdocs.insiders.yml
processes.docs.exec = "bin/mkdocs serve";
processes.docs.exec = "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"
echo " $ pip install -r requirements.txt"
echo
'';

scripts.devenv-bump-version.exec = ''
Expand Down
2 changes: 1 addition & 1 deletion devenv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ inputs:
url: github:cachix/pre-commit-hooks.nix
inputs:
nixpkgs:
follows: "nixpkgs"
follows: "nixpkgs"
154 changes: 154 additions & 0 deletions direnvrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# shellcheck shell=bash
# adapted from https://github.com/nix-community/nix-direnv/blob/master/direnvrc

REQUIRED_DIRENV_VERSION="2.21.3"

_nix_direnv_preflight () {
if [[ -z "$direnv" ]]; then
printf '%s\n' "\$direnv environment variable was not defined. Was this script run inside direnv?"
exit 1
fi

if [[ -z ${DEVENV_BIN:-} ]]; then
DEVENV_BIN=$(command -v devenv)
if [[ -z "${DEVENV_BIN}" ]]; then
log_status "command not found: devenv, see https://devenv.sh/getting-started/"
exit 1
fi
fi

if ! has direnv_version || ! direnv_version "$REQUIRED_DIRENV_VERSION" 2>/dev/null; then
log_status "base direnv version is older than the required v$REQUIRED_DIRENV_VERSION."
exit 1
fi

local layout_dir
layout_dir=$(direnv_layout_dir)

if [[ ! -d "$layout_dir" ]]; then
mkdir -p "$layout_dir"
fi
}

_nix_export_or_unset() {
local key=$1 value=$2
if [[ "$value" == __UNSET__ ]]; then
unset "$key"
else
export "$key=$value"
fi
}

_nix_import_env() {
local profile_rc=$1

local old_nix_build_top=${NIX_BUILD_TOP:-__UNSET__}
local old_tmp=${TMP:-__UNSET__}
local old_tmpdir=${TMPDIR:-__UNSET__}
local old_temp=${TEMP:-__UNSET__}
local old_tempdir=${TEMPDIR:-__UNSET__}
local old_xdg_data_dirs=${XDG_DATA_DIRS:-}
eval "$(< "$profile_rc")"
# `nix print-dev-env` will create a temporary directory and use it as TMPDIR
# We cannot rely on this directory being availble at all times,
# as it may be garbage collected.
# Instead - just remove it immediately.
# Use recursive & force as it may not be empty.
if [[ -n "${NIX_BUILD_TOP+x}" && "$NIX_BUILD_TOP" == */nix-shell.* && -d "$NIX_BUILD_TOP" ]]; then
rm -rf "$NIX_BUILD_TOP"
fi

_nix_export_or_unset NIX_BUILD_TOP "$old_nix_build_top"
_nix_export_or_unset TMP "$old_tmp"
_nix_export_or_unset TMPDIR "$old_tmpdir"
_nix_export_or_unset TEMP "$old_temp"
_nix_export_or_unset TEMPDIR "$old_tempdir"
local new_xdg_data_dirs=${XDG_DATA_DIRS:-}
export XDG_DATA_DIRS=
local IFS=:
for dir in $new_xdg_data_dirs${old_xdg_data_dirs:+:}$old_xdg_data_dirs; do
dir="${dir%/}" # remove trailing slashes
if [[ :$XDG_DATA_DIRS: = *:$dir:* ]]; then
continue # already present, skip
fi
XDG_DATA_DIRS="$XDG_DATA_DIRS${XDG_DATA_DIRS:+:}$dir"
done
}

_nix_argsum_suffix() {
local out checksum content

content=$(cat "$@" 2>/dev/null)

if has sha1sum; then
out=$(sha1sum <<< "$content")
elif has shasum; then
out=$(shasum <<< "$content")
else
log_status "not hashing your cache, please install sha1sum"
# degrate gracefully both tools are not present
return
fi
read -r checksum _ <<< "$out"
echo "-$checksum"
}

nix_direnv_watch_file() {
watch_file "$@"
nix_watches+=("$@")
}

use_devenv() {
_nix_direnv_preflight

flake_expr="${1:-.}"
flake_dir="${flake_expr%#*}"

local files_to_watch
files_to_watch=(".envrc" "$HOME/.direnvrc" "$HOME/.config/direnv/direnvrc")

if [[ -d "$flake_dir" ]]; then
files_to_watch+=("$flake_dir/devenv.nix" "$flake_dir/devenv.lock" "$flake_dir/devenv.yaml" "$flake_dir/devenv.local.nix")
if [[ -f "$flake_dir/devenv.yaml" ]]; then
if ! devenv assemble; then
log_status "$(devenv version) failed to parse devenv.yaml, make sure to use version 0.6 or newer and fix the errors above."
exit 1
fi

if [[ -f "$flake_dir/.devenv/imports.txt" ]]; then
for file in $(cat "$flake_dir/.devenv/imports.txt"); do
files_to_watch+=("$file")
done
fi
fi
fi

nix_direnv_watch_file "${files_to_watch[@]}"

local layout_dir profile_rc
layout_dir=$(direnv_layout_dir)
profile_rc="${layout_dir}/devenv-profile$(_nix_argsum_suffix "${files_to_watch[@]}").rc"

local need_update=0
local file=
for file in "${nix_watches[@]}"; do
if [[ "$file" -nt "$profile_rc" ]]; then
need_update=1
log_status "$file changed, reloading"
break
fi
done

if [[ ! -e "$profile_rc" || "$need_update" == "1" ]];
then
# We need to update our cache
local tmp_profile_rc
tmp_profile_rc=$("${DEVENV_BIN}" print-dev-env)
echo "$tmp_profile_rc" > "$profile_rc"
log_status "updated devenv shell cache"
else
log_status "using cached devenv shell"
fi

_nix_import_env "$profile_rc"
}
Loading