nixos/nix-required-mounts: fix infinite recursion with userborn

This commit is contained in:
Cameron Smith
2026-02-12 01:20:56 -05:00
parent fef9403a3e
commit 02b74722d8
3 changed files with 27 additions and 4 deletions
@@ -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
{
@@ -0,0 +1,23 @@
{
nixos,
lib,
runCommand,
}:
let
machine = nixos {
services.userborn.enable = true;
hardware.graphics.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;
};
in
runCommand "nix-required-mounts-eval-nvidia-gpu-preset" { } ''
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 = {