Compare commits
24
Commits
No files matched your search
@@ -4,6 +4,11 @@ on:
|
||||
push:
|
||||
branches: [master]
|
||||
|
||||
# Only the newest commit is worth building and caching
|
||||
concurrency:
|
||||
group: ci
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Check, build and cache nixfiles
|
||||
@@ -47,31 +52,6 @@ jobs:
|
||||
env:
|
||||
HARMONIA_SSH_KEY: ${{ secrets.HARMONIA_SSH_KEY }}
|
||||
CI_IFD_REQUIRED: ${{ steps.ifd.outputs.required }}
|
||||
run: |
|
||||
set -o pipefail
|
||||
nix_options=(--option allow-import-from-derivation "$CI_IFD_REQUIRED")
|
||||
|
||||
echo "::group::Collect cache garbage"
|
||||
ci/push-to-cache.sh --gc
|
||||
echo "::endgroup::"
|
||||
|
||||
nix eval "${nix_options[@]}" --json --apply "builtins.attrNames" .#ci.x86_64-linux | jq -cr '.[]' | while read job; do
|
||||
echo "::group::Build $job"
|
||||
nix build "${nix_options[@]}" --no-link .#ci.x86_64-linux."$job"
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Cache $job"
|
||||
ci/push-to-cache.sh "$(nix eval "${nix_options[@]}" --raw .#ci.x86_64-linux."$job")"
|
||||
echo "::endgroup::"
|
||||
done
|
||||
|
||||
if [[ "$CI_IFD_REQUIRED" == true ]]; then
|
||||
echo "::group::Check flake"
|
||||
# The target closures are available for the evaluation-time reference graphs.
|
||||
nix flake check "${nix_options[@]}"
|
||||
echo "::endgroup::"
|
||||
fi
|
||||
|
||||
echo "Building and caching CI derivation"
|
||||
nix build "${nix_options[@]}" --no-link .#ciDrv.x86_64-linux
|
||||
UPDATE_PROFILE=1 ci/push-to-cache.sh "$(nix eval "${nix_options[@]}" --raw .#ciDrv.x86_64-linux)"
|
||||
run: >-
|
||||
nix shell .#nixpkgs.unstable.x86_64-linux.python3 .#nixpkgs.unstable.x86_64-linux.nix-eval-jobs
|
||||
--command python3 ci/build-and-cache.py
|
||||
@@ -0,0 +1,47 @@
|
||||
name: Build llm-agents
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [master]
|
||||
types: [opened, synchronize, reopened]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# Only the update branch, whether dispatched by the updater or pushed by hand
|
||||
if: >-
|
||||
(github.event_name == 'workflow_dispatch' &&
|
||||
github.ref == 'refs/heads/automation/llm-agents') ||
|
||||
(github.event.pull_request.head.repo.full_name == github.repository &&
|
||||
github.event.pull_request.head.ref == 'automation/llm-agents')
|
||||
|
||||
runs-on: ubuntu-26.04
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- uses: DeterminateSystems/determinate-nix-action@v3
|
||||
with:
|
||||
github-token: ${{ secrets.GH_PULL_TOKEN }}
|
||||
extra-conf: |
|
||||
sandbox-fallback = false
|
||||
|
||||
lazy-trees = true
|
||||
eval-cores = 0
|
||||
|
||||
- name: Build installed agent packages
|
||||
shell: bash
|
||||
run: |
|
||||
attrs="$(nix eval --accept-flake-config --no-update-lock-file --raw \
|
||||
.#llmAgentPackages.x86_64-linux \
|
||||
--apply 'packages: builtins.concatStringsSep "\n" (builtins.attrNames packages)')"
|
||||
|
||||
if [[ -n "$attrs" ]]; then
|
||||
mapfile -t packages <<< "$attrs"
|
||||
nix build --accept-flake-config --no-update-lock-file --no-link \
|
||||
"${packages[@]/#/.#llmAgentPackages.x86_64-linux.}"
|
||||
fi
|
||||
@@ -0,0 +1,36 @@
|
||||
name: Update llm-agents
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '19 */4 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: update-llm-agents
|
||||
|
||||
jobs:
|
||||
update:
|
||||
if: github.ref == 'refs/heads/master'
|
||||
|
||||
runs-on: ubuntu-26.04
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
actions: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
ref: master
|
||||
persist-credentials: false
|
||||
|
||||
- uses: DeterminateSystems/determinate-nix-action@v3
|
||||
with:
|
||||
github-token: ${{ secrets.GH_PULL_TOKEN }}
|
||||
|
||||
- name: Update the dependency PR
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: >-
|
||||
nix shell --accept-flake-config .#nixpkgs.unstable.x86_64-linux.python3
|
||||
--command python3 ci/update-llm-agents.py
|
||||
@@ -5,4 +5,5 @@ result*
|
||||
!/.vms/.gitkeep
|
||||
/.keys/*.key
|
||||
*.swp
|
||||
__pycache__/
|
||||
/.claude/settings.local.json
|
||||
@@ -191,8 +191,10 @@ These APs are not managed by the flake; only their DNS records are. Read and upd
|
||||
## Working from `slop-cannon`
|
||||
|
||||
Agents on `slop-cannon` have no deploy or SSH keys, so `deploy` and `ssh-machine` don't work there.
|
||||
Use `slop` instead; `slop guide` explains it. Requests that need approval can wait up to five
|
||||
minutes for a human. See [`docs/slop-broker.md`](docs/slop-broker.md).
|
||||
Use `slop` instead; `slop guide` explains it. Run requests that need approval in the background
|
||||
or give the tool enough time for the [approval window](docs/slop-broker.md#approval-timeout).
|
||||
If a request expires and the task still depends on it, tell the user what is blocked and pause
|
||||
for their direction. Continue any independent work you can do under the existing approvals.
|
||||
|
||||
- `slop status`, `slop logs` and `slop failed` look at a box without waiting for approval.
|
||||
- `slop ssh <node> -- <cmd>` runs anything else. Nodes are the deploy-rs nodes on `master`;
|
||||
@@ -273,6 +275,10 @@ in churn.
|
||||
|
||||
## Documentation
|
||||
|
||||
**Work in progress goes in Gitea issues** on `dev/nixfiles`, not in `docs/` or in files on
|
||||
branches: plans, status, next steps and handoffs for a piece of work, one issue each, with its
|
||||
description kept current. When the work is done, move what lasts into `docs/` and close the issue.
|
||||
|
||||
Human-readable docs live under `docs/` (index: `docs/README.md`). Box pages are under
|
||||
`docs/sites/<site>/`, `docs/remote/`, `docs/mobile/`. A box that itself hosts sub-systems
|
||||
(containers/nested VMs) gets a **directory named for it** with a `README.md` and the child pages
|
||||
|
||||
Executable
+158
@@ -0,0 +1,158 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Evaluate, build and cache every attribute of `.#ci.<system>`.
|
||||
|
||||
Then point the cache's `nixfiles` profile at a link farm of the results.
|
||||
CI_IFD_REQUIRED=true allows import from derivation and runs the flake check
|
||||
after the builds, when the evaluation-time reference graphs are available.
|
||||
Expects `nix-eval-jobs` on PATH.
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from contextlib import contextmanager
|
||||
from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
|
||||
SYSTEM = "x86_64-linux"
|
||||
PUSH = "ci/push-to-cache.sh"
|
||||
|
||||
# Every evaluation worker first pays for a shared evaluation of the flake (a
|
||||
# few GiB), so keep workers alive for several jobs. workers * memory is the
|
||||
# evaluation budget; it must leave room on the runner for Gitea and for builds
|
||||
# started by import from derivation.
|
||||
EVAL_WORKERS = os.environ.get("CI_EVAL_WORKERS", "4")
|
||||
EVAL_WORKER_MEMORY = os.environ.get("CI_EVAL_WORKER_MEMORY", "6144")
|
||||
|
||||
ANSI_ESCAPE = re.compile(r"\x1b\[[0-9;]*m")
|
||||
|
||||
|
||||
@contextmanager
|
||||
def group(title: str):
|
||||
print(f"::group::{title}")
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
print("::endgroup::")
|
||||
|
||||
|
||||
def annotate_error(title: str, message: str):
|
||||
# Workflow commands are single lines, so escape multi-line messages
|
||||
message = ANSI_ESCAPE.sub("", message)
|
||||
for char, escape in (("%", "%25"), ("\r", "%0D"), ("\n", "%0A")):
|
||||
message = message.replace(char, escape)
|
||||
|
||||
print(f"::error title={title}::{message}")
|
||||
|
||||
|
||||
def succeeds(*command: str) -> bool:
|
||||
return subprocess.run(command).returncode == 0
|
||||
|
||||
|
||||
def evaluate(nix_options: list[str], work: Path) -> tuple[bool, list[dict]]:
|
||||
"""Evaluate every CI job, returning whether all of them evaluated."""
|
||||
result = subprocess.run(
|
||||
[
|
||||
"nix-eval-jobs", *nix_options,
|
||||
"--workers", EVAL_WORKERS, "--max-memory-size", EVAL_WORKER_MEMORY,
|
||||
"--gc-roots-dir", str(work / "gc-roots"),
|
||||
"--flake", f".#ci.{SYSTEM}",
|
||||
],
|
||||
stdout=subprocess.PIPE,
|
||||
text=True,
|
||||
)
|
||||
jobs = [json.loads(line) for line in result.stdout.splitlines() if line]
|
||||
|
||||
ok = result.returncode == 0
|
||||
for job in jobs:
|
||||
if "error" in job:
|
||||
annotate_error(f"Evaluation of {job['attrPath'][0]} failed", job["error"])
|
||||
ok = False
|
||||
|
||||
return ok, [job for job in jobs if "error" not in job]
|
||||
|
||||
|
||||
def build(jobs: list[dict]) -> tuple[bool, dict[str, str]]:
|
||||
"""Build the jobs' outputs, returning whether all built and the built ones by job."""
|
||||
ok = succeeds(
|
||||
"nix", "build", "--keep-going", "--no-link",
|
||||
*(f"{job['drvPath']}^out" for job in jobs),
|
||||
)
|
||||
|
||||
built = {}
|
||||
for job in jobs:
|
||||
name = job["attrPath"][0]
|
||||
path = job["outputs"]["out"]
|
||||
if succeeds("nix-store", "--check-validity", path):
|
||||
built[name] = path
|
||||
else:
|
||||
annotate_error(f"Build of {name} failed", "See the build log above.")
|
||||
ok = False
|
||||
|
||||
return ok, built
|
||||
|
||||
|
||||
def link_farm(outputs: dict[str, str], work: Path) -> str:
|
||||
"""Build a link farm of the outputs from their paths, without evaluating them again."""
|
||||
outputs_file = work / "outputs.json"
|
||||
outputs_file.write_text(json.dumps(outputs))
|
||||
|
||||
drv = subprocess.check_output(
|
||||
[
|
||||
"nix", "eval", "--impure", "--raw", f".#nixpkgs.unstable.{SYSTEM}",
|
||||
"--apply",
|
||||
f"""pkgs: (pkgs.linkFarm "ci" (builtins.mapAttrs (_: builtins.storePath)
|
||||
(builtins.fromJSON (builtins.readFile {json.dumps(str(outputs_file))})))).drvPath""",
|
||||
],
|
||||
text=True,
|
||||
)
|
||||
|
||||
return subprocess.check_output(
|
||||
["nix", "build", "--no-link", "--print-out-paths", f"{drv}^out"],
|
||||
text=True,
|
||||
).strip()
|
||||
|
||||
|
||||
def main():
|
||||
allow_ifd = os.environ.get("CI_IFD_REQUIRED", "false") == "true"
|
||||
nix_options = ["--option", "allow-import-from-derivation", str(allow_ifd).lower()]
|
||||
|
||||
with group("Collect cache garbage"):
|
||||
subprocess.run([PUSH, "--gc"], check=True)
|
||||
|
||||
with TemporaryDirectory() as work:
|
||||
work = Path(work)
|
||||
|
||||
with group("Evaluate"):
|
||||
ok, jobs = evaluate(nix_options, work)
|
||||
|
||||
built = {}
|
||||
if jobs:
|
||||
with group("Build"):
|
||||
built_all, built = build(jobs)
|
||||
ok = ok and built_all
|
||||
|
||||
# Cache whatever built, even when the run fails
|
||||
if built:
|
||||
with group("Cache"):
|
||||
subprocess.run([PUSH, *built.values()], check=True)
|
||||
|
||||
if not ok:
|
||||
sys.exit(1)
|
||||
|
||||
if allow_ifd:
|
||||
with group("Check flake"):
|
||||
subprocess.run(["nix", "flake", "check", *nix_options], check=True)
|
||||
|
||||
with group("Update cache profile"):
|
||||
farm = link_farm(built, work)
|
||||
subprocess.run([PUSH, farm], env=os.environ | {"UPDATE_PROFILE": "1"}, check=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Keep this script's output in order with its commands'
|
||||
sys.stdout.reconfigure(line_buffering=True)
|
||||
main()
|
||||
@@ -0,0 +1,29 @@
|
||||
{ lib, inputs, nixfiles, system }:
|
||||
let
|
||||
inherit (builtins) any attrValues filter tryEval;
|
||||
inherit (lib) concatMap filterAttrs getName groupBy isDerivation;
|
||||
inherit (nixfiles.config) nixos home-manager;
|
||||
|
||||
systems = filter (box: box.system == system) (attrValues nixos.systems);
|
||||
homes = filter (home: home.system == system) (attrValues home-manager.homes);
|
||||
|
||||
installedPackages =
|
||||
concatMap
|
||||
(box:
|
||||
let cfg = box.rendered.config;
|
||||
in cfg.environment.systemPackages
|
||||
++ concatMap (home: home.home.packages) (attrValues cfg.home-manager.users))
|
||||
systems
|
||||
++ concatMap (home: home.configuration.config.home.packages) homes;
|
||||
|
||||
installedByName = groupBy getName installedPackages;
|
||||
in
|
||||
filterAttrs
|
||||
(_: package:
|
||||
# Check names before forcing output paths. Some unrelated upstream exports
|
||||
# are helpers or packages that cannot be evaluated on this platform.
|
||||
let name = tryEval (if isDerivation package then getName package else null);
|
||||
in name.success && name.value != null
|
||||
&& any (installed: installed.drvPath == package.drvPath)
|
||||
(installedByName.${name.value} or [ ]))
|
||||
(inputs.llm-agents.packages.${system} or { })
|
||||
+8
-5
@@ -31,12 +31,15 @@ if [ "${1-}" = "--gc" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
path="$1"
|
||||
if [ -n "${UPDATE_PROFILE-}" ] && [ $# -ne 1 ]; then
|
||||
echo "UPDATE_PROFILE needs exactly one path" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Pushing $path to cache..."
|
||||
nix copy --no-check-sigs --to "$STORE_URI" "$path"
|
||||
echo "Pushing $# path(s) to cache..."
|
||||
nix copy --no-check-sigs --to "$STORE_URI" "$@"
|
||||
|
||||
if [ -n "$UPDATE_PROFILE" ]; then
|
||||
if [ -n "${UPDATE_PROFILE-}" ]; then
|
||||
echo "Updating profile..."
|
||||
remote_cmd nix-env -p "$REMOTE_STORE"/nix/var/nix/profiles/nixfiles --set "$path"
|
||||
remote_cmd nix-env -p "$REMOTE_STORE"/nix/var/nix/profiles/nixfiles --set "$1"
|
||||
fi
|
||||
Executable
+239
@@ -0,0 +1,239 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Keep the llm-agents update PR and its package build current."""
|
||||
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
from itertools import count
|
||||
from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
from urllib.error import HTTPError
|
||||
from urllib.parse import urlencode
|
||||
from urllib.request import Request, urlopen
|
||||
|
||||
|
||||
BASE = "master"
|
||||
BRANCH = "automation/llm-agents"
|
||||
REF = f"refs/heads/{BRANCH}"
|
||||
TITLE = "flake: Update llm-agents"
|
||||
LOCK = Path("flake.lock")
|
||||
BUILD_WORKFLOW = "actions/workflows/llm-agents.yaml"
|
||||
|
||||
|
||||
def git_output(*args: str) -> bytes:
|
||||
return subprocess.check_output(["git", *args])
|
||||
|
||||
|
||||
def versions(lock_file: Path | None = None) -> dict[str, str]:
|
||||
command = [
|
||||
"nix", "eval", "--accept-flake-config", "--no-update-lock-file", "--json",
|
||||
".#llmAgentPackages.x86_64-linux",
|
||||
"--apply", "builtins.mapAttrs (_: package: package.version)",
|
||||
]
|
||||
if lock_file is not None:
|
||||
command.extend(["--reference-lock-file", str(lock_file)])
|
||||
|
||||
return json.loads(subprocess.check_output(command))
|
||||
|
||||
|
||||
def api(path: str, *, method: str | None = None, query=None, data=None):
|
||||
server = os.environ["GITHUB_SERVER_URL"].rstrip("/")
|
||||
repo = os.environ["GITHUB_REPOSITORY"]
|
||||
url = f"{server}/api/v1/repos/{repo}/{path}"
|
||||
if query is not None:
|
||||
url += "?" + urlencode(query)
|
||||
|
||||
headers = {"Authorization": f"token {os.environ['GITEA_TOKEN']}"}
|
||||
payload = None
|
||||
if data is not None:
|
||||
headers["Content-Type"] = "application/json"
|
||||
payload = json.dumps(data).encode()
|
||||
|
||||
request = Request(url, data=payload, headers=headers, method=method)
|
||||
|
||||
try:
|
||||
with urlopen(request, timeout=30) as response:
|
||||
body = response.read()
|
||||
except HTTPError as error:
|
||||
message = error.read(4096).decode(errors="replace")
|
||||
raise RuntimeError(
|
||||
f"{request.get_method()} {path} returned HTTP {error.code}: {message}"
|
||||
) from None
|
||||
|
||||
return json.loads(body) if body else None
|
||||
|
||||
|
||||
def find_pull_request(state: str, sort: str | None = None):
|
||||
"""Return the first update PR in the listing, or None."""
|
||||
repo = os.environ["GITHUB_REPOSITORY"]
|
||||
query = {"state": state, "base_branch": BASE, "limit": 50}
|
||||
if sort is not None:
|
||||
query["sort"] = sort
|
||||
|
||||
for page in count(1):
|
||||
pulls = api("pulls", query=query | {"page": page})
|
||||
if not pulls:
|
||||
return None
|
||||
|
||||
for pull in pulls:
|
||||
head = pull["head"]
|
||||
if head["ref"] == BRANCH and (head["repo"] or {}).get("full_name") == repo:
|
||||
return pull
|
||||
|
||||
|
||||
def version_changes(before: dict[str, str], after: dict[str, str]) -> list[tuple[str, str, str]]:
|
||||
return [
|
||||
(name, before.get(name, "absent"), after.get(name, "absent"))
|
||||
for name in sorted(before.keys() | after.keys())
|
||||
if before.get(name) != after.get(name)
|
||||
]
|
||||
|
||||
|
||||
def locked_source(lock: bytes) -> dict[str, str]:
|
||||
nodes = json.loads(lock)["nodes"]
|
||||
return nodes[nodes["root"]["inputs"]["llm-agents"]]["locked"]
|
||||
|
||||
|
||||
def pull_request_body(
|
||||
before: dict[str, str], after: dict[str, str], base_lock: bytes, proposed_lock: bytes,
|
||||
) -> str:
|
||||
rows = "\n".join(
|
||||
f"| `{name}` | {old} | {new} |" for name, old, new in version_changes(before, after)
|
||||
)
|
||||
|
||||
old, new = locked_source(base_lock), locked_source(proposed_lock)
|
||||
source = f"`{old['rev'][:12]}` → `{new['rev'][:12]}`"
|
||||
if new.get("type") == "github":
|
||||
compare = f"https://github.com/{new['owner']}/{new['repo']}/compare/{old['rev']}...{new['rev']}"
|
||||
source = f"[{source}]({compare})"
|
||||
|
||||
return (
|
||||
f"Updates the `llm-agents` pin ({source}). Installed package versions:\n"
|
||||
"\n"
|
||||
f"| Package | `{BASE}` | Proposed |\n"
|
||||
"| --- | --- | --- |\n"
|
||||
f"{rows}\n"
|
||||
"\n"
|
||||
"Close this PR to skip these versions; a later release opens a new one."
|
||||
)
|
||||
|
||||
|
||||
def create_pull_request(body: str):
|
||||
return api("pulls", data={"base": BASE, "head": BRANCH, "title": TITLE, "body": body})
|
||||
|
||||
|
||||
def close_obsolete(pull) -> None:
|
||||
if pull is None:
|
||||
return
|
||||
|
||||
api(f"issues/{pull['number']}/comments", data={
|
||||
"body": f"`{BASE}` already has the latest installed llm-agents versions.",
|
||||
})
|
||||
api(f"pulls/{pull['number']}", method="PATCH", data={"state": "closed"})
|
||||
print(f"Closed the obsolete update PR {pull['html_url']}.")
|
||||
|
||||
|
||||
def declined(after: dict[str, str], reference: Path) -> bool:
|
||||
"""Check whether the most recently closed update PR rejected these versions."""
|
||||
pull = find_pull_request("closed", sort="recentclose")
|
||||
if pull is None or pull["merged"]:
|
||||
return False
|
||||
|
||||
# Gitea keeps the PR's head at close time even if the branch moves on.
|
||||
subprocess.run([
|
||||
"git", "fetch", "--no-tags", "--depth=1", "origin", f"refs/pull/{pull['number']}/head",
|
||||
], check=True)
|
||||
reference.write_bytes(git_output("show", f"FETCH_HEAD:{LOCK}"))
|
||||
if versions(reference) != after:
|
||||
return False
|
||||
|
||||
print(f"Skipping the versions declined in {pull['html_url']}.")
|
||||
return True
|
||||
|
||||
|
||||
def publish(previous: str, before: dict[str, str], after: dict[str, str]) -> str:
|
||||
changes = "\n".join(
|
||||
f"{name} {old} -> {new}" for name, old, new in version_changes(before, after)
|
||||
)
|
||||
|
||||
subprocess.run(["git", "add", "--", str(LOCK)], check=True)
|
||||
subprocess.run([
|
||||
"git", "-c", "user.name=github-actions[bot]",
|
||||
"-c", "user.email=github-actions[bot]@users.noreply.github.com",
|
||||
"commit", "-m", TITLE, "-m", changes,
|
||||
], check=True)
|
||||
|
||||
# Pass the credential to Git without putting it in the remote URL.
|
||||
auth = base64.b64encode(f"oauth2:{os.environ['GITEA_TOKEN']}".encode()).decode()
|
||||
subprocess.run([
|
||||
"git", "push", f"--force-with-lease={REF}:{previous}", "origin", f"HEAD:{REF}",
|
||||
], check=True, env=os.environ | {
|
||||
"GIT_CONFIG_COUNT": "1",
|
||||
"GIT_CONFIG_KEY_0": "http.extraHeader",
|
||||
"GIT_CONFIG_VALUE_0": f"Authorization: Basic {auth}",
|
||||
})
|
||||
|
||||
return git_output("rev-parse", "HEAD").decode().strip()
|
||||
|
||||
|
||||
def main() -> None:
|
||||
# Capture the tip before evaluating so the lease protects concurrent updates.
|
||||
previous = git_output("ls-remote", "origin", REF).decode().partition("\t")[0]
|
||||
if previous:
|
||||
subprocess.run(["git", "fetch", "--no-tags", "--depth=2", "origin", REF], check=True)
|
||||
|
||||
base_lock = git_output("show", f"HEAD:{LOCK}")
|
||||
subprocess.run(["nix", "flake", "update", "--accept-flake-config", "llm-agents"], check=True)
|
||||
candidate_lock = LOCK.read_bytes()
|
||||
|
||||
pull = find_pull_request("open")
|
||||
if candidate_lock == base_lock:
|
||||
print("The llm-agents pin is current.")
|
||||
close_obsolete(pull)
|
||||
return
|
||||
|
||||
with TemporaryDirectory() as temp:
|
||||
reference = Path(temp) / LOCK.name
|
||||
reference.write_bytes(base_lock)
|
||||
before = versions(reference)
|
||||
after = versions()
|
||||
|
||||
if before == after:
|
||||
print("Installed llm-agents package versions are unchanged.")
|
||||
close_obsolete(pull)
|
||||
return
|
||||
|
||||
if pull is None and declined(after, reference):
|
||||
return
|
||||
|
||||
pending = None
|
||||
pending_lock = None
|
||||
if previous and git_output("show", f"{previous}^:{LOCK}") == base_lock:
|
||||
pending_lock = git_output("show", f"{previous}:{LOCK}")
|
||||
reference.write_bytes(pending_lock)
|
||||
pending = after if pending_lock == candidate_lock else versions(reference)
|
||||
|
||||
if pending == after:
|
||||
head, proposed_lock = previous, pending_lock
|
||||
else:
|
||||
head, proposed_lock = publish(previous, before, after), candidate_lock
|
||||
|
||||
# Keep the description in step with the branch, including after master moves.
|
||||
body = pull_request_body(before, after, base_lock, proposed_lock)
|
||||
if pull is None:
|
||||
pull = create_pull_request(body)
|
||||
elif pull["body"] != body:
|
||||
api(f"pulls/{pull['number']}", method="PATCH", data={"body": body})
|
||||
print(f"Update PR {pull['html_url']}")
|
||||
|
||||
# Gitea suppresses events from the Actions token. Dispatch explicitly and
|
||||
# recover on the next poll if there is still no build for this commit.
|
||||
runs = api(f"{BUILD_WORKFLOW}/runs", query={"head_sha": head, "limit": 1})
|
||||
if runs["total_count"] == 0:
|
||||
api(f"{BUILD_WORKFLOW}/dispatches", data={"ref": BRANCH})
|
||||
print(f"Queued the llm-agents build for {head[:12]}.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+1
-1
@@ -42,7 +42,7 @@ Physical host and public-infrastructure hub — see [`sites/colony/README.md`](s
|
||||
```
|
||||
colony (physical VM host, ams1)
|
||||
├── estuary ── edge router: WAN, firewall/NAT, DNS, BGP (AS211024), WireGuard
|
||||
├── shill ──── NixOS container host ──┬── middleman (reverse proxy, ACME, nginx-sso, librespeed)
|
||||
├── shill ──── NixOS container host ──┬── middleman (reverse proxy, ACME, Pocket ID, librespeed)
|
||||
│ ├── vaultwarden (password manager)
|
||||
│ ├── colony-psql (shared PostgreSQL)
|
||||
│ ├── chatterbox (Matrix Synapse + bridges)
|
||||
|
||||
@@ -51,8 +51,7 @@ Per platform (`eachDefaultSystem`), the flake produces:
|
||||
- `devShells.default` — the `numtide/devshell` from [`devshell/`](../devshell) (see
|
||||
[deployment.md](deployment.md)).
|
||||
- `ci.<system>` — one attr per buildable thing (`system-<name>`, `home-<name>` with `@` mangled
|
||||
to `-at-`, `package-<name>`, plus `shell`), consumed by CI; `ciDrv` is a `linkFarm` of all of
|
||||
them.
|
||||
to `-at-`, `package-<name>`, plus `shell`), consumed by CI.
|
||||
|
||||
## Systems: `systemOpts` and `mkSystem`
|
||||
|
||||
@@ -188,7 +187,7 @@ descriptions) see [`reference/nixos-options.md`](reference/nixos-options.md).
|
||||
| `vms` | `my.vms.instances` — QEMU/KVM VMs as systemd units: TAP/bridge networking, LVM-backed disks, VFIO host-device passthrough (with udev tagging), UEFI, SPICE/TTY/QMP unix sockets under `/run/vms/`, clean shutdown via QMP `system_powerdown`. |
|
||||
| `network` | Baseline networking: networkd only (`useDHCP = false`), IPv6 on, resolved domain/negative-cache settings; dev VMs get DHCP on `eth0` and an SSH port forward. |
|
||||
| `pdns` | `my.pdns` — PowerDNS: authoritative server driven by BIND-style zone files (with templating and serial management) and recursor extra-settings wiring. |
|
||||
| `nginx-sso` | `my.nginx-sso` — runs `nginx-sso` (instead of the stock NixOS module) and generates per-instance nginx `auth_request` include files. |
|
||||
| `pocket-id` | `my.pocket-id` — Pocket ID with user groups and OIDC clients declared in Nix; `pocket-id-sync` applies them through the API with a static API key. |
|
||||
| `gui` | `my.gui.enable` (default on) — desktop baseline: graphics, polkit, swaylock PAM entry, Android udev rules, screenshot tmpdir. |
|
||||
| `l2mesh` | Consumes `nixos.vpns.l2` — builds the VXLAN + IPsec layer-2 meshes between edge routers; see [networking.md](networking.md). |
|
||||
| `borgthin` | `my.borgthin.jobs` — borg backups of thin-LVM snapshots to local or SSH repos on a systemd timer, with pruning. |
|
||||
|
||||
+56
-18
@@ -84,9 +84,10 @@ Boxes default to `fish`, so pipe multi-statement remote scripts through `bash`,
|
||||
|
||||
## Coding agents
|
||||
|
||||
The shared GUI home-manager module installs Codex and Claude Code from the `llm-agents` input, retaining
|
||||
that input's tested nixpkgs pin. Run `nix flake update llm-agents`, then switch the system
|
||||
or home configuration to use the updated package.
|
||||
The shared GUI home-manager module installs Codex and Claude Code from the `llm-agents` input,
|
||||
retaining that input's tested nixpkgs pin. [CI proposes version updates](#llm-agents-updates).
|
||||
To refresh the pin manually, run `nix flake update llm-agents`, then switch the system or home
|
||||
configuration to use the updated packages.
|
||||
|
||||
The shared cache settings in `lib.my.c.nix.cache` and the flake's `nixConfig` include
|
||||
the [Numtide binary cache](https://github.com/numtide/llm-agents.nix#binary-cache), so
|
||||
@@ -301,32 +302,69 @@ GitHub/Gitea Actions workflows live in [`.gitea/workflows/`](../.gitea/workflows
|
||||
|
||||
On pushes to `master`, this installs Determinate Nix on the runner (via
|
||||
`DeterminateSystems/determinate-nix-action`, configured with the same performance settings and
|
||||
Harmonia substituter as the boxes). CI normally runs `nix flake check --no-build` first and
|
||||
keeps import from derivation disabled. It builds every attribute of `.#ci.x86_64-linux`:
|
||||
systems as `system-<name>`, homes as `home-<name>` (with `@` changed to `-at-`), packages as
|
||||
`package-<name>`, and the development `shell`. Each result is pushed to the
|
||||
Harmonia cache with [`ci/push-to-cache.sh`](../ci/push-to-cache.sh). Before the first push, the
|
||||
workflow deletes cache-profile generations older than its retention period, then collects
|
||||
unreachable paths so a full cache cannot prevent collection from being reached. Paths pushed by
|
||||
`slop build` survive collection through their own GC roots (see
|
||||
[`slop-broker.md`](slop-broker.md#binary-cache)).
|
||||
Harmonia substituter as the boxes). A newer push cancels a run still in progress. CI normally
|
||||
runs `nix flake check --no-build` first and keeps import from derivation disabled. It then runs
|
||||
[`ci/build-and-cache.py`](../ci/build-and-cache.py), which builds every attribute of
|
||||
`.#ci.x86_64-linux`: systems as `system-<name>`, homes as `home-<name>` (with `@` changed to
|
||||
`-at-`), packages as `package-<name>`, and the development `shell`.
|
||||
|
||||
The script works in stages:
|
||||
|
||||
- **Collect garbage.** It deletes cache-profile generations older than their retention period,
|
||||
then collects unreachable paths so a full cache cannot prevent collection from being reached.
|
||||
Paths pushed by `slop build` survive collection through their own GC roots (see
|
||||
[`slop-broker.md`](slop-broker.md#binary-cache)).
|
||||
- **Evaluate.** [`nix-eval-jobs`](https://github.com/nix-community/nix-eval-jobs) evaluates the
|
||||
attributes in a pool of workers. Each worker reuses one evaluation of the flake for several
|
||||
jobs, and the worker count and per-worker memory bound (`CI_EVAL_WORKERS`,
|
||||
`CI_EVAL_WORKER_MEMORY`) cap the evaluation's memory on the runner.
|
||||
- **Build.** One `nix build --keep-going` builds every evaluated derivation, so a failing job
|
||||
doesn't stop the others.
|
||||
- **Cache.** Every output that built is pushed to the Harmonia cache with
|
||||
[`ci/push-to-cache.sh`](../ci/push-to-cache.sh). Any evaluation or build failure fails the run
|
||||
at this point.
|
||||
- **Update the profile.** A `linkFarm` of all the outputs, built from their known store paths
|
||||
rather than a second evaluation, is pushed with `UPDATE_PROFILE=1`. That updates the
|
||||
`nixfiles` profile on the cache box.
|
||||
|
||||
When `.#ciIfdReasons.x86_64-linux` lists an active exception, CI logs a warning with the reason
|
||||
and allows import from derivation for the target builds. It runs a build-capable flake
|
||||
check afterward. CI checks [the shared runtime replacement list](../lib/runtime-dependency-replacements.nix)
|
||||
and allows import from derivation for the evaluation. The evaluation workers then wait on those
|
||||
builds in parallel. CI runs a build-capable flake check after caching and before updating the
|
||||
profile. CI checks [the shared runtime replacement list](../lib/runtime-dependency-replacements.nix)
|
||||
against the nixpkgs channels used by its systems and standalone homes. A matching entry
|
||||
requires reading generated store reference graphs during evaluation.
|
||||
|
||||
It then builds `.#ciDrv.x86_64-linux`, a `linkFarm` of all CI attributes, and pushes it with
|
||||
`UPDATE_PROFILE=1`. That updates the `nixfiles` profile on the cache box. The SSH store uses
|
||||
`/var/lib/harmonia`, `HARMONIA_SSH_KEY`, and pinned `ci/known_hosts`; clients use
|
||||
`https://nix-cache.nul.ie` through `lib.my.c.nix.cache`.
|
||||
The SSH store uses `/var/lib/harmonia`, `HARMONIA_SSH_KEY`, and pinned `ci/known_hosts`; clients
|
||||
use `https://nix-cache.nul.ie` through `lib.my.c.nix.cache`.
|
||||
|
||||
### `installer.yaml`
|
||||
|
||||
Pushing the `installer` tag (refreshed by `update-installer`) builds `my.buildAs.iso` and
|
||||
`my.buildAs.netbootArchive`, then attaches both to a release.
|
||||
|
||||
### llm-agents updates
|
||||
|
||||
[`update-llm-agents.yaml`](../.gitea/workflows/update-llm-agents.yaml) checks for updates every
|
||||
four hours and can also be run manually on `master`. It matches packages directly installed
|
||||
by the x86_64 Linux NixOS and home-manager configurations to derivations exported by
|
||||
`llm-agents`. This discovers the tracked packages without building a whole system.
|
||||
|
||||
When an installed version changes, CI commits the updated lockfile on the dedicated
|
||||
`automation/llm-agents` branch. The PR description tabulates the version changes and links
|
||||
the upstream comparison, and the commit message lists them too. New versions refresh the branch
|
||||
behind the existing open PR, and the updater rewrites the description to match. Upstream revisions with the same package
|
||||
versions leave that branch alone.
|
||||
|
||||
- **Declining:** close the PR without merging. CI won't propose the same versions again, and
|
||||
opens a new PR once a later version appears.
|
||||
- **Obsolete PRs:** if `master` already has the latest installed versions, for example after a
|
||||
manual update, CI comments on the open PR and closes it.
|
||||
|
||||
[`llm-agents.yaml`](../.gitea/workflows/llm-agents.yaml) builds the discovered packages for
|
||||
the update commit using the flake's caches. The updater dispatches the build explicitly
|
||||
because Gitea suppresses automatic workflow events from its job token. The updater needs
|
||||
the repository's Actions token limits to allow writes to code, pull requests and Actions.
|
||||
|
||||
### `update-docs.yaml`
|
||||
|
||||
On pushes to `master`, excluding its own commits, this runs the assignment, option and DNS
|
||||
|
||||
@@ -47,6 +47,11 @@ over Tailscale.
|
||||
- Steam and Wireshark enabled; `fstrim`, LVM thin provisioning.
|
||||
- `nix.gc.automatic = false` — GC is run manually on the laptop.
|
||||
|
||||
## Antigravity CLI
|
||||
|
||||
`my.agents.antigravity.enable` installs Google's `agy` CLI. Run it in a local checkout and
|
||||
sign in with your Google account. A paid Google AI Pro or Ultra account can select Gemini 4 Neon.
|
||||
|
||||
## Notable config files
|
||||
|
||||
- [`nixos/boxes/tower/default.nix`](../../nixos/boxes/tower/default.nix) — the whole box (single file).
|
||||
@@ -20,6 +20,15 @@ The Git forge at `git.nul.ie` (self-registration disabled), configured in
|
||||
`gitea`, on [`object`](shill/containers/object.md)) — the secret is spliced into `app.ini` at
|
||||
startup.
|
||||
- Mail goes out via `mail.nul.ie`, including the issue-reply incoming-mail poller.
|
||||
- **Sign-in with Pocket ID:** `preStart` adds or updates the `id.nul.ie` OpenID Connect login
|
||||
source. The client `gitea` and its secret `gitea/oidc-secret.txt` are declared on
|
||||
[`middleman`](shill/containers/middleman.md#pocket-id).
|
||||
- Registration stays disabled, so a Pocket ID sign-in can't create an account. The first one
|
||||
links to an existing account after signing in with its password.
|
||||
- It runs before the server, which only reads login sources at startup. If it fails, Gitea
|
||||
starts without the source and logs a warning.
|
||||
- The CLI only takes the secret as an argument, so it is briefly visible in the process list
|
||||
while `preStart` runs.
|
||||
|
||||
### Gitea Actions runner
|
||||
|
||||
|
||||
@@ -33,6 +33,18 @@ The VM attaches to a dedicated, unbridged TAP (`vm-mail`). `colony` puts the poi
|
||||
estuary's reverse zone). `estuary` accepts traffic to the customer prefixes
|
||||
without per-port filtering; `colony` forwards it on ("trust for now").
|
||||
|
||||
## Sign-in with Pocket ID
|
||||
|
||||
mailcow's Generic-OIDC identity provider signs mailboxes in to the mailcow UI and SOGo with
|
||||
Pocket ID on [`middleman`](shill/containers/middleman.md#pocket-id).
|
||||
|
||||
- The `mailcow` client is declared in `middleman`'s `auth.nix`; its secret
|
||||
`mailcow/oidc-secret.txt` is only deployed there. On the mailcow side the provider is set up
|
||||
by hand under System → Configuration → Access → Identity Provider, with that secret pasted in.
|
||||
- Only mailboxes whose auth source is the identity provider use it. IMAP, SMTP and the DAV and
|
||||
ActiveSync clients can't follow a redirect, so those mailboxes use mailcow app passwords there.
|
||||
- Admin and domain-admin logins are unaffected.
|
||||
|
||||
## Notes
|
||||
|
||||
- ACME certificates are issued on `middleman` and pushed to the VM over SSH
|
||||
|
||||
@@ -48,7 +48,7 @@ their current addresses. Each container has its own page:
|
||||
|
||||
| Container | Role |
|
||||
|---|---|
|
||||
| [`middleman`](containers/middleman.md) | Reverse proxy, ACME, nginx-sso, librespeed, Paseo relay |
|
||||
| [`middleman`](containers/middleman.md) | Reverse proxy, ACME, Pocket ID and SSO, librespeed, Paseo relay |
|
||||
| [`vaultwarden`](containers/vaultwarden.md) | Password manager |
|
||||
| [`colony-psql`](containers/colony-psql.md) | Shared PostgreSQL (14) |
|
||||
| [`chatterbox`](containers/chatterbox.md) | Matrix Synapse + bridges |
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
The front-end reverse proxy for the colony's public web services — the single ingress that
|
||||
`estuary` DNATs HTTP/HTTPS (and Matrix federation on `:8448`) to. Terminates TLS with wildcard
|
||||
certificates it issues itself, provides nginx-sso for gated vhosts, and runs the Pocket ID
|
||||
identity provider, a librespeed backend and a Paseo relay.
|
||||
certificates it issues itself, runs the Pocket ID identity provider with oauth2-proxy in front of
|
||||
gated vhosts, and runs a librespeed backend and a Paseo relay.
|
||||
|
||||
- **Source:** [`shill/containers/middleman/`](../../../../../nixos/boxes/colony/vms/shill/containers/middleman)
|
||||
(`default.nix`, `vhosts.nix`)
|
||||
(`default.nix`, `auth.nix`, `vhosts.nix`)
|
||||
- **Host:** NixOS container on [`shill`](../README.md) (`my.containers` ephemeral nspawn on the
|
||||
`ctrs` bridge; bind-mounts `/mnt/media` read-only for the static file vhosts)
|
||||
- **nixpkgs:** `mine`
|
||||
@@ -32,24 +32,51 @@ also waits for `colony-psql` through `systemdAwaitPostgres`, avoiding an early-b
|
||||
`mailcow-ssl-reload` there.
|
||||
- Renewal reloads nginx; the `acme` group owns the secret files and includes the nginx user.
|
||||
|
||||
### nginx-sso
|
||||
|
||||
The `generic` SSO instance at `sso.nul.ie` uses Google OAuth by default and also offers a simple
|
||||
username/password provider. Its cookie domain is `.nul.ie`; gated vhosts include the generated
|
||||
`server-generic.conf` / `location-generic.conf` snippets from `/etc/nginx/includes/sso/`.
|
||||
|
||||
### Pocket ID
|
||||
|
||||
[Pocket ID](https://pocket-id.org) (`services.pocket-id`) is a passkey-only OpenID Connect
|
||||
provider at `id.nul.ie`, for apps that sign in with OIDC (first the `slop-broker` approvals web
|
||||
app, see [`slop-broker.md`](../../../../slop-broker.md#approvals-web-app)). It is meant to replace nginx-sso's
|
||||
Google sign-in later, with oauth2-proxy in front of apps that lack OIDC.
|
||||
provider at `id.nul.ie`. Apps with OIDC support sign in with it directly (such as the
|
||||
[`slop-broker` approvals web app](../../../../slop-broker.md#approvals-web-app)); the rest go
|
||||
through [oauth2-proxy](#sso).
|
||||
|
||||
- Listens on `127.0.0.1:1411` behind nginx and keeps its SQLite database in `/var/lib/pocket-id`
|
||||
(persisted by `my.tmproot`). The `middleman/pocket-id-encryption-key` secret encrypts it.
|
||||
- The first admin is created at `/setup`; nginx only allows that page and its API from
|
||||
internal networks (`lib.my.c.internalNets`). Further users are added from the admin UI.
|
||||
|
||||
**Declared groups and clients.** `my.pocket-id` (in
|
||||
[`auth.nix`](../../../../../nixos/boxes/colony/vms/shill/containers/middleman/auth.nix)) declares
|
||||
user groups and OIDC clients; `pocket-id-sync` creates and updates them through the API on every
|
||||
switch.
|
||||
|
||||
- It authenticates with the static API key `middleman/pocket-id-api-key`. nginx strips
|
||||
`X-API-Key` from outside requests, so API keys only work from inside the container.
|
||||
- Clients and groups that aren't declared are left alone, as is group membership: add users to
|
||||
groups in the admin UI.
|
||||
- A client's secret is an age file shared with the box that runs the app (or a key of an env
|
||||
file). Generate it with `slop secret generate`; after rotating one, restart `pocket-id-sync`.
|
||||
|
||||
### SSO
|
||||
|
||||
[oauth2-proxy](https://oauth2-proxy.github.io/oauth2-proxy/) signs users in with Pocket ID (client
|
||||
`sso`) for vhosts with no sign-in of their own.
|
||||
|
||||
- `ssoServer [ <groups> ]` in `vhosts.nix` gates a vhost with nginx `auth_request`, allowing
|
||||
members of any of the given Pocket ID groups. The gated vhosts currently allow `admins`.
|
||||
- Each gated vhost serves oauth2-proxy's `/oauth2/` endpoints itself. Its session cookie is
|
||||
host-only, so other `.nul.ie` sites (including `*.slop.nul.ie` previews) never receive it.
|
||||
Pocket ID's own session turns signing in to another gated vhost into a redirect.
|
||||
- The `sso` client's callback URLs are derived from the gated vhosts.
|
||||
- Sessions last a week. Every hour, oauth2-proxy uses a refresh token to check back with Pocket
|
||||
ID without a passkey, and picks up the user's current groups. A disabled user is signed out at
|
||||
the next check; someone removed from a group loses access once their access token expires (an
|
||||
hour at most, Pocket ID's default).
|
||||
- A location in a gated vhost with its own `add_header` would drop the refreshed session cookie
|
||||
that `ssoServer` passes on.
|
||||
- Its client secret and cookie secret are in the env file `middleman/oauth2-proxy.env`.
|
||||
- `id.nul.ie` resolves to the container itself, so oauth2-proxy reaches Pocket ID through the
|
||||
local nginx.
|
||||
|
||||
### librespeed
|
||||
|
||||
The frontend and backend are published as `speed.nul.ie` and `librespeed.ams1.int.nul.ie`, both
|
||||
@@ -80,14 +107,13 @@ rewrites outbound IPv6 to the container's own address on `host0`.
|
||||
## Published vhosts
|
||||
|
||||
Everything is under `*.nul.ie` with the public wildcard cert unless noted; defaults applied to
|
||||
all vhosts are `onlySSL`, kTLS and HTTP/2. "SSO" = gated behind nginx-sso (`generic` instance).
|
||||
all vhosts are `onlySSL`, kTLS and HTTP/2. "SSO" = gated behind [oauth2-proxy](#sso).
|
||||
|
||||
| Host | Upstream | Notes |
|
||||
| --- | --- | --- |
|
||||
| `nul.ie` (`_`, default) | static | landing page (`index.html`, CV PDF, SSH pubkey); serves Matrix `.well-known`s and redirects `webfinger`/`nodeinfo`/`host-meta` → `toot.nul.ie`, `atproto-did` → `pds.nul.ie`; `forceSSL` (plain HTTP redirects to HTTPS) |
|
||||
| `localhost` | — | loopback-only VTS status page at `/status` (scraped by netdata); plain HTTP |
|
||||
| `sso.nul.ie` | `localhost:8082` | nginx-sso endpoint |
|
||||
| `id.nul.ie` | `localhost:1411` | Pocket ID; `/setup` only from internal networks |
|
||||
| `id.nul.ie` | `localhost:1411` | Pocket ID; `/setup` only from internal networks; `X-API-Key` stripped |
|
||||
| `netdata-colony.nul.ie` | `<host>.ams1.int.nul.ie:19999` | netdata fan-out over `vm`, `fw`, `ctr`, `oci`, `http`, `jackflix-ctr`, `chatterbox-ctr`, `colony-psql-ctr`; **SSO** |
|
||||
| `pass.nul.ie` | `vaultwarden-ctr:8080` | [vaultwarden](vaultwarden.md); `/notifications/hub` proxied with websockets |
|
||||
| `matrix.nul.ie` | `chatterbox-ctr:8008` | [chatterbox](chatterbox.md) Synapse client + federation; also listens on `:8448` as federation `default_server`; `= /` redirects to Element; serves Matrix `.well-known`s |
|
||||
@@ -122,6 +148,7 @@ all vhosts are `onlySSL`, kTLS and HTTP/2. "SSO" = gated behind nginx-sso (`gene
|
||||
|
||||
## Notable config files
|
||||
|
||||
- [`nixos/boxes/colony/vms/shill/containers/middleman/default.nix`](../../../../../nixos/boxes/colony/vms/shill/containers/middleman/default.nix) — container definition: nginx, ACME, nginx-sso, Pocket ID, librespeed, Paseo relay, secrets
|
||||
- [`nixos/boxes/colony/vms/shill/containers/middleman/vhosts.nix`](../../../../../nixos/boxes/colony/vms/shill/containers/middleman/vhosts.nix) — all virtual hosts, the SSO include helpers, and the `.well-known` tree
|
||||
- [`nixos/boxes/colony/vms/shill/containers/middleman/default.nix`](../../../../../nixos/boxes/colony/vms/shill/containers/middleman/default.nix) — container definition: nginx, ACME, librespeed, Paseo relay, secrets
|
||||
- [`nixos/boxes/colony/vms/shill/containers/middleman/auth.nix`](../../../../../nixos/boxes/colony/vms/shill/containers/middleman/auth.nix) — Pocket ID, its declared groups and clients, oauth2-proxy
|
||||
- [`nixos/boxes/colony/vms/shill/containers/middleman/vhosts.nix`](../../../../../nixos/boxes/colony/vms/shill/containers/middleman/vhosts.nix) — all virtual hosts, the `ssoServer` helper, and the `.well-known` tree
|
||||
- [`nixos/boxes/colony/vms/shill/containers/middleman/default.html`](../../../../../nixos/boxes/colony/vms/shill/containers/middleman/default.html) — default vhost landing page
|
||||
@@ -26,6 +26,9 @@ The AMD desktop runs the GUI stack (`my.gui.enable`, Sway/Wayland via home-manag
|
||||
PipeWire, Bluetooth and Thunderbolt. Local `libvirtd`/`virt-manager` and the IOMMU are enabled, but
|
||||
the box has no VFIO or GPU-passthrough configuration.
|
||||
|
||||
`my.agents.antigravity.enable` installs Google's `agy` CLI. Run it in a local checkout and
|
||||
sign in with your Google account. A paid Google AI Pro or Ultra account can select Gemini 4 Neon.
|
||||
|
||||
### Netboot
|
||||
|
||||
With `my.netboot.client.enable`, the firmware iPXE-boots from the 2.5G NIC. Kea matches
|
||||
|
||||
@@ -176,6 +176,10 @@ SPDK only checks the host NQN, which root in the guest could forge.
|
||||
I/O errors, instead of the kernel retrying forever.
|
||||
- `devices/global_filter` rejects `/dev/nvme*` in `lvm.conf`, so `palace` never activates the
|
||||
guest's volume group (also called `main`). `palace` has no NVMe of its own.
|
||||
- The filter has no accept pattern: LVM accepts a device if any of its names matches one, and
|
||||
the disk's `/dev/disk/by-*` links would.
|
||||
- Without it, `palace` sees two VGs called `main`, and LVM commands naming `main` refuse to
|
||||
run.
|
||||
|
||||
## `slop-broker`
|
||||
|
||||
|
||||
@@ -75,8 +75,8 @@ See the consolidated [network assignments](../../networking.md#box-assignments)
|
||||
## Paseo
|
||||
|
||||
A daemon (`paseo-server`) that starts and manages agents and serves a WebSocket API to the Paseo
|
||||
app, the web UI and the `paseo` CLI. Claude Code runs through the Claude Agent SDK, using the
|
||||
installed `claude` and its claude.ai login; Codex runs through `codex app-server`.
|
||||
app, the web UI and the `paseo` CLI. Claude Code uses the Claude Agent SDK and the installed
|
||||
`claude` login. Codex runs through `codex app-server` and Antigravity through `agy acp`.
|
||||
|
||||
### Service
|
||||
|
||||
@@ -88,6 +88,9 @@ installed `claude` and its claude.ai login; Codex runs through `codex app-server
|
||||
`paseo workspace jj` in the CLI. Each `fork/jujutsu-v<version>` branch carries the fork commits
|
||||
on an upstream release; `main` mirrors upstream. The branch's `docs/jujutsu-fork.md` explains
|
||||
the controls and how to rebase the fork.
|
||||
- The fork also compacts an idle Claude agent with a large context shortly before its one-hour
|
||||
prompt cache expires, as Claude Code does in a terminal. It is on by default and set with
|
||||
`agents.idleCompaction` (see the fork's `public-docs/configuration.md`).
|
||||
- The daemon runs the `jj` from the system and user profiles on its `PATH`.
|
||||
- Runs as `slop-cannon`, so agents use that user's logins and settings, with `~/.paseo` as
|
||||
`PASEO_HOME`.
|
||||
@@ -107,10 +110,10 @@ from the app don't survive a restart. It:
|
||||
let an agent change its own mode, answer its own permission prompts or open terminals;
|
||||
- requires relay replay protection;
|
||||
- turns off dictation and voice, which would otherwise download a large local speech model;
|
||||
- hides providers other than Claude and Codex;
|
||||
- adds "Claude, bypass permissions" and "Codex, full access" agent profiles. Each provider's
|
||||
default mode is hardcoded upstream (Claude `auto`, Codex `auto-review`), and profiles are the
|
||||
only way to preset one, so pick a profile when starting an agent for the permissive mode.
|
||||
- enables Claude, Codex and Antigravity in the provider picker;
|
||||
- adds "Claude, bypass permissions" and "Codex, full access" agent profiles. Select one when
|
||||
starting an agent to override the upstream defaults (`auto` for Claude and `auto-review`
|
||||
for Codex).
|
||||
|
||||
### Connectivity
|
||||
|
||||
@@ -133,15 +136,18 @@ sessions live under `~/.claude/projects/` and Codex sessions under `~/.codex/ses
|
||||
|
||||
## Repos, worktrees and jj
|
||||
|
||||
Repos live under `~/src` as colocated jj clones (see `slop-clone` below). Paseo only calls `git`:
|
||||
Repos live under `~/src` as colocated jj clones (see `slop-clone` below). The fork drives them
|
||||
through `jj`:
|
||||
|
||||
- A `local` workspace runs the agent in the checkout itself; `jj` and Paseo's git views see the same
|
||||
changes. Use it for work you want to steer with `jj`.
|
||||
- A worktree workspace is a `git worktree` under `~/.paseo/worktrees` on its own branch. Use it for
|
||||
unattended agents. Archiving it removes the worktree with `--force`, losing uncommitted work.
|
||||
- Archiving a `local` workspace removes only Paseo's record; the folder is kept.
|
||||
- Only one colocated working copy per repo is possible, so parallel jj-driven work needs separate
|
||||
clones.
|
||||
- A `local` workspace runs the agent in the checkout itself. Archiving it removes only Paseo's
|
||||
record; the folder is kept.
|
||||
- A new jj workspace is a colocated `jj workspace` under `~/.paseo/worktrees` with its own
|
||||
working-copy change. Use it for parallel or unattended agents. Archiving saves the change for
|
||||
restore before removing the directory.
|
||||
- A workspace goes stale when another one rewrites its `@`, typically a `jj git fetch` after its
|
||||
pull request is merged. Paseo then offers **Update stale workspace** (`jj workspace
|
||||
update-stale`), which keeps edits jj hadn't recorded in a separate change. Run it once the
|
||||
workspace's agent is idle, since it changes the files under it.
|
||||
- Don't run `jj` in a folder while an agent is mid-turn there: jj snapshots its partial edits.
|
||||
|
||||
## Terminal access
|
||||
@@ -157,7 +163,7 @@ Repos live under `~/src` as colocated jj clones (see `slop-clone` below). Paseo
|
||||
Paseo has the full rights of `slop-cannon`, and `slop-cannon` has root: anyone with the daemon
|
||||
password or a pairing controls the VM.
|
||||
|
||||
- Claude Code and Codex come from the shared `my.agents` home-manager module.
|
||||
- Claude Code, Codex and Antigravity come from the shared `my.agents` home-manager module.
|
||||
- Claude's user settings deny raw `deploy` and `ssh-machine`, and allow `slop`, since the broker
|
||||
asks a human where its policy says so. The checkout's `.keys/` only has the committed public
|
||||
keys, so reading it isn't denied. Claude's managed settings
|
||||
@@ -170,13 +176,18 @@ password or a pairing controls the VM.
|
||||
sandbox (`approval_policy = "never"`, `sandbox_mode = "danger-full-access"`). Agents started
|
||||
through Paseo use its defaults unless started with one of the profiles above.
|
||||
- Codex stores its credentials in a file.
|
||||
- Antigravity defaults to **Full access** in Paseo. **Default** uses Antigravity's approval
|
||||
policy for edits and commands. **Accept edits** auto-approves workspace edits and can still
|
||||
prompt for commands.
|
||||
|
||||
### Privileged operations
|
||||
|
||||
Agents ask [`slop-broker`](../../slop-broker.md) on `palace` for anything needing credentials, with
|
||||
the `slop` command (`my.agents.slop.enable`). It connects over vsock (CID 3; see
|
||||
[`palace`](palace.md#slop-broker)). The agent guide, `slop guide`, is installed as a Claude rule
|
||||
(`~/.claude/rules/slop.md`) and as Codex's `AGENTS.md`.
|
||||
(`~/.claude/rules/slop.md`) and included in the global `AGENTS.md` for Codex and Antigravity.
|
||||
The `my.agents.rules.slop-approvals` rule adds the local guidance on waiting for approval
|
||||
and pausing after expiry to each provider's user-level instructions, including in Paseo sessions.
|
||||
|
||||
## SSH and first login
|
||||
|
||||
@@ -189,8 +200,12 @@ To set up provider logins and repos on a fresh agent home, connect with `ssh slo
|
||||
|
||||
1. `claude auth login` (a full login; `setup-token` tokens are not enough for every feature).
|
||||
2. `codex login --device-auth`.
|
||||
3. [Pair a Paseo client](#pair-a-paseo-client).
|
||||
4. `slop-clone <owner>/<repo>` for each repo. It clones a colocated jj repo over HTTPS into
|
||||
3. For Antigravity, run `agy acp --login` over SSH as `slop-cannon`. Sign in with a paid Google
|
||||
AI Pro or Ultra account for Gemini 4 Neon. Paseo uses the same token file through the
|
||||
provider's `SSH_CONNECTION` setting. Once the service has picked up its config, refresh
|
||||
**Settings → Providers → Antigravity** to see the account's models.
|
||||
4. [Pair a Paseo client](#pair-a-paseo-client).
|
||||
5. `slop-clone <owner>/<repo>` for each repo. It clones a colocated jj repo over HTTPS into
|
||||
`~/src/<repo>` and registers it with Paseo as a local workspace.
|
||||
|
||||
## Gitea
|
||||
@@ -202,10 +217,12 @@ scopes `write:repository` and `write:issue`).
|
||||
authored as Dev through the shared Git config; the pushes are the bot's.
|
||||
- **`tea`**, Gitea's CLI, is wrapped to log in with the same token, so agents can open and update
|
||||
pull requests.
|
||||
- **Pull requests:** a rule for every agent (`my.agents.rules.gitea`: a Claude rule, and part of
|
||||
Codex's `AGENTS.md`) makes a pull request from a branch of its own the default way to finish a
|
||||
piece of work, and says how with jj and `tea`. A repository's own `AGENTS.md` can allow more,
|
||||
such as pushing to its main branch.
|
||||
- **Pull requests:** a rule for every agent (`my.agents.rules.gitea`) makes a pull request from a
|
||||
branch of its own the default way to finish a piece of work and explains how to do it with jj
|
||||
and `tea`. A repository's own `AGENTS.md` can allow more, such as pushing to its main branch.
|
||||
- **Issues:** the same rule keeps agents' running notes, plans and handoffs in Gitea issues on
|
||||
the repository they're about, rather than in files on branches that go stale. Durable facts
|
||||
still go in the repository's docs, and the issue is closed.
|
||||
- **Access per repo:** where agents should only propose changes (`dev/nixfiles`, `slop-broker`),
|
||||
protect the main branch so only Dev pushes and merges. Elsewhere the bot's Write access is
|
||||
enough to push directly.
|
||||
|
||||
+28
-5
@@ -25,11 +25,22 @@ the requesters, the `agent` policy they share, the secrets, and the web app sett
|
||||
targets are the deploy-rs nodes on `master`, which the builder reads there, so a new box is a
|
||||
target once it's merged.
|
||||
|
||||
### Updating the broker
|
||||
|
||||
- **Deploying `palace` doesn't restart the broker** (`restartIfChanged = false`), so it can see a
|
||||
deploy of its own box through. Afterwards, restart it for a new version or configuration to take
|
||||
effect: `doas systemctl --no-block restart slop-broker` on `palace`. A restart drops pending
|
||||
requests and leases.
|
||||
- **Deploy every requester with it** when `slop`'s protocol version changes, or their requests fail
|
||||
with a protocol version error: `slop-cannon`, and `castle` over SSH.
|
||||
|
||||
## In this flake
|
||||
|
||||
- **Input:** `slop-broker` in [`flake.nix`](../flake.nix). Its overlay provides `pkgs.slop-broker`,
|
||||
and the common modules import `services.slop-broker`, `services.slop-broker-builder`,
|
||||
`services.slop-broker-cache` and `programs.slop`. Update it with `nix flake update slop-broker`.
|
||||
- **Input:** `slop-broker` in [`flake.nix`](../flake.nix) selects a release tag. To upgrade,
|
||||
change the tag and run `nix flake update slop-broker`.
|
||||
- Its overlay provides `pkgs.slop-broker`.
|
||||
- The common modules import `services.slop-broker`, `services.slop-broker-builder`,
|
||||
`services.slop-broker-cache` and `programs.slop`.
|
||||
- **Persistence:** [`tmproot.nix`](../nixos/modules/tmproot.nix) keeps `/var/lib/slop-broker` and
|
||||
the builder's home when those services are enabled.
|
||||
- **Firewall:** the web app's port is open only to `middleman`, in `palace`'s configuration.
|
||||
@@ -68,8 +79,9 @@ collects garbage in that store on every run, which the roots survive until they
|
||||
`master`'s `secrets.nix`. The approval says which file the content really is and whether the
|
||||
recipients match `master`'s rules for it (see the
|
||||
[design](https://git.nul.ie/dev/slop-broker/src/branch/main/docs/design.md#secrets)).
|
||||
- `secrets.names` labels `dev` and `slop-broker` in approvals (`lib.my.c.ageKeyFiles`); host keys
|
||||
are shown abbreviated.
|
||||
- Approvals label recipients by name: `dev` and `slop-broker` through `secrets.names`
|
||||
(`lib.my.c.ageKeyFiles`), and host keys through the system name `secrets.nix` writes after each
|
||||
key as its comment.
|
||||
|
||||
### `master` is protected
|
||||
|
||||
@@ -77,6 +89,17 @@ Deploy approvals ("on the branch", the diff since `master`) and secret approvals
|
||||
`master`, so only Dev may push to it or merge into it: branch protection on `dev/nixfiles` in Gitea
|
||||
refuses everyone else, including the bot user that agents on `slop-cannon` push as.
|
||||
|
||||
## Approval timeout
|
||||
|
||||
[`services.slop-broker.timeout` on `palace`](../nixos/boxes/home/palace/slop-broker.nix) gives
|
||||
each approval step up to 45 minutes. For example, a deploy can wait for builder approval before
|
||||
the build and for deploy approval afterward, with a separate window for each step.
|
||||
`slop` prints the window when a request starts waiting (`approvers have 45m to answer`).
|
||||
|
||||
Keep `slop` running while the request is pending. Use a background session for commands that
|
||||
may need approval. If the client disconnects, the broker cancels the pending request.
|
||||
`slop requests` shows how much time each pending request has left.
|
||||
|
||||
## Approvals web app
|
||||
|
||||
`middleman` proxies `approve.slop.nul.ie` to port 8095 on `palace`. Approvers sign in through
|
||||
|
||||
Generated
+21
-21
@@ -788,11 +788,11 @@
|
||||
"treefmt-nix": "treefmt-nix"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1795241446,
|
||||
"narHash": "sha256-v8/CnsHh4/p58E5d0k208omIYUUu6EruiKRIYYNNuE0=",
|
||||
"lastModified": 1795702923,
|
||||
"narHash": "sha256-OvSz3gO7ualG+RziLMyiKecxfkqVlt43YUzAbh/+UwU=",
|
||||
"owner": "numtide",
|
||||
"repo": "llm-agents.nix",
|
||||
"rev": "a59764a6424689d67c1bd9070fd48afa44a47ee0",
|
||||
"rev": "9e137fb04294426cdd3a8f97d5a6835c9124e13f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -1031,11 +1031,11 @@
|
||||
},
|
||||
"nixpkgs_6": {
|
||||
"locked": {
|
||||
"lastModified": 1795095985,
|
||||
"narHash": "sha256-DOTZsOOoEtOY0ysY9L6JzyDHZm4lGBr6P1bt1mFXcRw=",
|
||||
"lastModified": 1795249095,
|
||||
"narHash": "sha256-8JDgyVvWUZg5m9hNlL8Ge9aT647ng3Ukc8NPMiKNTPQ=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "19cfded70b91ca0981373973c5b1efffdd4d6647",
|
||||
"rev": "93a9ed0a866099a230ed5146a5bb7d16fd5c9b14",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -1111,16 +1111,16 @@
|
||||
"nixpkgs": "nixpkgs_7"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1795561002,
|
||||
"narHash": "sha256-mrq0nZBocjR/cb7Ov7jKLF1XOTB3oXW2u3DptUQBPKY=",
|
||||
"ref": "fork/jujutsu-v0.17.4",
|
||||
"rev": "b9518180f0130c0ad00a1eb312f799fde5954e49",
|
||||
"revCount": 6784,
|
||||
"lastModified": 1795790016,
|
||||
"narHash": "sha256-a+U4/NT4sGMLRX4K9x4yhTn/wkb/8yAGS21p9WMKkws=",
|
||||
"ref": "fork/jujutsu-v0.17.5",
|
||||
"rev": "d871d1a678ddef68e5237f61a784f6f23b368ace",
|
||||
"revCount": 6850,
|
||||
"type": "git",
|
||||
"url": "https://git.nul.ie/dev/paseo"
|
||||
},
|
||||
"original": {
|
||||
"ref": "fork/jujutsu-v0.17.4",
|
||||
"ref": "fork/jujutsu-v0.17.5",
|
||||
"type": "git",
|
||||
"url": "https://git.nul.ie/dev/paseo"
|
||||
}
|
||||
@@ -1249,16 +1249,16 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1795563488,
|
||||
"narHash": "sha256-fTRKZn95BBANQpEGkhrmHSoPb9yTl59ZfvfzVbXeo5g=",
|
||||
"ref": "main",
|
||||
"rev": "21c2d4715ec3bcf4a90b41c16125db75c599b8b7",
|
||||
"revCount": 26,
|
||||
"lastModified": 1795984395,
|
||||
"narHash": "sha256-AiAdbNcyquBNZLJDE/dVQsYZlKdqlbNlh9XNfJd8jgw=",
|
||||
"ref": "refs/heads/progress",
|
||||
"rev": "6bce33dc66b232a5401ead98c29adef33eb895fd",
|
||||
"revCount": 62,
|
||||
"type": "git",
|
||||
"url": "https://git.nul.ie/dev/slop-broker"
|
||||
},
|
||||
"original": {
|
||||
"ref": "main",
|
||||
"ref": "refs/heads/progress",
|
||||
"type": "git",
|
||||
"url": "https://git.nul.ie/dev/slop-broker"
|
||||
}
|
||||
@@ -1421,11 +1421,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1795173499,
|
||||
"narHash": "sha256-J8IYl3oEdctyvBgWr+/L01MY5Xm0TU4WXwZDccN5jjk=",
|
||||
"lastModified": 1795615686,
|
||||
"narHash": "sha256-/C0FK2Fwq0aWE/GADYyYbAIdQeGfYBbWMin3tfks1NA=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "a0a97e31a897a3537eea5c49df4f8adaa83b3b37",
|
||||
"rev": "b7b56d3c8833016c650ca542b1230e6130299741",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -76,8 +76,8 @@
|
||||
llm-agents.url = "github:numtide/llm-agents.nix";
|
||||
# Our fork with Jujutsu support, one branch per upstream release it is rebased onto. Don't make
|
||||
# it follow our nixpkgs: its npm dependency hash is tied to its own nixpkgs pin.
|
||||
paseo.url = "git+https://git.nul.ie/dev/paseo?ref=fork/jujutsu-v0.17.4";
|
||||
slop-broker.url = "git+https://git.nul.ie/dev/slop-broker?ref=main";
|
||||
paseo.url = "git+https://git.nul.ie/dev/paseo?ref=fork/jujutsu-v0.17.5";
|
||||
slop-broker.url = "git+https://git.nul.ie/dev/slop-broker?ref=refs/heads/progress";
|
||||
slop-broker.inputs.nixpkgs.follows = "nixpkgs-unstable";
|
||||
borgthin.url = "github:devplayer0/borg";
|
||||
# TODO: Update borgthin so this works
|
||||
@@ -287,6 +287,8 @@
|
||||
(import ./pkgs { inherit lib pkgs; }) //
|
||||
(import ./openwrt { inherit pkgs inputs; }));
|
||||
|
||||
llmAgentPackages = import ./ci/llm-agent-packages.nix { inherit lib inputs nixfiles system; };
|
||||
|
||||
devShells.default = shell;
|
||||
|
||||
ci =
|
||||
@@ -301,7 +303,6 @@
|
||||
homes' // systems' // packages' // {
|
||||
inherit shell;
|
||||
};
|
||||
ciDrv = pkgs.linkFarm "ci" ci;
|
||||
|
||||
ciIfdReasons =
|
||||
let
|
||||
|
||||
@@ -7,21 +7,25 @@ let
|
||||
agentPkgs = inputs.llm-agents.packages.${pkgs.stdenv.hostPlatform.system};
|
||||
slopGuide = "${pkgs.slop-broker}/share/slop-broker/slop-tools.md";
|
||||
|
||||
# Claude takes a rule file each; Codex takes one `AGENTS.md`
|
||||
# Claude takes individual rule files. Codex and Antigravity share one `AGENTS.md`.
|
||||
rules = optionalAttrs cfg.slop.enable { slop = slopGuide; }
|
||||
// mapAttrs (name: text: pkgs.writeText "${name}.md" text) cfg.rules;
|
||||
codexContext = pkgs.concatText "AGENTS.md" (attrValues rules);
|
||||
agentContext = pkgs.concatText "AGENTS.md" (attrValues rules);
|
||||
in
|
||||
{
|
||||
options.my.agents = {
|
||||
enable = mkBoolOpt' false "Whether to install and configure coding agents (Claude Code, Codex).";
|
||||
antigravity.enable = mkBoolOpt' false "Whether to also install and configure Antigravity CLI.";
|
||||
slop.enable = mkBoolOpt' false "Whether agents use the `slop` client for privileged operations.";
|
||||
rules = mkOpt' (types.attrsOf types.lines) { }
|
||||
"Instructions for every agent, by name: a Claude rule each, and appended to Codex's `AGENTS.md`.";
|
||||
"Named instructions for every agent, installed as individual Claude rules and combined into an `AGENTS.md` for Codex and Antigravity.";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = optional cfg.slop.enable pkgs.slop-broker;
|
||||
home.file = mkIf (cfg.antigravity.enable && rules != { }) {
|
||||
".gemini/AGENTS.md".source = agentContext;
|
||||
};
|
||||
|
||||
programs = {
|
||||
# TODO: Remove mutableSettings guard when Home Manager 26.11 releases; 26.05 lacks it.
|
||||
@@ -46,7 +50,7 @@ in
|
||||
} // optionalAttrs (options.programs.codex ? mutableSettings) {
|
||||
mutableSettings = true;
|
||||
} // optionalAttrs (rules != { }) {
|
||||
context = "${codexContext}";
|
||||
context = "${agentContext}";
|
||||
};
|
||||
|
||||
claude-code = {
|
||||
@@ -63,6 +67,8 @@ in
|
||||
};
|
||||
};
|
||||
};
|
||||
} // optionalAttrs cfg.antigravity.enable {
|
||||
antigravity-cli.enable = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -379,6 +379,8 @@ in
|
||||
|
||||
my = {
|
||||
#deploy.generate.system.mode = "boot";
|
||||
network.bbr = true;
|
||||
|
||||
secrets = {
|
||||
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPIijqzAWF6OxKr4aeCa1TAc5xGn4rdIjVTt0wAPU6uY";
|
||||
files = {
|
||||
|
||||
@@ -180,6 +180,8 @@ in
|
||||
};
|
||||
|
||||
my = {
|
||||
network.bbr = true;
|
||||
|
||||
secrets = {
|
||||
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP+KINpHLMduBuW96JzfSRDLUzkI+XaCBghu5/wHiW5R";
|
||||
files = {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
{ lib, pkgs, config, assignments, allAssignments, ... }:
|
||||
let
|
||||
inherit (lib) mkMerge;
|
||||
inherit (lib) mkMerge mkAfter getExe;
|
||||
inherit (lib.my.c) pubDomain;
|
||||
inherit (lib.my.c.colony) prefixes;
|
||||
|
||||
# Pocket ID login source, client `gitea` (declared on `middleman`)
|
||||
oidcSource = "id.${pubDomain}";
|
||||
in
|
||||
{
|
||||
config = {
|
||||
@@ -48,6 +51,40 @@ in
|
||||
# The default /tmp is on the small tmpfs root, so keep them on the state volume.
|
||||
environment.TMPDIR = "${config.services.gitea.stateDir}/tmp";
|
||||
}
|
||||
{
|
||||
# Gitea keeps login sources in its database: add the Pocket ID one, or bring it up to
|
||||
# date. The server only reads them at startup, so this runs before it; a failure only
|
||||
# warns, so Gitea still starts. The CLI only takes the secret as an argument.
|
||||
preStart = mkAfter (
|
||||
let
|
||||
gitea = getExe config.services.gitea.package;
|
||||
in
|
||||
''
|
||||
oidc_source_setup() {
|
||||
local oidc_args=(
|
||||
--name '${oidcSource}'
|
||||
--provider openidConnect
|
||||
--key gitea
|
||||
--secret "$(< '${config.age.secrets."gitea/oidc-secret.txt".path}')"
|
||||
--auto-discover-url 'https://${oidcSource}/.well-known/openid-configuration'
|
||||
--scopes openid --scopes email --scopes profile
|
||||
)
|
||||
|
||||
local list oidc_id
|
||||
list="$(${gitea} admin auth list)" || return
|
||||
oidc_id="$(${pkgs.gawk}/bin/awk '$2 == "${oidcSource}" { print $1 }' <<< "$list")" || return
|
||||
if [ -n "$oidc_id" ]; then
|
||||
${gitea} admin auth update-oauth --id "$oidc_id" "''${oidc_args[@]}"
|
||||
else
|
||||
${gitea} admin auth add-oauth "''${oidc_args[@]}"
|
||||
fi
|
||||
}
|
||||
|
||||
if ! oidc_source_setup; then
|
||||
echo "Couldn't set up the ${oidcSource} login source; starting without it" >&2
|
||||
fi
|
||||
'');
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
@@ -139,6 +176,8 @@ in
|
||||
"gitea/db.txt" = ownedByGit;
|
||||
"gitea/mail.txt" = ownedByGit;
|
||||
"gitea/minio.txt" = ownedByGit;
|
||||
# Shared with `middleman`, which registers it with Pocket ID
|
||||
"gitea/oidc-secret.txt" = ownedByGit;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
{ lib, config, ... }:
|
||||
let
|
||||
inherit (lib) attrNames filterAttrs;
|
||||
inherit (lib.my.c) pubDomain;
|
||||
|
||||
# Vhosts gated by `ssoServer` in `vhosts.nix`, each with its own `/oauth2/` endpoints
|
||||
ssoVhosts = attrNames (filterAttrs (_: v: v.locations ? "= /oauth2/auth") config.services.nginx.virtualHosts);
|
||||
in
|
||||
{
|
||||
my = {
|
||||
secrets.files = {
|
||||
# Pocket ID's database encryption key; it reads it through `LoadCredential`
|
||||
"middleman/pocket-id-encryption-key" = { };
|
||||
# Admin key for `pocket-id-sync`, which only works from inside (`vhosts.nix` strips it)
|
||||
"middleman/pocket-id-api-key" = { };
|
||||
# `OAUTH2_PROXY_CLIENT_SECRET` and `OAUTH2_PROXY_COOKIE_SECRET`
|
||||
"middleman/oauth2-proxy.env" = { };
|
||||
# Client secrets shared with the boxes that run the apps
|
||||
"gitea/oidc-secret.txt" = { };
|
||||
# Not deployed anywhere else: mailcow isn't NixOS, so it's pasted into its admin UI
|
||||
"mailcow/oidc-secret.txt" = { };
|
||||
};
|
||||
|
||||
pocket-id = {
|
||||
enable = true;
|
||||
apiKeyFile = config.age.secrets."middleman/pocket-id-api-key".path;
|
||||
|
||||
groups = {
|
||||
admins.friendlyName = "Admins";
|
||||
};
|
||||
|
||||
clients = {
|
||||
# oauth2-proxy, which gates vhosts that have no sign-in of their own (`ssoServer`)
|
||||
sso = {
|
||||
name = "nul.ie SSO";
|
||||
callbackURLs = map (h: "https://${h}/oauth2/callback") ssoVhosts;
|
||||
pkce = true;
|
||||
allowedGroups = [ "admins" ];
|
||||
extraSettings.skipConsent = true;
|
||||
secret = {
|
||||
file = config.age.secrets."middleman/oauth2-proxy.env".path;
|
||||
key = "OAUTH2_PROXY_CLIENT_SECRET";
|
||||
};
|
||||
};
|
||||
|
||||
# Gitea's `id.nul.ie` login source (`git` VM)
|
||||
gitea = {
|
||||
name = "Gitea";
|
||||
callbackURLs = [ "https://git.${pubDomain}/user/oauth2/id.${pubDomain}/callback" ];
|
||||
launchURL = "https://git.${pubDomain}/";
|
||||
secret.file = config.age.secrets."gitea/oidc-secret.txt".path;
|
||||
};
|
||||
|
||||
# mailcow's Generic-OIDC identity provider (`mail` VM), for mailbox sign-in
|
||||
mailcow = {
|
||||
name = "mailcow";
|
||||
callbackURLs = [ "https://mail.${pubDomain}" "https://mail.${pubDomain}/" ];
|
||||
launchURL = "https://mail.${pubDomain}/";
|
||||
secret.file = config.age.secrets."mailcow/oidc-secret.txt".path;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# oauth2-proxy talks to Pocket ID through the local nginx rather than out and back in
|
||||
networking.hosts = {
|
||||
"127.0.0.1" = [ "id.${pubDomain}" ];
|
||||
"::1" = [ "id.${pubDomain}" ];
|
||||
};
|
||||
|
||||
services = {
|
||||
# Passkey-only OpenID Connect provider at `id.nul.ie`, published by nginx
|
||||
pocket-id = {
|
||||
settings = {
|
||||
APP_URL = "https://id.${pubDomain}";
|
||||
HOST = "127.0.0.1";
|
||||
PORT = 1411;
|
||||
TRUST_PROXY = true;
|
||||
ANALYTICS_DISABLED = true;
|
||||
};
|
||||
credentials.ENCRYPTION_KEY = config.age.secrets."middleman/pocket-id-encryption-key".path;
|
||||
};
|
||||
|
||||
# Single sign-on for every `.nul.ie` vhost behind `ssoServer` in `vhosts.nix`
|
||||
oauth2-proxy = {
|
||||
enable = true;
|
||||
provider = "oidc";
|
||||
oidcIssuerUrl = "https://id.${pubDomain}";
|
||||
clientID = "sso";
|
||||
# On the vhost being signed in to
|
||||
redirectURL = "/oauth2/callback";
|
||||
keyFile = config.age.secrets."middleman/oauth2-proxy.env".path;
|
||||
# `offline_access` for a refresh token, so sessions can be checked again without a passkey
|
||||
scope = "openid email profile groups offline_access";
|
||||
approvalPrompt = "auto";
|
||||
# Access is decided by Pocket ID group (`allowed_groups` in `ssoServer`)
|
||||
email.domains = [ "*" ];
|
||||
|
||||
httpAddress = "http://127.0.0.1:4180";
|
||||
reverseProxy = true;
|
||||
trustedProxyIP = [ "127.0.0.1" ];
|
||||
setXauthrequest = true;
|
||||
|
||||
cookie = {
|
||||
# Host-only, so the cookie is only sent to the vhost it was issued for
|
||||
secure = true;
|
||||
# Sessions last a week, but Pocket ID checks the user (and their groups) every hour
|
||||
expire = "168h";
|
||||
refresh = "1h";
|
||||
};
|
||||
|
||||
extraConfig = {
|
||||
code-challenge-method = "S256";
|
||||
skip-provider-button = true;
|
||||
# Pocket ID doesn't verify email addresses, and they aren't used for access here
|
||||
insecure-oidc-allow-unverified-email = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.oauth2-proxy = {
|
||||
wants = [ "pocket-id-sync.service" ];
|
||||
after = [ "pocket-id-sync.service" "nginx.service" ];
|
||||
};
|
||||
}
|
||||
@@ -29,13 +29,14 @@ in
|
||||
inherit (lib.my) networkdAssignment;
|
||||
in
|
||||
{
|
||||
imports = [ ./vhosts.nix ];
|
||||
imports = [ ./auth.nix ./vhosts.nix ];
|
||||
|
||||
config = mkMerge [
|
||||
{
|
||||
my = {
|
||||
deploy.enable = false;
|
||||
server.enable = true;
|
||||
network.bbr = true;
|
||||
|
||||
secrets = {
|
||||
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAQM9U1e/XcUCyMJITrpAHjAGahpqkZCmtX6pJkYzuks";
|
||||
@@ -53,17 +54,11 @@ in
|
||||
group = "acme";
|
||||
mode = "400";
|
||||
};
|
||||
"middleman/nginx-sso.yaml" = {
|
||||
owner = "nginx-sso";
|
||||
group = "nginx-sso";
|
||||
};
|
||||
"middleman/htpasswd" = {
|
||||
owner = "nginx";
|
||||
group = "nginx";
|
||||
};
|
||||
"librespeed.toml" = { };
|
||||
# Pocket ID's database encryption key; it reads it through `LoadCredential`
|
||||
"middleman/pocket-id-encryption-key" = { };
|
||||
};
|
||||
};
|
||||
|
||||
@@ -78,56 +73,6 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
nginx-sso = {
|
||||
enable = true;
|
||||
extraConfigFile = config.age.secrets."middleman/nginx-sso.yaml".path;
|
||||
configuration = {
|
||||
listen = {
|
||||
addr = "[::]";
|
||||
port = 8082;
|
||||
};
|
||||
login = {
|
||||
title = "${pubDomain} login";
|
||||
default_redirect = "https://${pubDomain}";
|
||||
default_method = "google_oauth";
|
||||
names = {
|
||||
google_oauth = "Google account";
|
||||
simple = "Username / password";
|
||||
};
|
||||
};
|
||||
cookie = {
|
||||
domain = ".${pubDomain}";
|
||||
secure = true;
|
||||
};
|
||||
audit_log = {
|
||||
targets = [ "fd://stdout" ];
|
||||
events = [
|
||||
"access_denied"
|
||||
"login_success"
|
||||
"login_failure"
|
||||
"logout"
|
||||
#"validate"
|
||||
];
|
||||
};
|
||||
providers = {
|
||||
simple = {
|
||||
groups = {
|
||||
admin = [ "dev" ];
|
||||
};
|
||||
};
|
||||
google_oauth = {
|
||||
client_id = "545475967061-cag4g1qf0pk33g3pdbom4v69562vboc8.apps.googleusercontent.com";
|
||||
redirect_url = "https://sso.${pubDomain}/login";
|
||||
user_id_method = "user-id";
|
||||
};
|
||||
};
|
||||
};
|
||||
includes = {
|
||||
endpoint = "http://localhost:8082";
|
||||
baseURL = "https://sso.${pubDomain}";
|
||||
};
|
||||
};
|
||||
|
||||
librespeed = {
|
||||
frontend.servers = [
|
||||
{
|
||||
@@ -226,19 +171,6 @@ in
|
||||
};
|
||||
|
||||
services = {
|
||||
# Passkey-only OpenID Connect provider at `id.nul.ie`, published by nginx
|
||||
pocket-id = {
|
||||
enable = true;
|
||||
settings = {
|
||||
APP_URL = "https://id.${pubDomain}";
|
||||
HOST = "127.0.0.1";
|
||||
PORT = 1411;
|
||||
TRUST_PROXY = true;
|
||||
ANALYTICS_DISABLED = true;
|
||||
};
|
||||
credentials.ENCRYPTION_KEY = config.age.secrets."middleman/pocket-id-encryption-key".path;
|
||||
};
|
||||
|
||||
netdata = {
|
||||
enable = true;
|
||||
configDir = {
|
||||
|
||||
@@ -9,14 +9,40 @@ let
|
||||
dualStackListen' = l: map (addr: l // { inherit addr; }) [ "0.0.0.0" "[::]" ];
|
||||
dualStackListen = ll: flatten (map dualStackListen' ll);
|
||||
|
||||
ssoServer = i: {
|
||||
# Gate a vhost behind oauth2-proxy, for members of any of the given Pocket ID groups. The
|
||||
# session cookie is host-only, so other `.nul.ie` sites never see it; Pocket ID's own session
|
||||
# makes signing in to the next gated vhost a redirect.
|
||||
oauth2Proxy = config.services.oauth2-proxy.httpAddress;
|
||||
ssoServer = groups: {
|
||||
locations = {
|
||||
"^~ /oauth2/" = {
|
||||
proxyPass = oauth2Proxy;
|
||||
extraConfig = ''
|
||||
auth_request off;
|
||||
${proxyHeaders}
|
||||
# Where to return after signing in; on a 401 this is still the original request
|
||||
proxy_set_header X-Auth-Request-Redirect $request_uri;
|
||||
'';
|
||||
};
|
||||
# A literal `proxy_pass`: `proxyPass` sets `$nix_proxy_target`, which this subrequest would
|
||||
# overwrite for the main request too
|
||||
"= /oauth2/auth".extraConfig = ''
|
||||
proxy_pass ${oauth2Proxy}/oauth2/auth?allowed_groups=${concatStringsSep "," groups};
|
||||
internal;
|
||||
auth_request off;
|
||||
proxy_pass_request_body off;
|
||||
proxy_set_header Content-Length "";
|
||||
${proxyHeaders}
|
||||
'';
|
||||
};
|
||||
# A location with its own `add_header` would drop the refreshed cookie
|
||||
extraConfig = ''
|
||||
include /etc/nginx/includes/sso/server-${i}.conf;
|
||||
'';
|
||||
};
|
||||
ssoLoc = i: {
|
||||
extraConfig = ''
|
||||
include /etc/nginx/includes/sso/location-${i}.conf;
|
||||
auth_request /oauth2/auth;
|
||||
error_page 401 = /oauth2/start;
|
||||
|
||||
# Pass on the session cookie when a check refreshes it
|
||||
auth_request_set $sso_cookie $upstream_http_set_cookie;
|
||||
add_header Set-Cookie $sso_cookie;
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -58,12 +84,6 @@ let
|
||||
};
|
||||
in
|
||||
{
|
||||
my = {
|
||||
nginx-sso.includes.instances = {
|
||||
generic = {};
|
||||
};
|
||||
};
|
||||
|
||||
services.nginx.virtualHosts =
|
||||
let
|
||||
hosts = {
|
||||
@@ -111,11 +131,6 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
"sso.${pubDomain}" = {
|
||||
locations."/".proxyPass = config.my.nginx-sso.includes.endpoint;
|
||||
useACMEHost = pubDomain;
|
||||
};
|
||||
|
||||
"netdata-colony.${pubDomain}" =
|
||||
let
|
||||
hosts = [
|
||||
@@ -130,26 +145,23 @@ in
|
||||
locations = {
|
||||
"= /".return = "301 https://$host/vm/";
|
||||
"~ /(?<behost>${matchHosts})$".return = "301 https://$host/$behost/";
|
||||
"~ /(?<behost>${matchHosts})/(?<ndpath>.*)" = mkMerge [
|
||||
{
|
||||
proxyPass = "http://$behost.${domain}:19999/$ndpath$is_args$args";
|
||||
extraConfig = ''
|
||||
proxy_pass_request_headers on;
|
||||
${proxyHeaders}
|
||||
proxy_set_header Connection "keep-alive";
|
||||
proxy_store off;
|
||||
"~ /(?<behost>${matchHosts})/(?<ndpath>.*)" = {
|
||||
proxyPass = "http://$behost.${domain}:19999/$ndpath$is_args$args";
|
||||
extraConfig = ''
|
||||
proxy_pass_request_headers on;
|
||||
${proxyHeaders}
|
||||
proxy_set_header Connection "keep-alive";
|
||||
proxy_store off;
|
||||
|
||||
gzip on;
|
||||
gzip_proxied any;
|
||||
gzip_types *;
|
||||
'';
|
||||
}
|
||||
(ssoLoc "generic")
|
||||
];
|
||||
gzip on;
|
||||
gzip_proxied any;
|
||||
gzip_types *;
|
||||
'';
|
||||
};
|
||||
};
|
||||
useACMEHost = pubDomain;
|
||||
}
|
||||
(ssoServer "generic")
|
||||
(ssoServer [ "admins" ])
|
||||
];
|
||||
|
||||
"pass.${pubDomain}" =
|
||||
@@ -242,56 +254,40 @@ in
|
||||
|
||||
"torrents.${pubDomain}" = mkMerge [
|
||||
{
|
||||
locations."/" = mkMerge [
|
||||
{
|
||||
proxyPass = "http://jackflix-ctr.${domain}:9091";
|
||||
}
|
||||
(ssoLoc "generic")
|
||||
];
|
||||
locations."/".proxyPass = "http://jackflix-ctr.${domain}:9091";
|
||||
useACMEHost = pubDomain;
|
||||
}
|
||||
(ssoServer "generic")
|
||||
(ssoServer [ "admins" ])
|
||||
];
|
||||
|
||||
"jackett.${pubDomain}" = mkMerge [
|
||||
{
|
||||
locations."/" = mkMerge [
|
||||
{
|
||||
proxyPass = "http://jackflix-ctr.${domain}:9117";
|
||||
}
|
||||
(ssoLoc "generic")
|
||||
];
|
||||
locations."/".proxyPass = "http://jackflix-ctr.${domain}:9117";
|
||||
useACMEHost = pubDomain;
|
||||
}
|
||||
(ssoServer "generic")
|
||||
(ssoServer [ "admins" ])
|
||||
];
|
||||
"radarr.${pubDomain}" = mkMerge [
|
||||
{
|
||||
locations."/" = mkMerge [
|
||||
{
|
||||
proxyPass = "http://jackflix-ctr.${domain}:7878";
|
||||
proxyWebsockets = true;
|
||||
extraConfig = proxyHeaders;
|
||||
}
|
||||
(ssoLoc "generic")
|
||||
];
|
||||
locations."/" = {
|
||||
proxyPass = "http://jackflix-ctr.${domain}:7878";
|
||||
proxyWebsockets = true;
|
||||
extraConfig = proxyHeaders;
|
||||
};
|
||||
useACMEHost = pubDomain;
|
||||
}
|
||||
(ssoServer "generic")
|
||||
(ssoServer [ "admins" ])
|
||||
];
|
||||
"sonarr.${pubDomain}" = mkMerge [
|
||||
{
|
||||
locations."/" = mkMerge [
|
||||
{
|
||||
proxyPass = "http://jackflix-ctr.${domain}:8989";
|
||||
proxyWebsockets = true;
|
||||
extraConfig = proxyHeaders;
|
||||
}
|
||||
(ssoLoc "generic")
|
||||
];
|
||||
locations."/" = {
|
||||
proxyPass = "http://jackflix-ctr.${domain}:8989";
|
||||
proxyWebsockets = true;
|
||||
extraConfig = proxyHeaders;
|
||||
};
|
||||
useACMEHost = pubDomain;
|
||||
}
|
||||
(ssoServer "generic")
|
||||
(ssoServer [ "admins" ])
|
||||
];
|
||||
"gib.${pubDomain}" = {
|
||||
locations."/".proxyPass = "http://jackflix-ctr.${domain}:5055";
|
||||
@@ -427,9 +423,14 @@ in
|
||||
|
||||
"id.${pubDomain}" =
|
||||
let
|
||||
# API keys (including `pocket-id-sync`'s admin key) only work from inside
|
||||
pocketIdHeaders = ''
|
||||
${proxyHeaders}
|
||||
proxy_set_header X-API-Key "";
|
||||
'';
|
||||
pocketId = {
|
||||
proxyPass = "http://127.0.0.1:${toString config.services.pocket-id.settings.PORT}";
|
||||
extraConfig = proxyHeaders;
|
||||
extraConfig = pocketIdHeaders;
|
||||
};
|
||||
in
|
||||
{
|
||||
@@ -440,7 +441,7 @@ in
|
||||
extraConfig = ''
|
||||
${concatStringsSep "\n" (map (n: "allow ${n};") (with lib.my.c.internalNets; v4 ++ v6))}
|
||||
deny all;
|
||||
${proxyHeaders}
|
||||
${pocketIdHeaders}
|
||||
'';
|
||||
};
|
||||
};
|
||||
@@ -470,24 +471,18 @@ in
|
||||
|
||||
"pront.${pubDomain}" = mkMerge [
|
||||
{
|
||||
locations."/" = mkMerge [
|
||||
{
|
||||
proxyPass = "http://stream-hi.${home.domain}:5000";
|
||||
proxyWebsockets = true;
|
||||
extraConfig = proxyHeaders;
|
||||
}
|
||||
(ssoLoc "generic")
|
||||
];
|
||||
locations."~* ^/webcam/(.*)" = mkMerge [
|
||||
{
|
||||
proxyPass = "http://stream-hi.${home.domain}:5050/$1$is_args$args";
|
||||
extraConfig = proxyHeaders;
|
||||
}
|
||||
(ssoLoc "generic")
|
||||
];
|
||||
locations."/" = {
|
||||
proxyPass = "http://stream-hi.${home.domain}:5000";
|
||||
proxyWebsockets = true;
|
||||
extraConfig = proxyHeaders;
|
||||
};
|
||||
locations."~* ^/webcam/(.*)" = {
|
||||
proxyPass = "http://stream-hi.${home.domain}:5050/$1$is_args$args";
|
||||
extraConfig = proxyHeaders;
|
||||
};
|
||||
useACMEHost = pubDomain;
|
||||
}
|
||||
(ssoServer "generic")
|
||||
(ssoServer [ "admins" ])
|
||||
];
|
||||
"hass.${pubDomain}" = {
|
||||
locations."/" = {
|
||||
|
||||
@@ -166,6 +166,7 @@ in
|
||||
my = {
|
||||
secrets.key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ6bc1pQCYalLXdB4X+7kFXtkTdFalbH5rchjuYj2ceU";
|
||||
server.enable = true;
|
||||
network.bbr = true;
|
||||
|
||||
firewall = {
|
||||
tcp.allowed = [ 19999 ];
|
||||
|
||||
@@ -162,6 +162,7 @@ in
|
||||
my = {
|
||||
secrets.key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDBTIj1jVdknXLNNroMJfgy7S2cSUC/qgFdnaUopEUzZ";
|
||||
server.enable = true;
|
||||
network.bbr = true;
|
||||
|
||||
firewall = {
|
||||
tcp.allowed = [ 19999 ];
|
||||
|
||||
@@ -221,6 +221,7 @@ in
|
||||
|
||||
my = {
|
||||
tmproot.size = "24G";
|
||||
network.bbr = true;
|
||||
|
||||
user = {
|
||||
config.extraGroups = [ "input" ];
|
||||
@@ -280,6 +281,7 @@ in
|
||||
};
|
||||
|
||||
my = {
|
||||
agents.antigravity.enable = true;
|
||||
gui = {
|
||||
standalone = true;
|
||||
manageGraphical = true;
|
||||
|
||||
@@ -86,9 +86,10 @@ in
|
||||
};
|
||||
|
||||
# NVMe-oF disks connected here belong to guests (`palace` has no NVMe of its own; its
|
||||
# drives are passed to `cellar`); never activate their volume groups
|
||||
# drives are passed to `cellar`); never activate their volume groups. No accept pattern:
|
||||
# LVM accepts a device if any of its other names (`/dev/disk/by-*`) is accepted.
|
||||
environment.etc."lvm/lvm.conf".text = ''
|
||||
devices/global_filter = [ "r|^/dev/nvme|" "a|.*|" ]
|
||||
devices/global_filter = [ "r|^/dev/nvme|" ]
|
||||
'';
|
||||
|
||||
services = {
|
||||
|
||||
@@ -78,6 +78,7 @@
|
||||
|
||||
services.slop-broker = {
|
||||
enable = true;
|
||||
timeout = "45m";
|
||||
approvers = [ config.my.user.config.name ];
|
||||
|
||||
# For coding agents, wherever they run
|
||||
|
||||
@@ -76,6 +76,24 @@ in
|
||||
- Read a pull request and its comments with `tea pulls <index> --comments`, and reply with
|
||||
`tea comment <index> "<text>"`.
|
||||
- The repository's commit conventions still apply.
|
||||
|
||||
# Running notes in issues
|
||||
|
||||
Keep notes about work in progress (plans, where it stands, what's next, handoffs to
|
||||
another agent) in Gitea issues on the repository they're about, not in files in the
|
||||
repository or on branches, which go stale.
|
||||
|
||||
- Use one issue per piece of work, and keep its description current: what it's for, where
|
||||
it stands, what's next and open questions. Add progress and findings as comments.
|
||||
- Create one with `tea issues create --title "<summary>" --description-file <file>`, and
|
||||
update it with `tea issues edit <index> --description-file <file>`. List with
|
||||
`tea issues`, read one with `tea issues <index> --comments`, and comment with
|
||||
`tea comment <index> "<text>"`.
|
||||
- Mention the issue (`#<index>`) in pull requests that move it on. Closing keywords such
|
||||
as "fixes #<index>" close it when the pull request merges, so only use them when that
|
||||
finishes the work.
|
||||
- When the work is done, put what lasts in the repository's docs (its `AGENTS.md` says
|
||||
where) and close the issue with `tea issues close <index>`.
|
||||
'';
|
||||
|
||||
slopClone = pkgs.writeShellApplication {
|
||||
@@ -224,8 +242,17 @@ in
|
||||
home-manager.users.${agentUser} = {
|
||||
my.agents = {
|
||||
enable = true;
|
||||
antigravity.enable = true;
|
||||
slop.enable = true;
|
||||
rules.gitea = giteaRule;
|
||||
rules.slop-approvals = ''
|
||||
# Slop approval requests
|
||||
|
||||
Run `slop` in a background session when it may need approval so it can stay
|
||||
connected for the broker's configured approval window. If a request expires and
|
||||
the task still depends on it, tell the user what is blocked and pause for their
|
||||
direction. Continue any independent work you can do under the existing approvals.
|
||||
'';
|
||||
};
|
||||
|
||||
home.packages = [ slopClone slopPair tea ];
|
||||
@@ -339,8 +366,11 @@ in
|
||||
voiceMode.enabled = false;
|
||||
};
|
||||
agents.providers = lib.genAttrs
|
||||
[ "copilot" "opencode" "pi" "omp" "antigravity" "muse" ]
|
||||
(_: { enabled = false; });
|
||||
[ "copilot" "opencode" "pi" "omp" "muse" ]
|
||||
(_: { enabled = false; }) // {
|
||||
# Use the token file from the agent user's SSH login.
|
||||
antigravity.env.SSH_CONNECTION = "paseo";
|
||||
};
|
||||
log.file.level = "info";
|
||||
};
|
||||
};
|
||||
|
||||
@@ -317,6 +317,7 @@ in
|
||||
as211024 = config.age.secrets."l2mesh/as211024.key".path;
|
||||
};
|
||||
};
|
||||
network.bbr = true;
|
||||
firewall = {
|
||||
trustedInterfaces = [ "lan-hi" "lan-lo" ];
|
||||
udp.allowed = [ 5353 ];
|
||||
|
||||
@@ -160,6 +160,8 @@
|
||||
user = {
|
||||
tmphome = false;
|
||||
homeConfig = {
|
||||
my.agents.antigravity.enable = true;
|
||||
|
||||
services = {
|
||||
network-manager-applet.enable = true;
|
||||
};
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
vms = ./vms.nix;
|
||||
network = ./network.nix;
|
||||
pdns = ./pdns.nix;
|
||||
nginx-sso = ./nginx-sso.nix;
|
||||
pocket-id = ./pocket-id;
|
||||
gui = ./gui;
|
||||
l2mesh = ./l2mesh.nix;
|
||||
borgthin = ./borgthin.nix;
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
{ lib, pkgs, config, ... }:
|
||||
let
|
||||
inherit (lib) flatten optional mkIf mkDefault mkMerge versionAtLeast;
|
||||
inherit (lib.my) mkBoolOpt';
|
||||
|
||||
cfg = config.my.network;
|
||||
in
|
||||
{
|
||||
options.my.network.bbr = mkBoolOpt' false
|
||||
("Whether to use BBR congestion control for TCP connections this box sends. Unlike the default " +
|
||||
"(CUBIC), BBR doesn't treat packet loss as congestion, so it keeps throughput up on lossy paths. " +
|
||||
"It has no effect on traffic the box forwards.");
|
||||
|
||||
config = mkMerge [
|
||||
{
|
||||
networking = {
|
||||
@@ -22,6 +30,16 @@ in
|
||||
};
|
||||
}
|
||||
|
||||
(mkIf cfg.bbr {
|
||||
# BBR paces its own sending, so the default qdisc (fq_codel) stays as it is. A container's
|
||||
# network namespace copies the host's setting only when it's created, so enable this in
|
||||
# containers too for it to apply without a restart.
|
||||
boot = {
|
||||
kernelModules = [ "tcp_bbr" ];
|
||||
kernel.sysctl."net.ipv4.tcp_congestion_control" = "bbr";
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf config.my.build.isDevVM {
|
||||
networking.interfaces.eth0.useDHCP = mkDefault true;
|
||||
virtualisation = {
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
{ lib, pkgs, config, ... }:
|
||||
let
|
||||
inherit (lib) mkIf mkMerge getBin mapAttrsToList;
|
||||
inherit (lib.my) mkOpt' mkBoolOpt';
|
||||
|
||||
includeOpts = { ... }: {
|
||||
options = with lib.types; {
|
||||
auth = {
|
||||
path = mkOpt' str "/sso-auth" "HTTP path for SSO auth.";
|
||||
redirect = mkOpt' str "$scheme://$http_host$request_uri" "URL to redirect to upon successful login.";
|
||||
};
|
||||
logout = {
|
||||
path = mkOpt' str "/sso-logout" "HTTP path for SSO logout.";
|
||||
redirect = mkOpt' str "$scheme://$http_host/" "URL to redirect to upon successful logout.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
cfg = config.my.nginx-sso;
|
||||
|
||||
pkg = getBin cfg.package;
|
||||
baseConfig = pkgs.writeText "nginx-sso.yaml" (builtins.toJSON cfg.configuration);
|
||||
runCfg = "/run/nginx-sso/config.yaml";
|
||||
in
|
||||
{
|
||||
options.my.nginx-sso = with lib.types; {
|
||||
enable = mkBoolOpt' false "Whether to enable custom nginx-sso.";
|
||||
package = mkOpt' package pkgs.nginx-sso "nginx-sso package to use.";
|
||||
configuration = mkOpt' (attrsOf unspecified) { } "nginx-sso configuration.";
|
||||
extraConfigFile = mkOpt' (nullOr str) null "Path to configuration (e.g. for secrets).";
|
||||
|
||||
includes = {
|
||||
endpoint = mkOpt' str "http://localhost:8082" "Upstream for proxied auth requests.";
|
||||
baseURL = mkOpt' str null "Base URL for redirects.";
|
||||
|
||||
instances = mkOpt' (attrsOf (submodule includeOpts)) { } "nginx includes instances.";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = !config.services.nginx.sso.enable;
|
||||
message = "Stock nginx-sso cannot be used with this module.";
|
||||
}
|
||||
];
|
||||
|
||||
environment.etc = with cfg.includes; mkMerge (mapAttrsToList (n: i: {
|
||||
"nginx/includes/sso/server-${n}.conf".text = ''
|
||||
location ${i.auth.path} {
|
||||
# Do not allow requests from outside
|
||||
internal;
|
||||
|
||||
# Access /auth endpoint to query login state
|
||||
proxy_pass ${endpoint}/auth;
|
||||
|
||||
# Do not forward the request body (nginx-sso does not care about it)
|
||||
proxy_pass_request_body off;
|
||||
proxy_set_header Content-Length "";
|
||||
|
||||
# Set custom information for ACL matching: Each one is available as
|
||||
# a field for matching: X-Host = x-host, ...
|
||||
proxy_set_header X-Origin-URI $request_uri;
|
||||
proxy_set_header X-Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
# Define where to send the user to login and specify how to get back
|
||||
location @error401 {
|
||||
return 302 ${baseURL}/login?go=${i.auth.redirect};
|
||||
}
|
||||
|
||||
# If the user is lead to /logout redirect them to the logout endpoint
|
||||
# of ngninx-sso which then will redirect the user to / on the current host
|
||||
location ${i.logout.path} {
|
||||
return 302 ${baseURL}/logout?go=${i.logout.redirect};
|
||||
}
|
||||
'';
|
||||
"nginx/includes/sso/location-${n}.conf".text = ''
|
||||
# Protect this location using the auth_request
|
||||
auth_request ${i.auth.path};
|
||||
|
||||
# Redirect the user to the login page when they are not logged in
|
||||
error_page 401 = @error401;
|
||||
|
||||
# Automatically renew SSO cookie on request
|
||||
auth_request_set $cookie $upstream_http_set_cookie;
|
||||
add_header Set-Cookie $cookie;
|
||||
'';
|
||||
}) instances);
|
||||
|
||||
users = {
|
||||
groups.nginx-sso = {};
|
||||
users.nginx-sso = {
|
||||
group = "nginx-sso";
|
||||
isSystemUser = true;
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.nginx-sso = {
|
||||
description = "Nginx SSO Backend";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
preStart = ''
|
||||
umask 066
|
||||
${if (cfg.extraConfigFile != null) then ''
|
||||
${pkgs.yq-go}/bin/yq -P '. *= load("${cfg.extraConfigFile}")' "${baseConfig}" > ${runCfg}
|
||||
'' else ''
|
||||
${pkgs.yq-go}/bin/yq -P "${baseConfig}" > ${runCfg}
|
||||
''}
|
||||
'';
|
||||
serviceConfig = {
|
||||
RuntimeDirectory = "nginx-sso";
|
||||
User = "nginx-sso";
|
||||
Group = "nginx-sso";
|
||||
ExecStart = [
|
||||
# Specify twice to clear original value
|
||||
""
|
||||
''${pkg}/bin/nginx-sso --frontend-dir ${pkg}/share/frontend --config ${runCfg}''
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
{ lib, pkgs, config, ... }:
|
||||
let
|
||||
inherit (lib) mkIf mapAttrsToList filterAttrs;
|
||||
inherit (lib.my) mkOpt' mkBoolOpt';
|
||||
|
||||
cfg = config.my.pocket-id;
|
||||
pocketId = config.services.pocket-id;
|
||||
|
||||
groupOpts = { name, ... }: {
|
||||
options = with lib.types; {
|
||||
friendlyName = mkOpt' str name "Name shown in Pocket ID's UI.";
|
||||
};
|
||||
};
|
||||
|
||||
clientOpts = { name, ... }: {
|
||||
options = with lib.types; {
|
||||
name = mkOpt' str name "Name shown to users when they sign in.";
|
||||
callbackURLs = mkOpt' (listOf str) [ ] "Allowed redirect URLs after sign-in.";
|
||||
logoutCallbackURLs = mkOpt' (listOf str) [ ] "Allowed redirect URLs after sign-out.";
|
||||
launchURL = mkOpt' (nullOr str) null "URL that Pocket ID's app list links to.";
|
||||
public = mkBoolOpt' false "Whether this is a public client (no secret).";
|
||||
pkce = mkBoolOpt' false "Whether to require PKCE.";
|
||||
allowedGroups = mkOpt' (listOf str) [ ]
|
||||
"Pocket ID groups (by name) whose members may sign in; any user may when empty.";
|
||||
secret = {
|
||||
file = mkOpt' (nullOr path) null "File holding the client secret.";
|
||||
key = mkOpt' (nullOr str) null
|
||||
"Read the secret from this key of an env file instead of the whole file.";
|
||||
};
|
||||
extraSettings = mkOpt' (attrsOf unspecified) { }
|
||||
"Extra fields of Pocket ID's client API object (e.g. `skipConsent`).";
|
||||
};
|
||||
};
|
||||
|
||||
spec = pkgs.writeText "pocket-id-sync.json" (builtins.toJSON {
|
||||
groups = mapAttrsToList (n: g: { name = n; inherit (g) friendlyName; }) cfg.groups;
|
||||
clients = mapAttrsToList (id: c: {
|
||||
inherit id;
|
||||
groups = c.allowedGroups;
|
||||
secret = c.secret.file != null;
|
||||
secretKey = c.secret.key;
|
||||
settings = {
|
||||
inherit (c) name callbackURLs logoutCallbackURLs launchURL;
|
||||
isPublic = c.public;
|
||||
pkceEnabled = c.pkce;
|
||||
isGroupRestricted = c.allowedGroups != [ ];
|
||||
} // c.extraSettings;
|
||||
}) cfg.clients;
|
||||
});
|
||||
|
||||
sync = pkgs.writers.writePython3 "pocket-id-sync" {
|
||||
flakeIgnore = [ "E501" ];
|
||||
} (builtins.readFile ./sync.py);
|
||||
in
|
||||
{
|
||||
options.my.pocket-id = with lib.types; {
|
||||
enable = mkBoolOpt' false "Whether to manage Pocket ID groups and OIDC clients declaratively.";
|
||||
apiKeyFile = mkOpt' path null "File holding Pocket ID's static API key (at least 16 characters).";
|
||||
groups = mkOpt' (attrsOf (submodule groupOpts)) { }
|
||||
"User groups to create; membership is managed in Pocket ID.";
|
||||
clients = mkOpt' (attrsOf (submodule clientOpts)) { } "OIDC clients, by client ID.";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
assertions = mapAttrsToList (id: c: {
|
||||
assertion = c.public == (c.secret.file == null);
|
||||
message = "my.pocket-id.clients.${id}: a client needs a secret unless it is public.";
|
||||
}) cfg.clients;
|
||||
|
||||
services.pocket-id = {
|
||||
enable = true;
|
||||
credentials.STATIC_API_KEY = cfg.apiKeyFile;
|
||||
};
|
||||
|
||||
systemd.services.pocket-id-sync = {
|
||||
description = "Pocket ID groups and OIDC clients";
|
||||
requires = [ "pocket-id.service" ];
|
||||
after = [ "pocket-id.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
ExecStart = "${sync} ${spec} http://127.0.0.1:${toString pocketId.settings.PORT}";
|
||||
DynamicUser = true;
|
||||
RuntimeDirectory = "pocket-id-sync";
|
||||
StateDirectory = "pocket-id-sync";
|
||||
LoadCredential = [ "api-key:${cfg.apiKeyFile}" ]
|
||||
++ mapAttrsToList (id: c: "client-${id}:${c.secret.file}")
|
||||
(filterAttrs (_: c: c.secret.file != null) cfg.clients);
|
||||
|
||||
CapabilityBoundingSet = "";
|
||||
NoNewPrivileges = true;
|
||||
PrivateDevices = true;
|
||||
PrivateTmp = true;
|
||||
ProtectHome = true;
|
||||
ProtectSystem = "strict";
|
||||
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
"""Create and update Pocket ID user groups and OIDC clients from a JSON spec.
|
||||
|
||||
Usage: pocket-id-sync <spec.json> <base URL>
|
||||
|
||||
Credentials come from systemd's $CREDENTIALS_DIRECTORY: `api-key` (the static API key) and
|
||||
`client-<id>` (each confidential client's secret). Hashes of the secrets that were set are
|
||||
kept in $STATE_DIRECTORY, since Pocket ID only shows a secret's first few characters.
|
||||
"""
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
# Fields of a client that the update endpoint accepts
|
||||
CLIENT_FIELDS = [
|
||||
'name', 'description', 'callbackURLs', 'logoutCallbackURLs', 'backchannelLogoutURL',
|
||||
'isPublic', 'pkceEnabled', 'requiresReauthentication', 'requiresPushedAuthorizationRequests',
|
||||
'skipConsent', 'credentials', 'launchURL', 'hasLogo', 'hasDarkLogo', 'isGroupRestricted',
|
||||
'accessTokenDurationMinutes', 'refreshTokenDurationMinutes',
|
||||
]
|
||||
SECRET_PREFIX_LENGTH = 4
|
||||
|
||||
|
||||
class NotFound(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class API:
|
||||
def __init__(self, base, key):
|
||||
self.base = base
|
||||
self.key = key
|
||||
|
||||
def request(self, method, path, body=None):
|
||||
data = None if body is None else json.dumps(body).encode()
|
||||
req = urllib.request.Request(
|
||||
f'{self.base}/api{path}', data=data, method=method,
|
||||
headers={'X-API-Key': self.key, 'Content-Type': 'application/json'})
|
||||
try:
|
||||
with urllib.request.urlopen(req) as res:
|
||||
content = res.read()
|
||||
except urllib.error.HTTPError as e:
|
||||
if e.code == 404:
|
||||
raise NotFound(path) from e
|
||||
raise RuntimeError(f'{method} {path}: HTTP {e.code}: {e.read().decode()}') from e
|
||||
|
||||
return json.loads(content) if content else None
|
||||
|
||||
def wait(self, timeout=60):
|
||||
for _ in range(timeout):
|
||||
try:
|
||||
with urllib.request.urlopen(f'{self.base}/healthz'):
|
||||
return
|
||||
except OSError:
|
||||
time.sleep(1)
|
||||
raise RuntimeError('Pocket ID did not become healthy')
|
||||
|
||||
|
||||
def read_secret(path, key):
|
||||
text = path.read_text()
|
||||
if key is None:
|
||||
return text.rstrip('\n')
|
||||
|
||||
# A plain env file, as `slop secret` writes it
|
||||
value = None
|
||||
for line in text.splitlines():
|
||||
name, sep, v = line.removeprefix('export ').partition('=')
|
||||
if sep and name == key:
|
||||
value = v
|
||||
if value is None:
|
||||
raise RuntimeError(f'{path} has no {key}')
|
||||
if len(value) >= 2 and value[0] == value[-1] == '"':
|
||||
value = value[1:-1]
|
||||
return value
|
||||
|
||||
|
||||
def sync_groups(api, groups):
|
||||
existing = {g['name']: g for g in api.request('GET', '/user-groups?pagination[limit]=1000')['data']}
|
||||
|
||||
for group in groups:
|
||||
current = existing.get(group['name'])
|
||||
if current is None:
|
||||
print(f"Creating group {group['name']}")
|
||||
api.request('POST', '/user-groups', group)
|
||||
elif current['friendlyName'] != group['friendlyName']:
|
||||
print(f"Updating group {group['name']}")
|
||||
api.request('PUT', f"/user-groups/{current['id']}", group)
|
||||
|
||||
return {g['name']: g['id'] for g in api.request('GET', '/user-groups?pagination[limit]=1000')['data']}
|
||||
|
||||
|
||||
def sync_secret(api, client_id, value, state_dir):
|
||||
digest = hashlib.sha256(f'{client_id}\n{value}'.encode()).hexdigest()
|
||||
state = state_dir / f'{client_id}.sha256'
|
||||
secrets = api.request('GET', f'/oidc/clients/{client_id}/secrets')
|
||||
|
||||
installed = any(s['isActive'] and s['prefix'] == value[:SECRET_PREFIX_LENGTH] for s in secrets)
|
||||
if installed and state.exists() and state.read_text() == digest:
|
||||
return
|
||||
|
||||
print(f'Setting the secret of client {client_id}')
|
||||
new = api.request('POST', f'/oidc/clients/{client_id}/secrets', {'secret': value})
|
||||
for s in secrets:
|
||||
if s['id'] != new['id']:
|
||||
api.request('DELETE', f"/oidc/clients/{client_id}/secrets/{s['id']}")
|
||||
state.write_text(digest)
|
||||
|
||||
|
||||
def sync_client(api, client, group_ids, creds, state_dir):
|
||||
client_id = client['id']
|
||||
settings = client['settings']
|
||||
|
||||
# Update on top of the current client, so fields managed in the UI (like logos) stay
|
||||
try:
|
||||
current = api.request('GET', f'/oidc/clients/{client_id}')
|
||||
except NotFound:
|
||||
print(f'Creating client {client_id}')
|
||||
api.request('POST', '/oidc/clients', {**settings, 'id': client_id})
|
||||
else:
|
||||
merged = {**current, **settings}
|
||||
api.request('PUT', f'/oidc/clients/{client_id}', {f: merged.get(f) for f in CLIENT_FIELDS})
|
||||
|
||||
unknown = [g for g in client['groups'] if g not in group_ids]
|
||||
if unknown:
|
||||
raise RuntimeError(f'Client {client_id}: unknown groups {unknown}')
|
||||
api.request('PUT', f'/oidc/clients/{client_id}/allowed-user-groups',
|
||||
{'userGroupIds': [group_ids[g] for g in client['groups']]})
|
||||
|
||||
if client['secret']:
|
||||
value = read_secret(creds / f'client-{client_id}', client['secretKey'])
|
||||
sync_secret(api, client_id, value, state_dir)
|
||||
|
||||
|
||||
def main():
|
||||
spec = json.loads(Path(sys.argv[1]).read_text())
|
||||
creds = Path(os.environ['CREDENTIALS_DIRECTORY'])
|
||||
state_dir = Path(os.environ['STATE_DIRECTORY'])
|
||||
|
||||
api = API(sys.argv[2], (creds / 'api-key').read_text().strip())
|
||||
api.wait()
|
||||
|
||||
group_ids = sync_groups(api, spec['groups'])
|
||||
for client in spec['clients']:
|
||||
sync_client(api, client, group_ids, creds, state_dir)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
+7
-6
@@ -2,8 +2,8 @@ let
|
||||
self = getFlake (toString ./.);
|
||||
inherit (self) lib;
|
||||
|
||||
inherit (builtins) mapAttrs attrValues readFile getFlake;
|
||||
inherit (lib) fileContents optional flatten zipAttrsWith nameValuePair mapAttrs';
|
||||
inherit (builtins) mapAttrs readFile getFlake;
|
||||
inherit (lib) fileContents optional flatten zipAttrsWith nameValuePair mapAttrs' mapAttrsToList;
|
||||
|
||||
secretPath = p: "secrets/${p}.age";
|
||||
|
||||
@@ -15,12 +15,13 @@ let
|
||||
secretKeys =
|
||||
zipAttrsWith
|
||||
(_: keys: flatten (keys ++ defaultKeys))
|
||||
(map
|
||||
(c: let cfg = c.config.my.secrets; in mapAttrs'
|
||||
(mapAttrsToList
|
||||
# The comment names the key in `slop-broker` approvals; age ignores it
|
||||
(name: c: let cfg = c.config.my.secrets; in mapAttrs'
|
||||
(f: _: nameValuePair
|
||||
(secretPath f)
|
||||
(optional (cfg.key != null) cfg.key))
|
||||
(optional (cfg.key != null) "${cfg.key} ${name}"))
|
||||
cfg.files)
|
||||
(attrValues self.nixosConfigurations));
|
||||
self.nixosConfigurations);
|
||||
in
|
||||
mapAttrs (_: keys: { publicKeys = keys; }) secretKeys
|
||||
@@ -0,0 +1,15 @@
|
||||
-----BEGIN AGE ENCRYPTED FILE-----
|
||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IGpJOFJBZyBzU2lH
|
||||
U05YNG5ISEJtTklOZmZRUUI3MWxuU1JRWG0vNEIxekt3NTdWYVdJCldDMENWenl1
|
||||
ZmZCTW1ySFBXZFEvbHZhR0NDOWpLSzhNRTZUcFU1NWZXUWcKLT4gc3NoLWVkMjU1
|
||||
MTkgVkZjdzVnIDdXSXdnK1VvQzJrbWMyRzltL3BZMEZPV2pEV1lSUW5ySXkxaDRC
|
||||
RjRMVDAKRjVRSm9sMGRNUTBWYkdWNlEwKzNTTU8xRXBmV1JDREhtNThabFRIVERU
|
||||
MAotPiBYMjU1MTkgdHFnZ1RKQlRDTmg0TksvaGgrUER6SU5MYWV6WlpEWXA3Qktv
|
||||
MFZJTktTSQpyMHhRb0FNeGFFZkIvUUxjMWlVbkxRY2pKZnhSanlrUWFITWZHUE1i
|
||||
dldvCi0+IFgyNTUxOSBGbkhrVlZYYjZIakZ5MnZ5ZDJXdnoycEVtL08zYjNjNUty
|
||||
OTY2amsrWTJnCk9neE80T25naFBDV3pjZXh0QmFKNW9YZ1VHdXJsREJidHlNRUY5
|
||||
Y0haTDAKLT4gdEkuc210LWdyZWFzZSA0UT5jYyBkICUgIzArNQpCVE5aQnM1blNO
|
||||
L0Nvb1hDMTRSOVNHUmlTM1lmZWcKLS0tIGFBTDN1ZUhSM21LaVFLZDBUQkFJcDJZ
|
||||
OUVSYVp5Q2NIL01IUTNsSmQ3Y2MKAuYjogUq28f/Cdf5jd/RkWaPZEqA+qGAmTnx
|
||||
fXgii0zfKVsAMGtro8wB4RdKYcvyW86k7zYaZobXHzR4ApCF+Zg=
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
@@ -0,0 +1,13 @@
|
||||
-----BEGIN AGE ENCRYPTED FILE-----
|
||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IFZGY3c1ZyByOEdE
|
||||
dStNQUxBS2I4OFBNdjc1ek5VQ1d3UnIxMldmQllTVlhXdjFWdkZNClRQeVNxajBO
|
||||
bjBJRHRKTTJBOG1yZlV3VHFKRjVvN2ZoZjhmM3daQWQ2SjgKLT4gWDI1NTE5IDdJ
|
||||
OTQ1NlNIbUJHWE9wN0J4Qi82ZVhXZTUvbE14SDR5TlErYnRyRHNPeU0KaGJIZVE1
|
||||
WGt6N0NnZ0Q2TXBZRm9hOXJMSVY2Vis4TExBQnVETk1zZE53YwotPiBYMjU1MTkg
|
||||
RHVZS2VKUUxSdkk4aEQ5cGV4WkFQNDFZTnBlMmRrMjdCcHRPbDlYRzFIdwpVNG5R
|
||||
eHRsSGIyQnVKNE5qenlEa0cwcmw4NUpERHlnRlFYck9kckVTMVp3Ci0+IDNIKil9
|
||||
cSUtZ3JlYXNlIHMpK15qdwpnMkI3MzhjMHFkUlh0QWFvUWdJR1lsSFNuVFo5QVg1
|
||||
MWRXM3M5Q1hEWlAyOEoxVFR2dwotLS0gUTRlTTBuSG5vbm5Cc2wwa0JZajZoZXBP
|
||||
b0tPdjFEWHh2WHN5QVFxQStVYwqJgKKXVzhl1hAzrjCjL9Ms50Opvs0OEp9K0ncS
|
||||
hBKY7L8jR0mPVdZrTSlA249HW22nAYXxt419WMt9wITs3lDwiA==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
@@ -1,23 +0,0 @@
|
||||
-----BEGIN AGE ENCRYPTED FILE-----
|
||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IFZGY3c1ZyBjYUdx
|
||||
QkdtWUFpWTNiSUljaVRtQnRETktCZVYxQkkyQzRTWVhUanJKZDM0CnlhRXFML01Y
|
||||
ZWVNVDBiS3I1S1NnMDFGUzh4ZUx6eFFuQjlKSTYrWmNDTjAKLT4gWDI1NTE5IHRk
|
||||
OGNCMTFsN09ua0FHY3JkUjEzREZScCtDVDEwOEZPdzFWa3UvUW5mWEEKVXhubUd3
|
||||
b2dWMTByUm5IRGZlSmhnU3luNU1RemU0ZElsZy9kOWE2eHNYUQotPiBYMjU1MTkg
|
||||
b28vSU1RdTB1NG5TRHFZZkREc2l0cWVoOEZJdmhRTWJLS2VEOFN4NVBCZwpGcFFz
|
||||
U24rTEJhZGdVY3Nla1FkSmZwNStENElLS1RHZlphU0pPb3FOV1NnCi0+IHI2Inot
|
||||
Z3JlYXNlIGogKFFbZ2wgQ3AgYV9wWSVlPyUKK201VFJOUUF5U3FJbGFNaTBJc2dW
|
||||
ZDUvbzBkZ1NxNUdqc0RYN2ZhNE9VMjRGcTdrdUFhMEVZZ1M0SFZ6a2pHMQpwa2hB
|
||||
OE40UnBqS1Z4K3FwYWcKLS0tIG9iem93TDlNTEZKcjR1RjZZVzJkZzVDbGpYb0RV
|
||||
TDFrUkdWcEtpTXp3cTAKFSJ4JWRlInDZOngwNKx2MuiR34SegxSS3l/j0sLeRXjf
|
||||
RCScLwFQOUeuYZ6t9yIXp2oekftODiDFNiA5fY8UiTzhbqXVHO/9mpbkaSZ8C5Nw
|
||||
VymCLTf4WZX0vphPCTW0hM4nCdhdmY480U7vyen8il1pjhWgOFXm3AeOV3StG1KA
|
||||
Pu2m1jf9aceXoEblVI4RqFBkbwpYFnD+X0bKA6LUddk8jvz36s/eqAhMuw/L7KU3
|
||||
Fgd4vwU5qw5lgSEfKSkHednd4YDkc1dpTTzGIQ/L/ogfSqU3z1xp557VweGB3sjS
|
||||
QJSyY/Gj+Fzs1SUi0J1ot3TNYHiwM/QrzfNFj2gQqi/T6EfBhbtNfkkn4fgWh/ob
|
||||
dPXx6m3mB1MXMI69jy72v3Ejg9eqzmtv1uu2z7aoVU2vxhRKIN8y69oW+pMdbx5A
|
||||
u1RlPeJMlQXs8lIuA9x+UN3FEuXvq1YZv7SQL+RQWzCBIdb1XE6OyyvIzGdHts/N
|
||||
fJWo4PjnikpDk3zIPAdRdzvg+JjH8/7DwXxffC7uddeQ/rnKmL3y1OgVdjTeDuZv
|
||||
f7HfAj6K8BDz3zTZhuGbuhpbPhifzw5kg3H83mm1QdXlAH2CLRfnWUtBuoCV+DbZ
|
||||
1JyluvXr7PYlIFktmeWUMOyrYPeGbHIbrmbJGi3BGxN7csMkpAJ5
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
@@ -0,0 +1,15 @@
|
||||
-----BEGIN AGE ENCRYPTED FILE-----
|
||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IFZGY3c1ZyA1U0lS
|
||||
N2NNc1ZNTVZNekNiN0RUeTFCcXd4b1p5ZFd1WW53Sm5SZHNJQXprCnVpUGR2VDBE
|
||||
R1hZUFdHYjFOMUNGMDZ6cTQ4bHRtWHkxS2RaR1BTcDg4dDAKLT4gWDI1NTE5IHRO
|
||||
QjAzcUN6UC9kZ0psV1VkMU0vNTNyYUYxb3FNRmtvUmFDQ1U4RnNhUzAKOUEyVzNm
|
||||
TGlLUEpuOFR6ZmlGOUdueFpBNS9IN1pLcWh0Z0RadFJ1Mi9IYwotPiBYMjU1MTkg
|
||||
Vm0wNXdrd2g1VkxUTHJGQVcrcHZlVGpES0xTaEMyVzl1Y2hqLzNFY3JoRQpqTnNi
|
||||
dk1pOWowQ3JSa1FHTTV6MzdsM2Z1K1U2UC9rcXRnTCt5clJPaHZnCi0+IC08Ui1n
|
||||
cmVhc2UgQk85bSJEMyA+Y2Ywb1oKTXJZK21pME03L1E0NDFQV2tWRTBzOUpzakVE
|
||||
eGZpR2drbTFtNmltRnduamRHTlhWY2lHQUJ2awotLS0gNkdzZDVDUEVlOHpEazJG
|
||||
SVdhd3RVRDduNmR0TkRaeFlBTUViOHFzT2Zmdwru/OT2cMuikwH9vsUoMQKv/Vw/
|
||||
8GENAp13h4yh35bBbvkfMWAuuSu6r3BGyz7G2vytG+ntZFUO01QGVkphORqWd03Q
|
||||
aqspunHGf6HXRH0BzS7npRQgFPkT9pTSpg7AFR6LXkj4uWliqw/m8YRPlG9Fifb2
|
||||
20Jhh5zhAcPPdiiERK4U7s7D8DDsDAFpjNMeOXx9sAdT2fcWrA==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
@@ -0,0 +1,13 @@
|
||||
-----BEGIN AGE ENCRYPTED FILE-----
|
||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IFZGY3c1ZyBvclJm
|
||||
YnRLby9ubU5tcWVvbVFud0sweW9aYmowSWRSY2xWNjlGME40SUZNCkFkZmcyWG9O
|
||||
SFlWWWtnMnduS1FSN3VCUHNzWUtPUitvTXNaZ0tLYy8xSlEKLT4gWDI1NTE5IDd2
|
||||
UjcwOTNERFVwYWRnTXhyYWd1MUN0ZnRKNERrUjB2VTRrNzVLRU1RbU0KaXlFYXRN
|
||||
MmFtRE1DNDNkNUMyaG1vR0lvRlk0OFkzUHlQMWZrWVJzYlY1QQotPiBYMjU1MTkg
|
||||
SXlFUFR4WU9wUFhrRndOTUkvOGJsRHMxQ0VDOGxtRGNLVmNPaGJpcmxHYwpoUFJp
|
||||
SVcveVIvT3REWjllaDVFRHpzeC92b1ViaDRURmN5UEJadk9scFVZCi0+IHtJZGAt
|
||||
Z3JlYXNlICNoR1R2CkF0VlVtVTAwb0FFVXNBUEZ3QmtyNzk0czdSdUl1VHpVNlVL
|
||||
ZUg2U0VUVEEwTGZKRAotLS0gc21CdkE3UDB0WmJqaDNER25oRGVvYkszMld3VkFX
|
||||
UHoyaFRZVlA1ZHRIdwoq976vf2z9nu4ssEQ8S3+HSGf9BfXcH8Jrc+D83yYjy6Dp
|
||||
lWMspu8Gr7y+nshtzXoyVu7GbmLNT6trsvOTIp6/tg==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
Reference in new issue
Block a user