Skip to content

Commit b6e4af9

Browse files
committed
Fix stable channel compatibility with conditional microcode delivery
Restores `microcode-amd` replacement for NixOS <25.11 while using the `hardware.cpu.amd.microcodePackage` option on 25.11+, ensuring compatibility across channels. Closes #59
1 parent b01d140 commit b6e4af9

1 file changed

Lines changed: 33 additions & 15 deletions

File tree

flake.nix

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -148,23 +148,41 @@
148148
};
149149
};
150150

151-
config = lib.mkIf cfg.enable {
152-
warnings =
153-
lib.optional (!(builtins.elem "microcode.amd_sha_check=off" config.boot.kernelParams))
154-
"ucodenix: Kernel microcode checksum verification is active. This may prevent microcode from loading. Consider disabling it by setting `boot.kernelParams = [ \"microcode.amd_sha_check=off\" ];` in your configuration.";
155-
156-
nixpkgs.overlays = [
157-
(final: prev: {
158-
ucodenix = final.callPackage ucodenix { inherit (cfg) cpuModelId; };
159-
microcode-amd-ucodenix = final.callPackage microcode-amd-pkg {
160-
ucodenix = final.ucodenix;
161-
};
151+
config = lib.mkIf cfg.enable (
152+
let
153+
hasOverrideOption = lib.versionAtLeast (lib.versions.majorMinor lib.version) "25.11";
154+
in
155+
lib.mkMerge [
156+
{
157+
warnings =
158+
lib.optional (!(builtins.elem "microcode.amd_sha_check=off" config.boot.kernelParams))
159+
"ucodenix: Kernel microcode checksum verification is active. This may prevent microcode from loading. Consider disabling it by setting `boot.kernelParams = [ \"microcode.amd_sha_check=off\" ];` in your configuration.";
160+
161+
nixpkgs.overlays = [
162+
(final: prev: {
163+
ucodenix = final.callPackage ucodenix { inherit (cfg) cpuModelId; };
164+
microcode-amd-ucodenix = final.callPackage microcode-amd-pkg {
165+
ucodenix = final.ucodenix;
166+
};
167+
})
168+
];
169+
170+
hardware.cpu.amd.updateMicrocode = true;
171+
}
172+
173+
(lib.mkIf hasOverrideOption {
174+
hardware.cpu.amd.microcodePackage = pkgs.microcode-amd-ucodenix;
162175
})
163-
];
164176

165-
hardware.cpu.amd.updateMicrocode = true;
166-
hardware.cpu.amd.microcodePackage = pkgs.microcode-amd-ucodenix;
167-
};
177+
(lib.mkIf (!hasOverrideOption) {
178+
nixpkgs.overlays = [
179+
(final: prev: {
180+
microcode-amd = final.microcode-amd-ucodenix;
181+
})
182+
];
183+
})
184+
]
185+
);
168186

169187
imports = [
170188
(lib.mkRemovedOptionModule [ "services" "ucodenix" "cpuSerialNumber" ]

0 commit comments

Comments
 (0)