From accf1972618945e1b801871958f1d82e9a3db8e4 Mon Sep 17 00:00:00 2001 From: goodspark Date: Mon, 21 Apr 2025 21:14:55 -0700 Subject: [PATCH] sequoia-nixbld-user-migration: Try to recreate all missing users instead of just first contiguous set This script mostly worked for me, but the nixbld6 and nixbld7 accounts for me were still missing. Looking at the script, it seems it's because of the `until` loop in step 2. It assumes only the first contiguous set of users would have disappeared. So 6 and 7 were never restored. This just runs through all 32 users and ensures they exist. From: https://github.com/NixOS/nix/issues/10892#issuecomment-2820010714 --- scripts/sequoia-nixbld-user-migration.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/sequoia-nixbld-user-migration.sh b/scripts/sequoia-nixbld-user-migration.sh index 58b5fea64..1395aa547 100755 --- a/scripts/sequoia-nixbld-user-migration.sh +++ b/scripts/sequoia-nixbld-user-migration.sh @@ -79,18 +79,20 @@ change_nixbld_uids(){ local existing_gid name next_id user_n ((next_id=NEW_NIX_FIRST_BUILD_UID)) - ((user_n=1)) - name="$(nix_user_n "$user_n")" existing_gid="$(dsclattr "/Groups/nixbld" "PrimaryGroupID")" # we know that we have *some* nixbld users, but macOS may have # already clobbered the first few users if this system has been - # upgraded + # upgraded. just try to recreate any missing ones. echo "" - echo "Step 2: re-create missing early _nixbld# users." + echo "Step 2: re-create missing _nixbld# users." - until dscl . read "/Users/$name" &>/dev/null; do + for user_n in $(seq 1 32); do + name="$(nix_user_n "$user_n")" + if dscl . read "/Users/$name" &>/dev/null; then + continue + fi # iterate for a clean ID while id_unavailable "$next_id"; do ((next_id++))