From 3bdb75a3874cd33c8f98877169d6b7fd605a44e2 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sun, 9 Apr 2023 18:38:27 -0700 Subject: [PATCH] src/default.nix: use a list of overlays rather than a single overlay This commit changes from using a single overlay to using a nixpkgs-like list of overlays chained together by `lib.composeExtensions`. --- src/default.nix | 38 ++++++++++++++++++++-------------- src/platform/am1i/default.nix | 4 ++-- src/platform/kevin/default.nix | 4 ++-- src/platform/kgpe/default.nix | 4 ++-- 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/default.nix b/src/default.nix index 35d648f..0252fe1 100644 --- a/src/default.nix +++ b/src/default.nix @@ -5,25 +5,31 @@ let nixpkgsArgs = { config.allowNonSource = false; }; nixpkgsOnBuildForBuild = pkgsFun nixpkgsArgs; - ownerboot = { hostPlatform?null, overlay }: - (lib.makeScope lib.callPackageWith (self: { - inherit lib nixpkgsOnBuildForBuild; + ownerboot = { hostPlatform?null, overlays }: let + base = final: prev: { + inherit hostPlatform; + nixpkgsOnBuildForHost = pkgsFun + (nixpkgsArgs + // (lib.optionalAttrs (final.hostPlatform!=null) { + crossSystem = final.hostPlatform; + })); - nixpkgsOnBuildForHost = pkgsFun - (nixpkgsArgs // (lib.optionalAttrs (hostPlatform!=null) { - crossSystem = hostPlatform; })); + coreboot-toolchain = final.callPackage ./coreboot-toolchain { }; - coreboot-toolchain = self.callPackage ./coreboot-toolchain { }; - - iasl_20180531 = self.nixpkgsOnBuildForBuild.callPackage ./coreboot/iasl_20180531 { }; - coreboot = self.callPackage ./coreboot { - initramfs_image = self.initramfs; + iasl_20180531 = final.nixpkgsOnBuildForBuild.callPackage ./coreboot/iasl_20180531 { }; + coreboot = final.callPackage ./coreboot { + initramfs_image = final.initramfs; }; - kernel = self.callPackage ./kernel { }; - userspace = self.callPackage ./userspace { }; - initramfs = self.callPackage ./initramfs { }; - })) - .overrideScope' overlay; + kernel = final.callPackage ./kernel { }; + userspace = final.callPackage ./userspace { }; + initramfs = final.callPackage ./initramfs { }; + }; + in + (lib.makeScope + lib.callPackageWith + (self: { inherit lib nixpkgsOnBuildForBuild; })).overrideScope' + (lib.foldl' lib.composeExtensions (_: prev: prev) ([base] ++ overlays)); + in { # one entry for each supported platform kevin = ownerboot (import ./platform/kevin { inherit lib; }); diff --git a/src/platform/am1i/default.nix b/src/platform/am1i/default.nix index 363f494..bb1478c 100644 --- a/src/platform/am1i/default.nix +++ b/src/platform/am1i/default.nix @@ -4,7 +4,7 @@ { inherit hostPlatform; - overlay = (final: prev: { + overlays = [(final: prev: { platform_name = "am1i"; @@ -35,6 +35,6 @@ cp src/mainboard/asus/am1i-a/cmos.layout $out/ ''; }); - }); + })]; } diff --git a/src/platform/kevin/default.nix b/src/platform/kevin/default.nix index 6d95f24..6ed1a06 100644 --- a/src/platform/kevin/default.nix +++ b/src/platform/kevin/default.nix @@ -36,7 +36,7 @@ let in { inherit hostPlatform; - overlay = (final: prev: { + overlays = [(final: prev: { nixpkgsOnBuildForHost = prev.nixpkgsOnBuildForBuild.pkgsCross.aarch64-multiplatform; platform_name = "kevin"; @@ -107,5 +107,5 @@ in { }; ectool = final.nixpkgsOnBuildForHost.callPackage (import ../../util/ectool { boardName = "kevin"; }) { }; - }); + })]; } diff --git a/src/platform/kgpe/default.nix b/src/platform/kgpe/default.nix index 415c1de..0b47683 100644 --- a/src/platform/kgpe/default.nix +++ b/src/platform/kgpe/default.nix @@ -5,7 +5,7 @@ { inherit hostPlatform; - overlay = (final: prev: { + overlays = [(final: prev: { platform_name = "kgpe"; @@ -70,5 +70,5 @@ cp src/mainboard/asus/kgpe-d16/cmos.default $out/ ''; }); - }); + })]; }