Author SHA1 Message Date
Zhaofeng Li 3c67bdf688 ci: Activate with darwin-rebuild 2025-03-29 14:34:02 -06:00
4 changed files with 27 additions and 6 deletions
+5
View File
@@ -29,6 +29,11 @@ jobs:
printf 'run\tprivate/var/run\n' | sudo tee -a /etc/synthetic.conf
sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -t || true
- name: Set up nix-homebrew CI
run: |
sudo touch /etc/nix-homebrew-ci
sudo mv /etc/nix/nix.conf{,.before-nix-darwin}
- name: Migrate existing Homebrew installation (imperative taps)
run: |
sudo rm /etc/bashrc
+11 -5
View File
@@ -3,6 +3,11 @@ set -euo pipefail
DIR=$(dirname $0)
real_nix="$(type -P nix)"
nix() {
"${real_nix}" --extra-experimental-features "nix-command flakes" "$@"
}
if [[ "$#" != "1" ]]; then
>&2 echo "Usage: $0 [example]"
exit 1
@@ -12,11 +17,12 @@ example="$1"
system="$(nix eval --raw --impure --expr 'builtins.currentSystem')"
>&2 echo "System: ${system}"
systemProfile="$(nix build "./${DIR}/..#ci.${system}.${example}.system" -L --no-link --print-out-paths)"
>&2 echo "Built $systemProfile"
flakeDarwinAttr="${system}.${example}"
sudo rm "/etc/nix/nix.conf"
sudo "$systemProfile/activate"
"$systemProfile/activate-user"
darwinRebuild="$(nix build ".#darwinConfigurations.${flakeDarwinAttr}.config.system.build.darwin-rebuild" -L --no-link --print-out-paths)/bin/darwin-rebuild"
>&2 echo "Built $darwinRebuild"
set -x
"$darwinRebuild" switch --flake ".#${flakeDarwinAttr}" -L -v --option extra-experimental-features "nix-command flakes"
# vim: set et ts=2 sw=2:
+10
View File
@@ -4,6 +4,13 @@
let
inherit (pkgs) lib system;
checkCIMarker = ''
if [[ ! -e /etc/nix-homebrew-ci ]]; then
>&2 echo "[!!] This configuration is only intended for nix-homebrew CI"
>&2 echo "[!!] Refusing to activate since it will likely brick your machine"
exit 1
fi
'';
makeProfile = example: nix-darwin.lib.darwinSystem {
inherit system pkgs;
modules = [
@@ -15,6 +22,9 @@ let
nix-homebrew = {
user = lib.mkForce "runner";
};
system.activationScripts.preActivation.text = lib.mkBefore checkCIMarker;
system.activationScripts.preUserActivation.text = lib.mkBefore checkCIMarker;
}
];
};
+1 -1
View File
@@ -34,7 +34,7 @@
BREW_SRC = brew-src;
});
ci = forAllSystems (pkgs: import ./ci (inputs // {
darwinConfigurations = forAllSystems (pkgs: import ./ci (inputs // {
inherit pkgs;
}));