Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions docs/advanced/nixos.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ environment variables in camelCase:
wineExperimentalWayland = false;
# Networking mode for the container ("bridge" is default)
networking = "bridge";
# User ID for running the container (usually your own UID)
zwiftUid = "1000";
# Group ID for running the container (usually your own GID)
zwiftGid = "1000";
# GPU/device flags override (Docker: "--gpus=all", Podman/CDI: "--device=nvidia.com/gpu=all")
vgaDeviceFlag = "--device=nvidia.com/gpu=all";
# Enable debug output and verbose logging if true
Expand Down
4 changes: 0 additions & 4 deletions docs/advanced/podman-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,3 @@ From Podman 4.3 this became automatic by providing the Container UID/GID and pod
For example if the host uid/gid is 1001/1001 then we need to map the host resources from `/run/user/1001` to the container
resource `/run/user/1000` and map the user and group id's the same. This had to be done manually on the host podman start using
`--uidmap` and `--gidmap` (not covered here).

{: .warning }
Using ZWIFT_UID/GID will only work if the user starting podman has access to the `/run/user/$ZWIFT_UID` resources and does
not work the same way as in Docker so is not supported.
48 changes: 0 additions & 48 deletions docs/configuration/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ These environment variables can be used to alter the execution of the zwift bash
| [`ZWIFT_NO_GAMEMODE`](#zwift_no_gamemode) | `0` | If set to `1`, don't run game mode |
| [`WINE_EXPERIMENTAL_WAYLAND`](#wine_experimental_wayland) | `0` | If set to `1`, use native Wayland |
| [`NETWORKING`](#networking) | `bridge` | Sets the type of container networking to use |
| [`ZWIFT_UID`](#zwift_uid) | `$(id -u)` | Sets the UID that Zwift will run as |
| [`ZWIFT_GID`](#zwift_gid) | `$(id -g)` | Sets the GID that Zwift will run as |
| [`VGA_DEVICE_FLAG`](#vga_device_flag) | | Override container GPU/device flags |
| [`PRIVILEGED_CONTAINER`](#privileged_container) | `0` | If set to `1`, run the container in privileged mode |

Expand Down Expand Up @@ -657,52 +655,6 @@ Configure how the container connects to the Internet.

---

### `ZWIFT_UID`

See also [`ZWIFT_GID`](#zwift_gid).

Use this option to launch Zwift from a different user id.

| Item | Description |
|:------------------|:-------------------------|
| Allowed values | number |
| Default value | `$(id -u)` |
| Commandline usage | `ZWIFT_UID="1001" zwift` |
| Config file usage | `ZWIFT_UID="1001"` |

{: .warning }
> It is strongly discouraged to use a `ZWIFT_UID` that is different from your user uid. If you decide to do so anyway, know
> that:
>
> - It does not work with podman
> - It does not work with Wayland
> - Cats and dogs may start living together

---

### `ZWIFT_GID`

See also [`ZWIFT_UID`](#zwift_uid).

Use this option to launch Zwift from a different group id.

| Item | Description |
|:------------------|:-------------------------|
| Allowed values | number |
| Default value | `$(id -g)` |
| Commandline usage | `ZWIFT_GID="1001" zwift` |
| Config file usage | `ZWIFT_GID="1001"` |

{: .warning }
> It is strongly discouraged to use a `ZWIFT_GID` that is different from your user gid. If you decide to do so anyway, know
> that:
>
> - It does not work with podman
> - It does not work with Wayland
> - Cats and dogs may start living together

---

### `VGA_DEVICE_FLAG`

See also [Prerequisites for NVIDIA graphics cards][nvidia-prerequisites-href].
Expand Down
14 changes: 0 additions & 14 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
zwiftNoGameMode,
wineExperimentalWayland,
networking,
zwiftUid,
zwiftGid,
vgaDeviceFlag,
debug,
verbosity,
Expand Down Expand Up @@ -77,8 +75,6 @@
wineExperimentalWayland != ""
) "export WINE_EXPERIMENTAL_WAYLAND=${wineExperimentalWayland}"}
${pkgs.lib.optionalString (networking != "") "export NETWORKING='${networking}'"}
${pkgs.lib.optionalString (zwiftUid != "") "export ZWIFT_UID='${zwiftUid}'"}
${pkgs.lib.optionalString (zwiftGid != "") "export ZWIFT_GID='${zwiftGid}'"}
${pkgs.lib.optionalString (debug != "") "export DEBUG=${debug}"}
${pkgs.lib.optionalString (verbosity != "") "export VERBOSITY='${verbosity}'"}
${pkgs.lib.optionalString (vgaDeviceFlag != "") "export VGA_DEVICE_FLAG='${vgaDeviceFlag}'"}
Expand Down Expand Up @@ -201,14 +197,6 @@
type = str;
default = "";
};
zwiftUid = mkOption {
type = str;
default = "";
};
zwiftGid = mkOption {
type = str;
default = "";
};
vgaDeviceFlag = mkOption {
type = str;
default = "";
Expand Down Expand Up @@ -250,8 +238,6 @@
zwiftScreenshotsDir
zwiftOverrideResolution
networking
zwiftUid
zwiftGid
vgaDeviceFlag
verbosity
;
Expand Down
31 changes: 20 additions & 11 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
ARG DEBIAN_VERSION=trixie
ARG USER_UID=1000
ARG USER_GID=1000

FROM rust:1.90-slim AS build-runfromprocess

Expand Down Expand Up @@ -27,6 +29,8 @@ FROM debian:${DEBIAN_VERSION}-slim AS wine-base
# make sure to add "=" to the start, comment out for latest
# WINE_VERSION="=9.9~bookworm-1"
ARG DEBIAN_VERSION
ARG USER_UID
ARG USER_GID
ARG WINE_BRANCH="devel"
ARG WINE_VERSION="=9.9~${DEBIAN_VERSION}-1"
ARG WINETRICKS_VERSION=20240105
Expand All @@ -35,11 +39,9 @@ ARG WINETRICKS_VERSION=20240105
# - ca-certificates for wget and curl
# - curl used in zwift authentication script
# - gamemode for freedesktop screensaver inhibit
# - gosu for invoking scripts in entrypoint
# - libegl1 and libgl1 for GL library
# - libvulkan1 for vulkan loader library
# - procps for pgrep
# - sudo for normal user installation
# - wget for downloading winehq key
# - winbind for ntml_auth required by zwift/wine
# - xdg-utils seems to be a dependency of wayland
Expand All @@ -49,12 +51,10 @@ RUN dpkg --add-architecture i386 \
ca-certificates \
curl \
gamemode \
gosu \
libegl1 \
libgl1 \
libvulkan1 \
procps \
sudo \
wget \
winbind \
xdg-utils \
Expand All @@ -74,18 +74,27 @@ RUN wget -qO /etc/apt/trusted.gpg.d/winehq.asc https://dl.winehq.org/wine-builds
&& wget -qO /usr/local/bin/winetricks https://raw.githubusercontent.com/Winetricks/winetricks/${WINETRICKS_VERSION}/src/winetricks \
&& chmod +x /usr/local/bin/winetricks

# Create passwordless user and make nvidia libraries discoverable
RUN adduser --disabled-password --gecos '' user \
&& adduser user sudo \
&& echo '%SUDO ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
# Add audio driver config file
COPY pulse-client.conf /etc/pulse/client.conf

# Various configuration
# - Create user
# - Create runtime directory
# - Update audio driver config file
# - Make nvidia libraries discoverable
RUN addgroup --gid ${USER_GID} user \
&& adduser --uid ${USER_UID} --gid ${USER_GID} --disabled-password --comment '' user \
&& sed -i "s|/run/user/1000|/run/user/${USER_UID}|g" /etc/pulse/client.conf \
&& mkdir -p /run/user/${USER_UID} \
&& chown -R user:user /run/user/${USER_UID} \
&& echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf \
&& echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf

# Required for non-glvnd setups
# Make nvidia libraries discoverable (Required for non-glvnd setups)
ENV LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu:/usr/local/nvidia/lib:/usr/local/nvidia/lib64

# Configure audio driver
COPY pulse-client.conf /etc/pulse/client.conf
# Run as a regular user instead of root
USER user

FROM wine-base

Expand Down
28 changes: 19 additions & 9 deletions src/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ readonly XAUTHORITY="${XAUTHORITY:-}"

# Initialize script constants
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)"
ZWIFT_UID="${UID}"
ZWIFT_GID="$(id -g)"
readonly SCRIPT_DIR ZWIFT_UID ZWIFT_GID
readonly SCRIPT_DIR

# Initialize CONTAINER_TOOL: Use podman if available
msgbox info "Looking for container tool"
Expand Down Expand Up @@ -110,6 +108,10 @@ msgbox info "Image will be called ${IMAGE}"
###############################
##### Basic configuration #####

# Create array for build arguments
declare -a build_args
build_args=()

# Create array for container arguments
declare -a container_args
container_args=(
Expand All @@ -123,14 +125,22 @@ container_args=(
-e VERBOSITY="${VERBOSITY}"
-e COLORED_OUTPUT="${COLORED_OUTPUT_SUPPORTED}"
-e CONTAINER_TOOL="${CONTAINER_TOOL}"
-e ZWIFT_UID="${ZWIFT_UID}"
-e ZWIFT_GID="${ZWIFT_GID}"
)

# Initialize user ids
host_uid="${UID}"
host_gid="$(id -g)"
if [[ ${CONTAINER_TOOL} == "podman" ]]; then
# Podman maps the local user into the container as uid/gid 1000 (the container's user),
# consistent with zwift.sh. Using the host uid/gid here causes a uid mismatch at runtime.
container_args+=(--userns "keep-id:uid=1000,gid=1000")
container_uid=1000
container_args+=(--userns="keep-id:uid=1000,gid=1000")
else
container_uid="${host_uid}"
build_args+=(
--build-arg USER_UID="${host_uid}"
--build-arg USER_GID="${host_gid}"
)
fi

# Configure window manager
Expand All @@ -145,8 +155,8 @@ container_args+=(
)
if [[ -n ${XAUTHORITY} ]]; then
container_args+=(
-e XAUTHORITY="${XAUTHORITY}"
-v "${XAUTHORITY}:${XAUTHORITY}"
-e XAUTHORITY="${XAUTHORITY//${host_uid}/${container_uid}}"
-v "${XAUTHORITY}:${XAUTHORITY//${host_uid}/${container_uid}}"
)
elif command_exists xhost && xhost +local: > /dev/null; then
msgbox ok "Container X11 access provided through xhost"
Expand Down Expand Up @@ -185,7 +195,7 @@ cleanup() {
trap cleanup EXIT

msgbox info "Building image ${IMAGE}"
if ${CONTAINER_TOOL} build --force-rm -t "${BUILD_NAME}" "${SCRIPT_DIR}"; then
if ${CONTAINER_TOOL} build --force-rm "${build_args[@]}" -t "${BUILD_NAME}" "${SCRIPT_DIR}"; then
msgbox ok "Successfully built image ${IMAGE}"
else
msgbox error "Failed to build image"
Expand Down
Loading
Loading