Nixos-rebuild conflict: specialisation, different kernel avaliable to boot

I want to do some experiments with another kernel with stable available to boot.
So I’ve tried to create specialisation with only kernel changed, but nixos-rebuild has conflict error

What is the right way to do what I want?

$ nixos-rebuild dry-build
building the system configuration...
error: The option `boot.kernelPackages' has conflicting definition values:
- In `<unknown-file>'
- In `/etc/nixos/configuration.nix'
(use '--show-trace' to show detailed location information)

My configuration.nix related part:

	boot = {
		loader = {
			systemd-boot.enable = true;
			efi.canTouchEfiVariables = true;
		};
		kernelPackages = pkgs.linuxPackages_zen;
		supportedFilesystems = [ "ntfs" ];
	};
	specialisation = {
		"rt_kernel" = {
			inheritParentConfig = true;
			configuration = {
				boot.kernelPackages = pkgs.linuxPackages-rt_latest;
			};
		};
	};
nixos-rebuild dry-build --show-trace
$ nixos-rebuild dry-build --show-trace
building the system configuration...
error: while evaluating the attribute 'buildCommand' of the derivation 'nixos-system-nixos-21.05.4116.46251a79f75' at /nix/store/vj38s3mv3gs11dcqv5ihsasjp7gqz7j8-nixos-21.05.4116.46251a79f75/nixos/pkgs/stdenv/generic/make-derivation.nix:201:11:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:256:10, called from undefined position:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/top-level.nix:77:30, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:256:16:
while evaluating the attribute 'rt_kernel' at undefined position:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/top-level.nix:14:35, called from undefined position:
while evaluating the attribute 'config.system.build.toplevel' at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/top-level.nix:293:5:
while evaluating 'foldr' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:52:20, called from /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/top-level.nix:128:12:
while evaluating 'fold'' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:55:15, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:59:8:
while evaluating the attribute 'assertions' at undefined position:
while evaluating 'g' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:298:19, called from undefined position:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:140:72, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:301:20:
while evaluating the attribute 'value' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:525:9:
while evaluating the option `assertions':
while evaluating the attribute 'mergedValue' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:557:5:
while evaluating the attribute 'values' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:551:9:
while evaluating the attribute 'values' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:650:7:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:537:28, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:537:17:
while evaluating definitions from `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/boot/kernel.nix':
while evaluating 'dischargeProperties' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:609:25, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:538:137:
while evaluating 'dischargeProperties' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:609:25, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:615:11:
while evaluating the attribute 'content' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:693:14:
while evaluating the attribute 'boot.kernelPackages.kernel' at undefined position:
while evaluating 'g' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:298:19, called from undefined position:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:140:72, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:301:20:
while evaluating the attribute 'value' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:525:9:
while evaluating the option `boot.kernelPackages':
while evaluating 'apply' at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/boot/kernel.nix:40:15, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:518:35:
while evaluating the attribute 'mergedValue' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:557:5:
while evaluating 'mergeEqualOption' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/options.nix:137:27, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:559:59:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/options.nix:143:26, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/options.nix:143:11:
The option `boot.kernelPackages' has conflicting definition values:
- In `<unknown-file>'
- In `/etc/nixos/configuration.nix'

Possibly related issue switch to specialisation does not work · Issue #92999 · NixOS/nixpkgs · GitHub

1 Like

Related links:

search.nixos.org/options?query=specialisation

You need to give the altered version a higher priority.

  boot.kernelPackages = lib.mkForce pkgs.linuxPackages-rt_latest;
3 Likes