Can't upgrade NixOS: "unexpected argument 'specialArgs'"

I’m trying to upgrade my config from 20.09 to 21.05.

What I did to upgrade

First I backed up my data and read the release notes. I renamed kdeApplications to kdeGear in a couple places, and deleted gnome3.cheese since I’m not sure it’ll work now that NixOS has moved on from Gnome 3. I think a couple custom packages I made might break because they use wafHook or stdenv.lib, but I’ll deal with that later.

Next I ran sudo nix-channel --list. That displayed nothing, so I added 21.05, via sudo nix-channel --add https://nixos.org/channels/nixos-21.05 nixos. Then I ran sudo nix-channel --update.

Last I tried to rebuild, and got this:

The error

> sudo nixos-rebuild --upgrade boot --show-trace

unpacking channels...
error: while evaluating the attribute 'config' at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/lib/eval-config.nix:64:5:
while evaluating 'evalModules' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:63:17, called from /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/lib/eval-config.nix:58:12:
while evaluating 'mapAttrsRecursiveCond' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:293:36, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:140:28:
while evaluating 'recurse' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:295:23, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:303:8:
while evaluating the attribute 'matchedOptions' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:427:14:
while evaluating 'flip' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/trivial.nix:138:16, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:395:23:
while evaluating 'byName' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:364:25, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:383:21:
while evaluating 'reverseList' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:393:17, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:132:33:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:253:37, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:128:25:
while evaluating 'filterModules' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:243:36, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:254:7:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:247:31, called from undefined position:
while evaluating the attribute 'disabled' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:225:13:
while evaluating 'loadModule' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:189:53, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:230:22:
while evaluating 'unifyModuleSyntax' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:258:34, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:195:14:
while evaluating 'applyIfFunction' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:288:29, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:195:59:
anonymous function at /etc/nixos/audio.nix:9:1 called with unexpected argument 'specialArgs', at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:312:8
building Nix...
error: while evaluating the attribute 'config' at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/lib/eval-config.nix:64:5:
while evaluating 'evalModules' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:63:17, called from /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/lib/eval-config.nix:58:12:
while evaluating 'mapAttrsRecursiveCond' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:293:36, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:140:28:
while evaluating 'recurse' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:295:23, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:303:8:
while evaluating the attribute 'matchedOptions' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:427:14:
while evaluating 'flip' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/trivial.nix:138:16, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:395:23:
while evaluating 'byName' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:364:25, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:383:21:
while evaluating 'reverseList' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:393:17, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:132:33:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:253:37, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:128:25:
while evaluating 'filterModules' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:243:36, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:254:7:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:247:31, called from undefined position:
while evaluating the attribute 'disabled' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:225:13:
while evaluating 'loadModule' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:189:53, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:230:22:
while evaluating 'unifyModuleSyntax' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:258:34, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:195:14:
while evaluating 'applyIfFunction' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:288:29, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:195:59:
anonymous function at /etc/nixos/audio.nix:9:1 called with unexpected argument 'specialArgs', at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:312:8
building the system configuration...
error: while evaluating the attribute 'config.system.build.toplevel' at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/lib/eval-config.nix:64:5:
while evaluating 'evalModules' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:63:17, called from /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/lib/eval-config.nix:58:12:
while evaluating 'mapAttrsRecursiveCond' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:293:36, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:140:28:
while evaluating 'recurse' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:295:23, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:303:8:
while evaluating the attribute 'matchedOptions' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:427:14:
while evaluating 'flip' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/trivial.nix:138:16, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:395:23:
while evaluating 'byName' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:364:25, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:383:21:
while evaluating 'reverseList' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:393:17, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:132:33:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:253:37, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:128:25:
while evaluating 'filterModules' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:243:36, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:254:7:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:247:31, called from undefined position:
while evaluating the attribute 'disabled' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:225:13:
while evaluating 'loadModule' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:189:53, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:230:22:
while evaluating 'unifyModuleSyntax' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:258:34, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:195:14:
while evaluating 'applyIfFunction' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:288:29, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:195:59:
anonymous function at /etc/nixos/audio.nix:9:1 called with unexpected argument 'specialArgs', at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:312:8

The crux of the message seems to be “anonymous function at /etc/nixos/audio.nix:9:1 called with unexpected argument ‘specialArgs’, at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:312:8”.

But the term specialArgs does not appear in my config.

Nor is it part of the musnix repository, which was my initial suspicion since I use that and the error arises in my audio.nix file.

My other hunch was that my fork of nixpkgs is out of date.

Even after running git fetch upstream it still shows the last commit on master being 23b939cfc336612fc7c5ba6213aea7966c872153 by Jan Tojnar on November 11 2020. No idea what’s going on there. (Should I use nixos-21.05 instead of master?)

I used that fork of nixpkgs to install my custom packages serialosc and libmonome. But I installed those via nix-env rather than by rebuilding, and they aren’t mentioned in the error messages above.

The issue is that the function in audio.nix is being passed specialArgs argument by the module system, which it does not accept:

The solution is to add ellipsis so that unknown arguments are ignored.


GNOME is now in gnome namespace so just changing to gnome.cheese should work.

As mentioned the solution is to add an ellipsis:
{ config, lib, pkgs, options, modulesPath, ... }:

The error from a lack of an ellipsis(an expectation for modules) surfaced because of a recent change to the module system at: https://github.com/NixOS/nixpkgs/pull/121870.

It’s building! Thank you, Jan and Pacman!

After I started the build I noticed that NixOS 21.05 is marked as 10 days overdue and only 46% complete, which is a little disconcerting, but I don’t expect to turn back now!