-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/config/sysfs: init module #391329
base: master
Are you sure you want to change the base?
nixos/config/sysfs: init module #391329
Conversation
09c76cf
to
c1a036b
Compare
The NixOS manual build failure appears to be unrelated to this change. I am able to build the manual locally without any issues: |
4919977
to
cd2a1b7
Compare
15061d8
to
8461f59
Compare
4f517c7
to
ebfe568
Compare
One issue here, is that a lot of sysfs paths depend on kernel modules being loaded, which may happen at a later time. I wonder if we'd want to support something like that? Currently the module in this PR will only work for sysfs paths that are present at the time systemd-tmpfiles runs. |
boot.kernel.sysfs = lib.mkOption { | ||
type = lib.types.submodule { | ||
freeformType = lib.types.attrsOf sysfsAttrs // { | ||
description = "nested attribute set of null or sysfs attribute values"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
types have descriptions? That's new to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description is usually generated automatically, but due to the nesting this would lead to an infinite recursion. I therefore override the description
attribute and describe the type manually.
This description is included in the generated option documentation.
}; | ||
}; | ||
|
||
description = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if that will display properly on search.nxios.org because of its length.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a conventional upper limit on the description length?
I could perhaps elaborate on the option in a section of the NixOS manual and refer to it in this description.
sysctl has the same problem. I usually work around it by loading the kernel module already in the initrd. |
Instead of relying on |
ebfe568
to
9f0a15f
Compare
I have come up with a mostly working solution based on |
9f0a15f
to
6391a14
Compare
Unable to find an easy way to escape glob patterns for use in a shell script, I decided to just spawn an individual instance of |
6391a14
to
add7c3f
Compare
I reduced the number of individual services by using unit templates and instances. |
This module introduces a config option
boot.kernel.sysfs
, which permits setting of sysfs parameters.The configuration option accepts a nested attribute set of sysfs path components with arbitrary values, for example:
The options will be applied through systemd path units watching the individual files or glob patterns and writing the configured value through a small service using systemd-tmpfiles once they exist.
The supplied NixOS test checks if configured parameters are actually applied.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.