mirror of
https://github.com/nix-community/home-manager.git
synced 2026-01-11 01:19:32 +08:00
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.
This commit is contained in:
committed by
Austin Horstman
parent
47db0fde35
commit
a3ac4bb1f8
@@ -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
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -39,11 +39,12 @@ in
|
||||
setupScript="$TESTED/home-path/bin/non-nixos-gpu-setup"
|
||||
assertFileExists "$setupScript"
|
||||
|
||||
# Find the resources directory
|
||||
resourcesPath=$(grep -oP '/nix/store/[^/]+-non-nixos-gpu/resources' "$setupScript" | head -1)
|
||||
# Find the service file
|
||||
storePath="$(dirname "$(readlink "''${setupScript}")")"/../
|
||||
servicePath="$storePath/lib/systemd/system/non-nixos-gpu.service"
|
||||
|
||||
# Extract the GPU environment path
|
||||
envPath=$(grep -oP '/nix/store/[^/]+-non-nixos-gpu' "$resourcesPath/non-nixos-gpu.service" | head -1)
|
||||
envPath=$(grep -oP '/nix/store/[^/]+-non-nixos-gpu' "$servicePath" | head -1)
|
||||
|
||||
if [[ -z "$envPath" ]]; then
|
||||
fail "Could not find GPU environment path in service file"
|
||||
|
||||
@@ -11,19 +11,22 @@
|
||||
assertFileExists "$setupScript"
|
||||
assertFileIsExecutable "$setupScript"
|
||||
|
||||
# Find and check the resources directory
|
||||
resourcesPath=$(grep -oP '/nix/store/[^/]+-non-nixos-gpu/resources' "$setupScript" | head -1)
|
||||
assertDirectoryExists "$resourcesPath"
|
||||
|
||||
# Check that gcroots dir was set
|
||||
cat "$setupScript"
|
||||
assertFileRegex "$setupScript" ' "/custom/state/directory"/gcroots'
|
||||
|
||||
serviceFile="$resourcesPath/non-nixos-gpu.service"
|
||||
assertFileExists "$serviceFile"
|
||||
|
||||
# Check that no placeholders remain
|
||||
assertFileNotRegex "$serviceFile" '@@[^@]\+@@'
|
||||
assertFileNotRegex "$setupScript" '@@[^@]\+@@'
|
||||
|
||||
# Check that expected files are present and free of placeholders
|
||||
storePath="$(dirname "$(readlink "''${setupScript}")")"/../
|
||||
expectedFiles=(
|
||||
lib/systemd/system/non-nixos-gpu.service
|
||||
)
|
||||
|
||||
for f in "''${expectedFiles[@]}"; do
|
||||
assertFileExists "$storePath/$f"
|
||||
assertFileNotRegex "$storePath/$f" '@@[^@]\+@@'
|
||||
done
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user