mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-04 08:01:02 +01:00
generic-linux-gpu: add module
This commit is contained in:
parent
066874efb5
commit
193e44d316
10 changed files with 332 additions and 1 deletions
30
modules/targets/generic-linux/gpu/setup/default.nix
Normal file
30
modules/targets/generic-linux/gpu/setup/default.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
lib,
|
||||
stdenv,
|
||||
nixStateDirectory,
|
||||
nonNixosGpuEnv,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "non-nixos-gpu";
|
||||
|
||||
meta = {
|
||||
description = "GPU driver setup for Nix on non-NixOS Linux systems";
|
||||
homepage = "https://github.com/exzombie/non-nixos-gpu";
|
||||
license = lib.licenses.mit;
|
||||
mainProgram = "non-nixos-gpu-setup";
|
||||
};
|
||||
|
||||
src = ./.;
|
||||
patchPhase = ''
|
||||
substituteInPlace non-nixos-gpu* \
|
||||
--replace '@@resources@@' "$out/resources" \
|
||||
--replace '@@statedir@@' '${nixStateDirectory}' \
|
||||
--replace '@@env@@' "${nonNixosGpuEnv}"
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out/{bin,resources}
|
||||
cp non-nixos-gpu-setup $out/bin
|
||||
cp non-nixos-gpu.service $out/resources
|
||||
'';
|
||||
}
|
||||
13
modules/targets/generic-linux/gpu/setup/non-nixos-gpu-setup
Executable file
13
modules/targets/generic-linux/gpu/setup/non-nixos-gpu-setup
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
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 "$unit_path" "@@statedir@@"/gcroots/non-nixos-gpu.service
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable non-nixos-gpu.service
|
||||
systemctl restart non-nixos-gpu.service
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=GPU driver setup for Nix on non-NixOS Linux systems
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=ln -nsf @@env@@ /run/opengl-driver
|
||||
RemainAfterExit=yes
|
||||
Loading…
Add table
Add a link
Reference in a new issue