Compare commits
1
Commits
updates
...
f596d67ec6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f596d67ec6
|
No files matched your search
@@ -0,0 +1,19 @@
|
||||
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
|
||||
@@ -0,0 +1,70 @@
|
||||
# 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
@@ -0,0 +1,20 @@
|
||||
#!/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
|
||||
@@ -59,6 +59,16 @@
|
||||
apps.x86_64-linux.secrix = secrix.secrix self;
|
||||
|
||||
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 {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
{ 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;
|
||||
programs.git.enable = true;
|
||||
environment.systemPackages = [ pkgs.transcrypt ];
|
||||
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 -"
|
||||
];
|
||||
}
|
||||
@@ -20,6 +20,11 @@
|
||||
};
|
||||
|
||||
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 =
|
||||
let
|
||||
|
||||
@@ -26,6 +26,7 @@ let
|
||||
"|opnsense."
|
||||
"|vpgen."
|
||||
"|woodpecker."
|
||||
"|woodpecker-grpc."
|
||||
"||pgrok."
|
||||
"|sync."
|
||||
"|minecruft."
|
||||
|
||||
Reference in new issue
Block a user