refactor: share workstation setup and boot-staged updates

Use dev-owned checkouts and one update policy on both hosts. Keep only hardware and deployment identity in host modules, use the same SDDM/UWSM workstation module in the VM, and install a host-configured manual switch command with lock regression tests.
This commit is contained in:
OpenAI Coding Assistant
2026-09-05 23:52:51 -05:00
parent 209f4d8bda
commit 4893fcfec0
18 changed files with 358 additions and 247 deletions
+35 -16
View File
@@ -5,35 +5,54 @@
...
}:
let
env = config.systemd.services.nixos-update.environment;
repo = env.NIXOS_CONFIG_REPO;
runtimeInputs = with pkgs; [
nix
git
coreutils
util-linux
];
updater = pkgs.writeShellApplication {
name = "update-system";
runtimeInputs = with pkgs; [
nix
git
coreutils
util-linux
];
inherit runtimeInputs;
text = builtins.readFile ./update-system.sh;
};
switcher = pkgs.writeShellApplication {
name = "switch-system";
inherit runtimeInputs;
text = ''
export NIXOS_CONFIG_REPO=${lib.escapeShellArg repo}
export NIXOS_UPDATE_HOST=${lib.escapeShellArg env.NIXOS_UPDATE_HOST}
${builtins.readFile ./switch-system.sh}
'';
};
in
{
environment.systemPackages = [ updater ];
environment.systemPackages = [
updater
switcher
];
# Z does not follow symlinks: in /etc/nix, Nix-owned configuration links and
# result links never cause ownership changes in /etc/static or /nix/store.
systemd.tmpfiles.rules = [
"d ${repo} 0755 dev users -"
"Z ${repo} - dev users -"
"d /var/cache/nixos-update 0700 dev users -"
"Z /var/cache/nixos-update - dev users -"
];
systemd.services.nixos-update = {
description = "Build and record host-specific NixOS/tool updates without disturbing local work";
environment = {
NIXOS_CONFIG_REPO = lib.mkDefault "/etc/nixos";
NIXOS_UPDATE_HOST = lib.mkDefault "dev";
NIXOS_UPDATE_MODE = lib.mkDefault "switch";
};
description = "Build and stage NixOS/tool updates for the next boot";
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
path = [ "/run/wrappers" ];
serviceConfig = {
Type = "oneshot";
User = lib.mkDefault "dev";
Group = lib.mkDefault "users";
WorkingDirectory = config.systemd.services.nixos-update.environment.NIXOS_CONFIG_REPO;
User = "dev";
Group = "users";
WorkingDirectory = repo;
CacheDirectory = "nixos-update";
CacheDirectoryMode = "0700";
UMask = "0077";
Nice = 10;
IOSchedulingClass = "idle";