Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a90801fd69
|
No files matched your search
@@ -1,19 +0,0 @@
|
|||||||
when:
|
|
||||||
- event: [push, manual]
|
|
||||||
|
|
||||||
labels:
|
|
||||||
backend: local
|
|
||||||
nix-builder: true
|
|
||||||
|
|
||||||
clone:
|
|
||||||
- name: clone
|
|
||||||
image: woodpecker-plugin-git
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: build-and-cache
|
|
||||||
image: bash
|
|
||||||
environment:
|
|
||||||
TRANSCRYPT_PASSWORD:
|
|
||||||
from_secret: transcrypt_password
|
|
||||||
commands:
|
|
||||||
- bash ci/build.sh
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
# NixOS builds and LAN cache
|
|
||||||
|
|
||||||
`builder` is the headless configuration for the VM at `10.17.1.100`.
|
|
||||||
Woodpecker builds every `nixosConfigurations` toplevel on pushes and manual
|
|
||||||
runs. Builds run sequentially with one Nix job and four cores on this 8 GiB VM.
|
|
||||||
Secrix runtime secrets do not need decryption in CI.
|
|
||||||
|
|
||||||
## Finish Woodpecker registration
|
|
||||||
|
|
||||||
1. Create an agent in Woodpecker and restrict its server-side filters to
|
|
||||||
`repo=CaZzzer/nix-conf` (use the repository's exact spelling as displayed
|
|
||||||
by Woodpecker).
|
|
||||||
Allow only trusted users to push or change pipelines. The local backend
|
|
||||||
executes repository commands as the `woodpecker` user on the VM.
|
|
||||||
2. On the VM, use `sudo install -m 0600 /dev/null /var/lib/woodpecker/agent.env`
|
|
||||||
once, then `sudoedit /var/lib/woodpecker/agent.env` and enter:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
WOODPECKER_AGENT_SECRET=<agent token>
|
|
||||||
WOODPECKER_SERVER=<reachable gRPC host:port>
|
|
||||||
WOODPECKER_GRPC_SECURE=true
|
|
||||||
WOODPECKER_GRPC_SKIP_VERIFY=false
|
|
||||||
```
|
|
||||||
|
|
||||||
Use `WOODPECKER_GRPC_SECURE=false` for a private plaintext gRPC listener.
|
|
||||||
The public web UI address does not necessarily expose gRPC. The default
|
|
||||||
in the module is `woodpecker.cazzzer.com:9000`; override it here as needed.
|
|
||||||
3. Run `sudo systemctl start woodpecker-agent-nix`.
|
|
||||||
4. Enable this repository in Woodpecker. Add a repository secret named
|
|
||||||
`transcrypt_password` containing the existing transcrypt password. Limit
|
|
||||||
it to push/manual events; do not enable it for pull requests. Commit and
|
|
||||||
push these changes, then confirm the agent picks up the workflow.
|
|
||||||
|
|
||||||
The pipeline explicitly uses the native `woodpecker-plugin-git` clone binary.
|
|
||||||
It initializes transcrypt with `aes-256-cbc`, suppressing its credential output.
|
|
||||||
No secret values belong in Nix expressions or the repository.
|
|
||||||
|
|
||||||
## Cache
|
|
||||||
|
|
||||||
`nix-serve-ng` serves the VM's persistent store at `http://10.17.1.100:5000`
|
|
||||||
through the NixOS `nix-serve` service.
|
|
||||||
It signs responses using `/var/lib/nix-cache/cache-key.sec` (root-only).
|
|
||||||
Back up this key securely; its public key is configured in `hosts/common.nix`.
|
|
||||||
Rebuilding each client once installs cache trust. Clients need LAN/VPN access
|
|
||||||
to this address; the official NixOS cache remains configured.
|
|
||||||
|
|
||||||
Successful builds leave indirect GC roots at `/var/lib/nix-ci/<host>`, retaining
|
|
||||||
the latest successful closure per host. Weekly GC removes unrooted paths older
|
|
||||||
than 14 days. Monitor disk space: 100 GiB may become tight for desktop closures
|
|
||||||
and intermediate builds. Remove roots for retired hosts deliberately.
|
|
||||||
|
|
||||||
The cache is intended for a trusted LAN. Transcrypt plaintext can occur in Nix
|
|
||||||
store sources and generated configuration, so readers of the cache may recover
|
|
||||||
that information. Runtime secrix secrets remain encrypted. Do not expose this
|
|
||||||
endpoint publicly without adding access control.
|
|
||||||
|
|
||||||
## Updating the builder
|
|
||||||
|
|
||||||
Build `.#nixosConfigurations.builder.config.system.build.toplevel`, copy its
|
|
||||||
closure to the VM and activate it, or use `nixos-rebuild` targeting `builder`.
|
|
||||||
New repository files must be added to Git before a Git-flake build sees them;
|
|
||||||
`path:.` can be used when validating an uncommitted working tree.
|
|
||||||
|
|
||||||
Check services with:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
systemctl status woodpecker-agent-nix nix-serve
|
|
||||||
journalctl -u woodpecker-agent-nix -f
|
|
||||||
curl http://10.17.1.100:5000/nix-cache-info
|
|
||||||
```
|
|
||||||
-20
@@ -1,20 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
# Woodpecker traces commands; keep the password out of its logs.
|
|
||||||
set +x
|
|
||||||
: "${TRANSCRYPT_PASSWORD:?Set the transcrypt_password Woodpecker secret}"
|
|
||||||
transcrypt --yes --cipher=aes-256-cbc --password="$TRANSCRYPT_PASSWORD" >/dev/null
|
|
||||||
unset TRANSCRYPT_PASSWORD
|
|
||||||
|
|
||||||
# Discover every host so newly added configurations are automatically checked.
|
|
||||||
mapfile -t hosts < <(nix eval --json .#nixosConfigurations --apply builtins.attrNames | python3 -c 'import json,sys; print("\n".join(json.load(sys.stdin)))')
|
|
||||||
test "${#hosts[@]}" -gt 0
|
|
||||||
root_dir=/var/lib/nix-ci
|
|
||||||
for host in "${hosts[@]}"; do
|
|
||||||
echo "Building $host"
|
|
||||||
# A stable symlink per host retains its last successful closure across GC.
|
|
||||||
# Nix registers these out-links as indirect GC roots.
|
|
||||||
nix build --no-update-lock-file --print-build-logs \
|
|
||||||
--out-link "$root_dir/$host" \
|
|
||||||
".#nixosConfigurations.\"$host\".config.system.build.toplevel"
|
|
||||||
done
|
|
||||||
Generated
+6
-6
@@ -60,11 +60,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1795366757,
|
"lastModified": 1793033486,
|
||||||
"narHash": "sha256-Tp4Kh4R7ID1f2mMCDlb2PiFQ/DZZsnXB2u2juWN+TT4=",
|
"narHash": "sha256-fXVURa0+CSCgaxLt8tmPNJq2U+fGYOwbk5j2YUe7kSc=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "3b8140d21fa0a70b1b38c2ed29853dfe686234a6",
|
"rev": "7db163b2aee7e410e396b48aed02f646d742b9b8",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -135,11 +135,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1795234589,
|
"lastModified": 1792773339,
|
||||||
"narHash": "sha256-f/VVvxf5RsQgWVhUtefoca5ktVg0DA2bnkMOcmSnozo=",
|
"narHash": "sha256-rZLrzrC6i+jnTAlvPZHogKDulY7WWDEv9hJeHieO7Zw=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "2786a2a72088ecf32aea5b3ec52099e6a7cff78f",
|
"rev": "3ec636362e1816bc2f0888fa0fa2c69f1bc9e504",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -59,16 +59,6 @@
|
|||||||
apps.x86_64-linux.secrix = secrix.secrix self;
|
apps.x86_64-linux.secrix = secrix.secrix self;
|
||||||
|
|
||||||
nixosConfigurations = {
|
nixosConfigurations = {
|
||||||
builder = nixpkgs.lib.nixosSystem {
|
|
||||||
system = "x86_64-linux";
|
|
||||||
modules = [
|
|
||||||
./modules
|
|
||||||
./hosts/common.nix
|
|
||||||
./hosts/hw-vm.nix
|
|
||||||
./hosts/builder
|
|
||||||
./users/cazzzer
|
|
||||||
];
|
|
||||||
};
|
|
||||||
Yura-PC = nixpkgs.lib.nixosSystem {
|
Yura-PC = nixpkgs.lib.nixosSystem {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = [
|
modules = [
|
||||||
|
|||||||
@@ -12,8 +12,6 @@
|
|||||||
];
|
];
|
||||||
opts.kb-input.enable = true;
|
opts.kb-input.enable = true;
|
||||||
|
|
||||||
boot.kernelPackages = pkgs.linuxPackages_latest;
|
|
||||||
|
|
||||||
# Bootloader.
|
# Bootloader.
|
||||||
boot.kernelParams = [
|
boot.kernelParams = [
|
||||||
"amd_iommu=on"
|
"amd_iommu=on"
|
||||||
@@ -36,6 +34,7 @@
|
|||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
lmstudio
|
lmstudio
|
||||||
|
unsloth-desktop
|
||||||
];
|
];
|
||||||
|
|
||||||
services.ollama.enable = true;
|
services.ollama.enable = true;
|
||||||
|
|||||||
@@ -14,26 +14,17 @@
|
|||||||
boot.extraModulePackages = [ ];
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
fileSystems."/" =
|
fileSystems."/" =
|
||||||
{ device = "/dev/mapper/luks-42b36c51-a57a-4bdb-b554-5742f1ae815a";
|
{ device = "zroot/ROOT/nixos/default";
|
||||||
fsType = "btrfs";
|
fsType = "zfs";
|
||||||
};
|
|
||||||
|
|
||||||
boot.initrd.luks.devices."luks-42b36c51-a57a-4bdb-b554-5742f1ae815a".device = "/dev/disk/by-uuid/42b36c51-a57a-4bdb-b554-5742f1ae815a";
|
|
||||||
|
|
||||||
fileSystems."/home" =
|
|
||||||
{ device = "/dev/mapper/luks-42b36c51-a57a-4bdb-b554-5742f1ae815a";
|
|
||||||
fsType = "btrfs";
|
|
||||||
options = [ "subvol=home" ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/nix" =
|
fileSystems."/nix" =
|
||||||
{ device = "/dev/mapper/luks-42b36c51-a57a-4bdb-b554-5742f1ae815a";
|
{ device = "zroot/data/nix";
|
||||||
fsType = "btrfs";
|
fsType = "zfs";
|
||||||
options = [ "subvol=nix" ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/boot" =
|
fileSystems."/boot" =
|
||||||
{ device = "/dev/disk/by-uuid/A043-E763";
|
{ device = "/dev/disk/by-uuid/970C-6A15";
|
||||||
fsType = "vfat";
|
fsType = "vfat";
|
||||||
options = [ "fmask=0022" "dmask=0022" ];
|
options = [ "fmask=0022" "dmask=0022" ];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
boot.kernelPackages = pkgs.linuxPackages;
|
|
||||||
|
|
||||||
# Bootloader.
|
# Bootloader.
|
||||||
boot.kernelParams = [
|
boot.kernelParams = [
|
||||||
"sysrq_always_enabled=1"
|
"sysrq_always_enabled=1"
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
|
||||||
{
|
|
||||||
networking.hostName = "nix-builder";
|
|
||||||
networking.networkmanager.enable = true;
|
|
||||||
boot.loader.systemd-boot.enable = true;
|
|
||||||
boot.loader.efi.canTouchEfiVariables = true;
|
|
||||||
boot.loader.systemd-boot.configurationLimit = 5;
|
|
||||||
boot.kernelPackages = pkgs.linuxKernel.packages.linux_6_12;
|
|
||||||
services.qemuGuest.enable = true;
|
|
||||||
security.sudo.wheelNeedsPassword = false;
|
|
||||||
system.stateVersion = "24.11";
|
|
||||||
|
|
||||||
# Bound memory pressure on the initial 4 vCPU / 8 GiB VM.
|
|
||||||
nix.settings.max-jobs = 1;
|
|
||||||
nix.settings.cores = 4;
|
|
||||||
nix.settings.extra-substituters = lib.mkForce [ ];
|
|
||||||
zramSwap.enable = true;
|
|
||||||
nix.gc = {
|
|
||||||
automatic = true;
|
|
||||||
dates = "weekly";
|
|
||||||
options = "--delete-older-than 14d";
|
|
||||||
};
|
|
||||||
nix.optimise.automatic = true;
|
|
||||||
|
|
||||||
# Only serve on the LAN IPv4 address, including on this dual-stack VM.
|
|
||||||
services.nix-serve = {
|
|
||||||
enable = true;
|
|
||||||
package = pkgs.nix-serve-ng;
|
|
||||||
bindAddress = "10.17.1.100";
|
|
||||||
openFirewall = true;
|
|
||||||
secretKeyFile = "/var/lib/nix-cache/cache-key.sec";
|
|
||||||
};
|
|
||||||
|
|
||||||
users.groups.woodpecker = { };
|
|
||||||
users.users.woodpecker = {
|
|
||||||
isSystemUser = true;
|
|
||||||
group = "woodpecker";
|
|
||||||
home = "/var/lib/woodpecker";
|
|
||||||
};
|
|
||||||
services.woodpecker-agents.agents.nix = {
|
|
||||||
enable = true;
|
|
||||||
environment = {
|
|
||||||
WOODPECKER_BACKEND = "local";
|
|
||||||
WOODPECKER_SERVER = "woodpecker.cazzzer.com:9000";
|
|
||||||
WOODPECKER_MAX_WORKFLOWS = "1";
|
|
||||||
WOODPECKER_AGENT_LABELS = "repo=CaZzzer/nix-conf,!nix-builder=true";
|
|
||||||
WOODPECKER_BACKEND_LOCAL_TEMP_DIR = "/var/lib/woodpecker/workspaces";
|
|
||||||
};
|
|
||||||
# Root-owned, mode 0600; may also override server/TLS settings above.
|
|
||||||
environmentFile = [ "/var/lib/woodpecker/agent.env" ];
|
|
||||||
path = with pkgs; [
|
|
||||||
bash coreutils findutils git git-lfs openssh openssl python3 transcrypt
|
|
||||||
woodpecker-plugin-git config.nix.package
|
|
||||||
];
|
|
||||||
};
|
|
||||||
systemd.services.woodpecker-agent-nix.serviceConfig = {
|
|
||||||
DynamicUser = lib.mkForce false;
|
|
||||||
User = "woodpecker";
|
|
||||||
Group = "woodpecker";
|
|
||||||
StateDirectory = "woodpecker";
|
|
||||||
ReadWritePaths = [ "/var/lib/nix-ci" ];
|
|
||||||
};
|
|
||||||
systemd.services.woodpecker-agent-nix.unitConfig.ConditionPathExists =
|
|
||||||
"/var/lib/woodpecker/agent.env";
|
|
||||||
systemd.tmpfiles.rules = [
|
|
||||||
"d /var/lib/woodpecker/workspaces 0700 woodpecker woodpecker -"
|
|
||||||
"d /var/lib/nix-ci 0750 woodpecker woodpecker -"
|
|
||||||
"d /var/lib/nix-cache 0700 root root -"
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
"sysrq_always_enabled=1"
|
"sysrq_always_enabled=1"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
boot.kernelPackages = pkgs.linuxKernel.packages.linux_7_2;
|
||||||
boot.loader = {
|
boot.loader = {
|
||||||
efi.canTouchEfiVariables = true;
|
efi.canTouchEfiVariables = true;
|
||||||
timeout = 3;
|
timeout = 3;
|
||||||
@@ -60,12 +61,17 @@
|
|||||||
hardware.bluetooth.enable = true;
|
hardware.bluetooth.enable = true;
|
||||||
hardware.bluetooth.powerOnBoot = false;
|
hardware.bluetooth.powerOnBoot = false;
|
||||||
programs.kdeconnect.enable = true;
|
programs.kdeconnect.enable = true;
|
||||||
|
programs.fish.enable = true;
|
||||||
|
programs.git.enable = true;
|
||||||
programs.git.lfs.enable = true;
|
programs.git.lfs.enable = true;
|
||||||
# https://nixos.wiki/wiki/Git
|
# https://nixos.wiki/wiki/Git
|
||||||
programs.git.package = pkgs.git.override { withLibsecret = true; doInstallCheck = false; };
|
programs.git.package = pkgs.git.override { withLibsecret = true; doInstallCheck = false; };
|
||||||
programs.lazygit.enable = true;
|
programs.lazygit.enable = true;
|
||||||
|
programs.neovim.enable = true;
|
||||||
programs.wireshark.enable = true;
|
programs.wireshark.enable = true;
|
||||||
programs.wireshark.package = pkgs.wireshark; # wireshark-cli by default
|
programs.wireshark.package = pkgs.wireshark; # wireshark-cli by default
|
||||||
|
programs.bat.enable = true;
|
||||||
|
programs.htop.enable = true;
|
||||||
programs.nix-ld.enable = true;
|
programs.nix-ld.enable = true;
|
||||||
programs.nix-ld.libraries = with pkgs; [
|
programs.nix-ld.libraries = with pkgs; [
|
||||||
stdenv.cc.cc.lib
|
stdenv.cc.cc.lib
|
||||||
@@ -91,7 +97,17 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
|
dust
|
||||||
|
eza
|
||||||
|
fastfetch
|
||||||
|
fd
|
||||||
|
helix
|
||||||
|
micro
|
||||||
|
openssl
|
||||||
|
ripgrep
|
||||||
|
starship
|
||||||
|
tealdeer
|
||||||
|
transcrypt
|
||||||
] ++ [
|
] ++ [
|
||||||
efibootmgr
|
efibootmgr
|
||||||
ffmpeg
|
ffmpeg
|
||||||
@@ -120,7 +136,6 @@
|
|||||||
kdePackages.filelight
|
kdePackages.filelight
|
||||||
kdePackages.flatpak-kcm
|
kdePackages.flatpak-kcm
|
||||||
kdePackages.kate
|
kdePackages.kate
|
||||||
kdePackages.partitionmanager
|
|
||||||
kdePackages.yakuake
|
kdePackages.yakuake
|
||||||
mission-center
|
mission-center
|
||||||
(mpv.override {
|
(mpv.override {
|
||||||
@@ -151,10 +166,9 @@
|
|||||||
antigravity-cli
|
antigravity-cli
|
||||||
antigravity-ide-fhs
|
antigravity-ide-fhs
|
||||||
codex
|
codex
|
||||||
bubblewrap
|
|
||||||
# codex-acp
|
# codex-acp
|
||||||
# github-copilot-cli
|
# github-copilot-cli
|
||||||
# opencode
|
opencode
|
||||||
# opencode-desktop
|
# opencode-desktop
|
||||||
] ++ [
|
] ++ [
|
||||||
# C
|
# C
|
||||||
|
|||||||
@@ -20,11 +20,6 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
||||||
nix.settings.extra-substituters = [ "http://10.17.1.100:5000" ];
|
|
||||||
nix.settings.extra-trusted-public-keys = [
|
|
||||||
"nix-builder:PhxOkUyF2KD9ALkSC6saB2zoPp1o6hMOOpgp5/gngKI="
|
|
||||||
];
|
|
||||||
nix.settings.connect-timeout = 5;
|
|
||||||
|
|
||||||
environment.etc."current-system-packages".text =
|
environment.etc."current-system-packages".text =
|
||||||
let
|
let
|
||||||
@@ -37,25 +32,4 @@
|
|||||||
services.openssh.enable = true;
|
services.openssh.enable = true;
|
||||||
services.openssh.settings.PasswordAuthentication = false;
|
services.openssh.settings.PasswordAuthentication = false;
|
||||||
services.openssh.settings.KbdInteractiveAuthentication = false;
|
services.openssh.settings.KbdInteractiveAuthentication = false;
|
||||||
|
|
||||||
programs.fish.enable = true;
|
|
||||||
programs.git.enable = true;
|
|
||||||
|
|
||||||
programs.bat.enable = true;
|
|
||||||
programs.htop.enable = true;
|
|
||||||
programs.neovim.enable = true;
|
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
|
||||||
dua
|
|
||||||
dust
|
|
||||||
eza
|
|
||||||
fastfetch
|
|
||||||
fd
|
|
||||||
micro
|
|
||||||
openssl
|
|
||||||
ripgrep
|
|
||||||
starship
|
|
||||||
tealdeer
|
|
||||||
transcrypt
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,12 @@
|
|||||||
|
|
||||||
# Install firefox.
|
# Install firefox.
|
||||||
programs.firefox.enable = true;
|
programs.firefox.enable = true;
|
||||||
|
programs.fish.enable = true;
|
||||||
|
programs.git.enable = true;
|
||||||
|
programs.neovim.enable = true;
|
||||||
|
|
||||||
|
programs.bat.enable = true;
|
||||||
|
programs.htop.enable = true;
|
||||||
programs.wireshark.enable = true;
|
programs.wireshark.enable = true;
|
||||||
|
|
||||||
# List packages installed in system profile. To search, run:
|
# List packages installed in system profile. To search, run:
|
||||||
@@ -74,13 +79,23 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
|
dust
|
||||||
|
eza
|
||||||
|
fastfetch
|
||||||
|
fd
|
||||||
host-spawn # for flatpaks
|
host-spawn # for flatpaks
|
||||||
kdePackages.flatpak-kcm
|
kdePackages.flatpak-kcm
|
||||||
kdePackages.filelight
|
kdePackages.filelight
|
||||||
kdePackages.kate
|
kdePackages.kate
|
||||||
kdePackages.yakuake
|
kdePackages.yakuake
|
||||||
ldns
|
ldns
|
||||||
|
micro
|
||||||
mpv
|
mpv
|
||||||
|
openssl
|
||||||
|
ripgrep
|
||||||
|
starship
|
||||||
|
tealdeer
|
||||||
|
transcrypt
|
||||||
waypipe
|
waypipe
|
||||||
whois
|
whois
|
||||||
zfs
|
zfs
|
||||||
|
|||||||
@@ -52,15 +52,30 @@ in
|
|||||||
security.sudo.wheelNeedsPassword = false;
|
security.sudo.wheelNeedsPassword = false;
|
||||||
|
|
||||||
programs.firefox.enable = true;
|
programs.firefox.enable = true;
|
||||||
|
programs.fish.enable = true;
|
||||||
|
programs.git.enable = true;
|
||||||
|
programs.neovim.enable = true;
|
||||||
|
programs.bat.enable = true;
|
||||||
|
programs.htop.enable = true;
|
||||||
programs.wireshark.enable = true;
|
programs.wireshark.enable = true;
|
||||||
programs.wireshark.package = pkgs.wireshark; # wireshark-cli by default
|
programs.wireshark.package = pkgs.wireshark; # wireshark-cli by default
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
|
dust
|
||||||
|
eza
|
||||||
|
fastfetch
|
||||||
|
fd
|
||||||
kdePackages.kate
|
kdePackages.kate
|
||||||
ldns
|
ldns
|
||||||
lsof
|
lsof
|
||||||
|
micro
|
||||||
mpv
|
mpv
|
||||||
|
openssl
|
||||||
|
ripgrep
|
||||||
rustscan
|
rustscan
|
||||||
|
starship
|
||||||
|
tealdeer
|
||||||
|
transcrypt
|
||||||
wakeonlan
|
wakeonlan
|
||||||
waypipe
|
waypipe
|
||||||
whois
|
whois
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ let
|
|||||||
"|opnsense."
|
"|opnsense."
|
||||||
"|vpgen."
|
"|vpgen."
|
||||||
"|woodpecker."
|
"|woodpecker."
|
||||||
"|woodpecker-grpc."
|
|
||||||
"||pgrok."
|
"||pgrok."
|
||||||
"|sync."
|
"|sync."
|
||||||
"|minecruft."
|
"|minecruft."
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ in
|
|||||||
udp . 48425 : ${vars.extra.opnsense.addr4} . 48425,
|
udp . 48425 : ${vars.extra.opnsense.addr4} . 48425,
|
||||||
# Amnezia VPN server
|
# Amnezia VPN server
|
||||||
udp . 37138 : ${vars.extra.amnezia.addr4} . 37138,
|
udp . 37138 : ${vars.extra.amnezia.addr4} . 37138,
|
||||||
udp . 31405 : ${vars.extra.amnezia.addr4} . 31405,
|
|
||||||
tcp . 38247 : ${vars.extra.amnezia.addr4} . 22,
|
tcp . 38247 : ${vars.extra.amnezia.addr4} . 22,
|
||||||
# Minecruft server
|
# Minecruft server
|
||||||
tcp . 25565 : ${vars.extra.minecruft.addr4} . 25565,
|
tcp . 25565 : ${vars.extra.minecruft.addr4} . 25565,
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ in
|
|||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.caddy.withPlugins {
|
package = pkgs.caddy.withPlugins {
|
||||||
plugins = [ "github.com/caddy-dns/cloudflare@v0.2.4" ];
|
plugins = [ "github.com/caddy-dns/cloudflare@v0.2.4" ];
|
||||||
hash = "sha256-QSiwKqKvSxhksWBF4/MlBOpyXba5xOQ2sRwA0R7399E=";
|
hash = "sha256-xRJ5evsAJ2akg47j3Bt6YDXJOgX88B/rKNP50KSVyNY=";
|
||||||
};
|
};
|
||||||
virtualHosts."*.${domain}".extraConfig = ''
|
virtualHosts."*.${domain}".extraConfig = ''
|
||||||
encode
|
encode
|
||||||
|
|||||||
@@ -0,0 +1,192 @@
|
|||||||
|
---
|
||||||
|
name: run-workflow
|
||||||
|
description: 'How to write and run a dynamic workflow script with the `run_workflow` tool: a Python script that orchestrates many agents with `agent`, `parallel`, `pipeline`, and `phase`. Use when a task splits into many independent or staged pieces of agent work (fan out over files, modules, bugs, or review angles, then aggregate), or when the user asks for a workflow. Don''t use for a single delegated task (use a subagent) or for legacy workflow files (see migrate-workflows).'
|
||||||
|
metadata:
|
||||||
|
namespace: system
|
||||||
|
---
|
||||||
|
# Dynamic workflows with `run_workflow`
|
||||||
|
|
||||||
|
A workflow is a short Python script that the `run_workflow` tool executes. The
|
||||||
|
script decides which agents to start, in what order, and what to do with their
|
||||||
|
results. Use it instead of many manual subagent calls when the orchestration
|
||||||
|
itself is code: loops over a list, fan-out then aggregate, or staged pipelines.
|
||||||
|
|
||||||
|
## Steps
|
||||||
|
|
||||||
|
1. Pass the script inline as `Script`, or write it to a file (for example in
|
||||||
|
the conversation scratch directory) and pass its absolute path as
|
||||||
|
`ScriptPath`. Set exactly one of them; a file is easier to fix and rerun.
|
||||||
|
2. Call `run_workflow(Script="...", Description="...")` or
|
||||||
|
`run_workflow(ScriptPath="/abs/path/workflow.py", Description="...")`.
|
||||||
|
`Description` is a one-line goal shown in the UI.
|
||||||
|
The workflow runs in the background, and you are notified when it ends.
|
||||||
|
For a quick script, such as a `call_tool` fan-out, set
|
||||||
|
`WaitMsBeforeAsync` (up to 10000) to get the result in the same turn if it
|
||||||
|
finishes in time.
|
||||||
|
To pass inputs, set `Args` to a JSON object; the script reads it as the
|
||||||
|
`args` dict. When `ScriptPath` is a saved workflow's entry script, `Args`
|
||||||
|
is validated against the args schema in its `workflow.json`.
|
||||||
|
3. Read the tool result: it contains the `log()` output (`Logs:`) and what the
|
||||||
|
script printed (`Output:`). Each agent is also linked from the workflow
|
||||||
|
step, so the user can open its conversation.
|
||||||
|
4. If the tool returns an error, fix the script at the reported line and run
|
||||||
|
it again.
|
||||||
|
|
||||||
|
## Script rules
|
||||||
|
|
||||||
|
The script runs in its own `python3` process, which needs Python 3.8 or later
|
||||||
|
on `PATH`:
|
||||||
|
|
||||||
|
- `await` works at the top level, and you can define `async def` helpers.
|
||||||
|
- Installed library workflows are importable by name (`import <library>` or
|
||||||
|
`from <library> import <name>`); library modules see the same primitives as
|
||||||
|
the script.
|
||||||
|
- What the script prints (`print()`, `stderr`, child-process output, and the
|
||||||
|
`repr` of a trailing expression) is returned in the tool result's `Output:`
|
||||||
|
section (and appended to the error when the workflow fails).
|
||||||
|
- An uncaught exception stops the workflow and reports the script line.
|
||||||
|
- `CONVERSATION_ID` and `STEP_INDEX` identify the `run_workflow` step.
|
||||||
|
`WORKSPACES` is a tuple of the workspace directories, primary first (empty
|
||||||
|
if there are none).
|
||||||
|
- The working directory is `Cwd` if given, else `WORKSPACES[0]`, so relative
|
||||||
|
paths resolve against it. Local modules are not importable.
|
||||||
|
|
||||||
|
## Primitives
|
||||||
|
|
||||||
|
| Primitive | Behavior |
|
||||||
|
| --- | --- |
|
||||||
|
| `log(*args)` | Adds a line to the workflow output and the UI. |
|
||||||
|
| `phase(name)` | Starts a named phase; later logs and agents group under it. |
|
||||||
|
| `agent(prompt=None, schema=None, role=None, type_name="self", workspace="inherit", model=None)` | Defines an agent; nothing runs yet. `await agent(prompt, schema)` runs it once and returns its result. `a = agent(...)` then `await a(prompt, schema)` runs one turn in a conversation kept across calls. |
|
||||||
|
| `parallel(items, fn)` | Promise that calls `fn(item)` for each item and awaits all results concurrently; results are in item order. If one fails, the rest are cancelled. |
|
||||||
|
| `pipeline(items, fn)` | Promise that calls and awaits `fn(item)` one item at a time; results are in item order. |
|
||||||
|
| `trajectory(last=None, types=None, tools=None, min_index=None, max_index=None)` | `await trajectory()` returns steps before this `run_workflow` call started, oldest first. `min_index` and `max_index` bound `step.index` (inclusive); `types` and `tools` filter by step type or tool name; `last` keeps the last N matching steps. |
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
- `type_name`: the agent type to run. `"self"` uses the current agent's
|
||||||
|
configuration; any available custom agent name also works.
|
||||||
|
- `workspace`: `"inherit"` (the current workspace), `"branch"` (a new isolated
|
||||||
|
clone, for agents that edit code in parallel), or `"share"` (a new workspace
|
||||||
|
that shares the underlying repository). Other values are errors.
|
||||||
|
- `schema` (required): a JSON schema (dict or string) for the agent's result.
|
||||||
|
The agent returns the result by calling its `finish` tool, which checks it
|
||||||
|
against the schema, and `await agent(...)` returns the parsed value. An
|
||||||
|
agent that ends without calling `finish` fails the workflow. Use
|
||||||
|
`{"type": "string"}` for a free-form answer.
|
||||||
|
- `role`: an optional short title for the agent's card, such as
|
||||||
|
`"Security reviewer"`.
|
||||||
|
- `model`: the agent's model tier: `"inherit"` (default, your model),
|
||||||
|
`"flash_lite"`, `"flash"`, or `"pro"`. Use a lighter tier for simple,
|
||||||
|
high-fan-out work.
|
||||||
|
- `fn`: usually a `lambda` that returns `agent(...)`, or an `async def`
|
||||||
|
helper that awaits several agents. It must return something awaitable:
|
||||||
|
an `agent()` or a call on one, a nested `parallel()` / `pipeline()`, or
|
||||||
|
an `async def` call. Build per-item prompts and roles with f-strings.
|
||||||
|
|
||||||
|
Awaiting the same agent twice runs it once and returns the same result. An
|
||||||
|
`agent()` that is never awaited or called never runs, so always `await` it, or
|
||||||
|
pass it to `parallel` / `pipeline` and await that.
|
||||||
|
|
||||||
|
The workflow step shows one card per agent, in the order agents start, titled
|
||||||
|
with its `role`, or else the first line of its prompt, so set a role or start
|
||||||
|
each prompt with a short line that names the job.
|
||||||
|
|
||||||
|
## Agents that keep their context
|
||||||
|
|
||||||
|
When one agent should do several related turns, such as a reviewer that checks
|
||||||
|
the fixes for the bugs it found, call it instead of awaiting it. Each
|
||||||
|
`a(prompt, schema)` is lazy like an awaited `agent()` and returns that turn's
|
||||||
|
`finish` result; the agent's own `prompt`, if any, is its standing instructions
|
||||||
|
and leads the first turn. `schema` on a call defaults to the agent's. Turns on
|
||||||
|
one agent run one at a time, in the order they were started. A failed turn
|
||||||
|
raises, but the agent stays usable. An agent is either awaited or called, not
|
||||||
|
both. `del a` ends the agent, unless something else, such as a lambda, still
|
||||||
|
references it; every agent ends when the workflow ends.
|
||||||
|
|
||||||
|
```python
|
||||||
|
reviewer = agent("You review Go code for correctness.", role="Reviewer")
|
||||||
|
bugs = await reviewer("List the bugs in foo.go.", {"type": "array", "items": {"type": "string"}})
|
||||||
|
fixes = await parallel(bugs, lambda b: agent(f"Fix: {b}", {"type": "string"}))
|
||||||
|
ok = await reviewer(f"Fixes made: {fixes}. Are all your bugs fixed?", {"type": "boolean"})
|
||||||
|
del reviewer
|
||||||
|
```
|
||||||
|
|
||||||
|
## Calling tools from the script
|
||||||
|
|
||||||
|
Where the `run_workflow` tool description lists tools for `call_tool`, the
|
||||||
|
script can call them directly:
|
||||||
|
|
||||||
|
- `call_tool(name, **args)` returns a promise like `agent()` does. Awaiting it
|
||||||
|
runs the tool with the arguments you would pass to it directly and returns
|
||||||
|
the tool's output as a `str`.
|
||||||
|
- It raises `ToolError` (with `.tool` and `.message`) if the tool fails or
|
||||||
|
the call is denied. `.denied` is `True` when a pre-tool hook or the
|
||||||
|
permission check rejected the call before the tool ran, so a script can
|
||||||
|
skip denied calls and still fail on real errors.
|
||||||
|
- The user cannot be asked anything from a workflow: a call that needs user
|
||||||
|
approval that has not already been granted is denied.
|
||||||
|
- Tool outputs are not shown to you unless the script logs or prints them.
|
||||||
|
|
||||||
|
## Reading earlier conversation steps
|
||||||
|
|
||||||
|
Pass inputs you already have in `Args` (or inline in the script). Use
|
||||||
|
`await trajectory(...)` when the script needs to inspect steps from earlier in
|
||||||
|
this conversation—such as mining a failed `run_command` output without
|
||||||
|
rerunning it—and pass only the relevant slice into child `agent()` prompts.
|
||||||
|
|
||||||
|
Each returned `Step` is a `dict` that also supports attribute access (missing
|
||||||
|
fields return `None` as attributes):
|
||||||
|
|
||||||
|
- `index` (`int`): 0-based step index.
|
||||||
|
- `type` (`str`): step type, e.g. `"USER_INPUT"`, `"PLANNER_RESPONSE"`,
|
||||||
|
`"SYSTEM_MESSAGE"`, or `"GENERIC"` (tool calls).
|
||||||
|
- `status` (`str`): e.g. `"DONE"`, `"ERROR"`, or `"CLEARED"`.
|
||||||
|
- Message steps set `text` (`str`); tool steps set `tool` (`str`), `args`
|
||||||
|
(parsed `dict`), and `output` (`str`, truncated at 200k characters).
|
||||||
|
|
||||||
|
```python
|
||||||
|
steps = await trajectory(tools=["run_command"], last=20)
|
||||||
|
errors = [s.output for s in steps if s.status == "ERROR" and s.output]
|
||||||
|
log(f"Found {len(errors)} failed command(s)")
|
||||||
|
```
|
||||||
|
|
||||||
|
`trajectory()` only returns steps before the `run_workflow` call started (steps
|
||||||
|
added while the workflow runs in the background are not included). Older tool
|
||||||
|
steps evicted from memory have `status == "CLEARED"` and `output == None`; read
|
||||||
|
the conversation's `transcript.jsonl` / `transcript_full.jsonl` when you need
|
||||||
|
cleared tool outputs or steps added after the workflow started.
|
||||||
|
|
||||||
|
## Behavior to know
|
||||||
|
|
||||||
|
- Workflow agents are main agents, not subagents. They are hidden from the
|
||||||
|
conversation list and reachable from the workflow step. An awaited agent
|
||||||
|
is single-use; a called agent lasts until deleted or the workflow ends.
|
||||||
|
- `await agent(...)` returns when the agent's run ends, with the result it
|
||||||
|
passed to `finish`.
|
||||||
|
- If one agent in `parallel` fails, the whole call fails and the other agents
|
||||||
|
in it are cancelled. Stopping the parent conversation stops all running
|
||||||
|
workflow agents.
|
||||||
|
- Agents do not see the script or each other. Put all the context an agent
|
||||||
|
needs in its prompt, and ask for a short, well-defined output.
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
Fan out over a list that an agent produces:
|
||||||
|
|
||||||
|
```python
|
||||||
|
phase("Discover")
|
||||||
|
files = await agent(
|
||||||
|
"List the Go files under pkg/foo that call Bar(). Paths only.",
|
||||||
|
schema={"type": "array", "items": {"type": "string"}},
|
||||||
|
)
|
||||||
|
|
||||||
|
phase("Review")
|
||||||
|
reviews = await parallel(files, lambda f: agent(
|
||||||
|
f"Review {f} for misuse of Bar(). Reply in 3 bullets or 'OK'.",
|
||||||
|
schema={"type": "string"},
|
||||||
|
role=f"Review {f}",
|
||||||
|
))
|
||||||
|
for r in reviews:
|
||||||
|
log(r)
|
||||||
|
```
|
||||||
Reference in new issue
Block a user