From 313fa9dc99b2839cfee4dd2bcc6ce3e621466901 Mon Sep 17 00:00:00 2001 From: Val Packett Date: Tue, 16 Sep 2025 23:56:57 -0300 Subject: [PATCH] nixos/top-level: fix cutoffPackages without initialRamdisk In systems without initrd (e.g. containers) that also use system.replaceDependencies, we'd get: error: attribute 'initialRamdisk' missing at /nix/store/8vfhnwmmzqqzy97q9c5m4bzyaqqf63zy-source/nixos/modules/system/activation/top-level.nix:286:21: 285| cutoffPackages = mkOption { 286| default = [ config.system.build.initialRamdisk ]; | ^ Make that initialRamdisk reference conditional on the initrd being enabled. --- nixos/modules/system/activation/top-level.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix index 875e2d5410b3..9d33c4a79708 100644 --- a/nixos/modules/system/activation/top-level.nix +++ b/nixos/modules/system/activation/top-level.nix @@ -283,8 +283,8 @@ in }; cutoffPackages = mkOption { - default = [ config.system.build.initialRamdisk ]; - defaultText = literalExpression "[ config.system.build.initialRamdisk ]"; + default = lib.optionals config.boot.initrd.enable [ config.system.build.initialRamdisk ]; + defaultText = literalExpression "lib.optionals config.boot.initrd.enable [ config.system.build.initialRamdisk ]"; type = types.listOf types.package; description = '' Packages to which no replacements should be applied.