I’ve finally got my hands on this laptop. On Manjaro I could fix its audio problems following the guide here
However hdajackretask
is a gui programs that apparently can apply overrides on poweron.
Since a long term system config on nixos must be done in the config.nix,how can I override pins as the guide suggest using nixos’ module system?
What files are modified by the program?
I think I have done it once.
First you should run hdajackretask
in console.
nix run -f channel:nixos-20.09 alsaTools -c hdajackretask
Then config the card and choose install boot override
which will fail and print something like this in console.
mv: cannot move '/tmp/hda-jack-retask-33OI20/hda-jack-retask.fw' to '/lib/firmware/hda-jack-retask.fw': No such file or directory
Just grab the temporary hda-jack-retask.fw
and add this snippet into the configuration.nix
(or hardware-configuration.nix).
hardware.firmware = [ ( pkgs.writeTextDir "/lib/firmware/hda-jack-retask.fw" ( builtins.readFile ./hda-jack-retask.fw ) ) ];
Only test I have done is running nixos-rebuild build
and cheking that firmware/hda-jack-retask.fw
is present in the result. But it should work.
So I’ve built the iso however when I try to run from it the grub menu appears but it freezes once I select one of the options and if I press any button I go back to the bios menu
So I have put that line in my configuration.nix,however the audio is still broken. I know that that fix work on manjaro,however it does not fix it on Nixos.
The question is:why putting that file in /lib/firmware
would work on Manjaro? What component is reading *.fw files here?
I’ve also tried
systemd.services.asus-audio = {
wantedBy = [ "multi-user.target" ];
before = [ "multi-user.target" ];
script = "cat ${./hda-jack-retask.fw } >/sys/class/sound/hwC2D0/reconfig";
serviceConfig = {
Type = "oneshot";
Restart = "on-failure";
};
};
but,while the sservice result successful withsystemctl status
it still does not fix the audio
Ok,I’ve fixed it with
snd = "/sys/class/sound/hwC2D0";
in
{
# hardware.firmware = [ ( pkgs.writeTextDir "/lib/firmware/hda-jack-retask.fw" ( builtins.readFile ./hda-jack-retask.fw ) ) ];
systemd.services.asus-audio = {
wantedBy = [ "multi-user.target" ];
before = [ "multi-user.target" ];
script = ''
(
echo 0x14 0x90170152
echo 0x19 0x03a19020
echo 0x1e 0x90170151
)>${snd}/user_pin_configs
echo 1 > ${snd}/reconfig
'';
serviceConfig = {
Type = "oneshot";
Restart = "on-failure";
};
};
}
I’ll make a pr to nixos-hardware later
Ahh, I found out that hdajackretask needs another step: adding option for snd-hda-intel
driver.
boot.extraModprobeConfig = ''
options snd-hda-intel patch=hda-jack-retask.fw
'';
It looks familiar for me and I think a had used it too.
Inspired by Analog surround sound setup on Linux with a Realtek ALC898 sound card on the Clevo P751DM2-G · GitHub
Ok but my solution did not need to mess with modprobe.
I think later will write a module about rixing audio pins.