You've already forked tribes-plugin-aether
forked from tribes/tribes-plugin-template
feat: support Guix development shell
Add a repo-local Guix manifest, direnv backend selection, and PATH-based hook configuration for the Aether plugin development environment.
This commit is contained in:
@@ -2,11 +2,65 @@
|
||||
|
||||
export DIRENV_WARN_TIMEOUT=20s
|
||||
|
||||
eval "$(devenv direnvrc)"
|
||||
# Backend selection:
|
||||
# - default: use devenv when available, otherwise Guix
|
||||
# - optional local override: write "guix" or "devenv" to .dev-shell
|
||||
backend=auto
|
||||
if [ -f .dev-shell ]; then
|
||||
backend=$(tr -d '[:space:]' < .dev-shell)
|
||||
watch_file .dev-shell
|
||||
fi
|
||||
|
||||
# `use devenv` supports the same options as the `devenv shell` command.
|
||||
#
|
||||
# To silence all output, use `--quiet`.
|
||||
#
|
||||
# Example usage: use devenv --quiet --impure --option services.postgres.enable:bool true
|
||||
use devenv
|
||||
use_aether_guix() {
|
||||
watch_file guix-dev.scm
|
||||
watch_file .pre-commit-config.yaml
|
||||
watch_file scripts/plugin
|
||||
watch_file "$HOME/guix-tribes/tribes/packages/devtools.scm"
|
||||
watch_file "$HOME/guix-tribes/tribes/packages/node.scm"
|
||||
|
||||
use guix -L "$HOME/guix-tribes" -m guix-dev.scm
|
||||
|
||||
if [ -f .env ]; then set -a; . ./.env; set +a; fi
|
||||
export MIX_OS_DEPS_COMPILE_PARTITION_COUNT=8
|
||||
export NODE_ENV=development
|
||||
export NPM_CONFIG_MIN_RELEASE_AGE=7
|
||||
export TRIBES_HOST_ROOT="${TRIBES_HOST_ROOT:-$PWD/../tribes}"
|
||||
|
||||
plugin() { bash "$PWD/scripts/plugin" "$@"; }
|
||||
}
|
||||
|
||||
use_aether_devenv() {
|
||||
eval "$(devenv direnvrc)"
|
||||
use devenv
|
||||
}
|
||||
|
||||
case "$backend" in
|
||||
auto)
|
||||
if command -v devenv >/dev/null 2>&1; then
|
||||
use_aether_devenv
|
||||
elif command -v guix >/dev/null 2>&1; then
|
||||
use_aether_guix
|
||||
else
|
||||
log_error "neither devenv nor guix is available"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
nix|devenv)
|
||||
if ! command -v devenv >/dev/null 2>&1; then
|
||||
log_error ".dev-shell requested devenv, but devenv is unavailable"
|
||||
exit 1
|
||||
fi
|
||||
use_aether_devenv
|
||||
;;
|
||||
guix)
|
||||
if ! command -v guix >/dev/null 2>&1; then
|
||||
log_error ".dev-shell requested guix, but guix is unavailable"
|
||||
exit 1
|
||||
fi
|
||||
use_aether_guix
|
||||
;;
|
||||
*)
|
||||
log_error "unknown .dev-shell backend: $backend"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
+2
-3
@@ -39,9 +39,8 @@ Thumbs.db
|
||||
.env
|
||||
.null-ls_*.nix
|
||||
devenv.local.nix
|
||||
.guix-dev/
|
||||
.dev-shell
|
||||
|
||||
# direnv
|
||||
.direnv
|
||||
|
||||
# pre-commit
|
||||
.pre-commit-config.yaml
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# Shared by Nix/devenv and Guix shells. Keep hook entries PATH-based.
|
||||
default_stages:
|
||||
- pre-commit
|
||||
|
||||
repos:
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: check-added-large-files
|
||||
name: check added large files
|
||||
entry: scripts/hooks/check-added-large-files
|
||||
args: ["--maxkb=131072"]
|
||||
language: system
|
||||
types: [file]
|
||||
stages: [pre-commit, pre-push, manual]
|
||||
|
||||
- id: mix-format
|
||||
name: mix format
|
||||
entry: mix format
|
||||
language: system
|
||||
files: '\.(ex|exs|heex)$'
|
||||
types: [file]
|
||||
stages: [pre-commit]
|
||||
|
||||
- id: prettier
|
||||
name: prettier
|
||||
entry: prettier
|
||||
args:
|
||||
- --ignore-unknown
|
||||
- --list-different
|
||||
- --write
|
||||
language: system
|
||||
files: '\.(js|ts|tsx|css)$'
|
||||
types: [text]
|
||||
stages: [pre-commit]
|
||||
@@ -0,0 +1,39 @@
|
||||
;; Guix development manifest for the Aether plugin.
|
||||
;;
|
||||
;; Usage:
|
||||
;; guix shell -L ~/guix-tribes -m guix-dev.scm
|
||||
;;
|
||||
;; This intentionally keeps the repo-specific development package list here,
|
||||
;; similar to devenv.nix. Shared custom packages such as node-24, prek, and
|
||||
;; prettier come from the local guix-tribes channel.
|
||||
|
||||
(use-modules (gnu packages bash)
|
||||
(gnu packages base)
|
||||
(gnu packages elixir)
|
||||
(gnu packages erlang)
|
||||
(gnu packages gnome)
|
||||
(gnu packages linux)
|
||||
(gnu packages nss)
|
||||
(gnu packages version-control)
|
||||
(guix profiles)
|
||||
(tribes packages devtools)
|
||||
((tribes packages node) #:select (node-24)))
|
||||
|
||||
(packages->manifest
|
||||
(list bash
|
||||
coreutils
|
||||
findutils
|
||||
grep
|
||||
sed
|
||||
nss-certs
|
||||
git
|
||||
pre-commit
|
||||
prek
|
||||
prettier
|
||||
erlang
|
||||
elixir
|
||||
elixir-hex
|
||||
rebar3
|
||||
node-24
|
||||
libnotify
|
||||
inotify-tools))
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env sh
|
||||
set -eu
|
||||
|
||||
maxkb=500
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--maxkb=*)
|
||||
maxkb=${1#--maxkb=}
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-*)
|
||||
echo "check-added-large-files: unknown option: $1" >&2
|
||||
exit 2
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
limit=$((maxkb * 1024))
|
||||
failed=0
|
||||
|
||||
for file in "$@"; do
|
||||
[ -f "$file" ] || continue
|
||||
size=$(wc -c < "$file" | tr -d '[:space:]')
|
||||
if [ "$size" -gt "$limit" ]; then
|
||||
kb=$(((size + 1023) / 1024))
|
||||
echo "$file (${kb} KB) exceeds ${maxkb} KB" >&2
|
||||
failed=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit "$failed"
|
||||
Reference in New Issue
Block a user