From 8006ed52e4dd631570c612d253d36b79638185c5 Mon Sep 17 00:00:00 2001 From: tomwrw Date: Mon, 7 Sep 2026 10:04:55 +0100 Subject: [PATCH] feat: Moved all justfile logic in to devshell.nix for native nix management. --- README.md | 69 ++++--- justfile | 130 ------------- modules/aspects/core/nix.nix | 11 +- modules/aspects/core/security.nix | 2 +- modules/flake/deploy.nix | 11 -- modules/flake/devshell.nix | 29 +-- modules/flake/tasks.nix | 281 +++++++++++++++++++++++++++++ modules/hosts/flatmate/default.nix | 2 +- modules/users/tomwrw/tomwrw.nix | 2 +- 9 files changed, 352 insertions(+), 185 deletions(-) delete mode 100644 justfile delete mode 100644 modules/flake/deploy.nix create mode 100644 modules/flake/tasks.nix diff --git a/README.md b/README.md index 8bd7830..e7d8002 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ modules/ │ ├── virtualisation/ # libvirt │ └── apps/ # every user-facing app, one file each ├── den/ # defaults, the host roster, the schema, the quirks -├── flake/ # flake plumbing: inputs, treefmt, checks, devShell, deploy +├── flake/ # flake plumbing: inputs, treefmt, checks, devShell, tasks ├── hosts/ # one directory per host: its aspects, and its _hardware.nix │ ├── endgame/ │ └── flatmate/ @@ -232,32 +232,54 @@ This configuration has multiple system entry points. At the moment, I am a singl ### Prerequisites. - Nix with flakes enabled (`experimental-features = nix-command flakes`). -- `just`, `sops` and `age`. `nix develop` provides these plus `nixfmt`, `nvd`, - `ssh-to-age` and `nixos-anywhere` - see [devshell.nix](modules/flake/devshell.nix). +- Nothing else. `nix develop` provides `sops`, `age`, `nixfmt`, `nvd` and + `ssh-to-age`, and every task below - see + [devshell.nix](modules/flake/devshell.nix). - An age keypair per host and per user, and a FIDO2 token if you want the extra LUKS - keyslot. The deploy recipe expects these on a removable drive at the path in the - `usb` variable at the top of the [justfile](justfile). + keyslot. `deploy` expects these on a removable drive at `usbDefault` in + [tasks.nix](modules/flake/tasks.nix), overridable with `MEGADOTS_USB`. ### Getting Started. -Everything goes through `just`. Run it bare to list the recipes. +The repo's tasks are flake apps, defined in +[tasks.nix](modules/flake/tasks.nix). `nix flake show` lists them with a +description each. ```bash -just # list recipes -just build endgame # build a host's closure locally (no activation) -just diff endgame # build, then nvd diff against the running system -just rebuild endgame # switch a remote host (pushes a locally-built closure) -just deploy endgame # bare-metal install via nixos-anywhere (formats disks) -just check # build both hosts, format check, secrets scan -just fmt # nixfmt + deadnix + statix via treefmt -just update # nix flake update -just gc # collect garbage older than 30 days -just enroll-fido2 endgame # add the inserted token to the LUKS header -just secrets-edit secrets/users/tomwrw.yaml -just secrets-updatekeys # re-sync sops recipients after editing .sops.yaml +nix flake show # list the tasks +nix run .#build endgame # build a host's closure locally (no activation) +nix run .#diff-host endgame # build, then nvd diff against the running system +nix run .#rebuild endgame # switch a remote host (pushes a locally-built closure) +nix run .#deploy endgame # bare-metal install via nixos-anywhere (formats disks) +nix run .#enroll-fido2 endgame # add the inserted token to the LUKS header +nix run .#luks-device endgame # print the host's LUKS device path +nix run .#secrets-updatekeys # re-sync sops recipients after editing .sops.yaml ``` -`just check` builds both hosts, checks formatting and greps for plaintext key material. +Inside `nix develop` the same tasks are on `$PATH` as bare commands, so the +above is `build endgame`, `diff-host endgame`, and so on. It is `diff-host` and +not `diff` because that name belongs to diffutils, and shadowing it inside the +shell would be a nasty surprise. + +A positional host passes straight through, but a *flag* for the task needs `--` +first, or nix consumes it: `nix run .#rebuild -- endgame --flag`. + +An unknown or missing host is refused up front, with the valid list: + +```bash +$ nix run .#deploy typo +no such host: typo +valid hosts: endgame flatmate +``` + +These run from the checkout and can drive either host. For operating on the +machine you are sitting at, from any directory, use the `n*` aliases in +[core/nix.nix](modules/aspects/core/nix.nix) - `nr`, `nb`, `nd`, `nu`, `ncheck`, +`nfmt`, `nclean`. + +There is no wrapper for the things nix already does. `nix flake check` builds +both hosts, checks formatting and greps for plaintext key material; `nix fmt` +runs nixfmt, deadnix and statix; `nix flake update` updates the inputs. Building a host is the check that matters: it catches anything that has stopped evaluating or building. @@ -269,7 +291,7 @@ entry in the tree with it, without realising a single output. The host list is d ### Bootstrapping a host from scratch. -Four things have to be in place before `just deploy ` will produce a working +Four things have to be in place before `nix run .#deploy ` will produce a working machine. 1. **USB key material.** The USB mirrors the destination: whatever is under @@ -289,12 +311,13 @@ machine. Ownership is handled by nixos-anywhere's `--chown`, which runs during the install - `--extra-files` copies as root. - The `usb` path itself is a variable at the top of the [justfile](justfile). + The USB path itself is `usbDefault` at the top of + [tasks.nix](modules/flake/tasks.nix), overridable with `MEGADOTS_USB`. 2. **A `creation_rules` block for the new host** in [.sops.yaml](.sops.yaml) - one per secrets file, listing its recipients. Adding a key to the recipient list is not enough; without its own rule the host's secrets are encrypted to nobody. Then run - `just secrets-updatekeys`. + `nix run .#secrets-updatekeys`. 3. **`secrets/hosts/.yaml`** with at least `users//password`. Evaluation interpolates this filename from the hostname, so a missing file fails the build. 4. **`syncthing//{key,cert,guiPassword}` in `secrets/users/.yaml`** - the @@ -308,7 +331,7 @@ machine. `_hardware.nix` from `nixos-generate-config`. Then boot the target from a NixOS installer ISO, set a password for the `nixos` user so -SSH works, and run `just deploy `. nixos-anywhere partitions with disko, copies the +SSH works, and run `nix run .#deploy `. nixos-anywhere partitions with disko, copies the USB tree into /persist, chowns it to the user, and installs. The machine comes up with its secrets decryptable and its keys in place - no second pass, nothing to do by hand. diff --git a/justfile b/justfile deleted file mode 100644 index 87eb68a..0000000 --- a/justfile +++ /dev/null @@ -1,130 +0,0 @@ -cachyos-cache := "--option allow-import-from-derivation true --option extra-substituters 'https://nyx-cache.chaotic.cx/' --option extra-trusted-public-keys 'nyx-cache.chaotic.cx:dJxTrgMC3V3cFfyIiBQDQorG6k1LsqurH/srpMSq7qk='" -usb := "/run/media/tomwrw/SURVIVOR/keys" -user := "tomwrw" - -# List the available recipes. -default: - @just --list - -# Install HOST from scratch over SSH with nixos-anywhere. FORMATS ITS DISKS. -# The USB mirrors the destination, so there is no manifest and no mapping: -# -# /hosts//age.txt -> /persist/var/lib/sops-nix/key.txt -# /users//** -> /persist/home//** -# -# Everything lands under /persist and not /home, because / (and so /home) goes -# back to a blank snapshot every boot; impermanence bind mounts it into the -# live home. Whatever a user needs, put it on the USB at the path it should -# have in their home - .ssh/id_ed25519, .config/sops/age/keys.txt - and it -# arrives there. Adding a key is a copy on the USB and nothing in this repo. -# -# This replaced a 'seed' quirk, a host-scope consumer aspect that derived -# tmpfiles ownership and a chown unit, a machine-readable option, a recipe to -# read it and four invariants to police it - all of which existed because -# --extra-files copies as root. --chown does that job during the install -# instead of on every boot, which is where it belonged. - -# Install HOST from scratch over SSH with nixos-anywhere. FORMATS ITS DISKS. -deploy HOST: - #!/usr/bin/env bash - set -euo pipefail - staging=$(mktemp -d) - trap 'rm -rf "$staging"' EXIT - install -Dm600 {{ usb }}/hosts/{{ HOST }}/age.txt "$staging/persist/var/lib/sops-nix/key.txt" - # -a keeps the modes off the USB, so a 0600 private key stays 0600 and - # sshd/sops do not refuse it. Check them there, not here. - for u in {{ usb }}/users/*/; do - [[ -d "$u" ]] || continue - install -d "$staging/persist/home/$(basename "$u")" - cp -a "$u." "$staging/persist/home/$(basename "$u")/" - done - # uid:gid rather than names: this runs against the installer image, which - # has no account for my user. 1000:100 is the first normal user and the - # 'users' group, which is what den.batteries.primary-user creates. - chown_args=() - for u in {{ usb }}/users/*/; do - [[ -d "$u" ]] || continue - chown_args+=(--chown "/persist/home/$(basename "$u")" 1000:100) - done - # Pinned by this flake's own lock - see modules/flake/deploy.nix. - nix run .#nixos-anywhere -- \ - --disko-mode disko \ - --extra-files "$staging" \ - "${chown_args[@]}" \ - --flake .#{{ HOST }} \ - --target-host nixos@{{ HOST }} - -# Build HOST's closure locally, no activation. -build HOST: - nixos-rebuild build --flake .#{{ HOST }} {{ cachyos-cache }} - -# Switch HOST to a locally-built closure over SSH. -rebuild HOST: - nixos-rebuild switch --flake .#{{ HOST }} --target-host {{ user }}@{{ HOST }} --sudo --ask-sudo-password - -# Build HOST locally and show what would change versus the running system. -diff HOST: (build HOST) - nvd diff /run/current-system result - -# Read from the config that actually opens it at boot instead of rebuilding it -# from the disk id, so it survives repartitioning. The old version appended -# "-part2" and would have pointed at the ESP if the partition order changed. - -# Print the LUKS device path for HOST. -luks-device HOST: - @nix eval --raw .#nixosConfigurations.{{ HOST }}.config.boot.initrd.luks.devices.crypted.device - -# Add the inserted FIDO2 token as a LUKS keyslot on HOST. -enroll-fido2 HOST: - #!/usr/bin/env bash - set -euo pipefail - dev="$(just luks-device {{ HOST }})" - ssh -t {{ user }}@{{ HOST }} sudo systemd-cryptenroll --fido2-device=auto --fido2-with-client-pin=yes "$dev" - -# Remove all FIDO2 keyslots from HOST, leaving the passphrase. -unenroll-fido2 HOST: - #!/usr/bin/env bash - set -euo pipefail - dev="$(just luks-device {{ HOST }})" - if [[ "{{ HOST }}" == "$(hostname)" ]]; then - sudo cryptsetup open --test-passphrase "$dev" && sudo systemd-cryptenroll --wipe-slot=fido2 "$dev" - else - ssh -t {{ user }}@{{ HOST }} "sudo cryptsetup open --test-passphrase '$dev' && sudo systemd-cryptenroll --wipe-slot=fido2 '$dev'" - fi - -# Format the tree (nixfmt + deadnix + statix via treefmt). -fmt: - nix fmt - -# Builds both hosts, then runs the secrets scan, treefmt and flake-file. No -# list to keep in step - it takes whatever the flake exposes as checks. - -# Run every check. -check: - nix flake check - -# Update all flake inputs. -update: - nix flake update - -# Matches the 30-day window core/nix.nix already applies weekly. - -# Collect garbage on the local machine. -gc: - nix-collect-garbage --delete-older-than 30d - sudo nix-collect-garbage --delete-older-than 30d - -# Edit an encrypted secrets file in place, e.g. 'just secrets-edit secrets/users/tomwrw.yaml'. -secrets-edit FILE: - sops {{ FILE }} - -# Left interactive on purpose. This is exactly the moment to look at the -# per-recipient diff sops prints before it re-encrypts anything. - -# Re-sync sops recipients on every secrets file against .sops.yaml. -secrets-updatekeys: - #!/usr/bin/env bash - set -euo pipefail - for f in secrets/hosts/*.yaml secrets/users/*.yaml; do - sops updatekeys "$f" - done diff --git a/modules/aspects/core/nix.nix b/modules/aspects/core/nix.nix index fc1d1aa..e4dafdd 100644 --- a/modules/aspects/core/nix.nix +++ b/modules/aspects/core/nix.nix @@ -21,9 +21,9 @@ # occasional and the destructive ones are spelled out, so nboot cannot be a # fat-fingered nb. # - # Aliases and not just recipes because they cover the other axis: the - # justfile drives *either* host *from the checkout*, these drive *this* host - # *from anywhere*. nu/ncheck/nfmt deliberately overlap just update/check/fmt. + # Aliases and not tasks because they cover the other axis: the flake apps in + # flake/tasks.nix drive *either* host *from the checkout*, these drive *this* + # host *from anywhere*. den.aspects.nix.provides.to-users.homeManager = { host, ... }: { @@ -54,9 +54,8 @@ nback = "nh os rollback --ask"; # --keep-since 30d and not "-d --delete-old", which took every old # generation including yesterday's working one. This matches the window - # nix.gc already applies weekly below, and the justfile's gc recipe - - # two collectors with different retention on one store is how I lose - # the generation I wanted. + # nix.gc already applies weekly below - two collectors with different + # retention on one store is how I lose the generation I wanted. nclean = "nh clean all --keep 5 --keep-since 30d --ask"; # Search and inspect. ns queries search.nixos.org against diff --git a/modules/aspects/core/security.nix b/modules/aspects/core/security.nix index 2612e70..a88d954 100644 --- a/modules/aspects/core/security.nix +++ b/modules/aspects/core/security.nix @@ -12,7 +12,7 @@ _: { security.polkit.enable = true; # Only wheel can execute the setuid sudo binary. Everything of mine that - # needs root ('just rebuild', activation) runs as wheel anyway. + # needs root (the rebuild task, activation) runs as wheel anyway. security.sudo.execWheelOnly = true; # Users come from the config or not at all. This used to live in the tomwrw diff --git a/modules/flake/deploy.nix b/modules/flake/deploy.nix deleted file mode 100644 index 3efb0ae..0000000 --- a/modules/flake/deploy.nix +++ /dev/null @@ -1,11 +0,0 @@ -_: { - # Exposed so my justfile can run 'nix run .#nixos-anywhere' instead of - # pulling github:nix-community/nixos-anywhere at HEAD every time. Deploying - # is the one thing that formats disks, so it should be the least improvised - # step I have. This pins it to the same nixpkgs as everything else. - perSystem = - { pkgs, ... }: - { - packages.nixos-anywhere = pkgs.nixos-anywhere; - }; -} diff --git a/modules/flake/devshell.nix b/modules/flake/devshell.nix index 66a4ddb..4817872 100644 --- a/modules/flake/devshell.nix +++ b/modules/flake/devshell.nix @@ -1,21 +1,26 @@ _: { - # Everything my justfile recipes shell out to, so I can run them on a - # machine I haven't deployed yet. 'nix develop' is the way in. + # The repo's tasks, plus what I reach for by hand. 'nix develop' is the way + # in, and inside it every task in flake/tasks.nix is a bare command: + # 'rebuild endgame' rather than 'nix run .#rebuild endgame'. + # # core/system-packages.nix only carries what my hosts need at runtime, not # what working on this repo needs. perSystem = - { pkgs, ... }: + { config, pkgs, ... }: { devShells.default = pkgs.mkShell { - packages = with pkgs; [ - age - just - nixfmt - nixos-anywhere - nvd - sops - ssh-to-age - ]; + packages = + # Every task, from the one place they are defined. + builtins.attrValues config.packages + ++ (with pkgs; [ + # Not tasks, but the tools I use directly on this tree. The tasks + # declare their own runtimeInputs and do not rely on these. + age + nixfmt + nvd + sops + ssh-to-age + ]); }; }; } diff --git a/modules/flake/tasks.nix b/modules/flake/tasks.nix new file mode 100644 index 0000000..347d360 --- /dev/null +++ b/modules/flake/tasks.nix @@ -0,0 +1,281 @@ +{ config, lib, ... }: +let + # The two things the old justfile kept as variables at the top of the file. + # user is the account these tasks reach a host through; usbDefault is a + # removable mount, so it takes an environment override rather than an edit. + user = "tomwrw"; + usbDefault = "/run/media/tomwrw/SURVIVOR/keys"; + + # Derived, not hardcoded, the same way flake/checks.nix derives its per-host + # checks: a newly added host is never silently missing from the list a task + # will accept. + hosts = lib.attrNames config.flake.nixosConfigurations; + hostList = lib.concatStringsSep " " hosts; + + # Every task operates on '.', exactly as the recipes did. That keeps the + # division core/nix.nix documents: these are the in-the-checkout, either-host + # path, and the n* aliases are the this-machine, from-anywhere path. Baking + # inputs.self instead would make every task act on the last committed tree, + # which is wrong for a build-and-test loop. + requireFlake = '' + if [ ! -e flake.nix ]; then + echo "no flake.nix in $PWD - these tasks run from the checkout" >&2 + exit 1 + fi + ''; + + # The check the justfile never had: it passed a typo straight through to + # nixos-rebuild, which failed deep inside nix with nothing useful to read. + # A loop rather than a case: the host list is baked in at eval time, so a + # 'case " endgame flatmate " in' has a constant subject and shellcheck rejects + # it (SC2194). Worth noting that it caught this at build time - the justfile + # would have shipped it. + requireHost = '' + host="''${1:-}" + matched="" + for h in ${hostList}; do + if [ "$h" = "$host" ]; then + matched=1 + break + fi + done + if [ -z "$matched" ]; then + echo "no such host: ''${host:-}" >&2 + echo "valid hosts: ${hostList}" >&2 + exit 1 + fi + shift + ''; +in +{ + # The repo's own tasks, as flake apps. Replaces a justfile. + # + # Six of its fourteen recipes are gone rather than ported: fmt, check, update, + # gc, default and secrets-edit only wrapped 'nix fmt', 'nix flake check', + # 'nix flake update', nix-collect-garbage, 'just --list' and sops. The n* + # aliases in core/nix.nix already do the first four from any directory, which + # a justfile could never do, and 'nix flake show' lists these. + # + # writeShellApplication and not a plain script, so shellcheck runs over every + # one of them at build time. The deploy recipe was 25 lines of unchecked bash + # that formats disks. + perSystem = + { pkgs, ... }: + let + task = + { + name, + description, + runtimeInputs ? [ ], + text, + }: + pkgs.writeShellApplication { + inherit name runtimeInputs; + meta.description = description; + text = requireFlake + text; + }; + + # Install HOST from scratch over SSH with nixos-anywhere. FORMATS ITS DISKS. + # The USB mirrors the destination, so there is no manifest and no mapping: + # + # /hosts//age.txt -> /persist/var/lib/sops-nix/key.txt + # /users//** -> /persist/home//** + # + # Everything lands under /persist and not /home, because / (and so /home) + # goes back to a blank snapshot every boot; impermanence bind mounts it + # into the live home. Whatever a user needs, put it on the USB at the path + # it should have in their home - .ssh/id_ed25519, + # .config/sops/age/keys.txt - and it arrives there. Adding a key is a copy + # on the USB and nothing in this repo. + # + # This replaced a 'seed' quirk, a host-scope consumer aspect that derived + # tmpfiles ownership and a chown unit, a machine-readable option, a recipe + # to read it and four invariants to police it - all of which existed + # because --extra-files copies as root. --chown does that job during the + # install instead of on every boot, which is where it belonged. + deploy = task { + name = "deploy"; + description = "Install HOST from scratch over SSH. FORMATS ITS DISKS."; + # nixos-anywhere from this flake's own nixpkgs rather than + # github:nix-community/nixos-anywhere at HEAD. Deploying is the one + # thing that formats disks, so it should be the least improvised step I + # have. This is why flake/deploy.nix used to exist. + runtimeInputs = [ + pkgs.nixos-anywhere + pkgs.coreutils + ]; + text = '' + ${requireHost} + usb="''${MEGADOTS_USB:-${usbDefault}}" + if [ ! -d "$usb" ]; then + echo "no key material at $usb - is the USB mounted?" >&2 + echo "override with MEGADOTS_USB=/path/to/keys" >&2 + exit 1 + fi + + staging=$(mktemp -d) + trap 'rm -rf "$staging"' EXIT + install -Dm600 "$usb/hosts/$host/age.txt" \ + "$staging/persist/var/lib/sops-nix/key.txt" + + # -a keeps the modes off the USB, so a 0600 private key stays 0600 and + # sshd/sops do not refuse it. Check them there, not here. + for u in "$usb"/users/*/; do + [ -d "$u" ] || continue + install -d "$staging/persist/home/$(basename "$u")" + cp -a "$u." "$staging/persist/home/$(basename "$u")/" + done + + # uid:gid rather than names: this runs against the installer image, + # which has no account for my user. 1000:100 is the first normal user + # and the 'users' group, which is what den.batteries.primary-user + # creates. + chown_args=() + for u in "$usb"/users/*/; do + [ -d "$u" ] || continue + chown_args+=(--chown "/persist/home/$(basename "$u")" 1000:100) + done + + nixos-anywhere \ + --disko-mode disko \ + --extra-files "$staging" \ + "''${chown_args[@]}" \ + --flake ".#$host" \ + --target-host "nixos@$host" \ + "$@" + ''; + }; + + build = task { + name = "build"; + description = "Build HOST's closure locally, no activation."; + text = '' + ${requireHost} + # The CachyOS cache, which the justfile kept in a 'cachyos-cache' + # variable. IFD is on because stylix reads its base16 scheme out of a + # derivation at eval time. + nixos-rebuild build --flake ".#$host" \ + --option allow-import-from-derivation true \ + --option extra-substituters 'https://nyx-cache.chaotic.cx/' \ + --option extra-trusted-public-keys 'nyx-cache.chaotic.cx:dJxTrgMC3V3cFfyIiBQDQorG6k1LsqurH/srpMSq7qk=' \ + "$@" + ''; + }; + + rebuild = task { + name = "rebuild"; + description = "Switch HOST to a locally-built closure over SSH."; + text = '' + ${requireHost} + nixos-rebuild switch --flake ".#$host" \ + --target-host "${user}@$host" --sudo --ask-sudo-password "$@" + ''; + }; + + # Not called "diff": that is diffutils' command, and these land on $PATH + # inside nix develop, where shadowing it would be a nasty surprise. Every + # other task name is clear - checked against PATH, not assumed. + diff-host = task { + name = "diff-host"; + description = "Build HOST locally and show what would change versus the running system."; + # The Nix equivalent of just's 'diff HOST: (build HOST)' dependency. + runtimeInputs = [ + build + pkgs.nvd + ]; + text = '' + ${requireHost} + build "$host" + nvd diff /run/current-system result + ''; + }; + + # Read from the config that actually opens it at boot instead of + # rebuilding it from the disk id, so it survives repartitioning. The old + # version appended "-part2" and would have pointed at the ESP if the + # partition order changed. + luks-device = task { + name = "luks-device"; + description = "Print the LUKS device path for HOST."; + text = '' + ${requireHost} + nix eval --raw ".#nixosConfigurations.$host.config.boot.initrd.luks.devices.crypted.device" + ''; + }; + + enroll-fido2 = task { + name = "enroll-fido2"; + description = "Add the inserted FIDO2 token as a LUKS keyslot on HOST."; + runtimeInputs = [ + luks-device + pkgs.openssh + ]; + text = '' + ${requireHost} + dev="$(luks-device "$host")" + ssh -t "${user}@$host" \ + sudo systemd-cryptenroll --fido2-device=auto --fido2-with-client-pin=yes "$dev" + ''; + }; + + unenroll-fido2 = task { + name = "unenroll-fido2"; + description = "Remove all FIDO2 keyslots from HOST, leaving the passphrase."; + runtimeInputs = [ + luks-device + pkgs.openssh + ]; + text = '' + ${requireHost} + dev="$(luks-device "$host")" + if [ "$host" = "$(hostname)" ]; then + sudo cryptsetup open --test-passphrase "$dev" \ + && sudo systemd-cryptenroll --wipe-slot=fido2 "$dev" + else + ssh -t "${user}@$host" \ + "sudo cryptsetup open --test-passphrase '$dev' && sudo systemd-cryptenroll --wipe-slot=fido2 '$dev'" + fi + ''; + }; + + # Left interactive on purpose. This is exactly the moment to look at the + # per-recipient diff sops prints before it re-encrypts anything. + secrets-updatekeys = task { + name = "secrets-updatekeys"; + description = "Re-sync sops recipients on every secrets file against .sops.yaml."; + runtimeInputs = [ pkgs.sops ]; + text = '' + for f in secrets/hosts/*.yaml secrets/users/*.yaml; do + sops updatekeys "$f" + done + ''; + }; + + tasks = { + inherit + deploy + build + rebuild + diff-host + luks-device + enroll-fido2 + unenroll-fido2 + secrets-updatekeys + ; + }; + in + { + # Three exposures, one definition. packages so 'nix build .#deploy' runs + # shellcheck over it, apps so 'nix run .#deploy endgame' works, and + # flake/devshell.nix puts the same derivations on $PATH. + packages = tasks; + + # program takes the derivation directly: flake-parts coerces it through + # lib.getExe, and writeShellApplication sets meta.mainProgram. The + # description is what 'nix flake show' prints. + apps = lib.mapAttrs (_: p: { + program = p; + meta.description = p.meta.description; + }) tasks; + }; +} diff --git a/modules/hosts/flatmate/default.nix b/modules/hosts/flatmate/default.nix index d5d41c5..72796a0 100644 --- a/modules/hosts/flatmate/default.nix +++ b/modules/hosts/flatmate/default.nix @@ -8,7 +8,7 @@ den.aspects.dev # The choices only this machine makes - den.aspects.boot.systemd-boot + den.aspects.boot.lanzaboote den.aspects.gnome den.aspects.surface-pro ]; diff --git a/modules/users/tomwrw/tomwrw.nix b/modules/users/tomwrw/tomwrw.nix index 406c947..e854a79 100644 --- a/modules/users/tomwrw/tomwrw.nix +++ b/modules/users/tomwrw/tomwrw.nix @@ -84,7 +84,7 @@ in user = { osConfig, ... }: { - # Pinned rather than auto-allocated: .just deploy. chowns the seeded key + # Pinned rather than auto-allocated: the deploy task chowns the seeded key # tree to 1000:100 against an installer that has no account for me, so # the number has to be one this config guarantees. uid = 1000;