Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Nix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nora Puchreiner
Nix
Commits
0431cf6d
Commit
0431cf6d
authored
4 years ago
by
Travis A. Everett
Browse files
Options
Downloads
Patches
Plain Diff
fix nixbld user name/uid for macOS
parent
8127094f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
scripts/bigsur-nixbld-user-migration.sh
+46
-0
46 additions, 0 deletions
scripts/bigsur-nixbld-user-migration.sh
scripts/install-darwin-multi-user.sh
+2
-0
2 additions, 0 deletions
scripts/install-darwin-multi-user.sh
scripts/install-multi-user.sh
+4
-2
4 additions, 2 deletions
scripts/install-multi-user.sh
with
52 additions
and
2 deletions
scripts/bigsur-nixbld-user-migration.sh
0 → 100755
+
46
−
0
View file @
0431cf6d
#!/usr/bin/env bash
((
NEW_NIX_FIRST_BUILD_UID
=
301
))
id_available
(){
dscl
.
list /Users UniqueID |
grep
-E
'\b'
$1
'\b'
>
/dev/null
}
change_nixbld_names_and_ids
(){
local
name uid next_id
((
next_id
=
NEW_NIX_FIRST_BUILD_UID
))
echo
"Attempting to migrate nixbld users."
echo
"Each user should change from nixbld# to _nixbld#"
echo
"and their IDs relocated to
$next_id
+"
while
read
-r
name uid
;
do
echo
" Checking
$name
(uid:
$uid
)"
# iterate for a clean ID
while
id_available
"
$next_id
"
;
do
((
next_id++
))
if
((
next_id
>=
400
))
;
then
echo
"We've hit UID 400 without placing all of your users :("
echo
"You should use the commands in this script as a starting"
echo
"point to review your UID-space and manually move the"
echo
"remaining users (or delete them, if you don't need them)."
exit
1
fi
done
if
[[
$name
==
_
*
]]
;
then
echo
" It looks like
$name
has already been renamed--skipping."
else
# first 3 are cleanup, it's OK if they aren't here
sudo
dscl
.
delete /Users/
$name
dsAttrTypeNative:_writers_passwd &>/dev/null
||
true
sudo
dscl
.
change /Users/
$name
NFSHomeDirectory
"/private/var/empty 1"
"/var/empty"
&>/dev/null
||
true
# remove existing user from group
sudo
dseditgroup
-o
edit
-t
user
-d
$name
nixbld
||
true
sudo
dscl
.
change /Users/
$name
UniqueID
$uid
$next_id
sudo
dscl
.
change /Users/
$name
RecordName
$name
_
$name
# add renamed user to group
sudo
dseditgroup
-o
edit
-t
user
-a
_
$name
nixbld
echo
"
$name
migrated to _
$name
(uid:
$next_id
)"
fi
done
< <
(
dscl
.
list /Users UniqueID |
grep
nixbld |
sort
-n
-k2
)
}
change_nixbld_names_and_ids
This diff is collapsed.
Click to expand it.
scripts/install-darwin-multi-user.sh
+
2
−
0
View file @
0431cf6d
...
...
@@ -4,6 +4,8 @@ set -eu
set
-o
pipefail
readonly
PLIST_DEST
=
/Library/LaunchDaemons/org.nixos.nix-daemon.plist
NIX_FIRST_BUILD_UID
=
"301"
NIX_BUILD_USER_NAME_TEMPLATE
=
"_nixbld%d"
dsclattr
()
{
/usr/bin/dscl
.
-read
"
$1
"
\
...
...
This diff is collapsed.
Click to expand it.
scripts/install-multi-user.sh
+
4
−
2
View file @
0431cf6d
...
...
@@ -25,7 +25,9 @@ readonly RED='\033[31m'
readonly
NIX_USER_COUNT
=
${
NIX_USER_COUNT
:-
32
}
readonly
NIX_BUILD_GROUP_ID
=
"30000"
readonly
NIX_BUILD_GROUP_NAME
=
"nixbld"
readonly
NIX_FIRST_BUILD_UID
=
"30001"
# darwin installer needs to override these
NIX_FIRST_BUILD_UID
=
"30001"
NIX_BUILD_USER_NAME_TEMPLATE
=
"nixbld%d"
# Please don't change this. We don't support it, because the
# default shell profile that comes with Nix doesn't support it.
readonly
NIX_ROOT
=
"/nix"
...
...
@@ -104,7 +106,7 @@ EOF
}
nix_user_for_core
()
{
printf
"
nixbld%d
"
"
$1
"
printf
"
$NIX_BUILD_USER_NAME_TEMPLATE
"
"
$1
"
}
nix_uid_for_core
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment