[solved] Nohibernate option added to kernelParams and I don't know where it comes from

I am new to NixOS and i managed to set up my Laptop based on hlissners dotfiles.
my config so far: https://github.com/stfl/dotfiles
the host is trex

I am trying to configure hibernate.
I have a swap partition and to my knowledge everything should work…

The problem seams to be the kernelParam nohibernate which is automatically added and I have no idea where it comes from.

Is there a nix command to identify where (and why) this option was added?
or is there an option to manually remove the option in my hardware-configuration.nix file?

Are you sayimg that it has been added to that file automatically? That strikes me as odd.

You shouldn’t modify it by hand, but you can override what hardware-configuration.nix sets in configuration.nix using lib.mkOverride. E.g., to turn off all kernel parameters:

boot.kernelParams = lib.mkOverride 999 [];

Or to be a little less aggressive (at least I think this works, if you get a recursion error, my bad):

boot.kernelParams = lib.mkOverride 999 (builtins.filter (p: p != "nohibernate") config.boot.kernelParams);

It would indeed be better to figure out how it ended up in your config, though. It might come from https://github.com/NixOS/nixos-hardware, which if you’re not using yet you should :slight_smile:

This is a result of enabling the security.protectKernelImage option in modules/security.nix. This will automatically set nohibernate.

2 Likes

thank you pointing me towards config.security.protectKernelImage
searching through nixpkg repo would have given me an answer. now I know another place to look. thanks.

Besides manually looking through code, is there a way trace back all the places where a given config was set? This would be a great debugging feature.

Yes, nixos-option boot.kernelParams should be able to list all the places that touched the option. It is stuck on nix 2.3 right now though so it can be a bit janky. (I realised when trying to make an example that it broke again on my setup)

1 Like

You could use nix eval or nix repl to inspect where options were declared.

$ nix eval github:stfl/dotfiles\#nixosConfigurations.trex.options.boot.kernelParams.files
[ "/nix/store/60lvjx4513hq50qnq73bjxm7cyg0bdnw-source/hosts/trex/hardware-configuration.nix" "/nix/store/1mq6ivn9y8zkjljiy66d4xjjhlhq0h3r-source/nixos/modules/system/boot/systemd.nix" "/nix/store/1mq6ivn9y8zkjljiy66d4xjjhlhq0h3r-source/nixos/modules/system/boot/kernel.nix" ]
$ nix repl                                                                               
Welcome to Nix 2.8.1. Type :? for help.

nix-repl> flake = builtins.getFlake "github:stfl/dotfiles"                      

nix-repl> flake.nixosConfigurations.trex.options.boot.kernelParams.files        
[ "/nix/store/60lvjx4513hq50qnq73bjxm7cyg0bdnw-source/hosts/trex/hardware-configuration.nix" "/nix/store/1mq6ivn9y8zkjljiy66d4xjjhlhq0h3r-source/nixos/modules/system/boot/systemd.nix" "/nix/store/1mq6ivn9y8zkjljiy66d4xjjhlhq0h3r-source/nixos/modules/system/boot/kernel.nix" ]
3 Likes