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/hardware.display: init module #279789
base: master
Are you sure you want to change the base?
Conversation
580d12f
to
11e9e9b
Compare
this allows us not to pass `compressFirmware = false;` inside EDID derivations as this mechanic very tricky to discover. related to NixOS#279789 related to NixOS#279739
this allows us not to pass `compressFirmware = false;` inside EDID derivations as this mechanic very tricky to discover. related to NixOS#279789
this allows us not to pass `compressFirmware = false;` inside EDID derivations as this mechanic very tricky to discover. related to NixOS#279789
this allows us not to pass `compressFirmware = false;` inside EDID derivations as this mechanic very tricky to discover. related to NixOS#279789
this allows us not to pass `compressFirmware = false;` inside EDID derivations as this mechanic very tricky to discover. related to NixOS#279789
this allows us not to pass `compressFirmware = false;` inside EDID derivations as this mechanic very tricky to discover. related to NixOS#279789
this allows us not to pass `compressFirmware = false;` inside EDID derivations as this mechanic very tricky to discover. related to NixOS#279789
this allows us not to pass `compressFirmware = false;` inside EDID derivations as this mechanic very tricky to discover. related to NixOS#279789
this allows us not to pass `compressFirmware = false;` inside EDID derivations as this mechanic very tricky to discover. related to NixOS#279789
11e9e9b
to
44b70eb
Compare
this allows us not to pass `compressFirmware = false;` inside EDID derivations as this mechanic very tricky to discover. related to NixOS#279789
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.
Works correctly with nice logging. Only nitpick i have is to document this specific handling of lib/firmware/edid
somewhere. As it might not be clear to an end user that edids are required to be put into the edid
folder to function correctly.
Yeah, I also had trouble with discovering where to put edids and how to link them together on the system, but I have no idea where to document it. |
I am not sure either. But i could see a subsection like |
At this point, why not a NixOS option that does all the right plumbing? |
192b3c7
to
7bc1197
Compare
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 have no clue about edit but looking pretty good to my naive eyes and we can probably merge this with those small cleanups.
# let | ||
# edids = (linuxhw-edid-fetcher.override { | ||
# displays = { | ||
# PG278Q_2014 = [ "PG278Q" "2014" ]; | ||
# }; | ||
# }); | ||
# in | ||
# "${edids}/lib/firmware/edid/PG278Q_2014.bin"; |
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.
# let | |
# edids = (linuxhw-edid-fetcher.override { | |
# displays = { | |
# PG278Q_2014 = [ "PG278Q" "2014" ]; | |
# }; | |
# }); | |
# in | |
# "${edids}/lib/firmware/edid/PG278Q_2014.bin"; | |
# let | |
# edids = linuxhw-edid-fetcher.override { | |
# displays.PG278Q_2014 = [ "PG278Q" "2014" ]; | |
# }; | |
# in | |
# "${edids}/lib/firmware/edid/PG278Q_2014.bin"; |
we can minimize that example a bit further, to make it easier to understand
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.
actually I added (unnecessary) 2560x1440
to make it obvious PG278Q_2014.bin
is derived from the object key, not a search path.
''} | ||
''; | ||
|
||
passthru.updateScript = nix-update-script { extraArgs = [ "--version=branch=master" ]; }; |
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.
passthru.updateScript = nix-update-script { extraArgs = [ "--version=branch=master" ]; }; | |
passthru.updateScript = nix-update-script { extraArgs = [ "--version=branch=master" ]; }; | |
test -d "$1" && test -f "$1/AnalogDisplay.md" && test -f "$1/DigitalDisplay.md" | ||
} | ||
|
||
main() { |
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.
We could just drop the main function
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 prefer to have an explicit entry point in form of main()
because:
- it's hard to follow scripts interweaving running code with function definitions
- it's a lot harder to locate where the code starts executing
I just apply this "policy" to anything larger than ~10 lines of bash, as soon as you reach it you need helper functions etc.
repo="${TMPDIR:-/tmp}/edid" | ||
log "Not running inside 'https://github.com/linuxhw/EDID', downloading content to ${repo}" | ||
if ! check_repo "$repo"; then | ||
curl -L https://github.com/linuxhw/EDID/tarball/master | tar -zx -C "${repo}" --strip-components=1 |
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.
curl -L https://github.com/linuxhw/EDID/tarball/master | tar -zx -C "${repo}" --strip-components=1 | |
curl -L https://github.com/linuxhw/EDID/tarball/HEAD | tar -zx -C "${repo}" --strip-components=1 |
just in case they ever change the default branch
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.
nice, wasn't aware of this
exit 1 | ||
fi | ||
|
||
: "${repo:="$PWD"}" |
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.
Shouldn't we rather use a tmp file for this?
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.
it's just for detecting whether current directory is already checked out repository, if it's not it downloads stuff to /tmp/edid
}; | ||
} | ||
) | ||
(lib.mkIf (cfg.edid.packages != null) { |
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.
We should probably hide this behind en enable flag. Some modules, eg in nixos-hardware might fill this and having to use mkForce to clear it, is not that nice.
@SuperSandro2000 thanks for taking interest in it, I'm currently working on a separate script for doing the runtime configuration and would LOVE to merge after I got it to work. Yesterday I updated nixos-unstable in my configs + swapped Radeon RX550 to Pro W6600 and the current script stopped working completely because kernel/
Needed to add a few additional guards against it and thought it'll be easier to develop it in my own repo then upstream it. |
62dc18b
to
0fe1957
Compare
cb0b041
to
0467e26
Compare
ok, I've created and tested in my configs |
I have issues with the latest version of the display-edid-apply script (using applyAtRuntime, as the kernel parameters is still broken). With applyWithKernelParameters false, the only log line displayed is:
In this case the edid is not applied. With applyWithKernelParameters true it ends with:
I checked the hash of the current-firmware edid.bin and it did indeed match that of the edid_override. So CHANGED remains 0, and the trigger hotplug doesn't occur. With a manual trigger hotplug, the edid is functioning. I'm really not sure what is going on here. Perhaps something odd with the kernel where it loads it, but doesn't really. |
Yeah, the kernel has major issues loading EDID files over last few weeks, just getting worse with each update. Good catch with having no |
0467e26
to
ae53a50
Compare
Never thought I would need this, but yes, I need this! |
modules-closure.sh seems to consider everything under /lib/firmware to be a kernel module, this change adds a special handling of `edid` directory, which does not contain kernel modules fixes NixOS#279739
ae53a50
to
e70276e
Compare
Seems that errors like |
Complete shot in the dark, but if you use the unmodified kernel and add |
Nope, I can't even boot with this one, sadly. |
pathsToLink = [ "/lib/firmware/edid" ]; | ||
ignoreCollisions = true; | ||
}) // { | ||
compressFirmware = false; |
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.
We shouldn't actually need compressFirmware = false;
, since the kernel is built with compressed firmware support by default. While this looks trivial either way (compression vs nixos config complexity), I still think it should be removed if it isn't needed. If it is needed, then I think that means there are other problems with how nixos is configuring the kernel.
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.
it is needed, I think code paths in kernel/drivers do not decompress EDID files or at least not properly. Don't remember the details, but i tried to investigate quite extensively (without much knowledge of C/C++ itself)
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.
But my archlinux partition is using a zstd compressed edid firmware file without issue. Using Archlinux vanilla kernel v6.8.9.arch1-2. So it isn't a problem with the kernel, but with Nixos kernel configuration.
$ cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-linux root=UUID=eb3729f4-547c-42a7-86b4-6020f9a31762 rw loglevel=3 quiet nowatchdog intel_iommu=on iommu=pt zswap.enabled=0 ibt=off amdgpu.ppfeaturemask=0xffffffff drm.edid_firmware=edid/g70nc_edid.bin
$ ls /usr/lib/firmware/edid/
g70nc_edid.bin.zst
I compressed it manually with zstd -19 g70nc_edid.bin
That's odd that commit is causing the error, since the kernel configs in that commit match what is set in my Archlinux partition (dual boot), and it loads edid_firmware (compressed) without issue. It must be failing in combination with some other options nixos is setting. |
I noticed Archlinux has this patch in their kernel, to "skip simpledrm if nvidia-drm.modeset=1 is set". It could be relevant to the issues that @jys1670 mentioned were introduced with 1ed5df1 -- if the user has an Nvidia gpu. Though, I have an AMD gpu and still get the same err=-22 when loading edid firmware. |
fixes #279739
Description of changes
While preparing a bug report for root cause of #279739 I came up with a possible way to fix it and confirmed it is indeed working.
https://github.com/NixOS/nixpkgs/blob/580d12f7dc941cad010f3295eda1ed0cb513611c/pkgs/build-support/kernel/modules-closure.sh seems to ignore any files that are not kernel modules
As a part of the discussion feedback I have created a NixOS module out of the whole thing for handling
edid
files and additional kernel-level display configuration.Things done
Using it for a few weeks in my configurations https://github.com/nazarewk-iac/nix-configs
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.