diff --git a/devices/belkin-rt3200/default.nix b/devices/belkin-rt3200/default.nix index 574dd00..4962a87 100644 --- a/devices/belkin-rt3200/default.nix +++ b/devices/belkin-rt3200/default.nix @@ -79,11 +79,6 @@ ]; config = { kernel = { - src = pkgs.pkgsBuildBuild.fetchurl { - name = "linux.tar.gz"; - url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.137.tar.gz"; - hash = "sha256-PkdzUKZ0IpBiWe/RS70J76JKnBFzRblWcKlaIFNxnHQ="; - }; extraPatchPhase = '' ${pkgs.openwrt.applyPatches.mediatek} ''; diff --git a/devices/families/qemu.nix b/devices/families/qemu.nix index ce28d88..ccf054c 100644 --- a/devices/families/qemu.nix +++ b/devices/families/qemu.nix @@ -5,11 +5,6 @@ ]; config = { kernel = { - src = pkgs.pkgsBuildBuild.fetchurl { - name = "linux.tar.gz"; - url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.137.tar.gz"; - hash = "sha256-PkdzUKZ0IpBiWe/RS70J76JKnBFzRblWcKlaIFNxnHQ="; - }; config = { MTD = "y"; MTD_BLOCK = "y"; diff --git a/devices/gl-ar750/default.nix b/devices/gl-ar750/default.nix index 7be4c90..a7f18a6 100644 --- a/devices/gl-ar750/default.nix +++ b/devices/gl-ar750/default.nix @@ -161,12 +161,6 @@ appendDTB = true; }; kernel = { - src = pkgs.pkgsBuildBuild.fetchurl { - name = "linux.tar.gz"; - url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.137.tar.gz"; - hash = "sha256-PkdzUKZ0IpBiWe/RS70J76JKnBFzRblWcKlaIFNxnHQ="; - }; - # Mainline linux 5.19 doesn't have device-tree support for # this device or even for the SoC, so we use the extensive # OpenWrt kernel patches diff --git a/devices/gl-mt300a/default.nix b/devices/gl-mt300a/default.nix index 6659951..d972e44 100644 --- a/devices/gl-mt300a/default.nix +++ b/devices/gl-mt300a/default.nix @@ -114,11 +114,6 @@ }; kernel = { - src = pkgs.fetchurl { - name = "linux.tar.gz"; - url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.137.tar.gz"; - hash = "sha256-PkdzUKZ0IpBiWe/RS70J76JKnBFzRblWcKlaIFNxnHQ="; - }; extraPatchPhase = '' ${openwrt.applyPatches.ramips} ${openwrt.applyPatches.rt2x00} diff --git a/devices/gl-mt300n-v2/default.nix b/devices/gl-mt300n-v2/default.nix index ae12317..901bfaa 100644 --- a/devices/gl-mt300n-v2/default.nix +++ b/devices/gl-mt300n-v2/default.nix @@ -125,11 +125,6 @@ }; kernel = { - src = pkgs.fetchurl { - name = "linux.tar.gz"; - url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.137.tar.gz"; - hash = "sha256-PkdzUKZ0IpBiWe/RS70J76JKnBFzRblWcKlaIFNxnHQ="; - }; extraPatchPhase = '' ${openwrt.applyPatches.ramips} ''; diff --git a/devices/tp-archer-ax23/default.nix b/devices/tp-archer-ax23/default.nix index 64eff0f..6c6519c 100644 --- a/devices/tp-archer-ax23/default.nix +++ b/devices/tp-archer-ax23/default.nix @@ -50,11 +50,6 @@ ]; config = { kernel = { - src = pkgs.pkgsBuildBuild.fetchurl { - name = "linux.tar.gz"; - url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.137.tar.gz"; - hash = "sha256-PkdzUKZ0IpBiWe/RS70J76JKnBFzRblWcKlaIFNxnHQ="; - }; extraPatchPhase = '' ${pkgs.openwrt.applyPatches.ramips} ''; diff --git a/devices/zyxel-nwa50ax/default.nix b/devices/zyxel-nwa50ax/default.nix index 9c9b9d9..710473d 100644 --- a/devices/zyxel-nwa50ax/default.nix +++ b/devices/zyxel-nwa50ax/default.nix @@ -250,14 +250,8 @@ # IMAGE/ramboot-factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi kernel = { - src = pkgs.fetchurl { - name = "linux.tar.gz"; - url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.137.tar.gz"; - hash = "sha256-PkdzUKZ0IpBiWe/RS70J76JKnBFzRblWcKlaIFNxnHQ="; - }; extraPatchPhase = '' ${openwrt.applyPatches.ramips} - ''; config = { diff --git a/modules/kernel/default.nix b/modules/kernel/default.nix index e5431fe..373bfcc 100644 --- a/modules/kernel/default.nix +++ b/modules/kernel/default.nix @@ -6,7 +6,7 @@ { lib, pkgs, config, ...}: let inherit (lib) mkOption types ; - inherit (pkgs) liminix; + inherit (pkgs) liminix openwrt; mergeConditionals = conf : conditions : # for each key in conditions, if it is present in conf @@ -21,8 +21,8 @@ let in { options = { kernel = { - src = mkOption { type = types.path; } ; - version = mkOption { type = types.str; default = "5.15.137";} ; + src = mkOption { type = types.path; default = openwrt.kernelSrc; } ; + version = mkOption { type = types.str; default = openwrt.kernelVersion;} ; modular = mkOption { type = types.bool; default = true; diff --git a/pkgs/openwrt/default.nix b/pkgs/openwrt/default.nix index 2fb16ec..7376dd8 100644 --- a/pkgs/openwrt/default.nix +++ b/pkgs/openwrt/default.nix @@ -29,6 +29,17 @@ let ''; in { inherit src; + + # The kernel sources typically used with this version of openwrt + # You can find this in `include/kernel-5.15` or similar in the + # openwrt sources + kernelSrc = pkgsBuildBuild.fetchurl { + name = "linux.tar.gz"; + url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.137.tar.gz"; + hash = "sha256-PkdzUKZ0IpBiWe/RS70J76JKnBFzRblWcKlaIFNxnHQ="; + }; + kernelVersion = "5.15.137"; + applyPatches.ath79 = doPatch "ath79"; applyPatches.ramips = doPatch "ramips"; applyPatches.mediatek = doPatch "mediatek"; # aarch64