Compare commits
137
Commits
a7c1b1cc0c
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89484504e4 | ||
|
|
6fbc61c7ea | ||
|
|
1dc3ae47f9 | ||
|
|
a092e23f6e | ||
|
|
7a973aaee6 | ||
|
|
5c48ef9c1e | ||
|
|
4c9d8f88cb | ||
|
|
c8223aec40 | ||
|
|
6abc047879 | ||
|
|
a48af90346 | ||
|
|
32ea399d89 | ||
|
|
705f2eb4c6 | ||
|
|
5139a55daa | ||
|
|
f9835c150f | ||
|
|
e9479f9be1 | ||
|
|
a1ebcfb6aa | ||
|
|
956158729e | ||
|
|
87aea41843 | ||
|
|
f3d03f4c20 | ||
|
|
ff770c1d03 | ||
|
|
d7875b588e | ||
|
|
5881b9c8be | ||
|
|
d7bd46c0cd | ||
|
|
b583c550f3 | ||
|
|
08207da02b | ||
|
|
3efec42e72 | ||
|
|
fb5503ec36 | ||
|
|
be6e7492b3 | ||
|
|
10d85b2a91 | ||
|
|
6db82ed10a | ||
|
|
09c6fe2235 | ||
|
|
2547ec45b4 | ||
|
|
26856003d4 | ||
|
|
ce92096042 | ||
|
|
62c41a6f8e | ||
|
|
d8ea131327 | ||
|
|
a3178f0507 | ||
|
|
3b44ae1354 | ||
|
|
e72789fbb1 | ||
|
|
f06921593d | ||
|
|
416c648f99 | ||
|
|
25a21d2f66 | ||
|
|
dfd4ca06a2 | ||
|
|
d337d7605e | ||
|
|
f2d1ce5744 | ||
|
|
a8bc08de43 | ||
|
|
0c265f7a74 | ||
|
|
d6b79f8d8d | ||
|
|
39fc85e8f9 | ||
|
|
088de60af5 | ||
|
|
eb94f5a034 | ||
|
|
91d6511f01 | ||
|
|
e3f01e3c35 | ||
|
|
880c85facb | ||
|
|
6ff3b48fcf | ||
|
|
eb862ebf7e | ||
|
|
fa5343f211 | ||
|
|
82480e88f4 | ||
|
|
a60b842ee2 | ||
|
|
2d09b6c69f | ||
|
|
e2bff381b9 | ||
|
|
2b83e9c606 | ||
|
|
1c420283f4 | ||
|
|
8fec1dd4bb | ||
|
|
18f4639bb7 | ||
|
|
fdf7ecb3e4 | ||
|
|
2a2b1d8421 | ||
|
|
594a1c1901 | ||
|
|
dd4965f030 | ||
|
|
a12f10d964 | ||
|
|
9856e11416 | ||
|
|
fd733cdc21 | ||
|
|
cd7c908fde | ||
|
|
62e73eb4d2 | ||
|
|
0efbc5817b | ||
|
|
2e8529fff0 | ||
|
|
3a2cb09d07 | ||
|
|
bfdcd45746 | ||
|
|
9217e61675 | ||
|
|
6f0efacfca | ||
|
|
eecad5cc4a | ||
|
|
6ec9594f92 | ||
|
|
567a85b946 | ||
|
|
95b6885f4e | ||
|
|
57fbf70b7c | ||
|
|
86f9ae010e | ||
|
|
520f804738 | ||
|
|
9b537c9f62 | ||
|
|
bb3c73b310 | ||
|
|
eb6380ddfe | ||
|
|
0cf504ad27 | ||
|
|
39f062a7af | ||
|
|
4c8efd185d | ||
|
|
5d2ff990ae | ||
|
|
4a72048f0d | ||
|
|
97644f4598 | ||
|
|
53e272367e | ||
|
|
b53ab9c854 | ||
|
|
32bc1e83e9 | ||
|
|
b0da186ed3 | ||
|
|
3c244541cb | ||
|
|
8dcbd3bf6c | ||
|
|
56f93456cd | ||
|
|
7f8db88b8c | ||
|
|
246f2cf360 | ||
|
|
c9f459d4c6 | ||
|
|
e962c5cebc | ||
|
|
7dd5f9e17b | ||
|
|
53c41cf826 | ||
|
|
4f3a95b42c | ||
|
|
da93290953 | ||
|
|
e719674851 | ||
|
|
3b764654d2 | ||
|
|
71f0c086a4 | ||
|
|
1e6cf7251f | ||
|
|
a8fa1f83af | ||
|
|
ee00ccb0d7 | ||
|
|
faeeb885b6 | ||
|
|
6737aaa289 | ||
|
|
6fbdcf44cf | ||
|
|
58e0705aca | ||
|
|
39ffdfa219 | ||
|
|
0388875455 | ||
|
|
8a253f82c9 | ||
|
|
cd48b65656 | ||
|
|
41968e63d2 | ||
|
|
8ca671c89b | ||
|
|
6094b9dc93 | ||
|
|
52c2aac9df | ||
|
|
42b8cf4e4f | ||
|
|
206f353b77 | ||
|
|
adf0e990ce | ||
|
|
17b14b33e5 | ||
|
|
c4056e45cb | ||
|
|
4d1a269e00 | ||
|
|
34607e944b | ||
|
|
e063c3cfea |
No files matched your search
@@ -0,0 +1,18 @@
|
||||
# .agents/looprails
|
||||
|
||||
Looprail files for this repo.
|
||||
|
||||
## journal-triage
|
||||
|
||||
`journal-triage.toml` reads the journald log of this machine, has Claude Opus triage it
|
||||
against this repo, and writes a report ranked by urgency to `.tmp/journal-reports/<host>-<date>.md` (gitignored).
|
||||
|
||||
- `journal-triage/collect.sh`: pulls warnings (and worse), failed units and a digest of
|
||||
unique messages into the run folder.
|
||||
- `journal-triage/triage.md`: the brief for Opus. It reads `GUIDELINES.md`, traces each issue to
|
||||
`hosts/<host>/` or `modules/`, and suggests fixes as repo changes. It only reads and suggests:
|
||||
no edits, no builds, no sudo.
|
||||
- Inputs: `since` (default `24 hours ago`), `priority` (`err`, `warning`, `notice`),
|
||||
`host` (default `fwbook`), `repo` (default `/home/ari/nixos-setup`).
|
||||
|
||||
Run: `looprail run .agents/looprails/journal-triage.toml`, or ask the agent to run it.
|
||||
@@ -0,0 +1,45 @@
|
||||
name = "journal-triage"
|
||||
description = "Collect journald warnings, triage them with Claude Opus against this repo, and write an urgency-ranked report with fixes as repo changes."
|
||||
|
||||
[inputs.static]
|
||||
since = { type = "string", description = "How far back to read the journal.", min_length = 1, default = "24 hours ago" }
|
||||
priority = { type = "enum", description = "Lowest log priority to include.", values = ["err", "warning", "notice"], default = "warning" }
|
||||
host = { type = "string", description = "Name of the host folder under hosts/ to trace issues to.", min_length = 1, default = "fwbook" }
|
||||
repo = { type = "string", description = "Path of the NixOS config repo.", min_length = 1, default = "/home/ari/nixos-setup" }
|
||||
|
||||
[[step.collect]]
|
||||
kind = "shell"
|
||||
description = "Collects journal warnings and failed units into a digest."
|
||||
cwd = "{{ inputs.repo }}"
|
||||
run = ["sh .agents/looprails/journal-triage/collect.sh {{ inputs.since }} {{ inputs.priority }}"]
|
||||
|
||||
[step.collect.outputs]
|
||||
raw_log = { type = "string", description = "Path of the full raw journal log." }
|
||||
digest = { type = "string", description = "Path of the deduplicated digest." }
|
||||
lines = { type = "int", description = "Number of raw log lines." }
|
||||
unique = { type = "int", description = "Number of distinct messages." }
|
||||
|
||||
[[step.triage]]
|
||||
kind = "agent"
|
||||
description = "Has Opus triage the log against the repo and suggest fixes."
|
||||
needs = ["collect"]
|
||||
agent = { command = ["claude-agent-acp"], model = "opus" }
|
||||
cwd = "{{ inputs.repo }}"
|
||||
brief = "journal-triage/triage.md"
|
||||
failover = "agent"
|
||||
|
||||
[step.triage.outputs]
|
||||
summary = { type = "string", description = "Markdown report ranked by urgency.", min_length = 1 }
|
||||
issues = { type = "list", description = "The issues found, with urgency, fix and files.", items = { title = { type = "string" }, urgency = { type = "enum", values = ["critical", "high", "medium", "low", "noise"] }, fix = { type = "string" }, files = { type = "list" } } }
|
||||
|
||||
[[step.report]]
|
||||
kind = "shell"
|
||||
description = "Writes the report to .tmp/journal-reports."
|
||||
needs = ["triage"]
|
||||
run = [
|
||||
"R={{ inputs.repo }}; mkdir -p \"$R/.tmp/journal-reports\"",
|
||||
"S={{ steps.triage.outputs.summary }}; H={{ inputs.host }}; R={{ inputs.repo }}; f=\"$R/.tmp/journal-reports/$H-$(date +%Y-%m-%d-%H%M).md\"; printf '%s\\n' \"$S\" > \"$f\"; echo \"report=$f\" >> \"$NBOT_LR_OUTPUTS\"; echo \"Report written to $f\"",
|
||||
]
|
||||
|
||||
[step.report.outputs]
|
||||
report = { type = "string", description = "Path of the written report." }
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
# Collect journald warnings+ and failed units into the run folder, plus a deduplicated digest.
|
||||
set -eu
|
||||
since="$1"; priority="$2"
|
||||
dir="$NBOT_LR_RUN_DIR"
|
||||
raw="$dir/journal-raw.log"; digest="$dir/journal-digest.txt"
|
||||
|
||||
journalctl -p "$priority" --since "$since" --no-pager -q -o short-iso > "$raw" || true
|
||||
|
||||
{
|
||||
echo "=== Failed systemd units ==="
|
||||
systemctl --failed --no-legend --plain || true
|
||||
systemctl --user --failed --no-legend --plain 2>/dev/null || true
|
||||
echo
|
||||
echo "=== Boots in window ==="
|
||||
journalctl --list-boots --no-pager -q | tail -5 || true
|
||||
echo
|
||||
echo "=== Unique messages (count, source: message; numbers/hex normalized), most frequent first ==="
|
||||
cut -d' ' -f3- "$raw" \
|
||||
| sed -E 's/\[[0-9]+\]//; s/0x[0-9a-fA-F]+/0xN/g; s/[0-9]+/N/g' \
|
||||
| sort | uniq -c | sort -rn | head -400
|
||||
} > "$digest"
|
||||
|
||||
lines=$(wc -l < "$raw")
|
||||
uniq=$(grep -c '^ *[0-9]' "$digest" || true)
|
||||
printf 'raw_log=%s\ndigest=%s\nlines=%s\nunique=%s\n' "$raw" "$digest" "$lines" "$uniq" >> "$NBOT_LR_OUTPUTS"
|
||||
@@ -0,0 +1,65 @@
|
||||
You are triaging the systemd journal of the NixOS host `{{ inputs.host }}`, and tracing each issue
|
||||
back to the NixOS config repo that builds it: {{ inputs.repo }} (your working folder).
|
||||
|
||||
Window: since {{ inputs.since }}, priority {{ inputs.priority }} and worse.
|
||||
{{ steps.collect.outputs.lines }} log lines, {{ steps.collect.outputs.unique }} distinct messages.
|
||||
|
||||
- Digest (failed units, boots, deduplicated messages with counts): {{ steps.collect.outputs.digest }}
|
||||
- Full raw log (timestamps, for context): {{ steps.collect.outputs.raw_log }}
|
||||
|
||||
## Rules: read and suggest only
|
||||
|
||||
- Change nothing. Do not edit, create or delete files, in the repo or anywhere else.
|
||||
- Do not run builds or switches: no `nixos-rebuild`, `nh`, `skyg`, `nix build`, `nix flake check`,
|
||||
`nixos-anywhere`, docker/podman builds. No sudo. No git commands that change state.
|
||||
- You may run read-only commands: `systemctl status`, `journalctl -u`, `ls`, `cat`, `grep`, `rg`,
|
||||
`git log`, `git diff`, `nix-instantiate --parse`.
|
||||
- Never read anything in `secrets/`.
|
||||
|
||||
## Steps
|
||||
|
||||
1. Read `GUIDELINES.md` in the repo. Your suggested changes must follow it.
|
||||
2. Read the digest, then grep the raw log for detail where needed.
|
||||
3. Group related messages into issues. Ignore harmless boot-time noise unless it points to
|
||||
something real; list it briefly under "noise" so the reader knows it was seen.
|
||||
4. For each real issue, find where it comes from in the repo: start with `hosts/{{ inputs.host }}/`,
|
||||
then `modules/`, `configs/`, `pkgs/` and `flake.nix`. Check whether another host
|
||||
(`hosts/*/`) already solves the same problem, and reuse that pattern.
|
||||
Note when the cause is outside the repo (a hand-written file in `~/.config`, state on disk).
|
||||
|
||||
## How to write fixes
|
||||
|
||||
- Give each fix as a short suggested Nix change with its repo path, e.g.
|
||||
`hosts/{{ inputs.host }}/systemd.nix` plus a small snippet.
|
||||
- Follow the repo's layout: put config in the matching host sub-file (`hardware.nix`, `systemd.nix`,
|
||||
`packages.nix`, `networking.nix`, `services.nix` or `services/<name>.nix`, `home/default.nix`).
|
||||
Custom options live under `skyg.*`; check `modules/lib.nix` before naming one.
|
||||
- Never suggest `imports = [...]` in host files.
|
||||
- Never suggest editing `flake.lock`, anything in `hosts/*/hardware-configuration/` or
|
||||
`*.hardware-configuration.nix`, or `secrets/`. If the cause lives there, say so and suggest an
|
||||
override in the right host sub-file instead (e.g. `fileSystems."/boot".options` in `hardware.nix`
|
||||
with `lib.mkForce`).
|
||||
- When a fix is imperative (a one-off command), say it needs to be run by hand, and prefer a
|
||||
declarative option when one exists.
|
||||
- Remind the reader that they rebuild themselves; do not tell them a change has been applied.
|
||||
|
||||
## Urgency
|
||||
|
||||
- critical: data loss, security, hardware failing, system unbootable or core service down
|
||||
- high: a service failing or crash-looping, repeated errors with user-visible effect
|
||||
- medium: degraded behaviour, misconfiguration, something that will bite later
|
||||
- low: cosmetic or rare warnings worth a look
|
||||
- noise: benign, safe to ignore
|
||||
|
||||
## Output
|
||||
|
||||
`summary` is a Markdown report:
|
||||
- a one-paragraph overview
|
||||
- sections by urgency, critical first; each issue with evidence (unit, sample message, count,
|
||||
first/last seen), likely cause, the repo files involved, and fixes as suggested repo changes
|
||||
- a short "Repo recommendations" section: patterns across hosts or modules worth changing
|
||||
(duplication, hand-made units that should be declarative, a fix that would help other hosts too)
|
||||
|
||||
Keep it concise, with plain words.
|
||||
|
||||
`issues` is the same issues as a list; `files` holds the repo paths involved (empty if none).
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
name: nbot-wf
|
||||
description: When anything to do with workflows comes up, use the nbot-wf MCP tools; if they are not available, run nbot-wf install and restart the session.
|
||||
---
|
||||
|
||||
When anything to do with workflows comes up, use the nbot-wf MCP tools; if they are not available, run `nbot-wf install` and restart the session.
|
||||
|
||||
The `get_workflow_guide` tool explains how to find, run, watch, answer, stop, resume, write and update a workflow.
|
||||
@@ -0,0 +1,3 @@
|
||||
[mcp_servers.nbot-wf]
|
||||
command = "nbot-wf"
|
||||
args = ["mcp"]
|
||||
+15
@@ -1,5 +1,7 @@
|
||||
*.AppImage
|
||||
|
||||
.pytest_cache
|
||||
|
||||
# Devenv
|
||||
.devenv*
|
||||
devenv.local.nix
|
||||
@@ -33,3 +35,16 @@ docs
|
||||
|
||||
# worktrees
|
||||
.branches
|
||||
|
||||
# agents
|
||||
.commandcode
|
||||
.delta
|
||||
.claude
|
||||
.mnt
|
||||
.pi
|
||||
|
||||
# Zed local settings (machine-local MCP tokens live here)
|
||||
.zed/settings.local.json
|
||||
|
||||
|
||||
.nbot-wf
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"mcpServers": {
|
||||
"nbot-wf": {
|
||||
"command": "nbot-wf",
|
||||
"args": [
|
||||
"mcp"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
/nix/store/irqhrjyjaz9rb8ns04fp12dlcc6hq2q5-pre-commit-config.json
|
||||
/nix/store/mbdhxcacyi218765m4p2b53ww4fhrlsf-pre-commit-config.json
|
||||
+34
-25
@@ -1,29 +1,38 @@
|
||||
{
|
||||
"show_completions_on_input": true,
|
||||
"languages": {
|
||||
"QML": {
|
||||
"colorize_brackets": true,
|
||||
"inlay_hints": {
|
||||
"show_background": true,
|
||||
"enabled": true
|
||||
},
|
||||
"show_whitespaces": "all",
|
||||
"show_completions_on_input": true,
|
||||
"always_treat_brackets_as_autoclosed": true,
|
||||
"format_on_save": "on",
|
||||
"language_servers": ["qmljs"]
|
||||
}
|
||||
},
|
||||
"lsp": {
|
||||
"qmljs": {
|
||||
"context_servers": {
|
||||
"linux-tracker": {
|
||||
"url": "http://fwdesk.lab.internal:1984/mcp"
|
||||
}
|
||||
},
|
||||
"languages": {
|
||||
"QML": {
|
||||
"colorize_brackets": true,
|
||||
"inlay_hints": {
|
||||
"show_background": true,
|
||||
"enabled": true
|
||||
},
|
||||
"show_whitespaces": "all",
|
||||
"show_completions_on_input": true,
|
||||
"always_treat_brackets_as_autoclosed": true,
|
||||
"format_on_save": "on",
|
||||
"language_servers": [
|
||||
"qmljs"
|
||||
]
|
||||
}
|
||||
},
|
||||
"lsp": {
|
||||
"qmljs": {
|
||||
"enable_lsp_tasks": true,
|
||||
"binary": {
|
||||
"path": "qmlls",
|
||||
"arguments": ["-E"]
|
||||
},
|
||||
"initialization_options": {
|
||||
"buildDir": "."
|
||||
}
|
||||
}
|
||||
}
|
||||
"binary": {
|
||||
"path": "qmlls",
|
||||
"arguments": [
|
||||
"-E"
|
||||
]
|
||||
},
|
||||
"initialization_options": {
|
||||
"buildDir": "."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ Key non-negotiable rules from that file:
|
||||
changes — no matter how small the task.
|
||||
- **Never run builds, system switches, or remote installs** (`nixos-rebuild`,
|
||||
`nh os`, `skyg os`, `skyg remote install`, `nixos-anywhere`, `nix build`,
|
||||
`nix flake check`, etc.) — zero exceptions, even if asked.
|
||||
`nix flake check`, etc.). You may only run it after asking the user 3 times if the are sure about it!
|
||||
- Never edit `flake.lock`, `*.hardware-configuration.nix`, or anything in
|
||||
`secrets/`.
|
||||
- Never add `imports = [...]` to host files.
|
||||
|
||||
@@ -1,154 +1,153 @@
|
||||
# NixOS System Configurations
|
||||
|
||||
My comprehensive Nix configurations for managing multiple hosts, including local machines and remote servers.
|
||||
Nix configs for all my machines: local desktops/laptops and homelab servers.
|
||||
|
||||
## Repository Layout
|
||||
|
||||
```
|
||||
nixos-setup/
|
||||
├── bin/
|
||||
│ └── skyg # Main CLI tool for managing NixOS configurations
|
||||
├── configs/ # Application-specific configurations
|
||||
├── pkgs/ # Custom packages (niri-touchscreen-gestures, grok-cli)
|
||||
├── hosts/ # Host-specific NixOS configurations
|
||||
│ ├── *.nix # Host configuration files (fwbook, hl-bigbox1, hl-minipc*, etc.)
|
||||
│ ├── *.hardware-configuration.nix # Hardware-specific configurations
|
||||
│ └── scripts/ # Host-specific scripts
|
||||
├── modules/ # Reusable NixOS and Home Manager modules
|
||||
├── bin/ # `skyg` CLI (see bin/ABOUTME.md)
|
||||
│ ├── skyg # Bash shim → NuShell modules in bin/lib/
|
||||
│ ├── temp-monitor # CPU/GPU temperature logger (see TEMP_MONITOR_README.md)
|
||||
│ └── lib/ # Command modules: os, remote, secrets, ca, pkgs, flake, build, render, hm, net
|
||||
├── configs/ # App configs per host, plus configs/pki (lab TLS certs)
|
||||
├── pkgs/ # Custom packages (see pkgs/ABOUTME.md)
|
||||
├── hosts/ # One folder per host (fwbook, hl-*, iso) + disko/hardware files
|
||||
├── modules/
|
||||
│ ├── main.nix # Entry point that wires all modules together
|
||||
│ ├── core/ # Core system modules
|
||||
│ ├── nixos/ # NixOS modules (desktop, server, common)
|
||||
│ ├── home/ # Home Manager modules
|
||||
│ ├── nixos/ # NixOS-specific modules
|
||||
│ └── *.nix # Utility modules (lib, skyg-utils, network-drives, etc.)
|
||||
├── apps/ # Standalone applications
|
||||
├── flake.nix # Nix flake definition
|
||||
├── flake.lock # Locked dependency versions
|
||||
└── README.md # This file
|
||||
│ ├── openwrt/ # OpenWrt config generator
|
||||
│ └── *.nix # Shared helpers (lib, skyg-utils, internal-networking, …)
|
||||
├── openwrt-routers/ # OpenWrt router configs (glmain)
|
||||
├── secrets/ # agenix-encrypted secrets (keys listed in secrets.nix)
|
||||
├── docs/ # Documentation
|
||||
└── flake.nix # Flake definition
|
||||
```
|
||||
|
||||
## Using This Flake
|
||||
|
||||
To use the custom packages in your own NixOS/Home Manager configuration:
|
||||
Custom packages and helpers are exported for reuse:
|
||||
|
||||
```nix
|
||||
{
|
||||
inputs.nixos-setup.url = "github:skykanin/nixos-setup";
|
||||
|
||||
outputs = { self, nixpkgs, nixos-setup, ... }:
|
||||
outputs = { nixos-setup, ... }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
pkgs = nixos-setup.lib.pkgs.${system};
|
||||
pkgs = nixos-setup.lib.pkgs."x86_64-linux";
|
||||
in {
|
||||
environment.systemPackages = with pkgs; [
|
||||
niri-touchscreen-gestures
|
||||
];
|
||||
environment.systemPackages = [ pkgs.niri-touchscreen-gestures ];
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
You can also import `nixos-setup.lib` to reuse `makeNixOs`, `makeHomeManagerUsers`, and other utilities.
|
||||
`nixos-setup.lib` also provides `makeNixOs`, `makeHomeManagerUsers`, `makeIso`, `makeSdImage`, and more.
|
||||
|
||||
See [`pkgs/ABOUTME.md`](pkgs/ABOUTME.md) for details on each package.
|
||||
Inside this repo, every package in `pkgs/` is available as `pkgs.<name>` through the overlay.
|
||||
|
||||
## Quick Start
|
||||
## The `skyg` CLI
|
||||
|
||||
The `skyg` script is your main interface for managing these configurations. It's located in `bin/skyg` and uses NuShell.
|
||||
`bin/skyg` is the main tool for this repo. Run `skyg` to list subcommands, or `skyg <subcommand> --help` for details.
|
||||
|
||||
### Available Commands
|
||||
### Local system — `skyg os`
|
||||
|
||||
#### System Management
|
||||
| Command | Description |
|
||||
| -------------------------------------- | ---------------------------------------------------------------------------------- |
|
||||
| `skyg os <action>` | Rebuild locally. Actions: `test`, `dry-activate`, `run`, `switch`, `build`, `boot` |
|
||||
| `skyg os <action> --build-host <host>` | Build on another machine (e.g. `--build-host fwdesk`) |
|
||||
| `skyg os rollback` | Go back to the previous generation |
|
||||
|
||||
- **`skyg build`** - Build the current system configuration
|
||||
- **`skyg switch`** - Switch to a new configuration (with confirmation)
|
||||
- **`skyg test`** - Test a configuration without switching
|
||||
- **`skyg rollback`** - Rollback to the previous generation
|
||||
### Remote hosts — `skyg remote`
|
||||
|
||||
#### Profile Management
|
||||
| Command | Description |
|
||||
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `skyg remote <action> <target>` | Deploy to a remote host. Same actions as `skyg os` |
|
||||
| `skyg remote install <target>` | Fresh install via nixos-anywhere using `hosts/hl-<target>.disko.nix`. **Wipes disks.** Asks you to type the hostname; refuses if NixOS is already installed unless `--force-wipe` |
|
||||
| `skyg remote status <target>` | Show one host's status |
|
||||
| `skyg remote status --all` | Show all hosts: generation, pending reboot, needs rebuild |
|
||||
| `skyg remote boot-all` | Run `boot` on every online remote (skips this machine) |
|
||||
| `skyg remote reboot-pending` | Reboot hosts whose booted system differs from the current one, one at a time, after confirmation |
|
||||
|
||||
- **`skyg profiles`** - List all available local profiles
|
||||
- **`skyg profiles --only_remote`** - List only remote profiles (prefixed with `hl-`)
|
||||
Example: `skyg remote switch bigbox1` deploys `hl-bigbox1` to `root@bigbox1.lab.internal`.
|
||||
|
||||
#### Flake Updates
|
||||
### Flake — `skyg flake`
|
||||
|
||||
- **`skyg update`** - Update all flakes to their latest versions
|
||||
- **`skyg update <flake_name>`** - Update a specific flake (e.g., `skyg update nixpkgs`)
|
||||
| Command | Description |
|
||||
| --------------------------- | ---------------------------------------------------------- |
|
||||
| `skyg flake update [input]` | Update all inputs, or one, then show the `flake.lock` diff |
|
||||
| `skyg flake check` | Run `nix flake check --no-build` |
|
||||
| `skyg flake check-versions` | Check that all inputs use the same NixOS release |
|
||||
|
||||
Displays the diff of `flake.lock` after updating.
|
||||
### Images and routers — `skyg build`
|
||||
|
||||
#### Remote Deployments
|
||||
| Command | Description |
|
||||
| ----------------------------------------- | ------------------------------------------------------------------------------ |
|
||||
| `skyg build image <iso\|pi1\|pi2>` | Build an ISO or a Pi SD card image |
|
||||
| `skyg build openwrt [router] [--dry-run]` | Deploy a router config (default `glmain`). `--dry-run` only renders to `.tmp/` |
|
||||
|
||||
- **`skyg remote <command> <target>`** - Deploy to a remote machine
|
||||
### Home Manager — `skyg hm`
|
||||
|
||||
Supported remote commands: `test`, `dry-activate`, `run`, `switch`, `build`
|
||||
| Command | Description |
|
||||
| -------------------------- | ----------------------------------------- |
|
||||
| `skyg hm switch [profile]` | Apply Home Manager config (default `ari`) |
|
||||
| `skyg hm build [profile]` | Build Home Manager config |
|
||||
|
||||
Example: `skyg remote switch bigbox1` deploys using the `hl-bigbox1` profile to `root@bigbox1.lab.internal`
|
||||
### Secrets — `skyg secrets`
|
||||
|
||||
#### Home Manager
|
||||
| Command | Description |
|
||||
| -------------------------------------------- | ----------------------------------------------- |
|
||||
| `skyg secrets` / `skyg secrets list` | List secret names |
|
||||
| `skyg secrets show <secret>` | Decrypt to `.tmp/unencrypted-<secret>` |
|
||||
| `skyg secrets edit <secret> [file] [--yaml]` | Edit and re-encrypt (`--yaml` validates first) |
|
||||
| `skyg secrets compare <secret>` | Diff the working copy against the stored secret |
|
||||
|
||||
- **`skyg hm switch [profile]`** - Apply home-manager configuration (default: `ari`)
|
||||
- **`skyg hm build [profile]`** - Build home-manager configuration
|
||||
### Lab CA — `skyg ca`
|
||||
|
||||
Example: `skyg hm switch ari` or `skyg hm switch`
|
||||
| Command | Description |
|
||||
| ------------------------------------- | --------------------------------------------------------------------------------------- |
|
||||
| `skyg ca init` | Create the root CA: key → `secrets/lab-ca-key.age`, cert → `configs/pki/lab-ca.crt` |
|
||||
| `skyg ca issue <domain> --for <host>` | Issue a TLS cert: cert → `configs/pki/<domain>.crt`, key → `secrets/<name>-tls-key.age` |
|
||||
|
||||
#### ISO Images
|
||||
### Custom packages — `skyg pkgs`
|
||||
|
||||
- **`skyg build-iso`** - Build a bootable ISO image
|
||||
| Command | Description |
|
||||
| ---------------------------------- | ----------------------------------------------- |
|
||||
| `skyg pkgs update --all` | Update every package that has an `update.sh` |
|
||||
| `skyg pkgs update <pkg> [version]` | Update one package (latest, or a given version) |
|
||||
|
||||
## Usage Examples
|
||||
### Network — `skyg net`
|
||||
|
||||
```bash
|
||||
# Check available profiles
|
||||
skyg profiles
|
||||
| Command | Description |
|
||||
| ------------------------- | -------------------------------------------------------------------------------------------- |
|
||||
| `skyg net check [device]` | Show NIC info and run a speed test on every device (or one). `--no-speedtest` skips the test |
|
||||
| `skyg net last` | Show the results of the last `skyg net check` |
|
||||
|
||||
# Build and switch to new configuration
|
||||
skyg build
|
||||
skyg switch
|
||||
### Other
|
||||
|
||||
# Test configuration before switching
|
||||
skyg test
|
||||
|
||||
# Update dependencies
|
||||
skyg update nixpkgs
|
||||
|
||||
# Deploy to a remote server
|
||||
skyg remote switch bigbox1
|
||||
|
||||
# Rollback if something goes wrong
|
||||
skyg rollback
|
||||
|
||||
# Apply home-manager changes
|
||||
skyg hm switch
|
||||
```
|
||||
|
||||
### Using Custom Packages
|
||||
|
||||
All packages from `pkgs/` are available in your configuration as `pkgs.<name>` thanks to the overlay.
|
||||
|
||||
Example:
|
||||
|
||||
```nix
|
||||
environment.systemPackages = with pkgs; [ niri-touchscreen-gestures ];
|
||||
```
|
||||
|
||||
See [`pkgs/ABOUTME.md`](pkgs/ABOUTME.md) for details on each package.
|
||||
| Command | Description |
|
||||
| ----------------------------- | ------------------------------------------------------- |
|
||||
| `skyg profiles` | List all profiles |
|
||||
| `skyg profiles true` | List only remote (`hl-*`) profiles |
|
||||
| `skyg render html-tpl <file>` | Preview a Gitea `.tmpl` on `127.0.0.1` (Ctrl+C to stop) |
|
||||
|
||||
## Managing Secrets
|
||||
|
||||
Secrets are encrypted using [agenix](https://github.com/ryantm/agenix) and stored in `secrets/`.
|
||||
Secrets are encrypted with [agenix](https://github.com/ryantm/agenix) and stored in `secrets/`.
|
||||
|
||||
### Adding a Host to Secrets
|
||||
To give a new host access:
|
||||
|
||||
1. **Get the host's SSH public key**: `cat /etc/ssh/ssh_host_ed25519_key.pub`
|
||||
2. **Add to `secrets.nix`**: Create a variable with the key and add it to each secret's `publicKeys` list
|
||||
3. **Re-encrypt**: for each affected secret run `skyg decrypt <name>` then `skyg encrypt <name>` to re-encrypt it against the updated key set
|
||||
1. Get its key: `cat /etc/ssh/ssh_host_ed25519_key.pub`
|
||||
2. Add it to `secrets.nix` and to each secret's `publicKeys`
|
||||
3. Re-encrypt each affected secret: `skyg secrets show <name>`, then `skyg secrets edit <name>`
|
||||
|
||||
For more details, see `secrets/ABOUTME.md`.
|
||||
See `secrets/ABOUTME.md` and `docs/agenix.md` for more.
|
||||
|
||||
## Host Profiles
|
||||
|
||||
Available profiles include:
|
||||
|
||||
- **Local**: `fwbook` (Framework laptop)
|
||||
- **Remote**: `hl-bigbox1`, `hl-bigbox2`, `hl-fwdesk`, `hl-fws1`, `hl-minipc1`, `hl-minipc2`, `hl-minipc3`, `hl-terra1`
|
||||
- **ISO**: `iso` (bootable image)
|
||||
- **Remote**: `hl-bigbox1`, `hl-bigbox2`, `hl-fwdesk`, `hl-fws1`, `hl-minipc1`, `hl-minipc2`, `hl-minipc3`, `hl-pi1`, `hl-pi2`, `hl-terra1`
|
||||
- **ISO**: `iso` (bootable installer)
|
||||
|
||||
All profiles automatically have access to the custom packages from the `pkgs/` directory.
|
||||
See `docs/hosts/README.md` for per-host details.
|
||||
+47
-28
@@ -7,42 +7,61 @@ The `skyg` CLI — the single entry point for all system management tasks in thi
|
||||
```
|
||||
bin/
|
||||
├── skyg # Bash shim: exec nu --commands "use lib/cmds.nu *; skyg $*"
|
||||
├── check-flake-versions # Bash shim for `skyg check-flake-versions`
|
||||
|
||||
├── temp-monitor # NuShell script: collect CPU/GPU temps to CSV + optional graph
|
||||
├── TEMP_MONITOR_README.md # Usage docs for temp-monitor
|
||||
└── lib/
|
||||
├── cmds.nu # All subcommand implementations (NuShell — source of truth); commands only
|
||||
├── helpers.nu # Shared helpers: REPO_ROOT const + internal functions used by commands
|
||||
├── profile.nu # Profile helpers and tab-completion data
|
||||
└── types.nu # Type definitions + tab-completion data
|
||||
├── cmds.nu # Dispatcher + bare `skyg` + `skyg profiles`
|
||||
├── os.nu # `skyg os` (local NixOS rebuild/switch/rollback)
|
||||
├── remote.nu # `skyg remote *` (deploy, install, boot-all, status, reboot-pending)
|
||||
├── secrets.nu # `skyg secrets [list]/show/edit/compare`
|
||||
├── ca.nu # `skyg ca init/issue`
|
||||
├── buzz.nu # `skyg buzz identity`
|
||||
├── pkgs.nu # `skyg pkgs update`
|
||||
├── flake.nu # `skyg flake update/check/check-versions`
|
||||
├── build.nu # `skyg build image/openwrt`
|
||||
├── render.nu # `skyg render html-tpl`
|
||||
├── hm.nu # `skyg hm <action>`
|
||||
├── net.nu # `skyg net check` (per-device NIC info + shared-server speed test), `skyg net last`
|
||||
├── net-nic.sh # Bash probe piped to each device by `skyg net check` (NIC model, driver, link/supported speeds)
|
||||
├── helpers.nu # Shared helpers: REPO_ROOT const + internal functions
|
||||
├── profile.nu # Profile helpers and tab-completion data
|
||||
├── types.nu # Tab-completion completer functions
|
||||
└── remote.utils.nu # Remote-specific helpers (boot info, wait-for-host, notify)
|
||||
```
|
||||
|
||||
## Key Commands
|
||||
|
||||
| Command | Description |
|
||||
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `skyg os switch` | Rebuild and switch local system |
|
||||
| `skyg remote switch <host>` | Deploy to a remote host |
|
||||
| `skyg remote install <host>` | Fresh-install a remote host via nixos-anywhere, using `hosts/<profile>.disko.nix`. Always wipes the disks in that file. Aborts if the file is missing, if the host already boots NixOS from disk (unless `--force-wipe`), or if you do not type the short hostname. |
|
||||
| `skyg hm switch` | Apply Home Manager config |
|
||||
| `skyg update [input]` | Update flake inputs |
|
||||
| `skyg build-image iso | pi1 | pi2` | Build bootable image — ISO (`iso`) or Pi SD card image (`pi1`, `pi2`) |
|
||||
| `skyg openwrt` | Deploy OpenWrt config |
|
||||
| `skyg rollback` | Roll back to previous generation |
|
||||
| `skyg profiles` | List valid local/remote profiles |
|
||||
| `skyg check` | Run `nix flake check --no-build` |
|
||||
| `skyg check-flake-versions` | Verify NixOS release version consistency in flake.nix |
|
||||
| `skyg remote boot-all` | Boot all remote hosts (builds on `fwdesk`) |
|
||||
| `skyg remote status` | Check status of all remote hosts |
|
||||
| `skyg secrets` | List known secret names |
|
||||
| `skyg decrypt <secret>` | Decrypt a secret to `.tmp/unencrypted-<secret>` |
|
||||
| `skyg encrypt <secret> [--yaml]` | Encrypt a working copy back into the secret |
|
||||
| `skyg compare-secret <secret>` | Diff the working copy against the stored secret |
|
||||
| `skyg ca init` | Generate the lab root CA: key → `secrets/lab-ca-key.age`, cert → `configs/pki/lab-ca.crt` (see `configs/pki/ABOUTME.md`) |
|
||||
| `skyg ca issue <domain> --for <host>` | Mint a TLS leaf cert signed by the lab CA: cert → `configs/pki/<domain>.crt`, key → `secrets/<name>-tls-key.age`. Auto-registers missing `secrets.nix` entries. |
|
||||
| `skyg render html-tpl <file>` | Render a Gitea `.tmpl` (swaps `base/head`/`base/footer` for a minimal shell, strips `{{ … }}`) and serve it on `127.0.0.1` for preview. Foreground — Ctrl+C to stop. `<file>` tab-completes from `**/*.tmpl`. |
|
||||
| Command | Description |
|
||||
| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `skyg os switch` | Rebuild and switch local system |
|
||||
| `skyg os rollback` | Roll back to previous generation |
|
||||
| `skyg remote switch <host>` | Deploy to a remote host |
|
||||
| `skyg remote install <host>` | Fresh-install a remote host via nixos-anywhere, using `hosts/<profile>.disko.nix`. Always wipes the disks in that file. Aborts if the file is missing, if the host already boots NixOS from disk (unless `--force-wipe`), or if you do not type the short hostname. |
|
||||
| `skyg remote status <host>` | Check status of a single remote host: booted / current / next-boot generation. `reboot_pending` = booted != next boot (`/nix/var/nix/profiles/system`), `needs_build` = local build != next boot (or `"unknown"` if the local eval fails). So hosts deployed with `boot` show up correctly. |
|
||||
| `skyg remote status --all` | Check status of all remote hosts |
|
||||
| `skyg remote boot-all` | Boot all remote hosts |
|
||||
| `skyg remote reboot-pending` | Reboot every remote host with a pending reboot (`booted-system` != next-boot generation, so `boot` deploys count). Lists them, asks for confirmation, then reboots one at a time. Each host must prove it rebooted (boot id changed) and come back on its next-boot generation, otherwise it is reported as failed. Sends a desktop notification per host. |
|
||||
| `skyg hm switch` | Apply Home Manager config |
|
||||
| `skyg flake update [input]` | Update flake inputs |
|
||||
| `skyg flake check` | Run `nix flake check --no-build` |
|
||||
| `skyg flake check-versions` | Verify NixOS release version consistency in flake.nix |
|
||||
| `skyg build image iso\|pi1\|pi2` | Build bootable image — ISO (`iso`) or Pi SD card image (`pi1`, `pi2`) |
|
||||
| `skyg build openwrt [router]` | Deploy OpenWrt config |
|
||||
| `skyg profiles` | List valid local/remote profiles |
|
||||
| `skyg secrets list` | List known secret names |
|
||||
| `skyg secrets show <secret>` | Decrypt a secret to `.tmp/unencrypted-<secret>` |
|
||||
| `skyg secrets edit <secret> [--yaml]` | Encrypt a working copy back into the secret |
|
||||
| `skyg secrets compare <secret>` | Diff the working copy against the stored secret |
|
||||
| `skyg ca init` | Generate the lab root CA: key → `secrets/lab-ca-key.age`, cert → `configs/pki/lab-ca.crt` (see `configs/pki/ABOUTME.md`) |
|
||||
| `skyg ca issue <domain> --for <host>` | Mint a TLS leaf cert signed by the lab CA: cert → `configs/pki/<domain>.crt`, key → `secrets/<name>-tls-key.age`. Auto-registers missing `secrets.nix` entries. |
|
||||
| `skyg buzz identity <robot>` | Make a Buzz (Nostr) identity for a robot's Hermes agent and merge `BUZZ_RELAY_URL` / `BUZZ_PRIVATE_KEY` (plus optional `--channels`, `--home-channel`). The bot answers anyone on the relay by default (`BUZZ_ALLOW_ALL_USERS=true`); `--allowed-users <npubs>` limits it to a list, `--restricted` allows no one into `secrets/robots-<robot>.age`, keeping its other lines. Refuses to replace an existing key without `--rotate`. `--dry-run` only shows the npub. Prints the `buzz-manage add-member <npub>` step. Needs `nak` (dev shell). |
|
||||
| `skyg pkgs update [--all\|<pkg>]` | Update one or all custom packages |
|
||||
| `skyg net check [device]` | For every managed device (or just `[device]`): report the NIC on the default route (model, driver, current link speed, supported speeds), then run `speedtest-go` via `nix-shell` against one shared server. Logs progress per device and returns a table. `--server <id>` picks the server; `--no-speedtest` skips the test. Offline devices are listed, not tested. Every run saves the table to `.tmp/net-checks/<timestamp>.nuon`; `--save <file>` also writes it to `<file>` (format from extension). The server is saved in `.tmp/net-checks/server.nuon` on first run; later runs ask whether to change it (fuzzy pick list from `speedtest-go --list`). `--server` skips the question and leaves the saved server alone. |
|
||||
| `skyg net last` | Show the table from the most recent `skyg net check` run (newest file in `.tmp/net-checks/`). |
|
||||
| `skyg render html-tpl <file>` | Render a Gitea `.tmpl` and serve it on `127.0.0.1` for preview. Foreground — Ctrl+C to stop. `<file>` tab-completes from `**/*.tmpl`. |
|
||||
|
||||
## Agent Note
|
||||
|
||||
> **Never invoke `skyg` commands that trigger builds or switches.**
|
||||
> Only the user runs these. Edits to `cmds.nu` are safe if the user asks for CLI changes.
|
||||
> Only the user runs these. Edits to `cmds.nu` / `remote.nu` are safe if the user asks for CLI changes.
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
LIB="$SCRIPT_DIR/lib/cmds.nu"
|
||||
exec nu --commands "use \"$LIB\" *; skyg check-flake-versions"
|
||||
@@ -0,0 +1,35 @@
|
||||
use types.nu *
|
||||
use helpers.nu *
|
||||
|
||||
# Build a bootable image: ISO, or Pi SD card image (fully-baked, no on-device rebuild)
|
||||
export def "skyg build image" [target: string@image-targets] {
|
||||
cd $REPO_ROOT
|
||||
let spec = (match $target {
|
||||
"iso" => { config: "iso", out: "iso", attr: "isoImage" }
|
||||
"pi1" => { config: "hl-pi1", out: "sd-image", attr: "sdImage" }
|
||||
"pi2" => { config: "hl-pi2", out: "sd-image", attr: "sdImage" }
|
||||
_ => { error make { msg: $"Unknown image target '($target)'. Expected: iso, pi1, pi2" } }
|
||||
})
|
||||
let imageBuildTime = date now | format date "%Y.%m.%d_%H_%M_%S"
|
||||
let rootOutputFolder = $REPO_ROOT | path join "build" $spec.config
|
||||
let outPutFolder = $rootOutputFolder | path join $imageBuildTime
|
||||
rm -rf $rootOutputFolder
|
||||
mkdir $rootOutputFolder
|
||||
nix build $"#nixosConfigurations.($spec.config).config.system.build.($spec.attr)" -o $outPutFolder
|
||||
printf $outPutFolder
|
||||
}
|
||||
|
||||
# Deploy OpenWrt router configuration
|
||||
export def "skyg build openwrt" [
|
||||
router?: string@router-names,
|
||||
--dry-run # Render configs to .tmp/openwrt-<router>/ without touching the router
|
||||
] {
|
||||
cd $REPO_ROOT
|
||||
let router = $router | default "glmain"
|
||||
let decrypted_file = skyg secrets show $"($router).json"
|
||||
if $dry_run {
|
||||
^cat $decrypted_file | nix run .#openwrt-($router)-dry-run -- ($router)
|
||||
} else {
|
||||
^cat $decrypted_file | nix run .#openwrt-($router)
|
||||
}
|
||||
}
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
use types.nu *
|
||||
use helpers.nu *
|
||||
|
||||
# Same host as RELAY_URL in hosts/hl-minipc1/services/buzz.nix (public domain).
|
||||
const BUZZ_DEFAULT_RELAY = "https://buzz.home.sosnovsky.ca"
|
||||
|
||||
# Robots that have a secrets/robots-<name>.age (robots-shared is not a robot).
|
||||
def buzz-robots [] {
|
||||
secret-names
|
||||
| where {|s| ($s | str starts-with "robots-") and $s != "robots-shared" }
|
||||
| each {|s| $s | str replace "robots-" "" }
|
||||
}
|
||||
|
||||
# Drop existing KEY=... lines for the keys in `vars` and in `drop`, then append
|
||||
# the new values. Every other line is kept as is.
|
||||
def env-merge [lines: list<string>, vars: record, drop: list<string>] {
|
||||
let keys = (($vars | columns) ++ $drop)
|
||||
let kept = ($lines | where {|l|
|
||||
let t = ($l | str trim)
|
||||
not ($keys | any {|k| $t | str starts-with $"($k)=" })
|
||||
})
|
||||
$kept ++ ($vars | items {|k, v| $"($k)=($v)" })
|
||||
}
|
||||
|
||||
# Make a Buzz (Nostr) identity for a robot's Hermes agent and write the BUZZ_*
|
||||
# env vars into secrets/robots-<robot>.age. Other lines in the secret are kept.
|
||||
# By default the bot answers anyone on the relay (BUZZ_ALLOW_ALL_USERS=true).
|
||||
# Pass --allowed-users for an explicit list, or --restricted for no one.
|
||||
# The nsec is never printed. Afterwards, add the printed npub to the relay.
|
||||
export def "skyg buzz identity" [
|
||||
robot: string@buzz-robots # Robot name (secret: secrets/robots-<robot>.age)
|
||||
--relay: string # BUZZ_RELAY_URL (default: the lab relay)
|
||||
--allowed-users: string # Only these answer: comma-separated npubs or hex pubkeys (BUZZ_ALLOWED_USERS)
|
||||
--restricted # Neither allow-all nor a list is set: the bot ignores everyone until you add one
|
||||
--channels: string # BUZZ_CHANNELS: comma-separated channel UUIDs
|
||||
--home-channel: string # BUZZ_HOME_CHANNEL: channel UUID for cron/notifications
|
||||
--rotate # Replace an existing BUZZ_PRIVATE_KEY (loses relay membership)
|
||||
--dry-run # Make a key and show the npub; do not touch the secret
|
||||
] {
|
||||
cd $REPO_ROOT
|
||||
if (which nak | is-empty) {
|
||||
error make {msg: "nak not found — run inside the dev shell (nix develop)"}
|
||||
}
|
||||
let secret = $"secrets/robots-($robot).age"
|
||||
let relay_url = ($relay | default $BUZZ_DEFAULT_RELAY | str trim --right --char "/")
|
||||
|
||||
# Read the current secret first, so we fail before making anything.
|
||||
mut existing = []
|
||||
if not $dry_run {
|
||||
if not ($secret | path exists) {
|
||||
error make {msg: $"($secret) not found — create it first (skyg secrets edit robots-($robot))"}
|
||||
}
|
||||
$existing = (^agenix -d $secret | lines)
|
||||
let has_key = ($existing | any {|l| ($l | str trim) | str starts-with "BUZZ_PRIVATE_KEY=" })
|
||||
if $has_key and not $rotate {
|
||||
error make {msg: $"($secret) already has BUZZ_PRIVATE_KEY. Use --rotate to replace it (the robot gets a new identity and must be re-added to the relay)."}
|
||||
}
|
||||
}
|
||||
|
||||
let hex = (^nak key generate | str trim)
|
||||
let pubhex = (^nak key public $hex | str trim)
|
||||
let nsec = (^nak encode nsec $hex | str trim)
|
||||
let npub = (^nak encode npub $pubhex | str trim)
|
||||
let ok = ($nsec | str starts-with "nsec1") and ($npub | str starts-with "npub1")
|
||||
if not $ok {
|
||||
error make {msg: "nak returned an unexpected key format; nothing was written"}
|
||||
}
|
||||
|
||||
mut vars = {BUZZ_RELAY_URL: $relay_url, BUZZ_PRIVATE_KEY: $nsec}
|
||||
if ($allowed_users | is-not-empty) { $vars = ($vars | insert BUZZ_ALLOWED_USERS $allowed_users) }
|
||||
if ($channels | is-not-empty) { $vars = ($vars | insert BUZZ_CHANNELS $channels) }
|
||||
if ($home_channel | is-not-empty) { $vars = ($vars | insert BUZZ_HOME_CHANNEL $home_channel) }
|
||||
# Allow-all is the default; a list or --restricted turns it off (and clears a stale true).
|
||||
mut drop = []
|
||||
if ($allowed_users | is-not-empty) {
|
||||
$vars = ($vars | insert BUZZ_ALLOWED_USERS $allowed_users)
|
||||
$drop = ["BUZZ_ALLOW_ALL_USERS"]
|
||||
} else if $restricted {
|
||||
$drop = ["BUZZ_ALLOW_ALL_USERS"]
|
||||
} else {
|
||||
$vars = ($vars | insert BUZZ_ALLOW_ALL_USERS "true")
|
||||
}
|
||||
|
||||
if $dry_run {
|
||||
print $"Dry run: nothing written. Would set in ($secret):"
|
||||
print ($vars | columns | each {|k| $" ($k)" } | str join "\n")
|
||||
if ($drop | is-not-empty) { print $"Would remove: ($drop | str join ', ')" }
|
||||
print $"npub: ($npub)"
|
||||
return
|
||||
}
|
||||
|
||||
# Only --restricted can leave nobody allowed.
|
||||
let gated = (
|
||||
($allowed_users | is-not-empty)
|
||||
or ($existing | any {|l| ($l | str trim) | str starts-with "BUZZ_ALLOWED_USERS=" })
|
||||
)
|
||||
|
||||
# Straight into agenix over stdin: no plaintext file on disk.
|
||||
let body = ((env-merge $existing $vars $drop) | str join "\n") + "\n"
|
||||
$body | ^agenix -e $secret
|
||||
|
||||
print $"✅ Updated ($secret) with: ($vars | columns | str join ', ')"
|
||||
print $"npub: ($npub)"
|
||||
print "Next:"
|
||||
print $" 1. On hl-minipc1: sudo buzz-manage add-member ($npub)"
|
||||
if $restricted and not $gated {
|
||||
print "⚠️ --restricted with no BUZZ_ALLOWED_USERS: the bot will ignore everyone. Re-run with --rotate --allowed-users <npub,...> or edit the secret."
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
use types.nu *
|
||||
use helpers.nu *
|
||||
|
||||
# Generate the lab root CA: key encrypted to secrets/lab-ca-key.age,
|
||||
# public cert written to configs/pki/lab-ca.crt. Run once, before `ca issue`.
|
||||
export def "skyg ca init" [
|
||||
--days: int = 3650 # CA lifetime in days
|
||||
] {
|
||||
cd $REPO_ROOT
|
||||
let cert = "configs/pki/lab-ca.crt"
|
||||
let key_secret = "secrets/lab-ca-key.age"
|
||||
if ($cert | path exists) {
|
||||
error make {msg: $"($cert) already exists — refusing to overwrite the CA. Delete it manually to rotate."}
|
||||
}
|
||||
ensure-secret-entry $key_secret ["ari"]
|
||||
mkdir .tmp configs/pki
|
||||
let tmp_key = ".tmp/lab-ca-key.pem"
|
||||
(openssl req -x509 -newkey rsa:4096 -sha256 -days $days -nodes
|
||||
-keyout $tmp_key -out $cert
|
||||
-subj "/CN=Skyg Lab CA"
|
||||
-addext "basicConstraints=critical,CA:TRUE"
|
||||
-addext "keyUsage=critical,keyCertSign,cRLSign")
|
||||
^cat $tmp_key | agenix -e $key_secret
|
||||
rm -f $tmp_key
|
||||
print $"✅ CA cert: ($cert) — commit this"
|
||||
print $"✅ CA key encrypted: ($key_secret)"
|
||||
print "Next: skyg ca issue <domain> --for <host>"
|
||||
}
|
||||
|
||||
# Issue a TLS cert for a domain, signed by the lab CA.
|
||||
# Writes configs/pki/<domain>.crt; encrypts the key to secrets/<name>-tls-key.age.
|
||||
export def "skyg ca issue" [
|
||||
domain: string # e.g. buzz.app.internal
|
||||
--for: string@ca-recipients # secrets.nix key name allowed to decrypt the leaf key (e.g. minipc1)
|
||||
--days: int = 825 # leaf lifetime (825 = browser max)
|
||||
--name: string # secret slug override (default: first DNS label)
|
||||
] {
|
||||
cd $REPO_ROOT
|
||||
let ca_cert = "configs/pki/lab-ca.crt"
|
||||
let ca_key_secret = "secrets/lab-ca-key.age"
|
||||
if not ($ca_cert | path exists) {
|
||||
error make {msg: "No CA found — run `skyg ca init` first"}
|
||||
}
|
||||
let key_names = (^cat secrets.nix | parse --regex '(\w+) = "ssh-' | get capture0)
|
||||
if ($for not-in $key_names) {
|
||||
error make {msg: $"Unknown recipient '($for)'. Known: ($key_names | str join ', ')"}
|
||||
}
|
||||
let slug = $name | default ($domain | split row "." | first)
|
||||
let secret = $"secrets/($slug)-tls-key.age"
|
||||
let cert = $"configs/pki/($domain).crt"
|
||||
if ($cert | path exists) {
|
||||
error make {msg: $"($cert) already exists — delete it manually to re-issue."}
|
||||
}
|
||||
ensure-secret-entry $secret ["ari" $for]
|
||||
mkdir .tmp configs/pki
|
||||
let ca_key = ".tmp/lab-ca-key.pem"
|
||||
agenix -d $ca_key_secret | save -f $ca_key
|
||||
let leaf_key = $".tmp/($slug)-tls-key.pem"
|
||||
let csr = $".tmp/($slug).csr"
|
||||
let ext = $".tmp/($slug)-ext.cnf"
|
||||
$"basicConstraints=critical,CA:FALSE\nkeyUsage=critical,digitalSignature,keyEncipherment\nextendedKeyUsage=serverAuth\nsubjectAltName=DNS:($domain)\n" | save -f $ext
|
||||
(openssl req -newkey rsa:2048 -nodes
|
||||
-keyout $leaf_key -out $csr
|
||||
-subj $"/CN=($domain)")
|
||||
(openssl x509 -req -in $csr
|
||||
-CA $ca_cert -CAkey $ca_key -CAcreateserial
|
||||
-out $cert -days $days -sha256 -extfile $ext)
|
||||
^cat $leaf_key | agenix -e $secret
|
||||
rm -f $ca_key $leaf_key $csr $ext
|
||||
print $"✅ Cert: ($cert) — commit this"
|
||||
print $"✅ Key encrypted: ($secret)"
|
||||
print $"Wire it up: age.secrets.($slug)-tls-key.file = ../($secret);"
|
||||
}
|
||||
+11
-613
@@ -1,6 +1,17 @@
|
||||
use types.nu *
|
||||
use profile.nu *
|
||||
use helpers.nu *
|
||||
export use remote.nu *
|
||||
export use os.nu *
|
||||
export use secrets.nu *
|
||||
export use ca.nu *
|
||||
export use buzz.nu *
|
||||
export use pkgs.nu *
|
||||
export use flake.nu *
|
||||
export use build.nu *
|
||||
export use render.nu *
|
||||
export use hm.nu *
|
||||
export use net.nu *
|
||||
|
||||
export def skyg [] {
|
||||
print $REPO_ROOT
|
||||
@@ -19,616 +30,3 @@ export def "skyg profiles" [only_remote: bool = false] {
|
||||
valid_profiles | print
|
||||
}
|
||||
}
|
||||
|
||||
export def "skyg check" [] {
|
||||
nix flake check --no-build
|
||||
}
|
||||
|
||||
# Validate that all versioned flake inputs use the same NixOS release
|
||||
export def "skyg check-flake-versions" [] {
|
||||
let flake = "flake.nix"
|
||||
|
||||
if not ($flake | path exists) {
|
||||
print "check-flake-versions: flake.nix not found, skipping"
|
||||
return
|
||||
}
|
||||
|
||||
# Only scan url lines to avoid false positives from embedded script strings
|
||||
let url_lines = (open $flake | lines | enumerate | where { |row|
|
||||
($row.item | str contains "url") and ($row.item =~ 'release-\d+\.\d+')
|
||||
})
|
||||
|
||||
let versions = ($url_lines
|
||||
| each {|row| $row.item | parse --regex '.*release-(?P<version>\d+\.\d+).*' | get version }
|
||||
| flatten
|
||||
| uniq)
|
||||
|
||||
if ($versions | length) <= 1 {
|
||||
print "check-flake-versions: OK"
|
||||
return
|
||||
}
|
||||
|
||||
print "check-flake-versions: mismatched NixOS release versions in flake.nix:"
|
||||
print ""
|
||||
for version in $versions {
|
||||
print $" release-($version):"
|
||||
$url_lines | where {|row| $row.item | str contains $"release-($version)" } | each { |row|
|
||||
print $" line ($row.index + 1): ($row.item | str trim)"
|
||||
}
|
||||
}
|
||||
print ""
|
||||
print "All versioned inputs (home-manager, stylix, etc.) must use the same NixOS release."
|
||||
error make {msg: "Mismatched NixOS release versions"}
|
||||
}
|
||||
|
||||
# rollback configuration
|
||||
export def "skyg rollback" [] {
|
||||
sudo nixos-rebuild switch --rollback
|
||||
}
|
||||
|
||||
# update some flakes
|
||||
export def "skyg update" [input_name: string = ""] {
|
||||
cd $REPO_ROOT
|
||||
if $input_name == "" {
|
||||
print "Updating all flakes..."
|
||||
nix flake update | print
|
||||
} else {
|
||||
print $"Updating flake: ($input_name)"
|
||||
nix flake update $input_name | print
|
||||
}
|
||||
git diff flake.lock | print
|
||||
}
|
||||
|
||||
# Build local os
|
||||
export def "skyg os" [cmd: string, --build-host: string = ""] {
|
||||
cd $REPO_ROOT
|
||||
mut runcmd = $"nh os ($cmd)"
|
||||
if $build_host != "" {
|
||||
$runcmd = $"($runcmd) --build-host ($build_host).lab.internal"
|
||||
}
|
||||
$runcmd | print
|
||||
bash -c $runcmd
|
||||
}
|
||||
|
||||
# Deploy to remote machine
|
||||
export def "skyg remote" [
|
||||
cmd: string@remote-cmds,
|
||||
target: string@remote_targets = "",
|
||||
--build-host: string@remote_targets = "", # Optional remote builder host (e.g. builder.lab.internal)
|
||||
] {
|
||||
cd $REPO_ROOT
|
||||
mut target_host = $"root@($target).lab.internal"
|
||||
mut profile = $"hl-($target)"
|
||||
if not (is-valid-profile $profile true) {
|
||||
print $"Invalid Remote Profile '(ansi green_bold)($target)(ansi reset)', please select one of:"
|
||||
return (remote_targets)
|
||||
}
|
||||
$"Using [(ansi green_bold)($profile)(ansi reset)]" | print
|
||||
$"($cmd) on ($target_host) with ($profile)" | print
|
||||
mut runcmd = $"nh os ($cmd) --target-host ($target_host) --ask .#($profile)"
|
||||
if $build_host != "" {
|
||||
$runcmd = $"($runcmd) --build-host ($build_host).lab.internal"
|
||||
}
|
||||
$runcmd | print
|
||||
bash -c $runcmd
|
||||
}
|
||||
|
||||
# Fresh-install a remote machine via nixos-anywhere, using its disko config.
|
||||
# Always reformats every disk in the disko file — a second run is as destructive as the first.
|
||||
# Missing disko file, live disk OS (without --force-wipe), or mistyped hostname all abort.
|
||||
export def "skyg remote install" [
|
||||
target: string@remote_targets,
|
||||
--force-wipe, # wipe even if the host already runs NixOS from disk
|
||||
] {
|
||||
cd $REPO_ROOT
|
||||
let target_host = $"root@($target).lab.internal"
|
||||
let profile = $"hl-($target)"
|
||||
if not (is-valid-profile $profile true) {
|
||||
print $"Invalid Remote Profile '(ansi green_bold)($target)(ansi reset)', please select one of:"
|
||||
return (remote_targets)
|
||||
}
|
||||
let disko_file = $"hosts/($profile).disko.nix"
|
||||
if not ($disko_file | path exists) {
|
||||
error make {msg: $"Missing disko config: ($disko_file). Refusing to install ($profile) without a disko layout."}
|
||||
}
|
||||
|
||||
print ""
|
||||
print $"(ansi red_bold)WARNING: this WIPES every disk listed in ($disko_file).(ansi reset)"
|
||||
print "This is not a switch. Use `skyg remote switch` / `skyg remote boot` to update an installed host."
|
||||
print ""
|
||||
print "Disks in the disko file:"
|
||||
let disks = (
|
||||
open $disko_file
|
||||
| lines
|
||||
| where {|l| ($l | str contains "device") and ($l | str contains "=") }
|
||||
| each {|l| $l | str trim }
|
||||
)
|
||||
for line in $disks {
|
||||
print $" ($line)"
|
||||
}
|
||||
print ""
|
||||
|
||||
let ssh = $"ssh -o BatchMode=yes -o ConnectTimeout=5 -o StrictHostKeyChecking=accept-new ($target_host)"
|
||||
let root_fstype = (try {
|
||||
bash -c $"($ssh) 'findmnt -n -o FSTYPE /' 2>/dev/null" | str trim
|
||||
} catch { "" })
|
||||
|
||||
if $root_fstype == "" {
|
||||
print $"(ansi yellow)Could not SSH to ($target_host) to check for a live OS.(ansi reset)"
|
||||
} else {
|
||||
print $"Remote / fstype: ($root_fstype)"
|
||||
let installer_fs = ["overlay" "tmpfs" "squashfs"]
|
||||
if not ($root_fstype in $installer_fs) {
|
||||
if not $force_wipe {
|
||||
error make {msg: $"($target_host) already boots from disk (root fstype ($root_fstype)). Refusing to wipe. Use `skyg remote switch ($target)` to update, or pass --force-wipe to reinstall."}
|
||||
}
|
||||
print $"(ansi yellow)--force-wipe set: proceeding against a live disk OS.(ansi reset)"
|
||||
} else {
|
||||
print "Remote looks like an installer live image (ok to install)."
|
||||
}
|
||||
}
|
||||
|
||||
let confirm = input $"Type ($target) to continue: " | str trim
|
||||
if $confirm != $target {
|
||||
error make {msg: $"Aborted: typed '($confirm)', expected '($target)'."}
|
||||
}
|
||||
|
||||
$"Installing [(ansi green_bold)($profile)(ansi reset)] on ($target_host) via nixos-anywhere, using ($disko_file)" | print
|
||||
let runcmd = $"nix run github:nix-community/nixos-anywhere -- --flake .#($profile) ($target_host)"
|
||||
$runcmd | print
|
||||
let bash_path = which bash | get 0.path
|
||||
with-env { SHELL: $bash_path } {
|
||||
bash -c $runcmd
|
||||
}
|
||||
}
|
||||
|
||||
# Boot all remote hosts except the current machine (fwbook)
|
||||
# Checks online status first, runs `skyg remote boot --build-host fwdesk <host>` for each online host,
|
||||
# and writes a summary report to .tmp/boot-report.txt
|
||||
|
||||
export def "skyg remote boot-all" [] {
|
||||
cd $REPO_ROOT
|
||||
mkdir .tmp
|
||||
let current_host = "fwbook"
|
||||
let report_file = ".tmp/boot-report.txt"
|
||||
|
||||
# Discover remote targets from the flake (same logic as skyg remote)
|
||||
let all_hosts = remote_targets | where {|h| $h != $current_host }
|
||||
|
||||
print $"Found ($all_hosts | length) candidate hosts excluding ($current_host)"
|
||||
|
||||
mut successes = []
|
||||
mut failures = []
|
||||
mut skipped = []
|
||||
|
||||
# Phase 1: sequential SSH reachability checks (fast)
|
||||
mut online_hosts = []
|
||||
for host in $all_hosts {
|
||||
print $"\n=== Checking ($host) ==="
|
||||
let target = $"root@($host).lab.internal"
|
||||
let is_online = (try {
|
||||
bash -c $"ssh -o BatchMode=yes -o ConnectTimeout=3 -o StrictHostKeyChecking=accept-new ($target) 'true' >/dev/null 2>&1"
|
||||
true
|
||||
} catch { false })
|
||||
|
||||
if not $is_online {
|
||||
print $"(ansi yellow)OFFLINE(ansi reset): ($host)"
|
||||
$skipped = ($skipped | append $host)
|
||||
} else {
|
||||
print $"(ansi green)ONLINE(ansi reset): ($host)"
|
||||
$online_hosts = ($online_hosts | append $host)
|
||||
}
|
||||
}
|
||||
|
||||
# Phase 2: run boots in parallel (2 concurrent) without interactive prompts
|
||||
if ($online_hosts | length) > 0 {
|
||||
print "
|
||||
Starting parallel boots (concurrency: 2)..."
|
||||
let boot_results = ($online_hosts | par-each --threads 1 { |host|
|
||||
let target_host = $"root@($host).lab.internal"
|
||||
let profile = $"hl-($host)"
|
||||
let runcmd = $"nh os boot --target-host ($target_host) .#($profile)"
|
||||
print $runcmd
|
||||
let ok = (try {
|
||||
bash -c $runcmd
|
||||
true
|
||||
} catch {
|
||||
false
|
||||
})
|
||||
{host: $host, success: $ok}
|
||||
})
|
||||
|
||||
for r in $boot_results {
|
||||
if $r.success {
|
||||
$successes = ($successes | append $r.host)
|
||||
print $"(ansi green)SUCCESS(ansi reset): ($r.host)"
|
||||
} else {
|
||||
$failures = ($failures | append $r.host)
|
||||
print $"(ansi red)FAILED(ansi reset): ($r.host)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Write report
|
||||
let timestamp = date now | format date "%Y-%m-%d %H:%M:%S"
|
||||
let report = $"Boot Report - ($timestamp)
|
||||
|
||||
Total hosts considered: ($all_hosts | length)
|
||||
Skipped offline: ($skipped | length) - ($skipped | str join ', ')
|
||||
Successful: ($successes | length) - ($successes | str join ', ')
|
||||
Failed: ($failures | length) - ($failures | str join ', ')
|
||||
|
||||
Details:
|
||||
Online & Booted: ($successes | str join ', ')
|
||||
Offline: ($skipped | str join ', ')
|
||||
Failed: ($failures | str join ', ')
|
||||
"
|
||||
|
||||
$report | save -f $report_file
|
||||
print $"
|
||||
Report written to ($report_file)"
|
||||
print $report
|
||||
}
|
||||
|
||||
# Check status of all remotes: generation, pending reboot, needs rebuild
|
||||
export def "skyg remote status" [] {
|
||||
cd $REPO_ROOT
|
||||
mkdir .tmp
|
||||
let current_host = "fwbook"
|
||||
let report_file = ".tmp/status-report.txt"
|
||||
|
||||
let all_hosts = remote_targets | where {|h| $h != $current_host }
|
||||
print $"Checking status for ($all_hosts | length) remotes..."
|
||||
|
||||
let results = ($all_hosts | each { |host|
|
||||
print $"
|
||||
=== ($host) ==="
|
||||
let target = $"root@($host).lab.internal"
|
||||
let online = (try {
|
||||
bash -c $"ssh -o BatchMode=yes -o ConnectTimeout=3 ($target) 'true' >/dev/null 2>&1"
|
||||
true
|
||||
} catch { false })
|
||||
|
||||
if not $online {
|
||||
print $"(ansi yellow)OFFLINE(ansi reset)"
|
||||
return {host: $host, status: "offline", booted: "", current: "", reboot_pending: false, needs_build: false}
|
||||
}
|
||||
|
||||
let info = (try {
|
||||
let booted = bash -c $"ssh ($target) 'readlink /run/booted-system' 2>/dev/null" | str trim
|
||||
let current = bash -c $"ssh ($target) 'readlink /run/current-system' 2>/dev/null" | str trim
|
||||
let reboot_pending = ($booted != $current)
|
||||
|
||||
# Compare what the local flake currently evaluates to vs remote's active system
|
||||
let local_toplevel = (try {
|
||||
(bash -c $"nix eval --raw '.#hl-($host).config.system.build.toplevel.outPath' 2>/dev/null || true") | str trim
|
||||
} catch { "" })
|
||||
let needs_build = if $local_toplevel == "" { false } else { $local_toplevel != $current }
|
||||
|
||||
{host: $host, status: "online", booted: $booted, current: $current, reboot_pending: $reboot_pending, needs_build: $needs_build}
|
||||
} catch {
|
||||
{host: $host, status: "error", booted: "", current: "", reboot_pending: false, needs_build: false}
|
||||
})
|
||||
|
||||
print $"Booted: ($info.booted | path basename)"
|
||||
print $"Current: ($info.current | path basename)"
|
||||
if $info.reboot_pending {
|
||||
print $"(ansi yellow)REBOOT PENDING(ansi reset)"
|
||||
}
|
||||
if $info.needs_build {
|
||||
print $"(ansi red)NEEDS NEW BUILD(ansi reset)"
|
||||
} else {
|
||||
print $"(ansi green)UP TO DATE(ansi reset)"
|
||||
}
|
||||
|
||||
$info
|
||||
})
|
||||
|
||||
let timestamp = date now | format date "%Y-%m-%d %H:%M:%S"
|
||||
let lines = ($results | each { |r|
|
||||
if $r.status == "offline" {
|
||||
$"- ($r.host): (ansi yellow)OFFLINE(ansi reset)"
|
||||
} else if $r.status == "error" {
|
||||
$"- ($r.host): (ansi red)ERROR querying status(ansi reset)"
|
||||
} else {
|
||||
let pending = if $r.reboot_pending { $" [(ansi blue)REBOOT PENDING(ansi reset)]" } else { "" }
|
||||
let build = if $r.needs_build { $" [(ansi red)NEEDS REBUILD(ansi reset)]" } else { $" [(ansi green)current(ansi reset)]" }
|
||||
$"- ($r.host): booted=($r.booted | path basename) current=($r.current | path basename)($pending)($build)"
|
||||
}
|
||||
})
|
||||
let report = $"Remote Status Report - ($timestamp)
|
||||
|
||||
" + ($lines | str join "
|
||||
") + "
|
||||
"
|
||||
|
||||
$report | save -f $report_file
|
||||
print $"
|
||||
Report written to ($report_file)"
|
||||
print $report
|
||||
}
|
||||
|
||||
# Deploy OpenWrt router configuration
|
||||
export def "skyg openwrt" [
|
||||
router: string = "glmain",
|
||||
--dry-run # Render configs to .tmp/openwrt-<router>/ without touching the router
|
||||
] {
|
||||
cd $REPO_ROOT
|
||||
let decrypted_file = skyg decrypt $"($router).json"
|
||||
if $dry_run {
|
||||
^cat $decrypted_file | nix run .#openwrt-($router)-dry-run -- ($router)
|
||||
} else {
|
||||
^cat $decrypted_file | nix run .#openwrt-($router)
|
||||
}
|
||||
}
|
||||
|
||||
# Build a bootable image: ISO, or Pi SD card image (fully-baked, no on-device rebuild)
|
||||
export def "skyg build-image" [target: string] {
|
||||
cd $REPO_ROOT
|
||||
let spec = (match $target {
|
||||
"iso" => { config: "iso", out: "iso", attr: "isoImage" }
|
||||
"pi1" => { config: "hl-pi1", out: "sd-image", attr: "sdImage" }
|
||||
"pi2" => { config: "hl-pi2", out: "sd-image", attr: "sdImage" }
|
||||
_ => { error make { msg: $"Unknown image target '($target)'. Expected: iso, pi1, pi2" } }
|
||||
})
|
||||
let imageBuildTime = date now | format date "%Y.%m.%d_%H_%M_%S"
|
||||
let rootOutputFolder = $REPO_ROOT | path join "build" $spec.config
|
||||
let outPutFolder = $rootOutputFolder | path join $imageBuildTime
|
||||
rm -rf $rootOutputFolder
|
||||
mkdir $rootOutputFolder
|
||||
nix build $"#nixosConfigurations.($spec.config).config.system.build.($spec.attr)" -o $outPutFolder
|
||||
printf $outPutFolder
|
||||
}
|
||||
|
||||
# Home Manager operations
|
||||
export def "skyg hm" [action: string, profile: string = "ari"] {
|
||||
cd $REPO_ROOT
|
||||
$"Running home-manager ($action) for profile ($profile)" | print
|
||||
home-manager $action --flake $".#($profile)"
|
||||
}
|
||||
|
||||
# List all secret names
|
||||
export def "skyg secrets" [] {
|
||||
secret-names
|
||||
}
|
||||
|
||||
# Decrypt a secret from secrets/ folder
|
||||
export def "skyg decrypt" [secret: string] {
|
||||
cd $REPO_ROOT
|
||||
let src = $"secrets/($secret).age"
|
||||
if not ($src | path exists) {
|
||||
error make {msg: $"Secret not found: ($src)"}
|
||||
}
|
||||
mkdir .tmp
|
||||
let dest = $".tmp/unencrypted-($secret)"
|
||||
agenix -d $src | save -f $dest
|
||||
print $"Decrypted to ($dest)"
|
||||
return $dest
|
||||
}
|
||||
|
||||
# Encrypt a file to secrets/ folder (re-encrypts using agenix)
|
||||
# --yaml Validate the content as YAML (via yq) before encrypting
|
||||
export def "skyg encrypt" [
|
||||
secret: string@secret-names,
|
||||
source?: string,
|
||||
--yaml # Validate the content as YAML (via yq) before encrypting
|
||||
] {
|
||||
cd $REPO_ROOT
|
||||
let src = $source | default $".tmp/unencrypted-($secret)"
|
||||
if not ($src | path exists) {
|
||||
let encrypted = $"secrets/($secret).age"
|
||||
if ($encrypted | path exists) {
|
||||
agenix -d $encrypted | save -f $src
|
||||
} else {
|
||||
touch $src
|
||||
}
|
||||
}
|
||||
vi $src
|
||||
|
||||
if $yaml {
|
||||
|
||||
# `complete` captures stdout/stderr/exit_code; `try/catch` guards a missing yq
|
||||
let lint = (
|
||||
try {
|
||||
yq e '.' $src | complete
|
||||
} catch { null }
|
||||
)
|
||||
if $lint == null {
|
||||
print $"❌ Could not run yq — is it on PATH? Add 'yq' to the devShell in flake.nix."
|
||||
return
|
||||
}
|
||||
if $lint.exit_code != 0 {
|
||||
print $"❌ YAML validation failed for ($src):"
|
||||
print ($lint.stderr | str trim)
|
||||
print $"Fix the syntax, then re-run: skyg encrypt ($secret) --yaml"
|
||||
return
|
||||
}
|
||||
print $"✅ YAML valid: ($src)"
|
||||
}
|
||||
|
||||
let dest = $"secrets/($secret).age"
|
||||
cat $src | agenix -e $dest
|
||||
print $"Encrypted ($dest)"
|
||||
return $dest
|
||||
}
|
||||
|
||||
# Compare unencrypted local version with encrypted version of a secret
|
||||
export def "skyg compare-secret" [secret: string@secret-names] {
|
||||
cd $REPO_ROOT
|
||||
let unencrypted = $".tmp/unencrypted-($secret)"
|
||||
let encrypted = $"secrets/($secret).age"
|
||||
|
||||
let temp_decrypted = $"/tmp/skyg-compare-($secret)-($env.USER)-(random uuid)"
|
||||
agenix -d $encrypted | save -f $temp_decrypted
|
||||
print $"Comparing ($unencrypted) with decrypted ($encrypted)"
|
||||
try {
|
||||
print $"diff -u $(unencrypted) $(temp_decrypted)"
|
||||
diff -u $unencrypted $temp_decrypted | print
|
||||
} catch {
|
||||
print "Files are identical"
|
||||
}
|
||||
|
||||
rm -f $temp_decrypted
|
||||
}
|
||||
|
||||
# Generate the lab root CA: key encrypted to secrets/lab-ca-key.age,
|
||||
# public cert written to configs/pki/lab-ca.crt. Run once, before `ca issue`.
|
||||
export def "skyg ca init" [
|
||||
--days: int = 3650 # CA lifetime in days
|
||||
] {
|
||||
cd $REPO_ROOT
|
||||
let cert = "configs/pki/lab-ca.crt"
|
||||
let key_secret = "secrets/lab-ca-key.age"
|
||||
if ($cert | path exists) {
|
||||
error make {msg: $"($cert) already exists — refusing to overwrite the CA. Delete it manually to rotate."}
|
||||
}
|
||||
ensure-secret-entry $key_secret ["ari"]
|
||||
mkdir .tmp configs/pki
|
||||
let tmp_key = ".tmp/lab-ca-key.pem"
|
||||
(openssl req -x509 -newkey rsa:4096 -sha256 -days $days -nodes
|
||||
-keyout $tmp_key -out $cert
|
||||
-subj "/CN=Skyg Lab CA"
|
||||
-addext "basicConstraints=critical,CA:TRUE"
|
||||
-addext "keyUsage=critical,keyCertSign,cRLSign")
|
||||
^cat $tmp_key | agenix -e $key_secret
|
||||
rm -f $tmp_key
|
||||
print $"✅ CA cert: ($cert) — commit this"
|
||||
print $"✅ CA key encrypted: ($key_secret)"
|
||||
print "Next: skyg ca issue <domain> --for <host>"
|
||||
}
|
||||
|
||||
# Issue a TLS cert for a domain, signed by the lab CA.
|
||||
# Writes configs/pki/<domain>.crt; encrypts the key to secrets/<name>-tls-key.age.
|
||||
export def "skyg ca issue" [
|
||||
domain: string # e.g. buzz.app.internal
|
||||
--for: string # secrets.nix key name allowed to decrypt the leaf key (e.g. minipc1)
|
||||
--days: int = 825 # leaf lifetime (825 = browser max)
|
||||
--name: string # secret slug override (default: first DNS label)
|
||||
] {
|
||||
cd $REPO_ROOT
|
||||
let ca_cert = "configs/pki/lab-ca.crt"
|
||||
let ca_key_secret = "secrets/lab-ca-key.age"
|
||||
if not ($ca_cert | path exists) {
|
||||
error make {msg: "No CA found — run `skyg ca init` first"}
|
||||
}
|
||||
let key_names = (^cat secrets.nix | parse --regex '(\w+) = "ssh-' | get capture0)
|
||||
if ($for not-in $key_names) {
|
||||
error make {msg: $"Unknown recipient '($for)'. Known: ($key_names | str join ', ')"}
|
||||
}
|
||||
let slug = $name | default ($domain | split row "." | first)
|
||||
let secret = $"secrets/($slug)-tls-key.age"
|
||||
let cert = $"configs/pki/($domain).crt"
|
||||
if ($cert | path exists) {
|
||||
error make {msg: $"($cert) already exists — delete it manually to re-issue."}
|
||||
}
|
||||
ensure-secret-entry $secret ["ari" $for]
|
||||
mkdir .tmp configs/pki
|
||||
let ca_key = ".tmp/lab-ca-key.pem"
|
||||
agenix -d $ca_key_secret | save -f $ca_key
|
||||
let leaf_key = $".tmp/($slug)-tls-key.pem"
|
||||
let csr = $".tmp/($slug).csr"
|
||||
let ext = $".tmp/($slug)-ext.cnf"
|
||||
$"basicConstraints=critical,CA:FALSE\nkeyUsage=critical,digitalSignature,keyEncipherment\nextendedKeyUsage=serverAuth\nsubjectAltName=DNS:($domain)\n" | save -f $ext
|
||||
(openssl req -newkey rsa:2048 -nodes
|
||||
-keyout $leaf_key -out $csr
|
||||
-subj $"/CN=($domain)")
|
||||
(openssl x509 -req -in $csr
|
||||
-CA $ca_cert -CAkey $ca_key -CAcreateserial
|
||||
-out $cert -days $days -sha256 -extfile $ext)
|
||||
^cat $leaf_key | agenix -e $secret
|
||||
rm -f $ca_key $leaf_key $csr $ext
|
||||
print $"✅ Cert: ($cert) — commit this"
|
||||
print $"✅ Key encrypted: ($secret)"
|
||||
print $"Wire it up: age.secrets.($slug)-tls-key.file = ../($secret);"
|
||||
}
|
||||
|
||||
|
||||
# Update one or all packages. With a version, bumps explicitly.
|
||||
# Without a version, auto-detects the latest from upstream.
|
||||
#
|
||||
# skyg pkgs update --all
|
||||
# skyg pkgs update buzz-desktop
|
||||
# skyg pkgs update buzz-desktop 0.6.0
|
||||
export def "skyg pkgs update" [
|
||||
pkg_name?: string@updatable-pkgs # Package to update (omit with --all)
|
||||
version?: string # Explicit version (omit for auto-detect)
|
||||
--all # Update all packages that have update.sh
|
||||
] {
|
||||
cd $REPO_ROOT
|
||||
|
||||
if $all and $version != null {
|
||||
error make {msg: "Cannot use --all with a specific version. Run without --all to bump a single package."}
|
||||
}
|
||||
|
||||
let targets = if $all {
|
||||
updatable-pkgs
|
||||
} else if $pkg_name != null {
|
||||
[$pkg_name]
|
||||
} else {
|
||||
error make {msg: "Specify a package name or use --all to update all packages"}
|
||||
}
|
||||
|
||||
if ($targets | length) == 0 {
|
||||
print "No updatable packages found (no pkgs/*/update.sh scripts)"
|
||||
return
|
||||
}
|
||||
|
||||
print $"Updating ($targets | length) package\(s): ($targets | str join ', ')"
|
||||
print ""
|
||||
|
||||
for pkg in $targets {
|
||||
let update_script = $"pkgs/($pkg)/update.sh"
|
||||
if not ($update_script | path exists) {
|
||||
print $"⚠️ Skipping ($pkg) — no update.sh"
|
||||
continue
|
||||
}
|
||||
|
||||
print $"=== ($pkg) ==="
|
||||
cd $"pkgs/($pkg)"
|
||||
try {
|
||||
if $version != null {
|
||||
bash $"update.sh ($version)" | print
|
||||
} else {
|
||||
bash "update.sh" | print
|
||||
}
|
||||
} catch { |e|
|
||||
print $"❌ Failed to update ($pkg): ($e)"
|
||||
}
|
||||
cd $REPO_ROOT
|
||||
print ""
|
||||
}
|
||||
|
||||
print ""
|
||||
if $version != null {
|
||||
print "Bump complete. Review with:"
|
||||
git --no-pager diff pkgs/ | print
|
||||
} else {
|
||||
print "All updates complete. Review with:"
|
||||
git --no-pager diff pkgs/ | print
|
||||
}
|
||||
}
|
||||
|
||||
# Render a Gitea HTML template and serve it locally for preview.
|
||||
# Runs in the foreground — Ctrl+C to stop. Wrap it in nohup yourself to detach.
|
||||
export def "skyg render html-tpl" [
|
||||
file: string@html-tpl-files # Template to render (e.g. hosts/hl-minipc1/services/gitea-home.tmpl)
|
||||
--port: int = 8787 # Port for the local preview server
|
||||
] {
|
||||
cd $REPO_ROOT
|
||||
let src = ($file | path expand)
|
||||
if not ($src | path exists) {
|
||||
error make {msg: $"Template not found: ($file)"}
|
||||
}
|
||||
|
||||
let out_dir = ".tmp/render-html-tpl"
|
||||
mkdir $out_dir
|
||||
let name = ($src | path basename | str replace -r '\.tmpl$' '')
|
||||
let out = $"($out_dir)/($name).html"
|
||||
render-html-tpl $src $out
|
||||
|
||||
print $"Rendered ($file) -> ($out)"
|
||||
print $"Preview: http://127.0.0.1:($port)/($name).html"
|
||||
print "Press Ctrl+C to stop."
|
||||
|
||||
^python3 -m http.server $port --bind 127.0.0.1 --directory $out_dir
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
use types.nu *
|
||||
use helpers.nu *
|
||||
|
||||
# update some flakes
|
||||
export def "skyg flake update" [input_name?: string@flake-inputs] {
|
||||
cd $REPO_ROOT
|
||||
if $input_name == null {
|
||||
print "Updating all flakes..."
|
||||
nix flake update | print
|
||||
} else {
|
||||
print $"Updating flake: ($input_name)"
|
||||
nix flake update $input_name | print
|
||||
}
|
||||
git diff flake.lock | print
|
||||
}
|
||||
|
||||
# Run nix flake check
|
||||
export def "skyg flake check" [] {
|
||||
nix flake check --no-build
|
||||
}
|
||||
|
||||
# Validate that all versioned flake inputs use the same NixOS release
|
||||
export def "skyg flake check-versions" [] {
|
||||
let flake = "flake.nix"
|
||||
|
||||
if not ($flake | path exists) {
|
||||
print "check-versions: flake.nix not found, skipping"
|
||||
return
|
||||
}
|
||||
|
||||
# Only scan url lines to avoid false positives from embedded script strings
|
||||
let url_lines = (open $flake | lines | enumerate | where { |row|
|
||||
($row.item | str contains "url") and ($row.item =~ 'release-\d+\.\d+')
|
||||
})
|
||||
|
||||
let versions = ($url_lines
|
||||
| each {|row| $row.item | parse --regex '.*release-(?P<version>\d+\.\d+).*' | get version }
|
||||
| flatten
|
||||
| uniq)
|
||||
|
||||
if ($versions | length) <= 1 {
|
||||
print "check-versions: OK"
|
||||
return
|
||||
}
|
||||
|
||||
print "check-versions: mismatched NixOS release versions in flake.nix:"
|
||||
print ""
|
||||
for version in $versions {
|
||||
print $" release-($version):"
|
||||
$url_lines | where {|row| $row.item | str contains $"release-($version)" } | each { |row|
|
||||
print $" line ($row.index + 1): ($row.item | str trim)"
|
||||
}
|
||||
}
|
||||
print ""
|
||||
print "All versioned inputs (home-manager, stylix, etc.) must use the same NixOS release."
|
||||
error make {msg: "Mismatched NixOS release versions"}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
use types.nu *
|
||||
use profile.nu *
|
||||
use helpers.nu *
|
||||
|
||||
# Home Manager operations
|
||||
export def "skyg hm" [
|
||||
action: string@hm-actions,
|
||||
profile: string@valid_profiles = "ari",
|
||||
] {
|
||||
cd $REPO_ROOT
|
||||
$"Running home-manager ($action) for profile ($profile)" | print
|
||||
home-manager $action --flake $".#($profile)"
|
||||
}
|
||||
Executable
+63
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
# Probe the network card a host uses for internet traffic.
|
||||
# Piped to `bash -s` locally or over SSH by `skyg net check` (bin/lib/net.nu).
|
||||
# Prints KEY=VALUE lines; empty values mean "unknown".
|
||||
set -u
|
||||
|
||||
et() {
|
||||
if command -v ethtool >/dev/null 2>&1; then
|
||||
ethtool "$@"
|
||||
else
|
||||
nix-shell -p ethtool --run "ethtool $*"
|
||||
fi
|
||||
}
|
||||
|
||||
is_phys() { [ -e "/sys/class/net/$1/device" ]; }
|
||||
|
||||
# Interface on the default route (may be a bridge or other virtual device).
|
||||
iface=$(ip -4 route show default 2>/dev/null | awk '{for (i = 1; i <= NF; i++) if ($i == "dev") { print $(i + 1); exit }}')
|
||||
nic="$iface"
|
||||
|
||||
# Follow a bridge/virtual interface down to a physical port.
|
||||
if [ -n "$nic" ] && ! is_phys "$nic"; then
|
||||
for p in /sys/class/net/"$nic"/brif/* /sys/class/net/"$nic"/lower_*; do
|
||||
[ -e "$p" ] || continue
|
||||
c=$(basename "$p")
|
||||
c=${c#lower_}
|
||||
if is_phys "$c"; then nic="$c"; break; fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Fallback: first physical interface that is up.
|
||||
if [ -z "$nic" ] || ! is_phys "$nic"; then
|
||||
nic=""
|
||||
for d in /sys/class/net/*; do
|
||||
n=$(basename "$d")
|
||||
if is_phys "$n" && [ "$(cat "$d/operstate" 2>/dev/null)" = "up" ]; then nic="$n"; break; fi
|
||||
done
|
||||
fi
|
||||
|
||||
echo "IFACE=$iface"
|
||||
echo "NIC=$nic"
|
||||
[ -n "$nic" ] || exit 0
|
||||
|
||||
if [ -d "/sys/class/net/$nic/wireless" ] || [ -e "/sys/class/net/$nic/phy80211" ]; then
|
||||
echo "TYPE=wifi"
|
||||
else
|
||||
echo "TYPE=ethernet"
|
||||
fi
|
||||
|
||||
echo "DRIVER=$(basename "$(readlink -f "/sys/class/net/$nic/device/driver" 2>/dev/null)" 2>/dev/null)"
|
||||
echo "LINK=$(cat "/sys/class/net/$nic/speed" 2>/dev/null)"
|
||||
|
||||
props=$(udevadm info -q property -p "/sys/class/net/$nic" 2>/dev/null)
|
||||
echo "VENDOR=$(printf '%s\n' "$props" | sed -n 's/^ID_VENDOR_FROM_DATABASE=//p' | head -1)"
|
||||
echo "MODEL=$(printf '%s\n' "$props" | sed -n 's/^ID_MODEL_FROM_DATABASE=//p' | head -1)"
|
||||
|
||||
# Speeds from ethtool's "Supported link modes" block, e.g. "10 100 1000 2500".
|
||||
supported=$(et "$nic" 2>/dev/null \
|
||||
| awk '/Supported link modes:/ { f = 1; sub(/.*Supported link modes:/, "") }
|
||||
/Supported pause frame use:|Supports auto-negotiation:/ { f = 0 }
|
||||
f { print }' \
|
||||
| grep -oE '[0-9]+base' | grep -oE '^[0-9]+' | sort -n | uniq | tr '\n' ' ')
|
||||
echo "SUPPORTED=${supported% }"
|
||||
+236
@@ -0,0 +1,236 @@
|
||||
use profile.nu *
|
||||
use helpers.nu [REPO_ROOT]
|
||||
|
||||
const NIC_SCRIPT = path self | path dirname | path join "net-nic.sh"
|
||||
const SSH_OPTS = ["-o" "BatchMode=yes" "-o" "ConnectTimeout=5" "-o" "StrictHostKeyChecking=accept-new"]
|
||||
const CHECKS_DIR = $REPO_ROOT | path join ".tmp" "net-checks"
|
||||
const SERVER_CACHE = $CHECKS_DIR | path join "server.nuon"
|
||||
|
||||
def local-hostname [] {
|
||||
^cat /proc/sys/kernel/hostname | str trim
|
||||
}
|
||||
|
||||
# Devices `skyg net check` can test: every remote (hl-*) profile, plus this machine if it is a profile.
|
||||
export def net-targets [] {
|
||||
let local = (local-hostname)
|
||||
valid_profiles
|
||||
| each {|p|
|
||||
if ($p | str starts-with "hl-") {
|
||||
$p | str replace "hl-" ""
|
||||
} else if $p == $local {
|
||||
$p
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
| compact
|
||||
}
|
||||
|
||||
def is-local [device: string] {
|
||||
let local = (local-hostname)
|
||||
$device == $local or $"hl-($device)" == $local
|
||||
}
|
||||
|
||||
# Run a bash script on a device (locally or over SSH) and return the `complete` record.
|
||||
def run-on [device: string, script: string] {
|
||||
if (is-local $device) {
|
||||
$script | ^bash -s | complete
|
||||
} else {
|
||||
$script | ^ssh ...$SSH_OPTS $"root@($device).lab.internal" bash -s | complete
|
||||
}
|
||||
}
|
||||
|
||||
def is-online [device: string] {
|
||||
if (is-local $device) { return true }
|
||||
(^ssh ...$SSH_OPTS $"root@($device).lab.internal" true | complete | get exit_code) == 0
|
||||
}
|
||||
|
||||
def to-int-or-null [v] {
|
||||
if ($v | is-empty) { return null }
|
||||
try {
|
||||
let n = ($v | into int)
|
||||
if $n > 0 { $n } else { null }
|
||||
} catch { null }
|
||||
}
|
||||
|
||||
def bps-to-mbps [v] {
|
||||
if $v == null { null } else { ($v * 8 / 1_000_000) | math round --precision 1 }
|
||||
}
|
||||
|
||||
# Read the device's network card details via net-nic.sh (KEY=VALUE lines -> record).
|
||||
def probe-nic [device: string] {
|
||||
let r = (run-on $device (^cat $NIC_SCRIPT))
|
||||
$r.stdout
|
||||
| lines
|
||||
| parse --regex '^(?P<key>[A-Z]+)=(?P<value>.*)$'
|
||||
| reduce --fold {} {|it, acc| $acc | upsert $it.key ($it.value | str trim) }
|
||||
}
|
||||
|
||||
# Nearby speedtest.net servers as [{id, rest}], closest first.
|
||||
def list-servers [] {
|
||||
let r = (^bash -c "nix-shell -p speedtest-go --run 'speedtest-go --list'" | complete)
|
||||
$r.stdout
|
||||
| lines
|
||||
| parse --regex '^\[(?P<id>\d+)\]\s+(?P<rest>.*)$'
|
||||
}
|
||||
|
||||
def save-server [s: record] {
|
||||
mkdir $CHECKS_DIR
|
||||
$s | save --force $SERVER_CACHE
|
||||
}
|
||||
|
||||
# Server id to use for all devices: the saved one (asks if you want to change it),
|
||||
# or the closest one on first run. Returns "" if none could be found.
|
||||
def pick-server [] {
|
||||
# ^cat, not open: open may be aliased (e.g. to xdg-open) in the user's config.
|
||||
let saved = if ($SERVER_CACHE | path exists) { try { ^cat $SERVER_CACHE | from nuon } catch { null } } else { null }
|
||||
|
||||
if $saved == null {
|
||||
print "Finding the closest speedtest server (shared by all devices)..."
|
||||
let s = (list-servers | get 0?)
|
||||
if $s == null {
|
||||
print $"(ansi yellow)Could not list servers; each device will pick its own.(ansi reset)"
|
||||
return ""
|
||||
}
|
||||
save-server $s
|
||||
print $"Using server ($s.id): ($s.rest) \(saved to ($SERVER_CACHE)\)"
|
||||
return $s.id
|
||||
}
|
||||
|
||||
print $"Saved server ($saved.id): ($saved.rest)"
|
||||
let ans = (input "Change server? [y/N] " | str trim | str downcase)
|
||||
if $ans not-in ["y" "yes"] { return $saved.id }
|
||||
|
||||
print "Listing speedtest servers..."
|
||||
let servers = (list-servers)
|
||||
if ($servers | is-empty) {
|
||||
print $"(ansi yellow)Could not list servers; keeping saved server.(ansi reset)"
|
||||
return $saved.id
|
||||
}
|
||||
let s = ($servers | input list --fuzzy --display {|x| $"[($x.id)] ($x.rest)" } "Pick a server (closest first)")
|
||||
if $s == null {
|
||||
print "No server picked; keeping saved server."
|
||||
return $saved.id
|
||||
}
|
||||
save-server $s
|
||||
print $"Using server ($s.id): ($s.rest)"
|
||||
$s.id
|
||||
}
|
||||
|
||||
# Run speedtest-go on a device. Assumes dl_speed/ul_speed are bytes/s and latency is ns.
|
||||
def run-speedtest [device: string, server: string] {
|
||||
let srv = if $server == "" { "" } else { $"--server ($server)" }
|
||||
let r = (run-on $device $"timeout 600 nix-shell -p speedtest-go --run 'speedtest-go ($srv) --json'")
|
||||
let json_line = ($r.stdout | lines | where {|l| $l | str starts-with "{" } | reverse | get 0?)
|
||||
let s = if $json_line == null { null } else {
|
||||
try { $json_line | from json | get servers.0 } catch { null }
|
||||
}
|
||||
if $s == null {
|
||||
let err = ($r.stderr | lines | where {|l| $l != "" } | last 1 | str join)
|
||||
return {ok: false, error: (if $err == "" { $"exit code ($r.exit_code)" } else { $err })}
|
||||
}
|
||||
{
|
||||
ok: true
|
||||
server: $"($s.id? | default '?') ($s.name? | default '') / ($s.sponsor? | default '')"
|
||||
ping_ms: (if $s.latency? == null { null } else { ($s.latency / 1_000_000) | math round --precision 1 })
|
||||
down_mbps: (bps-to-mbps $s.dl_speed?)
|
||||
up_mbps: (bps-to-mbps $s.ul_speed?)
|
||||
}
|
||||
}
|
||||
|
||||
def empty-row [device: string, status: string] {
|
||||
{
|
||||
host: $device, status: $status, iface: "", nic: "", type: "", model: "", driver: ""
|
||||
link_mbps: null, supported_mbps: "", max_mbps: null
|
||||
server: null, ping_ms: null, down_mbps: null, up_mbps: null
|
||||
}
|
||||
}
|
||||
|
||||
# Check each managed device's network card and run a speed test against one shared server.
|
||||
export def "skyg net check" [
|
||||
device?: string@net-targets, # Only check this device (default: all devices)
|
||||
--server: string = "", # speedtest.net server id (default: closest to this machine)
|
||||
--no-speedtest, # Only report network card details
|
||||
--save: path, # Also save the table here (format from extension: .csv, .json, .nuon, .md, ...)
|
||||
] {
|
||||
let all = (net-targets)
|
||||
let devices = if $device == null { $all } else {
|
||||
if not ($device in $all) {
|
||||
error make {msg: $"Unknown device '($device)'. Valid devices: ($all | str join ', ')"}
|
||||
}
|
||||
[$device]
|
||||
}
|
||||
|
||||
let server_id = if (not $no_speedtest) and $server == "" { pick-server } else { $server }
|
||||
|
||||
let total = ($devices | length)
|
||||
mut rows = []
|
||||
for it in ($devices | enumerate) {
|
||||
let d = $it.item
|
||||
let tag = $"[($it.index + 1)/($total)] ($d)"
|
||||
|
||||
print $"($tag): checking reachability..."
|
||||
if not (is-online $d) {
|
||||
print $"($tag): (ansi yellow)OFFLINE(ansi reset)"
|
||||
$rows = ($rows | append (empty-row $d "offline"))
|
||||
continue
|
||||
}
|
||||
|
||||
print $"($tag): reading network card..."
|
||||
let nic = (probe-nic $d)
|
||||
let supported = ($nic.SUPPORTED? | default "" | split row " " | where {|x| $x != "" })
|
||||
let max = if ($supported | is-empty) { null } else { $supported | each {|x| $x | into int } | math max }
|
||||
let model = ([($nic.VENDOR? | default "") ($nic.MODEL? | default "")] | where {|x| $x != "" } | str join " ")
|
||||
mut row = (empty-row $d "online" | merge {
|
||||
iface: ($nic.IFACE? | default "")
|
||||
nic: ($nic.NIC? | default "")
|
||||
type: ($nic.TYPE? | default "")
|
||||
model: $model
|
||||
driver: ($nic.DRIVER? | default "")
|
||||
link_mbps: (to-int-or-null ($nic.LINK? | default ""))
|
||||
supported_mbps: ($supported | str join " ")
|
||||
max_mbps: $max
|
||||
})
|
||||
print $"($tag): ($row.nic) \(($row.type)\) ($model) | link ($row.link_mbps | default '?') Mbps | supports up to ($max | default '?') Mbps"
|
||||
|
||||
if not $no_speedtest {
|
||||
print $"($tag): running speedtest-go \(first run may download it via nix-shell\)..."
|
||||
let st = (run-speedtest $d $server_id)
|
||||
if $st.ok {
|
||||
$row = ($row | merge ($st | reject ok))
|
||||
print $"($tag): (ansi green)down ($st.down_mbps) Mbps, up ($st.up_mbps) Mbps, ping ($st.ping_ms) ms(ansi reset)"
|
||||
} else {
|
||||
$row = ($row | upsert status "speedtest failed")
|
||||
print $"($tag): (ansi red)speedtest failed: ($st.error)(ansi reset)"
|
||||
}
|
||||
}
|
||||
|
||||
$rows = ($rows | append $row)
|
||||
}
|
||||
|
||||
print $"Done: checked ($total) device\(s\)."
|
||||
|
||||
mkdir $CHECKS_DIR
|
||||
let auto_file = ($CHECKS_DIR | path join $"(date now | format date '%Y.%m.%d_%H_%M_%S').nuon")
|
||||
$rows | save --force $auto_file
|
||||
print $"Saved to ($auto_file)"
|
||||
if $save != null {
|
||||
$rows | save --force $save
|
||||
print $"Saved to ($save | path expand)"
|
||||
}
|
||||
print $"Show the last table again with: (ansi green_bold)skyg net last(ansi reset)"
|
||||
|
||||
$rows
|
||||
}
|
||||
|
||||
# Show the table from the most recent `skyg net check` run.
|
||||
export def "skyg net last" [] {
|
||||
# glob and ^cat, not ls/open: they may be aliased (e.g. to eza/xdg-open) in the user's config.
|
||||
let files = (glob ($CHECKS_DIR | path join "*.nuon") | where {|f| $f != $SERVER_CACHE })
|
||||
if ($files | is-empty) {
|
||||
error make {msg: $"No saved net checks in ($CHECKS_DIR). Run `skyg net check` first."}
|
||||
}
|
||||
let latest = ($files | sort | last)
|
||||
print $"From ($latest)"
|
||||
^cat $latest | from nuon
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
use types.nu *
|
||||
use profile.nu *
|
||||
use helpers.nu *
|
||||
|
||||
# Build local os
|
||||
export def "skyg os" [
|
||||
cmd: string@os-actions,
|
||||
--build-host: string@remote_targets = "",
|
||||
] {
|
||||
cd $REPO_ROOT
|
||||
mut runcmd = $"nh os ($cmd)"
|
||||
if $build_host != "" {
|
||||
$runcmd = $"($runcmd) --build-host ($build_host).lab.internal"
|
||||
}
|
||||
$runcmd | print
|
||||
bash -c $runcmd
|
||||
}
|
||||
|
||||
# rollback configuration
|
||||
export def "skyg os rollback" [] {
|
||||
sudo nixos-rebuild switch --rollback
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
use types.nu *
|
||||
use helpers.nu *
|
||||
|
||||
# Update one or all packages. With a version, bumps explicitly.
|
||||
# Without a version, auto-detects the latest from upstream.
|
||||
#
|
||||
# skyg pkgs update --all
|
||||
# skyg pkgs update buzz-desktop
|
||||
# skyg pkgs update buzz-desktop 0.6.0
|
||||
export def "skyg pkgs update" [
|
||||
pkg_name?: string@updatable-pkgs # Package to update (omit with --all)
|
||||
version?: string # Explicit version (omit for auto-detect)
|
||||
--all # Update all packages that have update.sh
|
||||
] {
|
||||
cd $REPO_ROOT
|
||||
|
||||
if $all and $version != null {
|
||||
error make {msg: "Cannot use --all with a specific version. Run without --all to bump a single package."}
|
||||
}
|
||||
|
||||
let targets = if $all {
|
||||
updatable-pkgs
|
||||
} else if $pkg_name != null {
|
||||
[$pkg_name]
|
||||
} else {
|
||||
error make {msg: "Specify a package name or use --all to update all packages"}
|
||||
}
|
||||
|
||||
if ($targets | length) == 0 {
|
||||
print "No updatable packages found (no pkgs/*/update.sh scripts)"
|
||||
return
|
||||
}
|
||||
|
||||
print $"Updating ($targets | length) package\(s): ($targets | str join ', ')"
|
||||
print ""
|
||||
|
||||
for pkg in $targets {
|
||||
let update_script = $"pkgs/($pkg)/update.sh"
|
||||
if not ($update_script | path exists) {
|
||||
print $"⚠️ Skipping ($pkg) — no update.sh"
|
||||
continue
|
||||
}
|
||||
|
||||
print $"=== ($pkg) ==="
|
||||
cd $"pkgs/($pkg)"
|
||||
try {
|
||||
if $version != null {
|
||||
bash $"update.sh ($version)" | print
|
||||
} else {
|
||||
bash "update.sh" | print
|
||||
}
|
||||
} catch { |e|
|
||||
print $"❌ Failed to update ($pkg): ($e)"
|
||||
}
|
||||
cd $REPO_ROOT
|
||||
print ""
|
||||
}
|
||||
|
||||
print ""
|
||||
if $version != null {
|
||||
print "Bump complete. Review with:"
|
||||
git --no-pager diff pkgs/ | print
|
||||
} else {
|
||||
print "All updates complete. Review with:"
|
||||
git --no-pager diff pkgs/ | print
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,378 @@
|
||||
use types.nu *
|
||||
use profile.nu *
|
||||
use helpers.nu *
|
||||
use remote.utils.nu *
|
||||
|
||||
# Deploy to remote machine
|
||||
export def "skyg remote" [
|
||||
cmd: string@os-actions,
|
||||
target: string@remote_targets = "",
|
||||
--build-host: string@remote_targets = "", # Optional remote builder host (e.g. builder.lab.internal)
|
||||
] {
|
||||
cd $REPO_ROOT
|
||||
mut target_host = $"root@($target).lab.internal"
|
||||
mut profile = $"hl-($target)"
|
||||
if not (is-valid-profile $profile true) {
|
||||
print $"Invalid Remote Profile '(ansi green_bold)($target)(ansi reset)', please select one of:"
|
||||
return (remote_targets)
|
||||
}
|
||||
$"Using [(ansi green_bold)($profile)(ansi reset)]" | print
|
||||
$"($cmd) on ($target_host) with ($profile)" | print
|
||||
mut runcmd = $"nh os ($cmd) --no-nom --target-host ($target_host) --ask .#($profile)"
|
||||
if $build_host != "" {
|
||||
$runcmd = $"($runcmd) --build-host ($build_host).lab.internal"
|
||||
}
|
||||
$runcmd | print
|
||||
bash -c $runcmd
|
||||
}
|
||||
|
||||
# Fresh-install a remote machine via nixos-anywhere, using its disko config.
|
||||
# Always reformats every disk in the disko file — a second run is as destructive as the first.
|
||||
# Missing disko file, live disk OS (without --force-wipe), or mistyped hostname all abort.
|
||||
export def "skyg remote install" [
|
||||
target: string@remote_targets,
|
||||
--force-wipe, # wipe even if the host already runs NixOS from disk
|
||||
] {
|
||||
cd $REPO_ROOT
|
||||
let target_host = $"root@($target).lab.internal"
|
||||
let profile = $"hl-($target)"
|
||||
if not (is-valid-profile $profile true) {
|
||||
print $"Invalid Remote Profile '(ansi green_bold)($target)(ansi reset)', please select one of:"
|
||||
return (remote_targets)
|
||||
}
|
||||
let disko_file = $"hosts/($profile).disko.nix"
|
||||
if not ($disko_file | path exists) {
|
||||
error make {msg: $"Missing disko config: ($disko_file). Refusing to install ($profile) without a disko layout."}
|
||||
}
|
||||
|
||||
print ""
|
||||
print $"(ansi red_bold)WARNING: this WIPES every disk listed in ($disko_file).(ansi reset)"
|
||||
print "This is not a switch. Use `skyg remote switch` / `skyg remote boot` to update an installed host."
|
||||
print ""
|
||||
print "Disks in the disko file:"
|
||||
let disks = (
|
||||
open $disko_file
|
||||
| lines
|
||||
| where {|l| ($l | str contains "device") and ($l | str contains "=") }
|
||||
| each {|l| $l | str trim }
|
||||
)
|
||||
for line in $disks {
|
||||
print $" ($line)"
|
||||
}
|
||||
print ""
|
||||
|
||||
let ssh = $"ssh -o BatchMode=yes -o ConnectTimeout=5 -o StrictHostKeyChecking=accept-new ($target_host)"
|
||||
let root_fstype = (try {
|
||||
bash -c $"($ssh) 'findmnt -n -o FSTYPE /' 2>/dev/null" | str trim
|
||||
} catch { "" })
|
||||
|
||||
if $root_fstype == "" {
|
||||
print $"(ansi yellow)Could not SSH to ($target_host) to check for a live OS.(ansi reset)"
|
||||
} else {
|
||||
print $"Remote / fstype: ($root_fstype)"
|
||||
let installer_fs = ["overlay" "tmpfs" "squashfs"]
|
||||
if not ($root_fstype in $installer_fs) {
|
||||
if not $force_wipe {
|
||||
error make {msg: $"($target_host) already boots from disk (root fstype ($root_fstype)). Refusing to wipe. Use `skyg remote switch ($target)` to update, or pass --force-wipe to reinstall."}
|
||||
}
|
||||
print $"(ansi yellow)--force-wipe set: proceeding against a live disk OS.(ansi reset)"
|
||||
} else {
|
||||
print "Remote looks like an installer live image (ok to install)."
|
||||
}
|
||||
}
|
||||
|
||||
let confirm = input $"Type ($target) to continue: " | str trim
|
||||
if $confirm != $target {
|
||||
error make {msg: $"Aborted: typed '($confirm)', expected '($target)'."}
|
||||
}
|
||||
|
||||
$"Installing [(ansi green_bold)($profile)(ansi reset)] on ($target_host) via nixos-anywhere, using ($disko_file)" | print
|
||||
let runcmd = $"nix run github:nix-community/nixos-anywhere -- --flake .#($profile) ($target_host)"
|
||||
$runcmd | print
|
||||
let bash_path = which bash | get 0.path
|
||||
with-env { SHELL: $bash_path } {
|
||||
bash -c $runcmd
|
||||
}
|
||||
}
|
||||
|
||||
# Boot all remote hosts except the current machine (fwbook)
|
||||
# Checks online status first, runs `skyg remote boot --build-host fwdesk <host>` for each online host,
|
||||
# and writes a summary report to .tmp/boot-report.txt
|
||||
|
||||
export def "skyg remote boot-all" [] {
|
||||
cd $REPO_ROOT
|
||||
mkdir .tmp
|
||||
let current_host = "fwbook"
|
||||
let report_file = ".tmp/boot-report.txt"
|
||||
|
||||
# Discover remote targets from the flake (same logic as skyg remote)
|
||||
let all_hosts = remote_targets | where {|h| $h != $current_host }
|
||||
|
||||
print $"Found ($all_hosts | length) candidate hosts excluding ($current_host)"
|
||||
|
||||
mut successes = []
|
||||
mut failures = []
|
||||
mut skipped = []
|
||||
|
||||
# Phase 1: sequential SSH reachability checks (fast)
|
||||
mut online_hosts = []
|
||||
for host in $all_hosts {
|
||||
print $"\n=== Checking ($host) ==="
|
||||
let target = $"root@($host).lab.internal"
|
||||
let is_online = (try {
|
||||
bash -c $"ssh -o BatchMode=yes -o ConnectTimeout=3 -o StrictHostKeyChecking=accept-new ($target) 'true' >/dev/null 2>&1"
|
||||
true
|
||||
} catch { false })
|
||||
|
||||
if not $is_online {
|
||||
print $"(ansi yellow)OFFLINE(ansi reset): ($host)"
|
||||
$skipped = ($skipped | append $host)
|
||||
} else {
|
||||
print $"(ansi green)ONLINE(ansi reset): ($host)"
|
||||
$online_hosts = ($online_hosts | append $host)
|
||||
}
|
||||
}
|
||||
|
||||
# Phase 2: run boots in parallel (2 concurrent) without interactive prompts
|
||||
if ($online_hosts | length) > 0 {
|
||||
print "
|
||||
Starting parallel boots (concurrency: 2)..."
|
||||
let boot_results = ($online_hosts | par-each --threads 1 { |host|
|
||||
let target_host = $"root@($host).lab.internal"
|
||||
let profile = $"hl-($host)"
|
||||
let runcmd = $"nh os boot --no-nom --target-host ($target_host) .#($profile)"
|
||||
print $runcmd
|
||||
let ok = (try {
|
||||
bash -c $runcmd
|
||||
true
|
||||
} catch {
|
||||
false
|
||||
})
|
||||
{host: $host, success: $ok}
|
||||
})
|
||||
|
||||
for r in $boot_results {
|
||||
if $r.success {
|
||||
$successes = ($successes | append $r.host)
|
||||
print $"(ansi green)SUCCESS(ansi reset): ($r.host)"
|
||||
} else {
|
||||
$failures = ($failures | append $r.host)
|
||||
print $"(ansi red)FAILED(ansi reset): ($r.host)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Write report
|
||||
let timestamp = date now | format date "%Y-%m-%d %H:%M:%S"
|
||||
let report = $"Boot Report - ($timestamp)
|
||||
|
||||
Total hosts considered: ($all_hosts | length)
|
||||
Skipped offline: ($skipped | length) - ($skipped | str join ', ')
|
||||
Successful: ($successes | length) - ($successes | str join ', ')
|
||||
Failed: ($failures | length) - ($failures | str join ', ')
|
||||
|
||||
Details:
|
||||
Online & Booted: ($successes | str join ', ')
|
||||
Offline: ($skipped | str join ', ')
|
||||
Failed: ($failures | str join ', ')
|
||||
"
|
||||
|
||||
$report | save -f $report_file
|
||||
print $"
|
||||
Report written to ($report_file)"
|
||||
print $report
|
||||
}
|
||||
|
||||
export def "skyg remote status" [
|
||||
target?: string@remote_targets,
|
||||
--all # Check status of all remote hosts
|
||||
] {
|
||||
if $all {
|
||||
skyg remote status-all
|
||||
} else if $target != null {
|
||||
get-remote-boot-info $target
|
||||
} else {
|
||||
error make {msg: "Specify a target host or use --all"}
|
||||
}
|
||||
}
|
||||
|
||||
# Check status of all remotes: generation, pending reboot, needs rebuild
|
||||
export def "skyg remote status-all" [] {
|
||||
cd $REPO_ROOT
|
||||
mkdir .tmp
|
||||
let current_host = "fwbook"
|
||||
let report_file = ".tmp/status-report.txt"
|
||||
|
||||
let all_hosts = remote_targets | where {|h| $h != $current_host }
|
||||
print $"Checking status for ($all_hosts | length) remotes..."
|
||||
|
||||
let results = ($all_hosts | par-each { |host|
|
||||
let info = get-remote-boot-info $host
|
||||
|
||||
# Print each host's status as one block, as soon as it finishes.
|
||||
let booted = (if ($info.booted | is-empty) { "-" } else { $info.booted | path basename })
|
||||
let current = (if ($info.current | is-empty) { "-" } else { $info.current | path basename })
|
||||
let next_boot = (if ($info.next_boot | is-empty) { "-" } else { $info.next_boot | path basename })
|
||||
let reboot_line = if $info.reboot_pending { $"(ansi yellow)REBOOT PENDING(ansi reset)\n" } else { "" }
|
||||
# needs_build is true, false, or "unknown" (local eval failed)
|
||||
let build_line = match $info.needs_build {
|
||||
true => $"(ansi red)NEEDS NEW BUILD(ansi reset)",
|
||||
false => $"(ansi green)UP TO DATE(ansi reset)",
|
||||
_ => $"(ansi yellow)BUILD UNKNOWN (eval failed)(ansi reset)",
|
||||
}
|
||||
print $"($host) | Booted: ($booted) | Current: ($current) | Next boot: ($next_boot)\n ($reboot_line)($build_line)"
|
||||
|
||||
$info
|
||||
})
|
||||
|
||||
return ($results | select host status reboot_pending needs_build)
|
||||
}
|
||||
|
||||
# Reboot every remote host that is pending a reboot (booted-system != next-boot generation).
|
||||
# Detects pending hosts, lists them, asks for confirmation, then reboots each one at a
|
||||
# time, waiting for it to come back online and sending a desktop notification when it does.
|
||||
export def "skyg remote reboot-pending" [] {
|
||||
cd $REPO_ROOT
|
||||
mkdir .tmp
|
||||
let current_host = "fwbook"
|
||||
let report_file = ".tmp/reboot-pending-report.txt"
|
||||
|
||||
let all_hosts = remote_targets | where {|h| $h != $current_host }
|
||||
print $"Checking ($all_hosts | length) remotes for pending reboots..."
|
||||
|
||||
# Phase 1: find hosts that are online and pending a reboot
|
||||
mut pending = []
|
||||
mut offline = []
|
||||
mut up_to_date = []
|
||||
|
||||
for host in $all_hosts {
|
||||
let target = $"root@($host).lab.internal"
|
||||
let online = (try {
|
||||
bash -c $"ssh -o BatchMode=yes -o ConnectTimeout=3 -o StrictHostKeyChecking=accept-new ($target) 'true' >/dev/null 2>&1"
|
||||
true
|
||||
} catch { false })
|
||||
|
||||
if not $online {
|
||||
print $"(ansi yellow)OFFLINE(ansi reset): ($host)"
|
||||
$offline = ($offline | append $host)
|
||||
continue
|
||||
}
|
||||
|
||||
let info = (try {
|
||||
let s = (get-boot-state $target)
|
||||
{booted: $s.booted, next_boot: $s.next_boot, pending: ($s.booted != "" and $s.booted != $s.next_boot)}
|
||||
} catch {
|
||||
{booted: "", next_boot: "", pending: false}
|
||||
})
|
||||
|
||||
if $info.pending {
|
||||
print $"(ansi blue)REBOOT PENDING(ansi reset): ($host) booted=($info.booted | path basename) next=($info.next_boot | path basename)"
|
||||
$pending = ($pending | append $host)
|
||||
} else {
|
||||
print $"(ansi green)UP TO DATE(ansi reset): ($host)"
|
||||
$up_to_date = ($up_to_date | append $host)
|
||||
}
|
||||
}
|
||||
|
||||
if ($pending | length) == 0 {
|
||||
print ""
|
||||
print "No remotes are pending a reboot."
|
||||
return
|
||||
}
|
||||
|
||||
# Phase 2: confirm before rebooting anything
|
||||
print ""
|
||||
print $"(ansi yellow_bold)($pending | length) remote\(s\) pending a reboot:(ansi reset)"
|
||||
for host in $pending {
|
||||
print $" - ($host)"
|
||||
}
|
||||
print ""
|
||||
let confirm = (input $"Reboot these ($pending | length) host\(s\)? [y/N]: " | str trim | str downcase)
|
||||
if not ($confirm in ["y" "yes"]) {
|
||||
print "Aborted — no hosts were rebooted."
|
||||
return
|
||||
}
|
||||
|
||||
# Phase 3: reboot each pending host one at a time, waiting for it to come back
|
||||
mut rebooted = []
|
||||
mut failed = []
|
||||
for host in $pending {
|
||||
let target = $"root@($host).lab.internal"
|
||||
print $"\n=== Rebooting ($host) ==="
|
||||
|
||||
# Capture the boot id so we can confirm the host actually rebooted.
|
||||
let boot_id_before = (try {
|
||||
bash -c $"ssh -o BatchMode=yes ($target) 'cat /proc/sys/kernel/random/boot_id' 2>/dev/null" | str trim
|
||||
} catch { "" })
|
||||
|
||||
let runcmd = $"ssh -o BatchMode=yes -o ConnectTimeout=5 ($target) 'systemctl reboot'"
|
||||
print $runcmd
|
||||
# The SSH connection drops as the host shuts down, so a non-zero exit is
|
||||
# expected here and does not mean the reboot failed.
|
||||
try {
|
||||
bash -c $"($runcmd) 2>/dev/null"
|
||||
} catch { }
|
||||
|
||||
print $"Waiting for ($host) to shut down..."
|
||||
let went_down = (wait-for-host $target false 90)
|
||||
if not $went_down {
|
||||
print $"(ansi yellow)($host) did not go offline within 90s — continuing to wait for it to come back.(ansi reset)"
|
||||
}
|
||||
|
||||
print $"Waiting for ($host) to come back online..."
|
||||
let came_up = (wait-for-host $target true 300)
|
||||
if $came_up {
|
||||
let boot_id_after = (try {
|
||||
bash -c $"ssh -o BatchMode=yes ($target) 'cat /proc/sys/kernel/random/boot_id' 2>/dev/null" | str trim
|
||||
} catch { "" })
|
||||
# Proof of reboot: boot id changed. If we can't read it, fall back to "it went offline".
|
||||
let did_reboot = if $boot_id_before != "" and $boot_id_after != "" {
|
||||
$boot_id_before != $boot_id_after
|
||||
} else {
|
||||
$went_down
|
||||
}
|
||||
if not $did_reboot {
|
||||
print $"(ansi red)($host) answered but did NOT reboot (same boot id, never went offline)(ansi reset)"
|
||||
notify $"❌ ($host) did not reboot" "Reboot command had no effect"
|
||||
$failed = ($failed | append $host)
|
||||
continue
|
||||
}
|
||||
|
||||
# Check the host really came up on the generation we wanted.
|
||||
let after = (try { get-boot-state $target } catch { null })
|
||||
if $after != null and $after.booted != $after.next_boot {
|
||||
print $"(ansi red)($host) rebooted but is NOT on its latest generation(ansi reset)"
|
||||
print $" booted=($after.booted | path basename)"
|
||||
print $" wanted=($after.next_boot | path basename)"
|
||||
notify $"⚠️ ($host) wrong generation" "Rebooted but not on the latest generation"
|
||||
$failed = ($failed | append $host)
|
||||
continue
|
||||
}
|
||||
|
||||
print $"(ansi green)($host) rebooted and is back online(ansi reset)"
|
||||
notify $"✅ ($host) rebooted" "Back online and reachable"
|
||||
$rebooted = ($rebooted | append $host)
|
||||
} else {
|
||||
print $"(ansi red)($host) did not come back online within 300s(ansi reset)"
|
||||
notify $"❌ ($host) did not come back" "Still unreachable after 300s"
|
||||
$failed = ($failed | append $host)
|
||||
}
|
||||
}
|
||||
|
||||
# Write report
|
||||
let timestamp = date now | format date "%Y-%m-%d %H:%M:%S"
|
||||
let report = $"Reboot-Pending Report - ($timestamp)
|
||||
|
||||
Total hosts considered: ($all_hosts | length)
|
||||
Pending reboot: ($pending | length) - ($pending | str join ', ')
|
||||
Rebooted: ($rebooted | length) - ($rebooted | str join ', ')
|
||||
Failed: ($failed | length) - ($failed | str join ', ')
|
||||
Offline: ($offline | length) - ($offline | str join ', ')
|
||||
Up to date: ($up_to_date | length) - ($up_to_date | str join ', ')
|
||||
"
|
||||
|
||||
$report | save -f $report_file
|
||||
print $"
|
||||
Report written to ($report_file)"
|
||||
print $report
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
use types.nu *
|
||||
use profile.nu *
|
||||
|
||||
# Read the 3 system paths on a remote host:
|
||||
# booted = what it booted from
|
||||
# current = what is running now (changed by switch/test)
|
||||
# next_boot = what the next reboot will use (changed by switch/boot)
|
||||
export def get-boot-state [target: string] {
|
||||
let lines = (bash -c $"ssh -o BatchMode=yes ($target) 'readlink /run/booted-system; readlink /run/current-system; readlink -f /nix/var/nix/profiles/system' 2>/dev/null" | lines)
|
||||
let booted = ($lines | get 0? | default "")
|
||||
let current = ($lines | get 1? | default "")
|
||||
let profile = ($lines | get 2? | default "")
|
||||
let next_boot = if $profile == "" { $current } else { $profile }
|
||||
{booted: $booted, current: $current, next_boot: $next_boot}
|
||||
}
|
||||
|
||||
export def get-remote-boot-info [ host: string@remote_targets ] {
|
||||
let target = $"root@($host).lab.internal"
|
||||
let is_online = (try {
|
||||
bash -c $"ssh -o BatchMode=yes -o ConnectTimeout=3 ($target) 'true' >/dev/null 2>&1"
|
||||
true
|
||||
} catch { false })
|
||||
if (not $is_online) {
|
||||
return {host: $host, status: "offline", booted: "", current: "", next_boot: "", reboot_pending: false, needs_build: false, local_toplevel: ""}
|
||||
}
|
||||
return (try {
|
||||
# Fetch remote system paths and the local toplevel concurrently.
|
||||
let fetched = (["remote" "local"] | par-each {|what|
|
||||
if $what == "remote" {
|
||||
get-boot-state $target
|
||||
} else {
|
||||
try {
|
||||
bash -c $"nix eval --raw '.#nixosConfigurations.hl-($host).config.system.build.toplevel.outPath' 2>/dev/null || true" | str trim
|
||||
} catch { "" }
|
||||
}
|
||||
})
|
||||
|
||||
let state = $fetched.0
|
||||
let booted = $state.booted
|
||||
let current = $state.current
|
||||
let next_boot = $state.next_boot
|
||||
let local_toplevel = $fetched.1
|
||||
|
||||
# A reboot only matters if it would land on a different system than we booted.
|
||||
let reboot_pending = ($booted != "" and $booted != $next_boot)
|
||||
let needs_build = if $local_toplevel == "" { "unknown" } else { $local_toplevel != $next_boot }
|
||||
|
||||
{host: $host, status: "online", booted: $booted, current: $current, next_boot: $next_boot, reboot_pending: $reboot_pending, needs_build: $needs_build, local_toplevel: $local_toplevel}
|
||||
} catch {
|
||||
{host: $host, status: "error", booted: "", current: "", next_boot: "", reboot_pending: false, needs_build: false, local_toplevel: ""}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
# Poll SSH until the host reaches the desired reachability, or the timeout elapses.
|
||||
export def wait-for-host [target: string, want_online: bool, timeout: int] {
|
||||
let deadline = (date now) + ($timeout * 1sec)
|
||||
while (date now) < $deadline {
|
||||
let online = (try {
|
||||
bash -c $"ssh -o BatchMode=yes -o ConnectTimeout=3 ($target) 'true' >/dev/null 2>&1"
|
||||
true
|
||||
} catch { false })
|
||||
if $online == $want_online {
|
||||
return true
|
||||
}
|
||||
sleep 3sec
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
# Send a desktop notification if notify-send is available; never fail the caller.
|
||||
export def notify [title: string, body: string] {
|
||||
try {
|
||||
^notify-send $title $body
|
||||
} catch { }
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
use types.nu *
|
||||
use helpers.nu *
|
||||
|
||||
# Render a Gitea HTML template and serve it locally for preview.
|
||||
# Runs in the foreground — Ctrl+C to stop. Wrap it in nohup yourself to detach.
|
||||
export def "skyg render html-tpl" [
|
||||
file: string@html-tpl-files # Template to render (e.g. hosts/hl-minipc1/services/gitea-home.tmpl)
|
||||
--port: int = 8787 # Port for the local preview server
|
||||
] {
|
||||
cd $REPO_ROOT
|
||||
let src = ($file | path expand)
|
||||
if not ($src | path exists) {
|
||||
error make {msg: $"Template not found: ($file)"}
|
||||
}
|
||||
|
||||
let out_dir = ".tmp/render-html-tpl"
|
||||
mkdir $out_dir
|
||||
let name = ($src | path basename | str replace -r '\.tmpl$' '')
|
||||
let out = $"($out_dir)/($name).html"
|
||||
render-html-tpl $src $out
|
||||
|
||||
print $"Rendered ($file) -> ($out)"
|
||||
print $"Preview: http://127.0.0.1:($port)/($name).html"
|
||||
print "Press Ctrl+C to stop."
|
||||
|
||||
^python3 -m http.server $port --bind 127.0.0.1 --directory $out_dir
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
use types.nu *
|
||||
use helpers.nu *
|
||||
|
||||
# List all secret names (same as `skyg secrets list`)
|
||||
export def "skyg secrets" [] {
|
||||
skyg secrets list
|
||||
}
|
||||
|
||||
# List all secret names
|
||||
export def "skyg secrets list" [] {
|
||||
secret-names
|
||||
}
|
||||
|
||||
# Decrypt a secret from secrets/ folder
|
||||
export def "skyg secrets show" [secret: string@secret-names] {
|
||||
cd $REPO_ROOT
|
||||
let src = $"secrets/($secret).age"
|
||||
if not ($src | path exists) {
|
||||
error make {msg: $"Secret not found: ($src)"}
|
||||
}
|
||||
mkdir .tmp
|
||||
let dest = $".tmp/unencrypted-($secret)"
|
||||
agenix -d $src | save -f $dest
|
||||
print $"Decrypted to ($dest)"
|
||||
return $dest
|
||||
}
|
||||
|
||||
# Encrypt a file to secrets/ folder (re-encrypts using agenix)
|
||||
# --yaml Validate the content as YAML (via yq) before encrypting
|
||||
export def "skyg secrets edit" [
|
||||
secret: string@secret-names,
|
||||
source?: string,
|
||||
--yaml # Validate the content as YAML (via yq) before encrypting
|
||||
] {
|
||||
cd $REPO_ROOT
|
||||
let src = $source | default $".tmp/unencrypted-($secret)"
|
||||
if not ($src | path exists) {
|
||||
let encrypted = $"secrets/($secret).age"
|
||||
if ($encrypted | path exists) {
|
||||
agenix -d $encrypted | save -f $src
|
||||
} else {
|
||||
touch $src
|
||||
}
|
||||
}
|
||||
vi $src
|
||||
|
||||
if $yaml {
|
||||
|
||||
# `complete` captures stdout/stderr/exit_code; `try/catch` guards a missing yq
|
||||
let lint = (
|
||||
try {
|
||||
yq e '.' $src | complete
|
||||
} catch { null }
|
||||
)
|
||||
if $lint == null {
|
||||
print $"❌ Could not run yq — is it on PATH? Add 'yq' to the devShell in flake.nix."
|
||||
return
|
||||
}
|
||||
if $lint.exit_code != 0 {
|
||||
print $"❌ YAML validation failed for ($src):"
|
||||
print ($lint.stderr | str trim)
|
||||
print $"Fix the syntax, then re-run: skyg secrets edit ($secret) --yaml"
|
||||
return
|
||||
}
|
||||
print $"✅ YAML valid: ($src)"
|
||||
}
|
||||
|
||||
let dest = $"secrets/($secret).age"
|
||||
cat $src | agenix -e $dest
|
||||
print $"Encrypted ($dest)"
|
||||
return $dest
|
||||
}
|
||||
|
||||
# Compare unencrypted local version with encrypted version of a secret
|
||||
export def "skyg secrets compare" [secret: string@secret-names] {
|
||||
cd $REPO_ROOT
|
||||
let unencrypted = $".tmp/unencrypted-($secret)"
|
||||
let encrypted = $"secrets/($secret).age"
|
||||
|
||||
let temp_decrypted = $"/tmp/skyg-compare-($secret)-($env.USER)-(random uuid)"
|
||||
agenix -d $encrypted | save -f $temp_decrypted
|
||||
print $"Comparing ($unencrypted) with decrypted ($encrypted)"
|
||||
try {
|
||||
print $"diff -u $(unencrypted) $(temp_decrypted)"
|
||||
diff -u $unencrypted $temp_decrypted | print
|
||||
} catch {
|
||||
print "Files are identical"
|
||||
}
|
||||
|
||||
rm -f $temp_decrypted
|
||||
}
|
||||
+23
-1
@@ -4,7 +4,7 @@ export def hm-actions [] {
|
||||
["switch", "build"]
|
||||
}
|
||||
|
||||
export def remote-cmds [] {
|
||||
export def os-actions [] {
|
||||
[
|
||||
"test"
|
||||
"dry-activate"
|
||||
@@ -37,3 +37,25 @@ export def html-tpl-files [] {
|
||||
| each {|f| $f | path relative-to $REPO_ROOT }
|
||||
| sort
|
||||
}
|
||||
|
||||
# Flake input names from flake.nix
|
||||
export def flake-inputs [] {
|
||||
cd $REPO_ROOT
|
||||
open flake.nix
|
||||
| lines
|
||||
| where {|l| $l =~ '^\s+\w+\.url\s*=' }
|
||||
| each {|l| $l | str trim | split row "." | first }
|
||||
| uniq
|
||||
}
|
||||
|
||||
# OpenWrt router names from openwrt-routers/*.nix
|
||||
export def router-names [] {
|
||||
cd $REPO_ROOT
|
||||
glob openwrt-routers/*.nix | each {|f| $f | path basename | str replace ".nix" "" }
|
||||
}
|
||||
|
||||
# CA recipient names from secrets.nix
|
||||
export def ca-recipients [] {
|
||||
cd $REPO_ROOT
|
||||
^cat secrets.nix | parse --regex '(\w+) = "ssh-' | get capture0
|
||||
}
|
||||
+5
-4
@@ -23,10 +23,11 @@ these cases where the source subdir and `~/.config` target differ.
|
||||
| `hl-fws1/hypr/` | Hyprland config for `hl-fws1` (remote slim desktop); **baked into the build** via `mountAsSource`, linked to `~/.config/hypr` |
|
||||
| `hl-pi1/quickshell/` | Quickshell configs for `hl-pi1` (full-screen clock + calendar); linked to `~/.config/quickshell` |
|
||||
| `fwbook/quickshell/` | Quickshell configs for `fwbook` (scrolling overview); linked to `~/.config/quickshell` |
|
||||
| `extra.nu` | Extra NuShell config sourced at shell startup |
|
||||
| `fwbook.knsv` | fwbook-specific Kanshi display profile |
|
||||
| `hypr-types/hl.lua` | Shared EmmyLua type stubs for the `hl` global; each host's Hyprland `.luarc.json` points here via `workspace.library` |
|
||||
| `pki/` | Public certs of the lab internal CA (`lab-ca.crt` + issued leaves), managed by `skyg ca`; **not** symlinked to `~/.config` — see `pki/ABOUTME.md` |
|
||||
|
||||
| `extra.nu` | Extra NuShell config sourced at shell startup |
|
||||
| `fwbook.knsv` | fwbook-specific Kanshi display profile |
|
||||
| `hypr-types/hl.lua` | Shared EmmyLua type stubs for the `hl` global; each host's Hyprland `.luarc.json` points here via `workspace.library` |
|
||||
| `pki/` | Public certs of the lab internal CA (`lab-ca.crt` + issued leaves), managed by `skyg ca`; **not** symlinked to `~/.config` — see `pki/ABOUTME.md` |
|
||||
|
||||
## Notes
|
||||
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
-- Autostart
|
||||
-- =========================
|
||||
local function autostart()
|
||||
-- hl.exec_cmd("setpriv --ambient-caps -all -- noctalia")
|
||||
hl.exec_cmd("setpriv --ambient-caps -all -- omarchy-launch-shell")
|
||||
hl.exec_cmd("setpriv --ambient-caps -all -- qs -c overview")
|
||||
hl.exec_cmd("setpriv --ambient-caps -all -- noctalia")
|
||||
-- hl.exec_cmd("setpriv --ambient-caps -all -- omarchy-launch-shell")
|
||||
-- hl.exec_cmd("setpriv --ambient-caps -all -- qs -c overview")
|
||||
hl.exec_cmd("setpriv --ambient-caps -all -- skygqts workspace-manager")
|
||||
hl.exec_cmd("setpriv --ambient-caps -all -- skygqts workspace-badge")
|
||||
end
|
||||
hl.on("hyprland.start", autostart)
|
||||
hl.bind("SUPER + SHIFT + A", autostart)
|
||||
@@ -12,7 +12,7 @@ hl.bind(mod .. " + B", hl.dsp.exec_cmd("chromium"))
|
||||
hl.bind(mod .. " + E", hl.dsp.exec_cmd("wofi-emoji"))
|
||||
hl.bind(mod .. " + ALT + E", hl.dsp.exec_cmd("zeditor ~/.config/hypr/conf/keybindings.lua"))
|
||||
hl.bind(mod .. " + Q", hl.dsp.window.close())
|
||||
hl.bind(mod .. " + ALT + N", hl.dsp.exec_cmd("skygqts workspace-manager toggle"))
|
||||
hl.bind(mod .. " + ALT + N", hl.dsp.exec_cmd("skygqts workspace-badge edit"))
|
||||
-- =========================
|
||||
-- Navigation
|
||||
-- =========================
|
||||
@@ -22,7 +22,9 @@ hl.bind(mod .. " + up", hl.dsp.focus({ workspace = "e-1" }))
|
||||
hl.bind(mod .. " + down", hl.dsp.focus({ workspace = "e+1" }))
|
||||
|
||||
-- for the 4-finger swipe equivalent)
|
||||
hl.bind(mod .. " + Tab", hl.dsp.exec_cmd("qs -c overview ipc call overview toggle"))
|
||||
-- hl.bind(mod .. " + Tab", hl.dsp.exec_cmd("qs -c overview ipc call overview toggle"))
|
||||
hl.bind(mod .. " + Tab", hl.dsp.exec_cmd("skygqts workspace-manager toggle"))
|
||||
--
|
||||
hl.bind(mod .. " + SHIFT + Tab", hl.dsp.focus({ monitor = "+1" }))
|
||||
|
||||
-- =========================
|
||||
|
||||
@@ -10,5 +10,5 @@ require("conf/inputs")
|
||||
require("conf/window-rules")
|
||||
require("conf/keybindings")
|
||||
require("conf/autostart")
|
||||
require("conf.omarchy.index")
|
||||
-- require("conf.noctalia.index")
|
||||
-- require("conf.omarchy.index")
|
||||
require("conf.noctalia.index")
|
||||
@@ -15,7 +15,7 @@ binds {
|
||||
Mod+E { spawn "wofi-emoji"; }
|
||||
Mod+Alt+E { spawn-sh "zeditor ~/.config/niri/shared/binds.kdl"; }
|
||||
Mod+Q { close-window; }
|
||||
Mod+Alt+N hotkey-overlay-title="Workspace: Rename" { spawn "skygqts" "workspace-manager" "rename"; }
|
||||
Mod+Alt+N hotkey-overlay-title="Workspace: Rename" { spawn "skygqts" "workspace-badge" "edit"; }
|
||||
|
||||
|
||||
// =========================
|
||||
@@ -26,7 +26,7 @@ binds {
|
||||
Mod+Up { focus-workspace-up; }
|
||||
Mod+Right { focus-column-right; }
|
||||
|
||||
Mod+Tab hotkey-overlay-title="Workspace: Rename" { spawn "skygqts" "workspace-manager" "windows"; }
|
||||
Mod+Ctrl+Tab hotkey-overlay-title="Workspace: Cycle" { spawn "skygqts" "workspace-manager" "toggle"; }
|
||||
Mod+Shift+Tab { focus-monitor-next; }
|
||||
|
||||
// =========================
|
||||
|
||||
@@ -2,5 +2,6 @@
|
||||
|
||||
|
||||
skygqts workspace-manager &
|
||||
skygqts workspace-badge &
|
||||
|
||||
notify-send "Autostarted ran!"
|
||||
@@ -0,0 +1,3 @@
|
||||
# Third-party plugin checkouts stay local (own .git, omarchy-plugin-update).
|
||||
# shell.json still lists enabled plugin ids; install/clone into plugins/ yourself.
|
||||
plugins/
|
||||
@@ -0,0 +1,30 @@
|
||||
# configs/fwbook/omarchy/
|
||||
|
||||
Host-specific Omarchy (nixarchy) shell config for `fwbook`.
|
||||
Symlinked to `~/.config/omarchy` by `hosts/fwbook/packages.nix`
|
||||
(`system.userActivationScripts.omarchyConfig`), same pattern as hypr/noctalia.
|
||||
|
||||
## Layout
|
||||
|
||||
| Path | Notes |
|
||||
| --- | --- |
|
||||
| `shell.json` | Bar layout, idle timings, enabled plugins. No `omarchy.system-update` widget (its 6h poll is a no-op on NixOS). |
|
||||
| `shell.toml` | Font base size for the shell. |
|
||||
| `defaults/` | Defaults the shell writes (e.g. `agent`). |
|
||||
| `backgrounds/` | User wallpapers / live-wallpaper sources. |
|
||||
| `plugins/` | **Not tracked** (gitignored). Third-party checkouts with their own `.git` so `omarchy-plugin-update` still works. `shell.json` lists enabled ids; clone/install into this dir on each machine. |
|
||||
|
||||
Runtime state stays under `~/.local/state/omarchy/` (clipboard, toggles, etc.) — not here.
|
||||
|
||||
## Plugins currently in use (local only)
|
||||
|
||||
| id | source |
|
||||
| --- | --- |
|
||||
| `tenzin.live-wallpaper` | https://github.com/yesheytenzin/live-wallpaper |
|
||||
| `io.github.ehlxr.advanced-workspaces` | https://github.com/ehlxr/advanced-workspaces |
|
||||
|
||||
## Package wiring
|
||||
|
||||
Shell binary + `OMARCHY_PATH` live in `hosts/fwbook/packages.nix`.
|
||||
Launch is `omarchy-launch-shell` from `configs/fwbook/hypr/conf/autostart.lua`.
|
||||
No nixarchy NixOS/HM modules.
|
||||
Whitespace-only changes.
Binary file not shown.
|
After Width: | Height: | Size: 659 KiB |
Binary file not shown.
@@ -0,0 +1 @@
|
||||
nord
|
||||
@@ -0,0 +1 @@
|
||||
pi
|
||||
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"bar": {
|
||||
"centerAnchor": "omarchy.clock",
|
||||
"layout": {
|
||||
"center": [
|
||||
{
|
||||
"id": "omarchy.indicators"
|
||||
},
|
||||
{
|
||||
"format": "dddd HH:mm",
|
||||
"formatAlt": "d MMMM 'W'ww yyyy",
|
||||
"id": "omarchy.clock",
|
||||
"verticalFormat": "HH\n—\nmm"
|
||||
},
|
||||
{
|
||||
"id": "omarchy.keyboard-layout"
|
||||
},
|
||||
{
|
||||
"id": "omarchy.weather"
|
||||
}
|
||||
],
|
||||
"left": [
|
||||
{
|
||||
"id": "omarchy.menu"
|
||||
},
|
||||
{
|
||||
"id": "omarchy.workspaces"
|
||||
},
|
||||
{
|
||||
"id": "io.github.ehlxr.advanced-workspaces"
|
||||
}
|
||||
],
|
||||
"right": [
|
||||
{
|
||||
"id": "omarchy.tray"
|
||||
},
|
||||
{
|
||||
"id": "omarchy.agents"
|
||||
},
|
||||
{
|
||||
"id": "omarchy.bluetooth"
|
||||
},
|
||||
{
|
||||
"id": "omarchy.network"
|
||||
},
|
||||
{
|
||||
"id": "omarchy.audio"
|
||||
},
|
||||
{
|
||||
"id": "omarchy.monitor"
|
||||
},
|
||||
{
|
||||
"id": "omarchy.power"
|
||||
}
|
||||
]
|
||||
},
|
||||
"position": "top",
|
||||
"transparent": false
|
||||
},
|
||||
"idle": {
|
||||
"lock": 300,
|
||||
"screensaver": 150
|
||||
},
|
||||
"plugins": [
|
||||
{
|
||||
"id": "tenzin.live-wallpaper"
|
||||
}
|
||||
],
|
||||
"version": 1
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
[font]
|
||||
base-size = 16
|
||||
@@ -8,6 +8,7 @@ local mod = "SUPER"
|
||||
-- =========================
|
||||
hl.bind(mod .. " + T", hl.dsp.exec_cmd("ghostty"))
|
||||
hl.bind(mod .. " + Q", hl.dsp.window.close())
|
||||
hl.bind(mod .. " + Space", hl.dsp.exec_cmd("noctalia msg panel-toggle launcher"))
|
||||
|
||||
-- =========================
|
||||
-- Navigation
|
||||
|
||||
Generated
+415
-326
File diff suppressed because it is too large.
Load diff
@@ -4,6 +4,24 @@
|
||||
skygqts.url = "git+ssh://gitea@gitea.app.internal:22/ari/skygqts.git";
|
||||
skygqts.inputs.nixpkgs.follows = "nixpkgs";
|
||||
hermenix.url = "git+ssh://gitea@gitea.app.internal:22/ari/hermenix.git";
|
||||
nbot = {
|
||||
url = "git+ssh://git@github.com/SkyG-Org/nBot.git";
|
||||
inputs.nixpkgs.follows = "nixpkgs-unstable";
|
||||
};
|
||||
looprail = {
|
||||
url = "git+ssh://git@github.com/SkyG-Org/LoopRail.git";
|
||||
inputs.nixpkgs.follows = "nixpkgs-unstable";
|
||||
};
|
||||
# Read-only host monitor (systemd, journal, Docker) over REST + MCP.
|
||||
skyg-linux-tracker = {
|
||||
url = "git+https://gitea.skyg.ca/ari/skyg-linux-tracker.git";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
# Headless Hyprland session streamed over a Unix socket.
|
||||
hhstream = {
|
||||
url = "git+ssh://gitea@gitea.app.internal:22/Hermenix/hyprland-headless-stream-plugin.git";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
# Hardware
|
||||
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
|
||||
systems.url = "github:nix-systems/default";
|
||||
@@ -16,6 +34,8 @@
|
||||
determinate.url = "https://flakehub.com/f/DeterminateSystems/determinate/*";
|
||||
determinate.inputs.nixpkgs.follows = "nixpkgs";
|
||||
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0";
|
||||
# Slack 4.53.287, NixOS/nixpkgs#557737.
|
||||
nixpkgs-slack.url = "github:NixOS/nixpkgs/713bc1926b25ad17376e552e339faeea73cf86dc";
|
||||
nixpkgs-unstable.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1";
|
||||
# my fork of nixpkgs
|
||||
my-nixpkgs.url = "github:asosnovsky/nixpkgs/ds4-init";
|
||||
@@ -71,30 +91,38 @@
|
||||
};
|
||||
# Hyprland
|
||||
hyprlauncher.url = "github:hyprwm/hyprlauncher";
|
||||
# Hyprland compositor via flake (latest git).
|
||||
hyprland.url = "github:hyprwm/Hyprland";
|
||||
# Hyprland compositor via flake — pinned to the latest stable release tag
|
||||
# (was floating on main, 50 commits past v0.57.0, which caused a
|
||||
# compositor render-spin episode on fwbook: ~4-core spin, 100°C, no
|
||||
# suspend requested). Re-lock with: nix flake lock --update-input hyprland
|
||||
hyprland.url = "github:hyprwm/Hyprland/v0.57.0";
|
||||
|
||||
# Secrets management
|
||||
agenix.url = "github:ryantm/agenix";
|
||||
|
||||
# Tether — iPhone ↔ Linux Wayland bridge
|
||||
tether = {
|
||||
url = "github:zackb/tether";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
herdr.url = "github:herdrdev/herdr";
|
||||
ai-usagebar.url = "github:akitaonrails/ai-usagebar";
|
||||
# Declarative disk partitioning (for nixos-anywhere installs)
|
||||
disko = {
|
||||
url = "github:nix-community/disko";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
# CI (buildbot-nix)
|
||||
buildbot-nix = {
|
||||
url = "github:nix-community/buildbot-nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs-unstable";
|
||||
};
|
||||
};
|
||||
outputs =
|
||||
{ self
|
||||
, skygqts
|
||||
, hermenix
|
||||
, skyg-linux-tracker
|
||||
, nbot
|
||||
, looprail
|
||||
, hhstream
|
||||
, nixpkgs-unstable
|
||||
, nixpkgs-slack
|
||||
, flox
|
||||
, determinate
|
||||
, nixos-hardware
|
||||
@@ -115,10 +143,9 @@
|
||||
, nix-index-database
|
||||
, agenix
|
||||
, hermes-agent
|
||||
, tether
|
||||
, herdr
|
||||
, disko
|
||||
, ai-usagebar
|
||||
, buildbot-nix
|
||||
}:
|
||||
let
|
||||
# Libs
|
||||
@@ -148,6 +175,7 @@
|
||||
skyg-secrets = {
|
||||
buzz-env = ./secrets/buzz-env.age;
|
||||
cloudflare-dns = ./secrets/cloudflare-dns.age;
|
||||
cloudflare-ddclient = ./secrets/cloudflare-ddclient.age;
|
||||
portainer-agent-minipc1 = ./secrets/portainer-agent-minipc1.age;
|
||||
portainer-agent-bigbox1 = ./secrets/portainer-agent-bigbox1.age;
|
||||
portainer-tls-key = ./secrets/portainer-tls-key.age;
|
||||
@@ -155,11 +183,32 @@
|
||||
stack2 = ./secrets/stack2.age;
|
||||
portainer-agent-minipc3 = ./secrets/portainer-agent-minipc3.age;
|
||||
portainer-cert = ./configs/pki/portainer.app.internal.crt;
|
||||
buildbot-worker-password-minipc3 = ./secrets/buildbot-worker-password-minipc3.age;
|
||||
buildbot-worker-password-fwdesk = ./secrets/buildbot-worker-password-fwdesk.age;
|
||||
buildbot-gitea-token = ./secrets/buildbot-gitea-token.age;
|
||||
buildbot-gitea-webhook-secret = ./secrets/buildbot-gitea-webhook-secret.age;
|
||||
buildbot-gitea-oauth-secret = ./secrets/buildbot-gitea-oauth-secret.age;
|
||||
immich-shared = ./secrets/immich-shared.age;
|
||||
grafana-secret-key = ./secrets/grafana-secret-key.age;
|
||||
umami-app-secret = ./secrets/umami-app-secret.age;
|
||||
linux-tracker-peer-minipc1 = ./secrets/linux-tracker-peer-minipc1.age;
|
||||
linux-tracker-peer-minipc2 = ./secrets/linux-tracker-peer-minipc2.age;
|
||||
linux-tracker-peer-minipc3 = ./secrets/linux-tracker-peer-minipc3.age;
|
||||
linux-tracker-peer-bigbox1 = ./secrets/linux-tracker-peer-bigbox1.age;
|
||||
linux-tracker-peer-bigbox2 = ./secrets/linux-tracker-peer-bigbox2.age;
|
||||
linux-tracker-peer-terra1 = ./secrets/linux-tracker-peer-terra1.age;
|
||||
scrypted-envs = ./secrets/scrypted-envs.age;
|
||||
nbot-slack = ./secrets/nbot-slack.age;
|
||||
nbot-goose = ./secrets/nbot-goose.age;
|
||||
nbot-cluster = ./secrets/nbot-cluster.age;
|
||||
nbot-cluster-hl-fws1 = ./secrets/nbot-cluster-hl-fws1.age;
|
||||
github-runner-token-fws1 = ./secrets/github-runner-token-fws1.age;
|
||||
};
|
||||
inherit
|
||||
hyprlauncher
|
||||
hyprland
|
||||
nixpkgs-unstable
|
||||
nixpkgs-slack
|
||||
my-nixpkgs
|
||||
dms
|
||||
dank-greeter
|
||||
@@ -169,11 +218,13 @@
|
||||
hermes-agent
|
||||
skygqts
|
||||
hermenix
|
||||
skyg-linux-tracker
|
||||
nbot
|
||||
looprail
|
||||
hhstream
|
||||
flox
|
||||
determinate
|
||||
tether
|
||||
herdr
|
||||
ai-usagebar
|
||||
;
|
||||
};
|
||||
}
|
||||
@@ -192,11 +243,40 @@
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
qtDocs = pkgs.qt6.qtdoc;
|
||||
# Hook: run skyg pkgs update --all at most once a week; fail if it bumped
|
||||
# anything under pkgs/ so bumps get reviewed and staged, never auto-committed.
|
||||
pkgs-update-script = pkgs.writeShellScriptBin "skyg-pkgs-update" ''
|
||||
set -euo pipefail
|
||||
export PATH=${pkgs.bash}/bin:${pkgs.coreutils}/bin:${pkgs.curl}/bin:${pkgs.jq}/bin:${pkgs.git}/bin:${pkgs.gnused}/bin:${pkgs.gawk}/bin:$PATH
|
||||
root=$(${pkgs.git}/bin/git rev-parse --show-toplevel)
|
||||
cd "$root"
|
||||
stamp=$(${pkgs.git}/bin/git rev-parse --git-path pkgs-update-last-success)
|
||||
now=$(date +%s)
|
||||
last_run=$(date -r "$stamp" +%s 2>/dev/null || echo 0)
|
||||
if (( now - last_run < 604800 )); then
|
||||
exit 0
|
||||
fi
|
||||
${pkgs.nushell}/bin/nu --commands 'use ./bin/lib/cmds.nu *; skyg pkgs update --all'
|
||||
touch "$stamp"
|
||||
if ! ${pkgs.git}/bin/git diff --quiet -- pkgs/; then
|
||||
echo ""
|
||||
echo "pkgs-update: version bumps applied under pkgs/ — review 'git diff pkgs/',"
|
||||
echo "stage them ('git add pkgs/') and commit again."
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
pre-commit-check = git-hooks.lib.${system}.run {
|
||||
src = ./.;
|
||||
hooks = {
|
||||
nixpkgs-fmt.enable = true;
|
||||
stylua.enable = true;
|
||||
pkgs-update = {
|
||||
enable = true;
|
||||
entry = "${pkgs-update-script}/bin/skyg-pkgs-update";
|
||||
language = "system";
|
||||
pass_filenames = false;
|
||||
always_run = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
@@ -216,6 +296,7 @@
|
||||
agenix.packages.${system}.default
|
||||
age
|
||||
yq
|
||||
nak
|
||||
home-manager.packages.${system}.home-manager
|
||||
rustc
|
||||
cargo
|
||||
@@ -274,9 +355,9 @@
|
||||
skyg-dns-records = dnsRecordsFile;
|
||||
ds4 = my-nixpkgs.legacyPackages.${system}.ds4;
|
||||
buzz-desktop = lib.pkgs.${system}.buzz-desktop;
|
||||
superset-desktop = lib.pkgs.${system}.superset-desktop;
|
||||
delta-editor = lib.pkgs.${system}.delta-editor;
|
||||
colibri = lib.pkgs.${system}.colibri;
|
||||
llama-cpp-halo = lib.pkgs.${system}.llama-cpp-halo;
|
||||
herdr = herdr.packages.${system}.default;
|
||||
}
|
||||
);
|
||||
@@ -306,6 +387,7 @@
|
||||
./hosts/hl-fws1.disko.nix
|
||||
nixos-hardware.nixosModules.framework-11th-gen-intel
|
||||
disko.nixosModules.disko
|
||||
nbot.nixosModules.host
|
||||
];
|
||||
};
|
||||
hl-fwdesk = lib.makeNixOs {
|
||||
@@ -315,6 +397,8 @@
|
||||
./hosts/hl-fwdesk
|
||||
nixos-hardware.nixosModules.framework-desktop-amd-ai-max-300-series
|
||||
hermenix.nixosModules.default
|
||||
buildbot-nix.nixosModules.buildbot-worker
|
||||
nbot.nixosModules.host
|
||||
];
|
||||
};
|
||||
hl-bigbox1 = lib.makeNixOs {
|
||||
@@ -346,6 +430,8 @@
|
||||
hostName = "hl-minipc3";
|
||||
configuration = [
|
||||
./hosts/hl-minipc3
|
||||
buildbot-nix.nixosModules.buildbot-master
|
||||
buildbot-nix.nixosModules.buildbot-worker
|
||||
];
|
||||
};
|
||||
hl-pi1 = lib.makeSdImage {
|
||||
|
||||
+14
-14
@@ -28,20 +28,20 @@ hosts/
|
||||
|
||||
## Managed Hosts
|
||||
|
||||
| Folder | Host | Role |
|
||||
| ------------- | ---------- | -------------------------------------------------------------------------------------------------- |
|
||||
| `fwbook/` | fwbook | Framework 13 AMD — personal laptop / daily driver |
|
||||
| `hl-fwdesk/` | hl-fwdesk | Framework Desktop AI Max 300 — AI workstation |
|
||||
| `hl-fws1/` | hl-fws1 | Framework 11th Intel — K3s server node |
|
||||
| `hl-bigbox1/` | hl-bigbox1 | AI/compute server (NVIDIA + AMD) |
|
||||
| `hl-bigbox2/` | hl-bigbox2 | NFS storage server |
|
||||
| `hl-minipc1/` | hl-minipc1 | Core infra: Gitea (native or containerized), nix-serve, registry, Buzz (docker, `buzz-manage` CLI) |
|
||||
| `hl-minipc2/` | hl-minipc2 | Container/media server |
|
||||
| `hl-minipc3/` | hl-minipc3 | K3s worker node; central Caddy reverse-proxy (`*.home.sosnovsky.ca`) |
|
||||
| `hl-pi1/` | hl-pi1 | Raspberry Pi CM4 (aarch64) — headless server, SSH only |
|
||||
| `hl-pi2/` | hl-pi2 | Raspberry Pi 4 (aarch64) — headless server, SSH only |
|
||||
| `hl-terra1/` | hl-terra1 | NFS storage + Jellyfin backup |
|
||||
| `iso/` | iso | Bootable NixOS installer image |
|
||||
| Folder | Host | Role |
|
||||
| ------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `fwbook/` | fwbook | Framework 13 AMD — personal laptop / daily driver |
|
||||
| `hl-fwdesk/` | hl-fwdesk | Framework Desktop AI Max 300 — AI workstation; buildbot-nix CI worker (4 cores); nbot master |
|
||||
| `hl-fws1/` | hl-fws1 | Framework 11th Intel — K3s server node; nbot worker |
|
||||
| `hl-bigbox1/` | hl-bigbox1 | AI/compute server (NVIDIA + AMD); Immich machine-learning (CUDA) |
|
||||
| `hl-bigbox2/` | hl-bigbox2 | NFS storage server; Immich server/db (docker, `immich.home.sosnovsky.ca`) |
|
||||
| `hl-minipc1/` | hl-minipc1 | Core infra: Gitea (native or containerized), nix-serve, registry, Buzz (docker, `buzz-manage` CLI), monitoring (Grafana, Prometheus, Loki, OTel collector) |
|
||||
| `hl-minipc2/` | hl-minipc2 | Container/media server; Umami for LoopRail telemetry (own nspawn container, `10.0.101.14`, reachable only from Caddy) |
|
||||
| `hl-minipc3/` | hl-minipc3 | K3s worker node; central Caddy reverse-proxy (`*.home.sosnovsky.ca`, plus `gitea.skyg.ca` HTTP/SSH); serves LoopRail docs at `looprails.skyg.ca`, plus its guarded telemetry route `/t/v1` → Umami and the LAN-only `umami.home.sosnovsky.ca`; buildbot-nix CI master + worker (2 cores) |
|
||||
| `hl-pi1/` | hl-pi1 | Raspberry Pi CM4 (aarch64) — headless server, SSH only |
|
||||
| `hl-pi2/` | hl-pi2 | Raspberry Pi 4 (aarch64) — headless server, SSH only |
|
||||
| `hl-terra1/` | hl-terra1 | NFS storage + Jellyfin backup |
|
||||
| `iso/` | iso | Bootable NixOS installer image |
|
||||
|
||||
## Rules
|
||||
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
imports = [
|
||||
./hardware-configuration
|
||||
./packages.nix
|
||||
./slack.nix
|
||||
./services.nix
|
||||
./networking.nix
|
||||
./hardware.nix
|
||||
./systemd.nix
|
||||
./omarchy.nix
|
||||
];
|
||||
|
||||
skyg = {
|
||||
@@ -28,6 +30,7 @@
|
||||
printers.enable = true;
|
||||
fixes = {
|
||||
airpod-bluetooth.enabled = true;
|
||||
fingerprint-autosuspend.enabled = true;
|
||||
};
|
||||
tiler = {
|
||||
enable = true;
|
||||
|
||||
@@ -19,7 +19,7 @@ in
|
||||
"x-scheme-handler/mailto" = "chromium-browser.desktop";
|
||||
"x-scheme-handler/sgnl" = "signal.desktop";
|
||||
"x-scheme-handler/signalcaptcha" = "signal.desktop";
|
||||
"x-scheme-handler/slack" = "slack.desktop";
|
||||
"x-scheme-handler/slack" = "slack-link-picker.desktop";
|
||||
"x-scheme-handler/terminal" = "com.mitchellh.ghostty.desktop";
|
||||
"application/pdf" = "chromium-browser.desktop";
|
||||
"application/xhtml+xml" = "chromium-browser.desktop";
|
||||
|
||||
@@ -13,6 +13,7 @@ in
|
||||
};
|
||||
networking.firewall.allowedUDPPorts = openPorts;
|
||||
networking.firewall.allowedTCPPorts = openPorts;
|
||||
programs.mosh.enable = true;
|
||||
networking.hosts = {
|
||||
"0.0.0.0" = [
|
||||
"auth.me.internal"
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
{ pkgs, nixarchy, skygUtils, config, ... }:
|
||||
let
|
||||
# Omarchy shell build
|
||||
dedent = "${pkgs.gawk}/bin/awk 'BEGIN{m=9999} {l[NR]=$0; match($0,/^ */); if ($0 ~ /[^ ]/ && RLENGTH<m) m=RLENGTH} END{for(i=1;i<=NR;i++) print substr(l[i],m+1)}'";
|
||||
omarchy = ((pkgs.extend nixarchy.overlays.default).omarchy).overrideAttrs (old: {
|
||||
installPhase = builtins.replaceStrings
|
||||
[ "python3 -c '" "' $menu\n" ]
|
||||
[ "python3 -c \"$(printf '%s' '" "' | ${dedent})\" $menu\n" ]
|
||||
old.installPhase;
|
||||
});
|
||||
# The shell's runtime deps, minus hyprland (we keep the flake's Hyprland).
|
||||
# Omarchy runtime deps
|
||||
omarchyRuntime = builtins.filter
|
||||
(d: !(pkgs.lib.hasPrefix "hyprland-" (d.name or "")))
|
||||
omarchy.passthru.runtimeDeps;
|
||||
in
|
||||
{
|
||||
# Omarchy env vars (shell resolves paths via OMARCHY_PATH)
|
||||
environment.sessionVariables.OMARCHY_PATH = "${omarchy}/share/omarchy";
|
||||
environment.sessionVariables.OMARCHY_SCREENSHOT_EDITOR = "satty-edit";
|
||||
|
||||
# Omarchy config link: ~/.config/omarchy -> configs/fwbook/omarchy
|
||||
system.userActivationScripts.omarchyConfig.text =
|
||||
skygUtils.makeHyperlinkScriptToConfigs {
|
||||
filePath = "fwbook/omarchy";
|
||||
targetPath = "omarchy";
|
||||
configSource = "/home/${config.skyg.user.name}/nixos-setup/configs";
|
||||
};
|
||||
|
||||
# Packages
|
||||
environment.systemPackages =
|
||||
[ omarchy ]
|
||||
++ omarchyRuntime;
|
||||
}
|
||||
+89
-122
@@ -1,24 +1,5 @@
|
||||
{ pkgs, unstablePkgs, ai-usagebar, hermes-agent, nixarchy, skygUtils, config, ... }:
|
||||
{ pkgs, unstablePkgs, looprail, ... }:
|
||||
let
|
||||
# Omarchy (nixarchy) shell, hand-wired — no nixarchy modules. The shell is
|
||||
# launched from configs/fwbook/hypr/conf/autostart.lua (omarchy-launch-shell).
|
||||
#
|
||||
# Workaround for an upstream bug in nixarchy v4.0.4-1: the omarchy package's
|
||||
# installPhase is one '' string whose least-indented lines are the shell-quoted
|
||||
# omarchy-theme-set patterns (indent 4), so Nix dedents the whole string by 4
|
||||
# and the inline `python3 -c '...'` menu check stays indented -> IndentationError.
|
||||
# Wrap that one invocation so its code is dedented before Python sees it.
|
||||
dedent = "${pkgs.gawk}/bin/awk 'BEGIN{m=9999} {l[NR]=$0; match($0,/^ */); if ($0 ~ /[^ ]/ && RLENGTH<m) m=RLENGTH} END{for(i=1;i<=NR;i++) print substr(l[i],m+1)}'";
|
||||
omarchy = ((pkgs.extend nixarchy.overlays.default).omarchy).overrideAttrs (old: {
|
||||
installPhase = builtins.replaceStrings
|
||||
[ "python3 -c '" "' $menu\n" ]
|
||||
[ "python3 -c \"$(printf '%s' '" "' | ${dedent})\" $menu\n" ]
|
||||
old.installPhase;
|
||||
});
|
||||
# The shell's runtime deps, minus hyprland (we keep the flake's Hyprland).
|
||||
omarchyRuntime = builtins.filter
|
||||
(d: !(pkgs.lib.hasPrefix "hyprland-" (d.name or "")))
|
||||
omarchy.passthru.runtimeDeps;
|
||||
gdk = pkgs.google-cloud-sdk.withExtraComponents (
|
||||
with pkgs.google-cloud-sdk.components;
|
||||
[
|
||||
@@ -26,145 +7,131 @@ let
|
||||
kubectl
|
||||
]
|
||||
);
|
||||
davinci-resolve-wrapped = pkgs.symlinkJoin {
|
||||
name = "davinci-resolve";
|
||||
paths = [ pkgs.davinci-resolve ];
|
||||
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/davinci-resolve --set QT_QPA_PLATFORM xcb
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
# The shell resolves everything through OMARCHY_PATH.
|
||||
environment.sessionVariables.OMARCHY_PATH = "${omarchy}/share/omarchy";
|
||||
environment.sessionVariables.OMARCHY_SCREENSHOT_EDITOR = "satty-edit";
|
||||
|
||||
# ~/.config/omarchy -> configs/fwbook/omarchy (same pattern as hypr/noctalia).
|
||||
system.userActivationScripts.omarchyConfig.text =
|
||||
skygUtils.makeHyperlinkScriptToConfigs {
|
||||
filePath = "fwbook/omarchy";
|
||||
targetPath = "omarchy";
|
||||
configSource = "/home/${config.skyg.user.name}/nixos-setup/configs";
|
||||
};
|
||||
|
||||
environment.systemPackages =
|
||||
[ omarchy ]
|
||||
++ omarchyRuntime
|
||||
# Theme application: omarchy-theme-set-gnome writes gsettings, and every
|
||||
# theme names a Yaru icon variant.
|
||||
++ (with pkgs; [
|
||||
(with pkgs; [
|
||||
# Desktop & theme
|
||||
glib
|
||||
gsettings-desktop-schemas
|
||||
gnome-themes-extra
|
||||
yaru-theme
|
||||
adwaita-icon-theme
|
||||
])
|
||||
++ (with pkgs; [
|
||||
oreo-cursors-plus
|
||||
|
||||
# Screen & images
|
||||
grim
|
||||
slurp
|
||||
wl-clipboard
|
||||
tesseract
|
||||
wl-screenrec
|
||||
gpu-screen-recorder
|
||||
gifski
|
||||
imagemagick
|
||||
zbar
|
||||
curl
|
||||
translate-shell
|
||||
wl-screenrec
|
||||
tesseract
|
||||
|
||||
# Media & creative
|
||||
obs-studio
|
||||
davinci-resolve-wrapped
|
||||
shotcut
|
||||
ffmpeg
|
||||
gifski
|
||||
libusb1
|
||||
lshw
|
||||
jq
|
||||
parted
|
||||
gparted-full
|
||||
f3
|
||||
nixd
|
||||
kdePackages.qtdeclarative
|
||||
krita
|
||||
gimp-with-plugins
|
||||
simple-scan
|
||||
orca-slicer
|
||||
|
||||
# Chat & meetings
|
||||
zoom-us
|
||||
discord
|
||||
betterdiscordctl
|
||||
signal-desktop
|
||||
telegram-desktop
|
||||
|
||||
# Office
|
||||
onlyoffice-desktopeditors
|
||||
darling-dmg
|
||||
piper-tts
|
||||
ffmpeg
|
||||
oreo-cursors-plus
|
||||
|
||||
postgresql
|
||||
google-cloud-sdk
|
||||
awscli
|
||||
openfortivpn
|
||||
openfortivpn-webview
|
||||
openfortivpn-webview-qt
|
||||
nodejs
|
||||
|
||||
# Wine
|
||||
wineWow64Packages.stable
|
||||
winetricks
|
||||
wineWow64Packages.waylandFull
|
||||
|
||||
obs-studio
|
||||
davinci-resolve
|
||||
grim
|
||||
slurp
|
||||
wl-clipboard
|
||||
tesseract
|
||||
imagemagick
|
||||
zbar
|
||||
curl
|
||||
translate-shell
|
||||
wl-screenrec
|
||||
ffmpeg
|
||||
gifski
|
||||
jq
|
||||
# Cloud, VPN & data
|
||||
postgresql
|
||||
google-cloud-sdk
|
||||
gdk
|
||||
awscli
|
||||
openfortivpn
|
||||
openfortivpn-webview
|
||||
openfortivpn-webview-qt
|
||||
bitwarden-cli
|
||||
|
||||
krita
|
||||
gimp-with-plugins
|
||||
shotcut
|
||||
simple-scan
|
||||
|
||||
zoom-us
|
||||
betterdiscordctl
|
||||
discord
|
||||
signal-desktop
|
||||
telegram-desktop
|
||||
# Disks & hardware
|
||||
libusb1
|
||||
lshw
|
||||
parted
|
||||
gparted-full
|
||||
f3
|
||||
rpi-imager
|
||||
rpiboot
|
||||
libimobiledevice
|
||||
ifuse
|
||||
idevicerestore
|
||||
|
||||
# Languages & dev tools
|
||||
nodejs
|
||||
python313
|
||||
python314
|
||||
uv
|
||||
pipx
|
||||
cargo
|
||||
rustc
|
||||
go
|
||||
pipx
|
||||
rust-analyzer
|
||||
|
||||
vscode
|
||||
unstablePkgs.zed-editor-fhs
|
||||
devenv
|
||||
nixd
|
||||
kdePackages.qtdeclarative
|
||||
just
|
||||
rpi-imager
|
||||
rpiboot
|
||||
code-cursor-fhs
|
||||
nix-prefetch
|
||||
orca-slicer
|
||||
devcontainer
|
||||
gpu-screen-recorder
|
||||
unstablePkgs.devcontainer
|
||||
unstablePkgs.devenv
|
||||
flox_dev
|
||||
|
||||
darling-dmg
|
||||
|
||||
bitwarden-cli
|
||||
|
||||
onlyoffice-desktopeditors
|
||||
|
||||
nix-prefetch
|
||||
gh
|
||||
gdk
|
||||
unstablePkgs.slack
|
||||
bubblewrap
|
||||
delta-editor
|
||||
|
||||
libimobiledevice
|
||||
ifuse
|
||||
|
||||
idevicerestore
|
||||
# Editors
|
||||
unstablePkgs.vscode
|
||||
unstablePkgs.zed-editor-fhs
|
||||
code-cursor-fhs
|
||||
|
||||
# Agents & LLM tools
|
||||
unstablePkgs.claude-code
|
||||
unstablePkgs.claude-agent-acp
|
||||
unstablePkgs.grok-build
|
||||
unstablePkgs.pi-coding-agent
|
||||
unstablePkgs.goose-cli
|
||||
unstablePkgs.claude-agent-acp
|
||||
unstablePkgs.claude-code
|
||||
buzz-desktop
|
||||
bubblewrap
|
||||
delta-editor
|
||||
herdr
|
||||
superset-desktop
|
||||
ai-usagebar.packages.${pkgs.stdenv.hostPlatform.system}.default
|
||||
hermes-agent.packages.${pkgs.stdenv.hostPlatform.system}.default
|
||||
|
||||
skygqts
|
||||
unstablePkgs.herdr
|
||||
unstablePkgs.codex
|
||||
unstablePkgs.codex-acp
|
||||
looprail.packages.${pkgs.stdenv.hostPlatform.system}.looprail
|
||||
hermenix
|
||||
unstablePkgs.pi-coding-agent
|
||||
|
||||
# Remote & CLI tools
|
||||
unstablePkgs.et
|
||||
curl
|
||||
jq
|
||||
translate-shell
|
||||
buzz-desktop
|
||||
skygqts
|
||||
]);
|
||||
}
|
||||
@@ -1,20 +1,8 @@
|
||||
{ pkgs, unstablePkgs, config, ... }:
|
||||
{ unstablePkgs, ... }:
|
||||
{
|
||||
services.tailscale.enable = true;
|
||||
services.tailscale.extraDaemonFlags = [ "--statedir=/var/lib/tailscale" ];
|
||||
|
||||
programs.tether = {
|
||||
enable = true;
|
||||
wifi = {
|
||||
enable = true;
|
||||
openFirewall = true;
|
||||
};
|
||||
bluetooth = {
|
||||
enable = true;
|
||||
adapters = [ "hci0" ];
|
||||
};
|
||||
};
|
||||
|
||||
services.flatpak.enable = true;
|
||||
services.flatpak.packages = [
|
||||
"io.github.kolunmi.Bazaar"
|
||||
@@ -30,7 +18,7 @@
|
||||
|
||||
programs.steam = {
|
||||
enable = true;
|
||||
extest.enable = true;
|
||||
extest.enable = false;
|
||||
remotePlay.openFirewall = true;
|
||||
dedicatedServer.openFirewall = true;
|
||||
localNetworkGameTransfers.openFirewall = true;
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
{ pkgs, nixpkgs-slack, ... }:
|
||||
let
|
||||
slack = (import nixpkgs-slack {
|
||||
system = pkgs.stdenv.hostPlatform.system;
|
||||
config.allowUnfreePredicate = pkg: pkgs.lib.getName pkg == "slack";
|
||||
}).slack;
|
||||
slackIcon = "${slack}/share/icons/hicolor/512x512/apps/slack.png";
|
||||
makeSlack =
|
||||
{ id, name, color }:
|
||||
let
|
||||
icon = pkgs.runCommand "slack-${id}-icon.png" { nativeBuildInputs = [ pkgs.imagemagick ]; } ''
|
||||
magick ${slackIcon} -modulate 100,0 -fill '${color}' -tint 100 $out
|
||||
'';
|
||||
bin = pkgs.writeShellScriptBin "slack-${id}" ''
|
||||
exec ${slack}/bin/slack --user-data-dir="''${XDG_CONFIG_HOME:-$HOME/.config}/Slack-${name}" "$@"
|
||||
'';
|
||||
desktop = pkgs.makeDesktopItem {
|
||||
name = "slack-${id}";
|
||||
desktopName = "Slack (${name})";
|
||||
exec = "${bin}/bin/slack-${id} -s %U";
|
||||
inherit icon;
|
||||
startupWMClass = "Slack";
|
||||
categories = [ "Network" "InstantMessaging" ];
|
||||
};
|
||||
in
|
||||
pkgs.symlinkJoin {
|
||||
name = "slack-${id}";
|
||||
paths = [ bin desktop ];
|
||||
};
|
||||
slack-sibli = makeSlack { id = "sibli"; name = "Sibli"; color = "#2EB67D"; };
|
||||
slack-personal = makeSlack { id = "personal"; name = "Personal"; color = "#4A154B"; };
|
||||
|
||||
# Opens slack:// links in the Slack you pick.
|
||||
slack-link-picker =
|
||||
let
|
||||
bin = pkgs.writeShellScriptBin "slack-link-picker" ''
|
||||
choice=$(printf '%s\n' "Slack" "Slack (Sibli)" "Slack (Personal)" \
|
||||
| ${pkgs.rofi}/bin/rofi -dmenu -i -p "Open Slack link in")
|
||||
case "$choice" in
|
||||
"Slack") exec ${slack}/bin/slack -s "$@" ;;
|
||||
"Slack (Sibli)") exec ${slack-sibli}/bin/slack-sibli -s "$@" ;;
|
||||
"Slack (Personal)") exec ${slack-personal}/bin/slack-personal -s "$@" ;;
|
||||
esac
|
||||
'';
|
||||
desktop = pkgs.makeDesktopItem {
|
||||
name = "slack-link-picker";
|
||||
desktopName = "Slack Link Picker";
|
||||
exec = "${bin}/bin/slack-link-picker %U";
|
||||
icon = "slack";
|
||||
noDisplay = true;
|
||||
mimeTypes = [ "x-scheme-handler/slack" ];
|
||||
};
|
||||
in
|
||||
pkgs.symlinkJoin {
|
||||
name = "slack-link-picker";
|
||||
paths = [ bin desktop ];
|
||||
};
|
||||
in
|
||||
{
|
||||
environment.systemPackages = [
|
||||
slack-sibli
|
||||
slack-personal
|
||||
slack-link-picker
|
||||
];
|
||||
}
|
||||
@@ -1,4 +1,10 @@
|
||||
{ ... }:
|
||||
{
|
||||
systemd.services.systemd-udev-settle.enable = false;
|
||||
|
||||
# Snapper needs a .snapshots subvolume in each snapshotted volume
|
||||
systemd.tmpfiles.rules = [
|
||||
"v /.snapshots 0750 root root -"
|
||||
"v /home/.snapshots 0750 root root -"
|
||||
];
|
||||
}
|
||||
@@ -10,14 +10,16 @@
|
||||
skyg = {
|
||||
user.enable = true;
|
||||
server.admin.enable = true;
|
||||
server.exporters.enable = true;
|
||||
|
||||
nixos = {
|
||||
desktop = {
|
||||
enable = false;
|
||||
gnome.enable = false;
|
||||
};
|
||||
common.ssh-server.enable = true;
|
||||
common.containers.openMetricsPort = true;
|
||||
common.diagnix.enable = true;
|
||||
|
||||
common.dns.enable = true;
|
||||
common.hardware = {
|
||||
nvidia.enable = true;
|
||||
amdgpu.enable = true;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
services.fwupd.enable = true;
|
||||
boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
|
||||
boot.kernelPackages = pkgs.linuxPackages;
|
||||
networking.interfaces.enp4s0.wakeOnLan.enable = true;
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
{
|
||||
imports = [
|
||||
./jellyfin.nix
|
||||
./immich-ml.nix
|
||||
./portainer.nix
|
||||
./timers.nix
|
||||
./linux-tracker.nix
|
||||
./llama-cpp.nix
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
{ config, ... }:
|
||||
let
|
||||
version = "v3";
|
||||
app = config.skyg.internalNetworkingMap.apps.immich-ml;
|
||||
in
|
||||
{
|
||||
skyg.nixos.common.container-services.immich-ml = {
|
||||
enable = true;
|
||||
autoUpdate.enable = true;
|
||||
networks.lan = config.skyg.nixos.common.containers.networks.ipvlanLab.compose;
|
||||
volumes.model-cache = { };
|
||||
services.immich-machine-learning = {
|
||||
image = "ghcr.io/immich-app/immich-machine-learning:${version}-cuda";
|
||||
networks.lan.ipv4_address = app.ip;
|
||||
volumes = [ "model-cache:/cache" ];
|
||||
environment.NVIDIA_VISIBLE_DEVICES = "all";
|
||||
deploy.resources = {
|
||||
limits = {
|
||||
cpus = "4";
|
||||
memory = "16G";
|
||||
};
|
||||
reservations.devices = [
|
||||
{
|
||||
driver = "cdi";
|
||||
device_ids = [ "nvidia.com/gpu=all" ];
|
||||
capabilities = [ "gpu" ];
|
||||
}
|
||||
];
|
||||
};
|
||||
restart = "always";
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -6,6 +6,7 @@ in
|
||||
skyg.nixos.common.container-services.jellyfin = {
|
||||
enable = true;
|
||||
autoUpdate.enable = true;
|
||||
networks.lan = config.skyg.nixos.common.containers.networks.ipvlanLab.compose;
|
||||
services.jellyfin = {
|
||||
image = "jellyfin/jellyfin";
|
||||
deploy.resources.reservations.devices = [
|
||||
@@ -34,7 +35,7 @@ in
|
||||
JELLYFIN_CONFIG_DIR = "/mnt/apps/jellyfin/config";
|
||||
NVIDIA_VISIBLE_DEVICES = "all";
|
||||
};
|
||||
ports = [ "8096:8096" ];
|
||||
networks.lan.ipv4_address = app.ip;
|
||||
};
|
||||
volumes = {
|
||||
torrents = {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
{ config, ... }:
|
||||
{
|
||||
services.skyg-linux-tracker = {
|
||||
enable = true;
|
||||
bind = "0.0.0.0";
|
||||
openFirewall = true;
|
||||
docker.enable = config.virtualisation.docker.enable;
|
||||
# Reachable only by its lab FQDN; the short name does not resolve.
|
||||
allowedHosts = [ "bigbox1.lab.internal" ];
|
||||
# OTLP out to the collector on minipc1.
|
||||
settings.otel = {
|
||||
enabled = true;
|
||||
endpoint = "http://minipc1.lab.internal:4317";
|
||||
protocol = "grpc";
|
||||
export_logs = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
{ ... }:
|
||||
|
||||
{
|
||||
# llama.cpp with DFlash2 speculative decoding on RTX 3060 (12GB VRAM).
|
||||
#
|
||||
# Off by default: it needs ~19 GB of weights on disk. Fetch the files, then
|
||||
# flip enable:
|
||||
#
|
||||
# sudo install -d -o ari -g users /var/lib/llama-cpp
|
||||
# cd /var/lib/llama-cpp
|
||||
# curl -L -O https://huggingface.co/ggml-org/Qwen3.8-27B-GGUF/resolve/main/Qwen3.8-27B-Q4_K_M.gguf
|
||||
# curl -L -O https://huggingface.co/z-lab/Qwen3.8-27B-DFlash2-GGUF/resolve/main/Qwen3.8-27B-DFlash2-Q8_0.gguf
|
||||
#
|
||||
# Measured expectation: ~15-25 tok/s (RTX 3060 has less bandwidth than Strix
|
||||
# Halo, but the dedicated VRAM is snappier for inference).
|
||||
skyg.nixos.server.services.llama-cpp = {
|
||||
enable = false;
|
||||
|
||||
package = "llama-cpp-cuda";
|
||||
model = "/var/lib/llama-cpp/Qwen3.8-27B-Q4_K_M.gguf";
|
||||
draftModel = "/var/lib/llama-cpp/Qwen3.8-27B-DFlash2-Q8_0.gguf";
|
||||
specType = "draft-dflash";
|
||||
specDraftNMax = 7;
|
||||
|
||||
ctx = 32768;
|
||||
kvCacheType = "q8_0";
|
||||
cacheReuse = 256;
|
||||
|
||||
# RTX 3060: 12GB VRAM, offload most layers but leave headroom for context.
|
||||
gpuLayers = 30;
|
||||
parallel = 2;
|
||||
|
||||
host = "0.0.0.0";
|
||||
port = 8081;
|
||||
openFirewall = true;
|
||||
};
|
||||
}
|
||||
@@ -1,16 +1,7 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
ports = {
|
||||
nixServe = 5000;
|
||||
lockdPort = 4001;
|
||||
mountdPort = 4002;
|
||||
statdPort = 4000;
|
||||
};
|
||||
openPorts = builtins.attrValues ports;
|
||||
in
|
||||
{ lib, ... }:
|
||||
{
|
||||
imports = [
|
||||
./services.nix
|
||||
./services
|
||||
./hardware-configuration
|
||||
./hardware.nix
|
||||
];
|
||||
@@ -22,14 +13,21 @@ in
|
||||
user.enable = true;
|
||||
nixos.common = {
|
||||
ssh-server.enable = true;
|
||||
containers.openMetricsPort = true;
|
||||
diagnix.enable = true;
|
||||
|
||||
dns.enable = true;
|
||||
|
||||
containers.networks.ipvlanLab = {
|
||||
enable = true;
|
||||
parent = "enp3s0";
|
||||
};
|
||||
cachePush.enable = false;
|
||||
cacheReceive.enable = true;
|
||||
};
|
||||
server.exporters.enable = true;
|
||||
|
||||
networkDrives = {
|
||||
enable = true;
|
||||
bigBox2.enable = false;
|
||||
};
|
||||
};
|
||||
|
||||
skyg.nixos.common.cachePush.enable = false;
|
||||
}
|
||||
@@ -1,4 +1,39 @@
|
||||
{ ... }:
|
||||
{ config, pkgs, ... }:
|
||||
{
|
||||
services.fwupd.enable = true;
|
||||
|
||||
# Interim: the box loses power under load. Use less power and heat, log more.
|
||||
# Remove this block once the new board is in and stable.
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
# No turbo. Lost on reboot unless set here.
|
||||
"w /sys/devices/system/cpu/cpufreq/boost - - - - 0"
|
||||
# Max clock 2.5 GHz. Steps on this CPU: 3.5, 3.0, 2.5, 2.0, 1.4.
|
||||
"w /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq - - - - 2500000"
|
||||
];
|
||||
|
||||
# Keep logs on disk and flush often, so the last seconds before a crash survive.
|
||||
services.journald.extraConfig = ''
|
||||
Storage=persistent
|
||||
SystemMaxUse=2G
|
||||
SyncIntervalSec=5s
|
||||
'';
|
||||
|
||||
# Reboot 10 s after a kernel panic instead of hanging.
|
||||
boot.kernel.sysctl."kernel.panic" = 10;
|
||||
|
||||
# Watch disk health and log warnings. No mail set up.
|
||||
services.smartd = {
|
||||
enable = true;
|
||||
autodetect = true;
|
||||
};
|
||||
|
||||
environment.systemPackages = [
|
||||
pkgs.smartmontools
|
||||
pkgs.lm_sensors
|
||||
pkgs.dmidecode
|
||||
pkgs.stress-ng
|
||||
pkgs.memtester
|
||||
pkgs.ethtool
|
||||
config.boot.kernelPackages.cpupower
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{ ... }:
|
||||
{
|
||||
imports = [
|
||||
./nix-serve.nix
|
||||
./nfs-server.nix
|
||||
./immich.nix
|
||||
./linux-tracker.nix
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
{ config, skygUtils, skyg-secrets, ... }:
|
||||
let
|
||||
version = "v3";
|
||||
app = config.skyg.internalNetworkingMap.apps.immich;
|
||||
envVars = {
|
||||
REDIS_PORT = "6379";
|
||||
REDIS_HOSTNAME = "redis";
|
||||
DB_HOSTNAME = "database";
|
||||
|
||||
DB_USERNAME = "immich";
|
||||
POSTGRES_USER = "immich";
|
||||
POSTGRES_DB = "immich";
|
||||
DB_DATABASE_NAME = "immich";
|
||||
|
||||
IMMICH_MACHINE_LEARNING_URL = "http://${config.skyg.internalNetworkingMap.apps.immich-ml.ip}:3003";
|
||||
};
|
||||
nfsVolume = skygUtils.container-services.nfsVols.tnas1;
|
||||
in
|
||||
{
|
||||
age.secrets.immich-shared.file = skyg-secrets.immich-shared;
|
||||
|
||||
skyg.nixos.common.container-services.immich = {
|
||||
enable = true;
|
||||
autoUpdate.enable = true;
|
||||
networks = {
|
||||
main = { driver = "bridge"; };
|
||||
lan = config.skyg.nixos.common.containers.networks.ipvlanLab.compose;
|
||||
};
|
||||
volumes = {
|
||||
family-storage = nfsVolume "/mnt/EightTerra/FamilyStorage";
|
||||
};
|
||||
services.immich-server = {
|
||||
image = "ghcr.io/immich-app/immich-server:${version}";
|
||||
environmentFiles = [ config.age.secrets.immich-shared.path ];
|
||||
environment = envVars;
|
||||
deploy.resources.limits = {
|
||||
cpus = "1";
|
||||
memory = "8G";
|
||||
};
|
||||
networks = {
|
||||
lan.ipv4_address = app.ip;
|
||||
main = { };
|
||||
};
|
||||
volumes = [
|
||||
"/data/fourTerra/immich-upload:/usr/src/app/upload"
|
||||
"family-storage:/family-storage"
|
||||
];
|
||||
extraConfig.depends_on = {
|
||||
database.condition = "service_healthy";
|
||||
redis.condition = "service_healthy";
|
||||
};
|
||||
restart = "always";
|
||||
};
|
||||
services.redis = {
|
||||
image = "docker.io/valkey/valkey:9@sha256:c123e3715db63d06d4ad6964884037aa0d5d4d703939b9929954112889708e1d";
|
||||
networks.main = { };
|
||||
healthcheck = {
|
||||
test = [ "CMD-SHELL" "redis-cli ping || exit 1" ];
|
||||
interval = "30s";
|
||||
timeout = "5s";
|
||||
retries = 5;
|
||||
start_period = "10s";
|
||||
};
|
||||
restart = "always";
|
||||
};
|
||||
services.database = {
|
||||
image = "ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0@sha256:bcf63357191b76a916ae5eb93464d65c07511da41e3bf7a8416db519b40b1c23";
|
||||
environmentFiles = [ config.age.secrets.immich-shared.path ];
|
||||
environment.POSTGRES_INITDB_ARGS = "--data-checksums";
|
||||
networks.main = { };
|
||||
volumes = [ "/data/fourTerra/immich-db:/var/lib/postgresql/data" ];
|
||||
healthcheck = {
|
||||
test = [ "CMD-SHELL" ''pg_isready --dbname="$$POSTGRES_DB" --username="$$POSTGRES_USER" || exit 1'' ];
|
||||
interval = "5m";
|
||||
timeout = "10s";
|
||||
retries = 5;
|
||||
start_period = "5m";
|
||||
start_interval = "30s";
|
||||
};
|
||||
restart = "always";
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{ config, ... }:
|
||||
{
|
||||
services.skyg-linux-tracker = {
|
||||
enable = true;
|
||||
bind = "0.0.0.0";
|
||||
openFirewall = true;
|
||||
docker.enable = config.virtualisation.docker.enable;
|
||||
# Reachable only by its lab FQDN; the short name does not resolve.
|
||||
allowedHosts = [ "bigbox2.lab.internal" ];
|
||||
# OTLP out to the collector on minipc1.
|
||||
settings.otel = {
|
||||
enabled = true;
|
||||
endpoint = "http://minipc1.lab.internal:4317";
|
||||
protocol = "grpc";
|
||||
export_logs = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
{ ... }:
|
||||
let
|
||||
ports = {
|
||||
nixServe = 5000;
|
||||
lockdPort = 4001;
|
||||
mountdPort = 4002;
|
||||
statdPort = 4000;
|
||||
@@ -9,12 +8,6 @@ let
|
||||
openPorts = builtins.attrValues ports;
|
||||
in
|
||||
{
|
||||
services.nix-serve = {
|
||||
enable = true;
|
||||
secretKeyFile = "/home/ari/cache-keys/cache-priv-key.pem";
|
||||
port = ports.nixServe;
|
||||
};
|
||||
|
||||
skyg.nixos.common.networking.nfsServer.enable = true;
|
||||
services.nfs.server = {
|
||||
lockdPort = ports.lockdPort;
|
||||
@@ -0,0 +1,16 @@
|
||||
{ ... }:
|
||||
let
|
||||
ports = {
|
||||
nixServe = 5000;
|
||||
};
|
||||
openPorts = builtins.attrValues ports;
|
||||
in
|
||||
{
|
||||
services.nix-serve = {
|
||||
enable = true;
|
||||
secretKeyFile = "/home/ari/cache-keys/cache-priv-key.pem";
|
||||
port = ports.nixServe;
|
||||
};
|
||||
networking.firewall.allowedUDPPorts = openPorts;
|
||||
networking.firewall.allowedTCPPorts = openPorts;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
{ pkgs, unstablePkgs, myPkgs, my-nixpkgs, ... }:
|
||||
{ pkgs, my-nixpkgs, ... }:
|
||||
let
|
||||
ports = {
|
||||
tabby = 11029;
|
||||
@@ -40,11 +40,18 @@ in
|
||||
|
||||
environment.sessionVariables.ELECTRON_OZONE_PLATFORM_HINT = "wayland";
|
||||
|
||||
programs.nh.clean = {
|
||||
dates = "daily";
|
||||
extraArgs = "--keep-since 2d --keep 5";
|
||||
};
|
||||
|
||||
skyg = {
|
||||
user.enable = true;
|
||||
core.qemu.enable = true;
|
||||
nixos = {
|
||||
common.ssh-server.enable = true;
|
||||
common.diagnix.enable = true;
|
||||
common.dns.enable = true;
|
||||
common.cachePush.enable = true;
|
||||
common.hardware = {
|
||||
pipewire.enable = true;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
{ ... }:
|
||||
{
|
||||
services.tailscale.enable = true;
|
||||
|
||||
systemd.network.wait-online.enable = false;
|
||||
}
|
||||
@@ -16,6 +16,13 @@
|
||||
lmstudio
|
||||
signal-cli
|
||||
blueman
|
||||
unstablePkgs.devenv
|
||||
|
||||
unstablePkgs.grok-build
|
||||
unstablePkgs.pi-coding-agent
|
||||
unstablePkgs.goose-cli
|
||||
unstablePkgs.claude-agent-acp
|
||||
unstablePkgs.claude-code
|
||||
])
|
||||
++ [ myPkgs.ds4-rocm ];
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{ config, skyg-secrets, ... }:
|
||||
let
|
||||
# Must match the master's domain on hl-minipc3.
|
||||
masterDomain = "minipc3.lab.internal";
|
||||
in
|
||||
{
|
||||
age.secrets.buildbot-worker-password-fwdesk.file = skyg-secrets.buildbot-worker-password-fwdesk;
|
||||
|
||||
services.buildbot-nix.worker = {
|
||||
enable = true;
|
||||
name = "hl-fwdesk";
|
||||
workers = 4;
|
||||
masterUrl = "tcp:host=${masterDomain}:port=9989";
|
||||
workerPasswordFile = config.age.secrets.buildbot-worker-password-fwdesk.path;
|
||||
};
|
||||
}
|
||||
@@ -1,10 +1,14 @@
|
||||
{
|
||||
imports = [
|
||||
./ds4.nix
|
||||
./llama-cpp.nix
|
||||
./ollama.nix
|
||||
./libretranslate.nix
|
||||
./hermenix.nix
|
||||
./wyoming.nix
|
||||
./steam.nix
|
||||
./buildbot.nix
|
||||
./linux-tracker.nix
|
||||
./nbot.nix
|
||||
];
|
||||
}
|
||||
@@ -4,7 +4,7 @@ let
|
||||
in
|
||||
{
|
||||
services.ds4 = {
|
||||
enable = true;
|
||||
enable = false;
|
||||
package = (myPkgs.ds4-rocm.override { rocmArch = "gfx1151"; });
|
||||
user = "ari";
|
||||
group = "users";
|
||||
|
||||
@@ -3,9 +3,12 @@ let
|
||||
ports = {
|
||||
hermes = 8642;
|
||||
hermesDashboard = 9119;
|
||||
hhstreamView = 9988;
|
||||
hermenixDocs = 9989;
|
||||
hermesCache = 5001;
|
||||
ollama = 11434;
|
||||
ds4 = 8000;
|
||||
tracker = 1984;
|
||||
};
|
||||
in
|
||||
{
|
||||
@@ -21,13 +24,14 @@ in
|
||||
hostLanAddress = "10.0.10.11";
|
||||
lanGateway = "10.0.0.1";
|
||||
};
|
||||
vcpu = 2;
|
||||
vcpu = 3;
|
||||
mem = 8000;
|
||||
hermesHome = "/var/lib/hermes/.hermes";
|
||||
hostCache.port = ports.hermesCache;
|
||||
hostAccess = [
|
||||
{ port = ports.ollama; }
|
||||
{ port = ports.ds4; }
|
||||
{ port = ports.tracker; }
|
||||
];
|
||||
lanAccess = [
|
||||
{ address = "10.0.12.1"; port = 80; }
|
||||
@@ -37,10 +41,14 @@ in
|
||||
{ address = "10.0.101.3"; port = 8080; }
|
||||
{ address = "10.0.101.3"; port = 9102; }
|
||||
{ address = "10.0.101.8"; port = 3000; }
|
||||
{ address = "10.0.10.0/24"; port = 22; }
|
||||
|
||||
];
|
||||
publish = [
|
||||
{ hostPort = ports.hermes; guestPort = 8642; }
|
||||
{ hostPort = ports.hermesDashboard; guestPort = 9119; }
|
||||
{ hostPort = ports.hhstreamView; guestPort = ports.hhstreamView; }
|
||||
{ hostPort = ports.hermenixDocs; guestPort = 80; }
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
{ config, lib, skyg-secrets, ... }:
|
||||
let
|
||||
# Hosts this primary tracker consolidates.
|
||||
peers = [ "minipc1" "minipc2" "minipc3" "bigbox1" "bigbox2" "terra1" ];
|
||||
secretName = peer: "linux-tracker-peer-${peer}";
|
||||
in
|
||||
{
|
||||
age.secrets = lib.genAttrs (map secretName peers) (name: {
|
||||
file = skyg-secrets.${name};
|
||||
owner = "root";
|
||||
mode = "0400";
|
||||
});
|
||||
|
||||
services.skyg-linux-tracker = {
|
||||
enable = true;
|
||||
bind = "0.0.0.0";
|
||||
openFirewall = true;
|
||||
docker.enable = config.virtualisation.docker.enable;
|
||||
# The Hermes VM reaches this host at 10.77.0.1.
|
||||
allowedHosts = [ "fwdesk.lab.internal" "10.77.0.1" ];
|
||||
# Primary: one endpoint for the whole lab (Hermes only talks to this one).
|
||||
peers = {
|
||||
enable = true;
|
||||
peers = lib.genAttrs peers (peer: {
|
||||
url = "http://${peer}.lab.internal:1984";
|
||||
tokenFile = config.age.secrets.${secretName peer}.path;
|
||||
# Trackers have no TLS; token travels in the clear on the lab LAN.
|
||||
allowPlainHttp = true;
|
||||
});
|
||||
};
|
||||
# OTLP out to the collector on minipc1.
|
||||
settings.otel = {
|
||||
enabled = true;
|
||||
endpoint = "http://minipc1.lab.internal:4317";
|
||||
protocol = "grpc";
|
||||
export_logs = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
{ ... }:
|
||||
|
||||
{
|
||||
# llama.cpp with DFlash2 speculative decoding.
|
||||
#
|
||||
# Off by default: it needs ~19 GB of weights on disk and a first build of the
|
||||
# ROCm package. Fetch the files, then flip enable:
|
||||
#
|
||||
# sudo install -d -o ari -g users /var/lib/llama-cpp
|
||||
# cd /var/lib/llama-cpp
|
||||
# curl -L -O https://huggingface.co/ggml-org/Qwen3.8-27B-GGUF/resolve/main/Qwen3.8-27B-Q4_K_M.gguf
|
||||
# curl -L -O https://huggingface.co/z-lab/Qwen3.8-27B-DFlash2-GGUF/resolve/main/Qwen3.8-27B-DFlash2-Q8_0.gguf
|
||||
#
|
||||
# Measured expectation for this box: ~25-40 tok/s, not the 380 tok/s in the
|
||||
# post that prompted this — that figure is a 3090 copying a document.
|
||||
skyg.nixos.server.services.llama-cpp = {
|
||||
enable = false;
|
||||
|
||||
model = "/var/lib/llama-cpp/Qwen3.8-27B-Q4_K_M.gguf";
|
||||
draftModel = "/var/lib/llama-cpp/Qwen3.8-27B-DFlash2-Q8_0.gguf";
|
||||
specType = "draft-dflash";
|
||||
specDraftNMax = 7;
|
||||
|
||||
ctx = 32768;
|
||||
kvCacheType = "q8_0";
|
||||
cacheReuse = 256;
|
||||
|
||||
host = "0.0.0.0";
|
||||
port = 8081;
|
||||
openFirewall = true;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
{ config, lib, pkgs, skyg-secrets, ... }:
|
||||
let
|
||||
ports = { cluster = 7946; };
|
||||
homes = "/data/nbot";
|
||||
goCache = "/data/nbot-cache/go";
|
||||
secrets = [ "nbot-slack" "nbot-goose" "nbot-cluster" ];
|
||||
settings = {
|
||||
# The system each container boots (nbot's agent + gh); updated on every rebuild.
|
||||
system = "${config.skyg.nixos.server.services.nbot-agent.system}";
|
||||
machines_dir = "/var/lib/machines";
|
||||
state_dir = "/var/lib/nbot";
|
||||
agent_cwd = "/root";
|
||||
|
||||
idle_timeout = "6h";
|
||||
max_idle_timeout = "0s";
|
||||
allow_indefinite = true;
|
||||
boot_timeout = "2m";
|
||||
|
||||
# Go caches shared by all containers on this node (see ABOUTME). Env vars are in agent_env.
|
||||
rw_binds = [
|
||||
"${goCache}/mod:/var/cache/go/mod:idmap"
|
||||
"${goCache}/build:/var/cache/go/build:idmap"
|
||||
];
|
||||
|
||||
summaries = {
|
||||
timeout = "10s";
|
||||
};
|
||||
|
||||
# Goose settings sent to every container (also on fws1).
|
||||
# Values come from the nbot-goose secret.
|
||||
agent_env = {
|
||||
COMMAND_CODE_API_KEY = "$COMMAND_CODE_API_KEY";
|
||||
GH_TOKEN = "$GH_TOKEN";
|
||||
DIAGNIX_KEY = "$DIAGNIX_KEY";
|
||||
GOMODCACHE = "/var/cache/go/mod";
|
||||
GOCACHE = "/var/cache/go/build";
|
||||
};
|
||||
|
||||
model_providers = [
|
||||
{
|
||||
id = "custom_commandcode";
|
||||
name = "Command Code";
|
||||
key_env = "COMMAND_CODE_API_KEY";
|
||||
models = [
|
||||
"deepseek/deepseek-v4-flash"
|
||||
"minimax/minimax-m3.1-flash"
|
||||
"minimaxai/minimax-m3"
|
||||
"anthropic/claude-opus-5-5"
|
||||
"anthropic/claude-sonnet-5-5"
|
||||
"anthropic/claude-haiku-5-5"
|
||||
"reflection/beam:free"
|
||||
"moonshotai/kimi-k3"
|
||||
"moonshotai/kimi-k2.7-code"
|
||||
"zai-org/glm-5.3"
|
||||
"z-ai/glm-5.3-flash"
|
||||
"xai/grok-4.7"
|
||||
"openai/gpt-6.1-sol"
|
||||
];
|
||||
}
|
||||
];
|
||||
|
||||
container = { memory_mb = 4096; cpus = 1.0; };
|
||||
max_container = { memory_mb = 16384; cpus = 4; };
|
||||
host_reserve = { memory_mb = 32768; cpus = 4.0; };
|
||||
storage = { min = "2G"; max = "5G"; limit = "20G"; };
|
||||
drives = [{ path = homes; reserve = "40G"; allow_subdir = true; }];
|
||||
|
||||
cluster = {
|
||||
node_secrets = { hl-fws1 = "$HL_FWS1_CLUSTER_SECRET"; };
|
||||
listen = ":${toString ports.cluster}";
|
||||
};
|
||||
|
||||
# Only read on first start; after that, manage permissions from Slack.
|
||||
permissions = {
|
||||
managers = [ "U0CBGSS4U6A" ];
|
||||
default.U0CBGSS4U6A = [ "all" ];
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
age.secrets = lib.genAttrs secrets (name: {
|
||||
file = skyg-secrets.${name};
|
||||
owner = "root";
|
||||
mode = "0400";
|
||||
});
|
||||
|
||||
# nbot flake input; options and docs in its repo.
|
||||
services.nbot = {
|
||||
enable = true;
|
||||
mode = "master";
|
||||
clusterPort = ports.cluster;
|
||||
kvm = true;
|
||||
drives = [ homes ];
|
||||
stateDir = "/var/lib/nbot";
|
||||
configFile = (pkgs.formats.toml { }).generate "nbot.toml" settings;
|
||||
};
|
||||
|
||||
# The module takes one env file; these add to it.
|
||||
systemd.services.nbot.serviceConfig.EnvironmentFile =
|
||||
map (name: config.age.secrets.${name}.path) secrets;
|
||||
|
||||
# Container links belong to systemd-networkd.
|
||||
networking.networkmanager.unmanaged = [ "interface-name:ve-*" ];
|
||||
networking.dhcpcd.denyInterfaces = [ "ve-*" ];
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"d ${homes} 0700 root root -"
|
||||
"d ${goCache}/mod 0700 root root -"
|
||||
"d ${goCache}/build 0700 root root -"
|
||||
];
|
||||
}
|
||||
@@ -3,8 +3,6 @@ let
|
||||
ports = { ollama = 11434; };
|
||||
in
|
||||
{
|
||||
services.open-webui.enable = true;
|
||||
|
||||
users.users.ollama = {
|
||||
enable = true;
|
||||
home = "/var/lib/ollama";
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
{ ... }:
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
programs.steam = {
|
||||
enable = true;
|
||||
extest.enable = true;
|
||||
extraPackages = [ pkgs.pulseaudio ];
|
||||
remotePlay.openFirewall = true;
|
||||
dedicatedServer.openFirewall = true;
|
||||
localNetworkGameTransfers.openFirewall = true;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{ pkgs, config, ... }:
|
||||
{
|
||||
imports = [
|
||||
./services.nix
|
||||
./services
|
||||
./hardware-configuration
|
||||
./hardware.nix
|
||||
./systemd.nix
|
||||
@@ -11,6 +11,8 @@
|
||||
user.enable = true;
|
||||
nixos = {
|
||||
common.ssh-server.enable = true;
|
||||
common.diagnix.enable = true;
|
||||
common.dns.enable = true;
|
||||
common.hardware.pipewire.enable = true;
|
||||
desktop = {
|
||||
enable = true;
|
||||
@@ -53,6 +55,11 @@
|
||||
playerctl
|
||||
];
|
||||
|
||||
programs.nh.clean = {
|
||||
dates = "daily";
|
||||
extraArgs = "--keep-since 2d --keep 5";
|
||||
};
|
||||
|
||||
services.flatpak.enable = true;
|
||||
services.flatpak.packages = [ "com.spotify.Client" ];
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
{ ... }:
|
||||
{
|
||||
imports = [ ./nbot.nix ./github-runners.nix ];
|
||||
|
||||
services.pipewire = {
|
||||
extraConfig.pipewire-pulse."10-raop-discover" = {
|
||||
context.modules = [
|
||||
@@ -31,4 +33,18 @@
|
||||
enable = true;
|
||||
arguments = "-o pipewire";
|
||||
};
|
||||
|
||||
services.skyg-linux-tracker = {
|
||||
enable = true;
|
||||
bind = "0.0.0.0";
|
||||
openFirewall = true;
|
||||
allowedHosts = [ "fws1.lab.internal" ];
|
||||
# OTLP out to the collector on minipc1.
|
||||
settings.otel = {
|
||||
enabled = true;
|
||||
endpoint = "http://minipc1.lab.internal:4317";
|
||||
protocol = "grpc";
|
||||
export_logs = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
{ config, lib, skyg-secrets, ... }:
|
||||
let
|
||||
concurrency = 4;
|
||||
runnerNames = map (i: "runner-${toString i}") (lib.range 1 concurrency);
|
||||
stateVersion = config.system.stateVersion;
|
||||
cache = "/var/cache/github-runners/go";
|
||||
credentials = "/run/github-runner-registration";
|
||||
|
||||
# The same numeric identity owns the bind-mounted caches on the host and in every container.
|
||||
runnerUser = {
|
||||
users.github-runner = {
|
||||
uid = 915;
|
||||
isSystemUser = true;
|
||||
group = "github-runner";
|
||||
};
|
||||
groups.github-runner.gid = 915;
|
||||
};
|
||||
in
|
||||
{
|
||||
age.secrets.github-runner-token-fws1 = {
|
||||
file = skyg-secrets.github-runner-token-fws1;
|
||||
path = "${credentials}/token";
|
||||
# The containers mount this directory and must see token rotations.
|
||||
symlink = false;
|
||||
mode = "0400";
|
||||
};
|
||||
|
||||
users = runnerUser;
|
||||
systemd.tmpfiles.rules = [
|
||||
"d ${credentials} 0700 root root -"
|
||||
"d ${cache} 0755 root root -"
|
||||
"d ${cache}/build 0700 github-runner github-runner -"
|
||||
"d ${cache}/mod 0700 github-runner github-runner -"
|
||||
];
|
||||
|
||||
systemd.services = lib.genAttrs (map (name: "container@${name}") runnerNames) (_: {
|
||||
serviceConfig = {
|
||||
MemoryLow = "4G";
|
||||
MemoryMax = "8G";
|
||||
CPUQuota = "200%";
|
||||
};
|
||||
});
|
||||
|
||||
containers = lib.genAttrs runnerNames (name: {
|
||||
autoStart = true;
|
||||
bindMounts = {
|
||||
"${credentials}".isReadOnly = true;
|
||||
"/var/cache/go" = {
|
||||
hostPath = cache;
|
||||
isReadOnly = false;
|
||||
};
|
||||
};
|
||||
|
||||
config = { pkgs, ... }: {
|
||||
system.stateVersion = stateVersion;
|
||||
users = runnerUser;
|
||||
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
||||
|
||||
services.github-runners.${name} = {
|
||||
enable = true;
|
||||
inherit name;
|
||||
replace = true;
|
||||
url = "https://github.com/SkyG-Org";
|
||||
tokenFile = "${credentials}/token";
|
||||
user = "github-runner";
|
||||
group = "github-runner";
|
||||
extraLabels = [ "fws1" "nixos" "go" ];
|
||||
extraPackages = [ pkgs.go ];
|
||||
extraEnvironment = {
|
||||
NIX_REMOTE = "daemon";
|
||||
GOCACHE = "/var/cache/go/build";
|
||||
GOMODCACHE = "/var/cache/go/mod";
|
||||
};
|
||||
serviceOverrides.ReadWritePaths = [ "/var/cache/go" ];
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
{ config, pkgs, skyg-secrets, ... }:
|
||||
let
|
||||
homes = "/var/lib/nbot/homes";
|
||||
goCache = "/var/lib/nbot-cache/go";
|
||||
settings = {
|
||||
# The system each container boots (nbot's agent + gh); updated on every rebuild.
|
||||
system = "${config.skyg.nixos.server.services.nbot-agent.system}";
|
||||
machines_dir = "/var/lib/machines";
|
||||
state_dir = "/var/lib/nbot";
|
||||
agent_cwd = "/root";
|
||||
|
||||
idle_timeout = "6h";
|
||||
max_idle_timeout = "0s";
|
||||
allow_indefinite = true;
|
||||
boot_timeout = "2m";
|
||||
|
||||
# Go caches shared by all containers on this node (see ABOUTME). Env vars come from the master.
|
||||
rw_binds = [
|
||||
"${goCache}/mod:/var/cache/go/mod:idmap"
|
||||
"${goCache}/build:/var/cache/go/build:idmap"
|
||||
];
|
||||
|
||||
container = { memory_mb = 4096; cpus = 1.0; };
|
||||
max_container = { memory_mb = 51200; cpus = 6; };
|
||||
host_reserve = { memory_mb = 8192; cpus = 2.0; };
|
||||
storage = { min = "2G"; max = "10G"; limit = "50G"; };
|
||||
drives = [{ path = homes; reserve = "200G"; allow_subdir = true; }];
|
||||
|
||||
# Worker of the master on fwdesk. Slack tokens and goose settings come
|
||||
# from the master. Trusts the first certificate it sees (saved in
|
||||
# state_dir/master.fingerprint); pin it in master_fingerprint if wanted.
|
||||
cluster = {
|
||||
name = "hl-fws1";
|
||||
master = "wss://fwdesk.lab.internal:7946";
|
||||
master_fingerprint = [ "ce08c6b0f3aec855cc8b936d81449c1a34074d181089b26acbdddacfca60af1d" ];
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
age.secrets.nbot-cluster = {
|
||||
file = skyg-secrets.nbot-cluster-hl-fws1;
|
||||
owner = "root";
|
||||
mode = "0400";
|
||||
};
|
||||
|
||||
# nbot flake input; options and docs in its repo.
|
||||
services.nbot = {
|
||||
enable = true;
|
||||
mode = "slave";
|
||||
kvm = true;
|
||||
drives = [ homes ];
|
||||
stateDir = "/var/lib/nbot";
|
||||
configFile = (pkgs.formats.toml { }).generate "nbot.toml" settings;
|
||||
environmentFile = config.age.secrets.nbot-cluster.path;
|
||||
};
|
||||
|
||||
# Container links belong to systemd-networkd.
|
||||
networking.networkmanager.unmanaged = [ "interface-name:ve-*" ];
|
||||
networking.dhcpcd.denyInterfaces = [ "ve-*" ];
|
||||
# networkd only has the container links here (NetworkManager owns wlan),
|
||||
# so wait-online would always time out.
|
||||
systemd.network.wait-online.enable = false;
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"d ${homes} 0700 root root -"
|
||||
"d ${goCache}/mod 0700 root root -"
|
||||
"d ${goCache}/build 0700 root root -"
|
||||
];
|
||||
}
|
||||
@@ -33,24 +33,25 @@ in
|
||||
imports = [
|
||||
./services
|
||||
./hardware-configuration
|
||||
./hardware.nix
|
||||
];
|
||||
|
||||
skyg.user.enable = true;
|
||||
skyg.nixos.common.ssh-server.enable = true;
|
||||
skyg.nixos.common.diagnix.enable = true;
|
||||
skyg.nixos.common.dns.enable = true;
|
||||
skyg.server.dns.routing = {
|
||||
enable = false;
|
||||
openFirewall = true;
|
||||
addressesSecretName = "dns-addresses.conf";
|
||||
};
|
||||
skyg.nixos.common.containers.runtime = "docker";
|
||||
skyg.nixos.common.containers.openMetricsPort = true;
|
||||
|
||||
skyg.nixos.common.containers.networks.ipvlanLab = {
|
||||
enable = true;
|
||||
parent = "eno1";
|
||||
};
|
||||
skyg.server.admin.enable = true;
|
||||
skyg.server.exporters.enable = true;
|
||||
|
||||
skyg.nixos.server.k3s.enable = false;
|
||||
skyg.networkDrives.enable = true;
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
{ ... }:
|
||||
{
|
||||
services.fwupd.enable = true;
|
||||
}
|
||||
@@ -1,17 +1,12 @@
|
||||
{ config, ... }:
|
||||
{ config, skygUtils, ... }:
|
||||
let
|
||||
nfsVolume = exportPath: {
|
||||
driver_opts = {
|
||||
type = "nfs";
|
||||
o = "addr=tnas1.lab.internal,rw,nfsvers=4.0,nolock,hard,noatime";
|
||||
device = ":${exportPath}";
|
||||
};
|
||||
};
|
||||
nfsVolume = skygUtils.container-services.nfsVols.tnas1;
|
||||
app = config.skyg.internalNetworkingMap.apps.buzz;
|
||||
buzz = {
|
||||
domain = app.effectiveDns;
|
||||
publicDomain = builtins.elemAt app.aliases 0;
|
||||
port = 3000;
|
||||
pairPort = 5000;
|
||||
ip = app.ip;
|
||||
bucket = "buzz-media";
|
||||
images = {
|
||||
@@ -47,6 +42,7 @@ in
|
||||
redis.condition = "service_healthy";
|
||||
minio.condition = "service_healthy";
|
||||
minio-init.condition = "service_completed_successfully";
|
||||
relay-index-prebuild.condition = "service_completed_successfully";
|
||||
};
|
||||
networks = [ "internal" ];
|
||||
environmentFiles = [ config.age.secrets.buzz-env.path ];
|
||||
@@ -58,6 +54,7 @@ in
|
||||
BUZZ_MEDIA_BASE_URL = "https://${buzz.publicDomain}/media";
|
||||
BUZZ_MEDIA_SERVER_DOMAIN = buzz.publicDomain;
|
||||
BUZZ_CORS_ORIGINS = "https://${buzz.publicDomain}";
|
||||
BUZZ_PAIRING_RELAY_URL = "wss://${buzz.publicDomain}/pair";
|
||||
BUZZ_S3_ENDPOINT = "http://minio:9000";
|
||||
BUZZ_S3_REGION = "us-east-1";
|
||||
BUZZ_S3_ADDRESSING_STYLE = "path";
|
||||
@@ -76,9 +73,18 @@ in
|
||||
start_period = "30s";
|
||||
};
|
||||
};
|
||||
pair = {
|
||||
image = buzz.images.relay;
|
||||
networks = [ "internal" ];
|
||||
environment.BUZZ_PAIR_RELAY_BIND_ADDR = "0.0.0.0:${toString buzz.pairPort}";
|
||||
extraConfig.entrypoint = [ "/usr/local/bin/buzz-pair-relay" ];
|
||||
};
|
||||
caddy = {
|
||||
image = buzz.images.caddy;
|
||||
extraConfig.depends_on.relay.condition = "service_healthy";
|
||||
extraConfig.depends_on = {
|
||||
relay.condition = "service_healthy";
|
||||
pair.condition = "service_started";
|
||||
};
|
||||
networks = {
|
||||
internal = { };
|
||||
lan = { ipv4_address = buzz.ip; };
|
||||
@@ -87,7 +93,13 @@ in
|
||||
${buzz.publicDomain} {
|
||||
tls /etc/caddy/tls/fullchain.pem /etc/caddy/tls/key.pem
|
||||
encode zstd gzip
|
||||
reverse_proxy relay:${toString buzz.port}
|
||||
# Only /pair goes to the pairing service
|
||||
handle /pair {
|
||||
reverse_proxy pair:${toString buzz.pairPort}
|
||||
}
|
||||
handle {
|
||||
reverse_proxy relay:${toString buzz.port}
|
||||
}
|
||||
}
|
||||
http://${buzz.domain} {
|
||||
redir https://${buzz.publicDomain}{uri} permanent
|
||||
@@ -179,6 +191,47 @@ in
|
||||
};
|
||||
restart = "no";
|
||||
};
|
||||
relay-index-prebuild = {
|
||||
image = buzz.images.posgres;
|
||||
networks = [ "internal" ];
|
||||
environmentFiles = [ config.age.secrets.buzz-env.path ];
|
||||
environment = {
|
||||
POSTGRES_DB = "buzz";
|
||||
POSTGRES_USER = "buzz";
|
||||
};
|
||||
files."/usr/local/bin/prebuild-indexes.sh" = ''
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
export PGPASSWORD="$POSTGRES_PASSWORD"
|
||||
|
||||
run_psql() {
|
||||
psql -v ON_ERROR_STOP=1 -h postgres -U "$POSTGRES_USER" -d "$POSTGRES_DB" "$@"
|
||||
}
|
||||
|
||||
ensure_index() {
|
||||
name="$1"
|
||||
sql="$2"
|
||||
state=$(run_psql -tAc "SELECT coalesce((SELECT CASE WHEN i.indisvalid AND i.indisready AND i.indislive THEN 'valid' ELSE 'invalid' END FROM pg_index i WHERE i.indexrelid = to_regclass('public.$name')), 'missing')")
|
||||
if [ "$state" = valid ]; then
|
||||
return 0
|
||||
fi
|
||||
if [ "$state" = invalid ]; then
|
||||
run_psql -c "DROP INDEX CONCURRENTLY IF EXISTS public.$name"
|
||||
fi
|
||||
run_psql -c "$sql"
|
||||
}
|
||||
|
||||
ensure_index artifact_heads_modified "CREATE INDEX CONCURRENTLY artifact_heads_modified ON public.artifact_heads (community_id, modified_at, artifact_id);"
|
||||
ensure_index artifact_heads_channel "CREATE INDEX CONCURRENTLY artifact_heads_channel ON public.artifact_heads (community_id, channel_id, artifact_id);"
|
||||
ensure_index channel_members_sync "CREATE INDEX CONCURRENTLY channel_members_sync ON public.channel_members (community_id, pubkey, sync_modified_at, channel_id);"
|
||||
ensure_index artifact_revisions_moves "CREATE INDEX CONCURRENTLY artifact_revisions_moves ON public.artifact_revisions (community_id, modified_at, event_id) WHERE source_channel_id IS NOT NULL;"
|
||||
'';
|
||||
extraConfig = {
|
||||
entrypoint = [ "/bin/sh" "/usr/local/bin/prebuild-indexes.sh" ];
|
||||
depends_on.postgres.condition = "service_healthy";
|
||||
};
|
||||
restart = "no";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{ config, skyg-secrets, ... }:
|
||||
{
|
||||
age.secrets.cloudflare-ddclient.file = skyg-secrets.cloudflare-ddclient;
|
||||
|
||||
services.ddclient = {
|
||||
enable = true;
|
||||
protocol = "cloudflare";
|
||||
username = "token";
|
||||
passwordFile = config.age.secrets.cloudflare-ddclient.path;
|
||||
usev6 = "disabled";
|
||||
domains = [ ];
|
||||
extraConfig = ''
|
||||
zone=sosnovsky.ca
|
||||
*.sosnovsky.ca,*.home.sosnovsky.ca,home.sosnovsky.ca
|
||||
|
||||
zone=skyg.ca
|
||||
*.skyg.ca
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -7,9 +7,15 @@
|
||||
./gitea-container.nix
|
||||
./public-gitea.nix
|
||||
./acme.nix
|
||||
./ddclient.nix
|
||||
./portainer.nix
|
||||
./iu.nix
|
||||
./audiobookshelf.nix
|
||||
./buzz.nix
|
||||
./linux-tracker.nix
|
||||
./otel-collector.nix
|
||||
./prometheus.nix
|
||||
./loki.nix
|
||||
./grafana.nix
|
||||
];
|
||||
}
|
||||
@@ -73,6 +73,8 @@ in
|
||||
GITEA__server__HTTP_PORT = toString gitea.httpPort;
|
||||
GITEA__server__ROOT_URL = "http://${app.effectiveDns}:${toString gitea.httpPort}/";
|
||||
GITEA__service__DISABLE_REGISTRATION = "true";
|
||||
GITEA__migrations__ALLOW_LOCALNETWORKS = "true";
|
||||
GITEA__migrations__ALLOWED_DOMAINS = "gitea.skyg.ca,github.com";
|
||||
};
|
||||
volumes = [
|
||||
"${gitea.stateDir}:${gitea.stateDir}"
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
{ config, skyg-secrets, ... }:
|
||||
let
|
||||
ports = {
|
||||
grafana = 3001;
|
||||
prometheus = 9090;
|
||||
loki = 3100;
|
||||
};
|
||||
in
|
||||
{
|
||||
age.secrets.grafana-secret-key = {
|
||||
file = skyg-secrets.grafana-secret-key;
|
||||
owner = "grafana";
|
||||
group = "grafana";
|
||||
};
|
||||
|
||||
services.grafana = {
|
||||
enable = true;
|
||||
openFirewall = true;
|
||||
|
||||
settings = {
|
||||
server = {
|
||||
http_addr = "0.0.0.0";
|
||||
http_port = ports.grafana;
|
||||
};
|
||||
security.secret_key = "$__(file){${config.age.secrets.grafana-secret-key.path}}";
|
||||
};
|
||||
|
||||
provision = {
|
||||
enable = true;
|
||||
datasources.settings.datasources = [
|
||||
{
|
||||
name = "Prometheus";
|
||||
type = "prometheus";
|
||||
access = "proxy";
|
||||
url = "http://127.0.0.1:${toString ports.prometheus}";
|
||||
isDefault = true;
|
||||
}
|
||||
{
|
||||
name = "Loki";
|
||||
type = "loki";
|
||||
access = "proxy";
|
||||
url = "http://127.0.0.1:${toString ports.loki}";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{ config, ... }:
|
||||
{
|
||||
services.skyg-linux-tracker = {
|
||||
enable = true;
|
||||
bind = "0.0.0.0";
|
||||
openFirewall = true;
|
||||
docker.enable = config.virtualisation.docker.enable;
|
||||
# Reachable only by its lab FQDN; the short name does not resolve.
|
||||
allowedHosts = [ "minipc1.lab.internal" ];
|
||||
# OTLP out to the collector on this box (see ./otel-collector.nix).
|
||||
settings.otel = {
|
||||
enabled = true;
|
||||
endpoint = "http://127.0.0.1:4317";
|
||||
protocol = "grpc";
|
||||
export_logs = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
{ ... }:
|
||||
let
|
||||
ports = {
|
||||
loki = 3100;
|
||||
grpc = 9096;
|
||||
};
|
||||
dataDir = "/var/lib/loki";
|
||||
in
|
||||
{
|
||||
services.loki = {
|
||||
enable = true;
|
||||
|
||||
# Single-binary Loki on the filesystem: no object store, no ring.
|
||||
configuration = {
|
||||
auth_enabled = false;
|
||||
|
||||
server = {
|
||||
http_listen_port = ports.loki;
|
||||
grpc_listen_port = ports.grpc;
|
||||
};
|
||||
|
||||
common = {
|
||||
instance_addr = "127.0.0.1";
|
||||
path_prefix = dataDir;
|
||||
replication_factor = 1;
|
||||
ring.kvstore.store = "inmemory";
|
||||
storage.filesystem = {
|
||||
chunks_directory = "${dataDir}/chunks";
|
||||
rules_directory = "${dataDir}/rules";
|
||||
};
|
||||
};
|
||||
|
||||
schema_config.configs = [
|
||||
{
|
||||
from = "2026-10-01";
|
||||
store = "tsdb";
|
||||
object_store = "filesystem";
|
||||
schema = "v13";
|
||||
index = {
|
||||
prefix = "index_";
|
||||
period = "24h";
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
# The compactor is what enforces the 24h window below.
|
||||
compactor = {
|
||||
working_directory = "${dataDir}/compactor";
|
||||
retention_enabled = true;
|
||||
delete_request_store = "filesystem";
|
||||
};
|
||||
|
||||
limits_config = {
|
||||
retention_period = "24h";
|
||||
reject_old_samples = true;
|
||||
reject_old_samples_max_age = "168h";
|
||||
# Required for OTLP ingestion; on by default since 3.0.
|
||||
allow_structured_metadata = true;
|
||||
};
|
||||
|
||||
ruler = {
|
||||
storage.type = "local";
|
||||
storage.local.directory = "${dataDir}/rules";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Loki data lives on tnas1. Prometheus and Grafana stay on local disk, since
|
||||
# their databases do not work well on NFS.
|
||||
# The export must exist on the NAS and be writable by uid 985 / gid 981.
|
||||
# The mount is ordered after network-online so tnas1's name resolves at boot.
|
||||
fileSystems.${dataDir} = {
|
||||
device = "tnas1.lab.internal:/mnt/SmallG/monitoring/loki";
|
||||
fsType = "nfs";
|
||||
options = [
|
||||
"nfsvers=4.0"
|
||||
"hard"
|
||||
"noatime"
|
||||
"nofail"
|
||||
"_netdev"
|
||||
"x-systemd.automount"
|
||||
"x-systemd.requires=network-online.target"
|
||||
"x-systemd.after=network-online.target"
|
||||
];
|
||||
};
|
||||
systemd.services.loki.unitConfig.RequiresMountsFor = [ dataDir ];
|
||||
|
||||
# NFS ownership is numeric, so pin the ids instead of letting NixOS assign
|
||||
# them by name order (a new user sorting before "loki" would shift them).
|
||||
users.users.loki.uid = 985;
|
||||
users.groups.loki.gid = 981;
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ ports.loki ];
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
ports = {
|
||||
otlpGrpc = 4317;
|
||||
otlpHttp = 4318;
|
||||
# Loopback scrape target for the Prometheus below.
|
||||
metrics = 9464;
|
||||
};
|
||||
in
|
||||
{
|
||||
services.opentelemetry-collector = {
|
||||
enable = true;
|
||||
# The prometheus exporter is a contrib component, not core.
|
||||
package = pkgs.opentelemetry-collector-contrib;
|
||||
|
||||
settings = {
|
||||
receivers.otlp.protocols = {
|
||||
grpc.endpoint = "0.0.0.0:${toString ports.otlpGrpc}";
|
||||
http.endpoint = "0.0.0.0:${toString ports.otlpHttp}";
|
||||
};
|
||||
|
||||
processors.batch.timeout = "5s";
|
||||
|
||||
exporters = {
|
||||
# Pull endpoint. Resource attributes (host.name, service.name) only
|
||||
# become labels when conversion is enabled — off by default, which
|
||||
# would leave every host's series with an identical label set.
|
||||
prometheus = {
|
||||
endpoint = "127.0.0.1:${toString ports.metrics}";
|
||||
resource_to_telemetry_conversion.enabled = true;
|
||||
};
|
||||
# The contrib `loki` exporter was removed upstream; Loki ingests
|
||||
# OTLP/HTTP natively at /otlp instead.
|
||||
"otlphttp/loki".endpoint = "http://127.0.0.1:3100/otlp";
|
||||
nop = { };
|
||||
};
|
||||
|
||||
service.pipelines = {
|
||||
metrics = {
|
||||
receivers = [ "otlp" ];
|
||||
processors = [ "batch" ];
|
||||
exporters = [ "prometheus" ];
|
||||
};
|
||||
logs = {
|
||||
receivers = [ "otlp" ];
|
||||
processors = [ "batch" ];
|
||||
exporters = [ "otlphttp/loki" ];
|
||||
};
|
||||
# The tracker ships its own spans; nothing here stores them.
|
||||
traces = {
|
||||
receivers = [ "otlp" ];
|
||||
processors = [ "batch" ];
|
||||
exporters = [ "nop" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Only the OTLP listeners face the lab; 9464 stays on loopback.
|
||||
networking.firewall.allowedTCPPorts = [ ports.otlpGrpc ports.otlpHttp ];
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{ ... }:
|
||||
let
|
||||
ports = { prometheus = 9090; };
|
||||
in
|
||||
{
|
||||
services.prometheus = {
|
||||
enable = true;
|
||||
port = ports.prometheus;
|
||||
listenAddress = "0.0.0.0";
|
||||
retentionTime = "48h";
|
||||
|
||||
scrapeConfigs = [
|
||||
{
|
||||
job_name = "lab-trackers";
|
||||
static_configs = [{ targets = [ "127.0.0.1:9464" ]; }];
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ ports.prometheus ];
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 529 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 112 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 46 KiB |
Loaded 100 of 217 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user