generic-linux-gpu: put systemd unit in lib/systemd

This is where unit files are expected to be, making GPU setup compatible
with things like selinux. Fixes #8438. The `resources/` directory was
kept because it is expected to be used in the future.

(cherry picked from commit a3ac4bb1f8)
This commit is contained in:
Jure Varlec 2026-01-02 11:43:32 +01:00 committed by Austin Horstman
parent 82fb7dedaa
commit 2a63d0e9d2
4 changed files with 22 additions and 17 deletions

View file

@ -18,13 +18,14 @@ stdenv.mkDerivation {
src = ./.;
patchPhase = ''
substituteInPlace non-nixos-gpu* \
--replace '@@resources@@' "$out/resources" \
--replace '@@statedir@@' '${nixStateDirectory}' \
--replace '@@env@@' "${nonNixosGpuEnv}"
--replace-quiet '@@resources@@' "$out/resources" \
--replace-quiet '@@statedir@@' '${nixStateDirectory}' \
--replace-quiet '@@systemddir@@' "$out/lib/systemd/system" \
--replace-quiet '@@env@@' "${nonNixosGpuEnv}"
'';
installPhase = ''
mkdir -p $out/{bin,resources}
mkdir -p $out/{bin,resources,lib/systemd/system}
cp non-nixos-gpu-setup $out/bin
cp non-nixos-gpu.service $out/resources
cp non-nixos-gpu.service $out/lib/systemd/system
'';
}

View file

@ -5,7 +5,7 @@ set -e
# Install the systemd service file and ensure that the store path won't be
# garbage-collected as long as it's installed.
unit_path=/etc/systemd/system/non-nixos-gpu.service
ln -sf @@resources@@/non-nixos-gpu.service "$unit_path"
ln -sf @@systemddir@@/non-nixos-gpu.service "$unit_path"
ln -sf "$unit_path" "@@statedir@@"/gcroots/non-nixos-gpu.service
systemctl daemon-reload