fix infinite recursion caused by the unnecessary inspection of options #51541
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation for this change
When you have a NixOS configuration like the following:
And you test it like so:
NIXOS_CONFIG=debug-fs-user-recursion.nix nix-instantiate --eval \ --expr '(import <nixpkgs/nixos> { }).config.services.rpcbind.enable'
You will get infinite recursion:
users.extraUsers.rpc
services.rpcbind.enable
depending onconfig.boot.supportedFilesystems
boot.supportedFilesystems
based ontoposort fsBefore (attrValues config.fileSystems)
fsBefore
and usesconfig.fileSystems.<name>.options
to do sofileSystems."/".options
to refer toconfig.users.users
(extraUsers
is an alias forusers
)The original check had this:
However any file system type that allows a device to be what is also valid in a mount point (i.e. normal directories), like "bind" and "move" do, are the only ones that will ever pass the
a.mountPoint == b.device
condition. Hence the preconditionany (x: elem x [ "bind" "move" ]) b.options
should be unnecessary. Removing the precondition solves the infinite recursion issue.Then to address
# FIXME: it's incorrect to simply use hasPrefix here: "/dev/a" is not a parent of "/dev/ab"
, we could just ensure that the prefix check always end with a "/", such that hasPrefix only succeeds if its an actual parent, like so:Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)