From 877428c2fe102f5771c76cb13a97989be5174d57 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Wed, 18 Sep 2024 14:07:49 +0200 Subject: [PATCH] Only save kernel and opensbi build inputs --- flake.nix | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/flake.nix b/flake.nix index d4236b6..af50ba0 100644 --- a/flake.nix +++ b/flake.nix @@ -8,6 +8,16 @@ let system = "x86_64-linux"; nixosSystem = import (nixpkgs + "/nixos/lib/eval-config.nix"); + buildRoots = { pkgs, save }: + let + buildInner = { package, attr }: + if (attr == "") + then pkgs.linkFarmFromDrvs "${package.name}" [ package ] + else pkgs.linkFarmFromDrvs "${package.name}.${attr}" package.${attr}; + in pkgs.linkFarmFromDrvs "top-level" (pkgs.lib.mapCartesianProduct buildInner { + package = save; + attr = [ "" "buildInputs" "nativeBuildInputs" ]; + }); in { #overlay = import ./overlay.nix; nixosConfigurations = { @@ -100,17 +110,7 @@ nixosconf = self.nixosConfigurations.lagarto-ox; syspkgs = nixosconf.pkgs; build = nixosconf.config.system.build; - - buildRoots = savePkgs: - let - pkgs = syspkgs; - buildInner = { package, attr }: pkgs.linkFarmFromDrvs "${package.name}.${attr}" package.${attr}; - in pkgs.linkFarmFromDrvs "top-level" (pkgs.lib.mapCartesianProduct buildInner { - package = savePkgs; - attr = [ "buildInputs" "nativeBuildInputs" ]; - }); - - in syspkgs.mkShell { + in syspkgs.mkShell rec { pname = "lagarto-ox-shell"; TOPLEVEL = build.toplevel; OPENSBI = syspkgs.opensbi; @@ -120,7 +120,7 @@ UBOOT_ENV = syspkgs.uboot-env; BITSTREAM = syspkgs.bitstream; BOOTROM = syspkgs.bootrom; - GCROOT = buildRoots [ build.toplevel build.kernel ]; + GCROOT = buildRoots { pkgs = syspkgs; save = [ KERNEL OPENSBI ]; }; shellHook = '' echo "Here are the current system pieces:" echo " TOPLEVEL = $TOPLEVEL" @@ -136,9 +136,13 @@ }; devShells.x86_64-linux.lagarto-ox-rd = - self.outputs.devShells.x86_64-linux.lagarto-ox.overrideAttrs (old:{ + let + nixosconf = self.nixosConfigurations.lagarto-ox; + syspkgs = nixosconf.pkgs; + in self.outputs.devShells.x86_64-linux.lagarto-ox.overrideAttrs (old:{ TOPLEVEL = ""; ROOTFS = ""; + GCROOT = buildRoots { pkgs = syspkgs; save = [ old.OPENSBI ]; }; }); devShells.x86_64-linux.default =