Something went wrong. Try again.
Monorepo for Tangled tangled.org
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435# shellcheck shell=bash# prepare the job container before the first step, as rootset -eu
# the engine gives the directories as one space-separated listread -ra dirs <<< "$TANGLED_DIRS"read -ra trees <<< "$TANGLED_TREES"mkdir -p "${dirs[@]}"
# steps run as this uid, so make a user for it if the image has none# a group or user with this id from the image is used as it isgrep -q "^[^:]*:[^:]*:$TANGLED_UID:" /etc/group || echo "tangled:x:$TANGLED_UID:" >> /etc/groupgrep -q "^[^:]*:[^:]*:$TANGLED_UID:" /etc/passwd || echo "tangled:x:$TANGLED_UID:$TANGLED_UID::$TANGLED_HOME:/bin/bash" >> /etc/passwdchown "$TANGLED_UID:$TANGLED_UID" "${dirs[@]}"
# give the step user the trees that steps write to, such as /nix and the cache volume# a tree from an earlier run is already the user's, so only change it when its top is notfor tree in "${trees[@]}"; do if [ -d "$tree" ] && [ "$(stat -c %u "$tree")" != "$TANGLED_UID" ]; then chown -R "$TANGLED_UID:$TANGLED_UID" "$tree" fidone
# let the step user boot virtual machines when the machine gives the container kvmif [ -e /dev/kvm ]; then chmod 666 /dev/kvmfi
# let the step user become root without a password, but only if the image has sudoif command -v sudo >/dev/null; then mkdir -p /etc/sudoers.d echo "#$TANGLED_UID ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/tangled chmod 440 /etc/sudoers.d/tangledfi