feat(dev-env): backport matured dev-env implementation from /etc/nixos
Replace the stub dev-env with the real, working implementation that grew
in the reference machine config — de-identified for the public scaffold.
Nix layer:
- options.nix: full project schema (url/upstream/fork/category/
worktreeRoot/worktrees{branch,path,remote}/isClone/deployFlakeInput),
deploy.targets, github.forkUser, writeDirenvHints. Drops the
forgejo-URL block + deploy-flake auto-derivation (incoherent in a
scaffold that uses explicit per-project urls).
- lib.nix: mkProject + worktreePath/bareRepoPath/projectRemotes,
generalized to the explicit-url model (origin falls back to upstream).
- config.nix: renders /etc/dev-env/{config.sh,projects.json,
tmux-sessions.json}, installs helpers via writeShellScriptBin, loads
shell functions into interactive shells, wires the git pre-commit hook.
Scripts (config-driven, read /etc/dev-env at runtime):
- bootstrap.sh, nav.sh, worktree.sh, pr-helpers.sh, rebase.sh,
status.sh, deploy.sh, regtest.sh, tmux-launch.sh.
- Stripped aiolabs/forgejo/bitspire/lamassu/webapp hardcoding; the
github-fork remote is renamed 'fork' to match git.remotes vocabulary.
- Removes the dev.sh stub (the matured impl uses discrete commands +
shell functions, not a unified 'dev' CLI).
presets/example.nix: a worked, generic project list replacing the
identity-specific aiolabs preset. tests/smoke.nix + flake checks
exercise the schema; 'nix flake check' is green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
773632562e
commit
e38d313db2
17 changed files with 2925 additions and 147 deletions
104
modules/dev-env/presets/example.nix
Normal file
104
modules/dev-env/presets/example.nix
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
# Example dev-env preset — a worked, generic project list.
|
||||
#
|
||||
# Importing this file is opt-in and illustrative. Copy it, rename it,
|
||||
# and edit the URLs / worktrees / targets for your own stack. The
|
||||
# dev-env module ships **no** projects by default — you declare them
|
||||
# either here or inline in your host config.
|
||||
#
|
||||
# Wire it up in configuration.nix:
|
||||
#
|
||||
# imports = [
|
||||
# ./modules/dev-env
|
||||
# ./modules/dev-env/presets/example.nix
|
||||
# ];
|
||||
#
|
||||
# Then `nixos-rebuild switch` and `dev-env-bootstrap` to materialize the
|
||||
# bare repos + worktrees on disk.
|
||||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
# `mk` cuts boilerplate: derives the `fork` remote from
|
||||
# github.forkUser, defaults worktreeRoot to the project name, etc.
|
||||
mk = config.lnbits-sensei.devEnv.lib.mkProject;
|
||||
in
|
||||
{
|
||||
lnbits-sensei.devEnv = {
|
||||
# Personal github username — used to derive `fork` remotes for any
|
||||
# project that declares an upstream. Leave null if you never send
|
||||
# upstream PRs.
|
||||
github.forkUser = lib.mkDefault "octocat";
|
||||
|
||||
# Hostname → SSH target map for `dev-deploy`. Empty by default.
|
||||
deploy.targets = lib.mkDefault {
|
||||
# prod = "root@prod-host";
|
||||
# staging = "root@staging-host";
|
||||
};
|
||||
|
||||
projects = {
|
||||
|
||||
# ─── lnbits: your fork, dev + main worktrees tracking upstream ──
|
||||
#
|
||||
# `url` is your origin (your fork on whatever git host you use).
|
||||
# `upstream` adds the lnbits/lnbits remote so the rebase + sync
|
||||
# helpers (lnbits-status, lnbits-sync-dev, rebase) work.
|
||||
lnbits = mk {
|
||||
name = "lnbits";
|
||||
url = "git@github.com:octocat/lnbits.git";
|
||||
upstream = "https://github.com/lnbits/lnbits";
|
||||
deployFlakeInput = "lnbits";
|
||||
worktrees = {
|
||||
dev.branch = "dev";
|
||||
main.branch = "main";
|
||||
};
|
||||
};
|
||||
|
||||
# ─── an LNbits extension, grouped under an `extensions` category ─
|
||||
#
|
||||
# Single clone (one branch checked out at a time). Lands at
|
||||
# ${root}/extensions/myext.
|
||||
myext = mk {
|
||||
name = "myext";
|
||||
category = "extensions";
|
||||
url = "git@github.com:octocat/myext.git";
|
||||
upstream = "https://github.com/lnbits/myext";
|
||||
isClone = true;
|
||||
};
|
||||
|
||||
# ─── a pure-upstream reference checkout (no fork, read-only) ─────
|
||||
#
|
||||
# No `url` → origin falls back to `upstream`. Useful for grepping
|
||||
# a reference codebase alongside your own work.
|
||||
nostr-tools = mk {
|
||||
name = "nostr-tools";
|
||||
category = "refs";
|
||||
upstream = "https://github.com/nbd-wtf/nostr-tools";
|
||||
worktrees.master.branch = "master";
|
||||
};
|
||||
};
|
||||
|
||||
# ─── a declarative tmux session for the lnbits dev loop ───────────
|
||||
tmux = {
|
||||
enable = lib.mkDefault true;
|
||||
sessions.lnbits = {
|
||||
cwd = "lnbits/dev";
|
||||
windows = [
|
||||
{
|
||||
name = "edit";
|
||||
cwd = "lnbits/dev";
|
||||
cmd = "nvim .";
|
||||
}
|
||||
{
|
||||
name = "run";
|
||||
cwd = "lnbits/dev";
|
||||
cmd = null;
|
||||
}
|
||||
{
|
||||
name = "git";
|
||||
cwd = "lnbits/dev";
|
||||
cmd = "lazygit";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in a new issue