How to set .conf file in /etc

Is there a NixOS way of setting the following in configuration.nix:

DisableCapsuleUpdateOnDisk=true

in /etc/fwupd/uefi_capsule.conf

1 Like

Use environment.etc, this is what the NixOS modules use under the hood to place configuration files, too.

1 Like

Use environment.etc, this is what the NixOS modules use under the hood to place configuration files, too.

Unfortunately, it’s not that easy in this specific case.

The fwupd module links the /etc/fwupd/uefi_capsule.conf' into place from /nix/store/hashashhashhash-fwupd/etc/uefi_capsule.conf’. The module should be fixed to allow overriding all the files in there.

You might be able to do this (untested - I’m not sure mkForce works in this case):
β”Œβ”€β”€β”€β”€
β”‚ {
β”‚ environment.etc.β€œfwupd/uefi_capsule.conf”.text = lib.mkForce β€˜β€™
β”‚ [uefi_capsule]
β”‚ whatever settings you need
β”‚ β€˜β€™;
β”‚ }
└────

Hmm. Looking more closely at https://github.com/NixOS/nixpkgs/blob/e43cf1748462c81202a32b26294e9f8eefcc3462/nixos/modules/services/hardware/fwupd.nix and https://github.com/NixOS/nixpkgs/blob/e43cf1748462c81202a32b26294e9f8eefcc3462/pkgs/os-specific/linux/firmware/fwupd/default.nix, I think you’d have to edit uefi_capsule.conf by using overrideAttrs and adding/editing a step in the build (I’d probably choose to amend postPatch), then feeding that overridden fwupd derivation to services.fwupd.package.

We might want to do something like nixos/fwupd: Make daemon.conf structured by zhaofengli Β· Pull Request #195341 Β· NixOS/nixpkgs Β· GitHub for uefi_capsule.conf as well. Though until then, doing as suggested by Peter is your only option:

  environment.etc."fwupd/uefi_capsule.conf".text = lib.mkForce ''
    [uefi_capsule]
    OverrideESPMountPoint=${config.boot.loader.efi.efiSysMountPoint}
    whatever settings you need
  '';

@zeorin Editing the package with overrideAttrs will not help, as ${pkgs.fwupd}/etc/fwupd/ uefi_capsule.conf is not really used.

1 Like

Thank you very much for this. I decided to give this a try, but got an error:

error: undefined variable 'lib'

       at /nix/store/x5sds18hn8b7aia1y0bvzp4qh0s60fgs-source/system/configuration.nix:169:52:

          168|
          169|   environment.etc."fwupd/uefi_capsule.conf".text = lib.mkForce ''
             |                                                    ^
          170|     [uefi_capsule]

I’m proud to say that I figured out the solution:

environment.etc."fwupd/uefi_capsule.conf".text = pkgs.lib.mkForce ''
  [uefi_capsule]
  OverrideESPMountPoint=${config.boot.loader.efi.efiSysMountPoint}
    whatever settings you need
'';

Once again, thank you!

Right. Or alternately, you can add lib as the argument to your configuration.

2 Likes