Using different kernel for GPUsupport errs

Hello,

I am trying to configure my system to support my old GPU (AMD R9 290X for the reference), thus I am trying to use an older linux kernel (4.9) to be able to use the amd drivers still compatible with my GPU.
After applying the following diff :

Diff between the two configurations (click to open)
diff --git a/machines/hyperion/default.nix b/machines/hyperion/default.nix
index 6a0c3e8..f593535 100644
--- a/machines/hyperion/default.nix
+++ b/machines/hyperion/default.nix
@@ -22,13 +24,26 @@
+   hardware.opengl = {
+     enable = true;
+     driSupport = true;
+     driSupport32Bit = true;
+   };

   boot = {
-    kernelPackages = pkgs.linuxPackages_latest;
+    kernelPackages = pkgs.linuxPackages_4_9.ati_drivers_x11;

and run sudo nixos-rebuild switch I get the following error message (excerpt; full log with the trace in the spoiler at the end ) :

while evaluating 'apply' at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/boot/kernel.nix:39:15, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:333:11:
attribute 'extend' missing, at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/boot/kernel.nix:39:31

Would anyone know why this happens and would have a fix for it ?

Full `sudo nixos-rebuild switch` log with trace
building Nix...
building the system configuration...
error: 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:276:5:
while evaluating 'foldr' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:39:20, called from /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/top-level.nix:140:12:
while evaluating 'fold'' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:42:15, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:46:8:
while evaluating the attribute 'assertions' at undefined position:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:75:45, called from undefined position:
while evaluating the attribute 'value' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:338:9:
while evaluating the option `assertions':
while evaluating the attribute 'isDefined' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:375:5:
while evaluating the attribute 'values' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:364:9:
while evaluating the attribute 'values' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:458:7:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:350:28, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:350:17:
while evaluating 'dischargeProperties' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:417:25, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:351:62:
while evaluating 'dischargeProperties' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:417:25, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:423:11:
while evaluating the attribute 'content' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:502:14:
while evaluating the attribute 'boot.kernelPackages.kernel' at undefined position:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:75:45, called from undefined position:
while evaluating the attribute 'value' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:338: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:39:15, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:333:11:
attribute 'extend' missing, at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/boot/kernel.nix:39:31

boot.kernelPackages should be the kernel package set and not an individual package.
I.e. you should set it to pkgs.linuxPackages_4_9

However, the derivation for ati_drivers_x11 has the following comment

This derivation requires a maximum of gcc49, Linux kernel 4.1 and xorg.xserver 1.17
and will not build or run using versions newer

We don’t have such an old kernel in nixpkgs anymore, though. So you’ll have to create a derivation for it yourself. (Or look in an old nixpkgs revision).

When you’ve got that, you can add it to boot.extraModulePackages = [ pkgs.linuxPackages_4_9.ati_drivers_x11 ]; in your config.

Thank you so much for your answer. I am sorry for the silly question. I am wondering now if it is a good idea to use those out-dated pieces of software for such small improvements. I will ponder on that.