Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

add update script for macos machines #98

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion darwin-configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
./nixops/modules/ofborg/module.nix
];

system.stateVersion = 5;

nixpkgs.overlays = [
(final: prev: {
# https://github.com/NixOS/nixpkgs/pull/198306
Expand All @@ -18,7 +20,7 @@
programs.zsh.enable = true;
programs.zsh.enableCompletion = false;
programs.bash.enable = true;
programs.bash.enableCompletion = false;
programs.bash.completion.enable = false;

#services.activate-system.enable = true;
services.ofborg.enable = true;
Expand All @@ -40,6 +42,7 @@
# depending on what modules are enabled.
users.knownGroups = [ "ofborg" ];
users.knownUsers = [ "ofborg" ];
users.users.ofborg.home = "/private/var/lib/ofborg";

services.nix-daemon.enable = true;

Expand All @@ -48,6 +51,9 @@
};

nix.package = pkgs.nix;
# bash doesn't export /run/current-system/sw/bin to $PATH,
# which we need for nix-store
users.users.root.shell = "/bin/zsh";
nix.settings.max-jobs = 4;
nix.settings.cores = 1;
nix.gc.automatic = true;
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions update-macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env nix
#! nix shell --inputs-from .# nixpkgs#bashInteractive nixpkgs#openssh nixpkgs#nix nixpkgs#jq --command bash

set -euo pipefail -x

targets=(
root@208.83.1.145
root@208.83.1.173
root@208.83.1.181
root@208.83.1.186
root@208.83.1.175
)

path=$(nix flake metadata --json | jq -r '.path')

SSHOPTS=(
"-o" "ControlMaster=auto"
"-o" "ControlPath=~/.ssh/cm-%r@%h:%p"
"-o" "ControlPersist=60m"
)

# Establish persistent connections
for target in "${targets[@]}"; do
ssh "${SSHOPTS[@]}" -Nf "$target"
done

for target in "${targets[@]}"; do
NIX_SSHOPTS="${SSHOPTS[*]}" nix copy --to "ssh://$target" "$path"
done

declare -A builds
for target in "${targets[@]}"; do
ssh "${SSHOPTS[@]}" "$target" "darwin-rebuild build -L --flake $path" &
builds["$target"]=$!
done

for target in "${!builds[@]}"; do
wait "${builds["$target"]}" || {
echo "Build failed on $target"
exit 1
}
done

for target in "${targets[@]}"; do
ssh "${SSHOPTS[@]}" "$target" "darwin-rebuild switch -L --flake $path"
done

# Close the persistent connections
for target in "${targets[@]}"; do
ssh "${SSHOPTS[@]}" -O exit "$target"
done