I wanted to add a library in package zoom-us, so I tried to use overrideAttrs to edit the package’s config. However, nixos-rebuild keeps showing this error message:
error: cannot coerce a set to a string
at /etc/nixos/configuration.nix:302:11:
301| (zoom-us.overrideAttrs (old: {
302| srcs = {
| ^
303| version = "5.8.4.210";
(use '--show-trace' to show detailed location information)
This is the part of my configuration.nix which has this issue.
The function overrideAttrs allows overriding the attribute set passed to a stdenv.mkDerivation call, producing a new derivation based on the original one.
The attributes other than the special ones are passed to builtins.derivations. Those attributes are then passed as environment variables to the builder as follows^1:
Strings and numbers are just passed verbatim.
A path (e.g., …/foo/sources.tar) causes the referenced file to be copied to the store; its location in the store is put in the environment variable. The idea is that all sources should reside in the Nix store, since all inputs to a derivation should reside in the Nix store.
A derivation causes that derivation to be built prior to the present derivation; its default output path is put in the environment variable.
Lists of the previous types are also allowed. They are simply concatenated, separated by spaces.
true is passed as the string 1, false and null are passed as an empty string.
Note that it is not possible to pass an attribute set as an environment variable to the builder, which is the source of the error you are getting:
The variable you are trying to override, srcs, is in a let expression.
It is an internal variable that is used to get the correct src value for the current platform using this expression:
src = srcs.${stdenv.hostPlatform.system};
Since it is a variable in a let expression instead of an attribute passed to mkDerivation, it can’t be modified with overrideAttrs. You would get the same error if you used any other name instead of srcs inside the overrideAttrs.