nixos/nix-required-mounts: fix infinite recursion with userborn (#488199)
This commit is contained in:
@@ -47,10 +47,7 @@ let
|
||||
);
|
||||
|
||||
driverPaths = [
|
||||
# opengl:
|
||||
# NOTE: Since driverLink is just a symlink, we need to include its target as well.
|
||||
pkgs.addDriverRunpath.driverLink
|
||||
config.systemd.tmpfiles.settings.graphics-driver."/run/opengl-driver"."L+".argument
|
||||
|
||||
# mesa:
|
||||
config.hardware.graphics.package
|
||||
@@ -62,7 +59,9 @@ let
|
||||
defaults = {
|
||||
nvidia-gpu.onFeatures = package.allowedPatterns.nvidia-gpu.onFeatures;
|
||||
nvidia-gpu.paths = package.allowedPatterns.nvidia-gpu.paths ++ driverPaths;
|
||||
nvidia-gpu.unsafeFollowSymlinks = false;
|
||||
# TODO: Refactor `hardware.graphics` to ease referencing the closure
|
||||
# NOTE: A naive implementation may e.g. introduce a conditional infinite recursion (https://github.com/NixOS/nixpkgs/pull/488199)
|
||||
nvidia-gpu.unsafeFollowSymlinks = true;
|
||||
};
|
||||
in
|
||||
{
|
||||
@@ -112,6 +111,7 @@ in
|
||||
lib.mkMerge [
|
||||
{ nix.settings.pre-build-hook = lib.getExe cfg.package; }
|
||||
(lib.mkIf cfg.presets.nvidia-gpu.enable {
|
||||
hardware.graphics.enable = lib.mkDefault true;
|
||||
nix.settings.system-features = cfg.allowedPatterns.nvidia-gpu.onFeatures;
|
||||
programs.nix-required-mounts.allowedPatterns = {
|
||||
inherit (defaults) nvidia-gpu;
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
nixos,
|
||||
lib,
|
||||
runCommand,
|
||||
}:
|
||||
let
|
||||
base = nixos {
|
||||
services.userborn.enable = true;
|
||||
programs.nix-required-mounts = {
|
||||
enable = true;
|
||||
presets.nvidia-gpu.enable = true;
|
||||
};
|
||||
fileSystems."/".device = "/dev/null";
|
||||
boot.loader.grub.enable = false;
|
||||
system.stateVersion = lib.trivial.release;
|
||||
};
|
||||
machine = base.extendModules {
|
||||
modules = [ { hardware.graphics.enable = true; } ];
|
||||
};
|
||||
in
|
||||
runCommand "nix-required-mounts-eval-nvidia-gpu-preset" { } ''
|
||||
echo "Successfully evaluated ${base.config.system.build.toplevel}"
|
||||
echo "Successfully evaluated ${machine.config.system.build.toplevel}"
|
||||
echo "This means that combining nix-required-mounts with userborn no longer causes infinite recursion (#488199)"
|
||||
touch $out
|
||||
''
|
||||
@@ -55,6 +55,7 @@ python3Packages.buildPythonApplication {
|
||||
inherit allowedPatterns;
|
||||
tests = {
|
||||
inherit (nixosTests) nix-required-mounts;
|
||||
eval-nvidia-gpu-preset = callPackage ./eval-test.nix { };
|
||||
};
|
||||
};
|
||||
meta = {
|
||||
|
||||
Reference in New Issue
Block a user