Skip to content

Instantly share code, notes, and snippets.

@TerrorJack
Created August 19, 2022 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TerrorJack/a56fc1e5f38a7f36d03f36a1967a6ba4 to your computer and use it in GitHub Desktop.
Save TerrorJack/a56fc1e5f38a7f36d03f36a1967a6ba4 to your computer and use it in GitHub Desktop.
readonly NIX_BUILD_GROUP_ID=30000
readonly NIX_BUILD_GROUP_NAME=nixbld
readonly NIX_FIRST_BUILD_UID=30001
readonly NIX_USER_COUNT=48
sudo groupadd \
-g "$NIX_BUILD_GROUP_ID" \
--system \
"$NIX_BUILD_GROUP_NAME"
for i in $(seq 1 "$NIX_USER_COUNT"); do
sudo useradd \
--home-dir /var/empty \
--comment "Nix build user $i" \
--gid "$NIX_BUILD_GROUP_ID" \
--groups "$NIX_BUILD_GROUP_NAME" \
--no-user-group \
--system \
--shell /sbin/nologin \
--uid $((NIX_FIRST_BUILD_UID + i - 1)) \
--password "!" \
"$NIX_BUILD_GROUP_NAME$i"
done
echo "build-users-group = $NIX_BUILD_GROUP_NAME" > ~/.config/nix/nix.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment