From a1e2ef99462643050aac8f88d2084c1f06f2a526 Mon Sep 17 00:00:00 2001 From: Erin <79354991+oati@users.noreply.github.com> Date: Thu, 19 Jan 2023 12:30:16 -0600 Subject: [PATCH] remove nixpkgs re-imports --- packages/linux-asahi/default.nix | 41 +++++++++++++++----------------- packages/m1n1/default.nix | 15 ++++-------- packages/uboot-asahi/default.nix | 9 ++----- 3 files changed, 26 insertions(+), 39 deletions(-) diff --git a/packages/linux-asahi/default.nix b/packages/linux-asahi/default.nix index 941bff53..7223340b 100644 --- a/packages/linux-asahi/default.nix +++ b/packages/linux-asahi/default.nix @@ -1,18 +1,15 @@ -{ pkgs, _4KBuild ? false, withRust ? false, kernelPatches ? [ ] }: +{ lib +, callPackage +, runCommand +, writeShellScriptBin +, writeText +, linuxPackagesFor +, _4KBuild ? false +, withRust ? false +, kernelPatches ? [ ] +}: let - # we do this so the config IFDs will have the same output hash - # when evaluated in the cross system - # - # TODO: is this really necessary? the hash shoud remain the same - # as long as `hardware.asahi.pkgsSystem` is set correctly. - localPkgs = import (pkgs.path) { - crossSystem = pkgs.stdenv.buildPlatform; - localSystem = pkgs.stdenv.buildPlatform; - }; - - lib = localPkgs.lib; - parseExtraConfig = cfg: let lines = builtins.filter (s: s != "") (lib.strings.splitString "\n" cfg); perLine = line: let @@ -21,7 +18,7 @@ let "CONFIG_${builtins.elemAt kv 0}=${builtins.elemAt kv 1}"; in lib.strings.concatMapStringsSep "\n" perLine lines; - readConfig = configfile: import (localPkgs.runCommand "config.nix" { } '' + readConfig = configfile: import (runCommand "config.nix" { } '' echo "{ } // " > "$out" while IFS='=' read key val; do [ "x''${key#CONFIG_}" != "x$key" ] || continue @@ -35,12 +32,12 @@ let rustPlatform, rustfmt, rust-bindgen, ... } @ args: let configfile = if kernelPatches == [ ] then ./config else - pkgs.writeText "config" '' - ${builtins.readFile ./config} + writeText "config" '' + ${builtins.readFile ./config} - # Patches - ${lib.strings.concatMapStringsSep "\n" ({extraConfig ? "", ...}: parseExtraConfig extraConfig) kernelPatches} - ''; + # Patches + ${lib.strings.concatMapStringsSep "\n" ({extraConfig ? "", ...}: parseExtraConfig extraConfig) kernelPatches} + ''; _kernelPatches = kernelPatches; in @@ -88,7 +85,7 @@ let # is running, so we give the kernel build a rustc that wraps the real rustc # while setting the appropriate environment variable during its execution. # https://github.com/NixOS/nixpkgs/pull/209113 - (pkgs.writeShellScriptBin "rustc" '' + (writeShellScriptBin "rustc" '' NIX_LDFLAGS=-lgcc ${rustPlatform.rust.rustc}/bin/rustc "$@" '') ]; @@ -102,6 +99,6 @@ let ''; } else {}); - linux-asahi = (pkgs.callPackage linux-asahi-pkg { }); -in pkgs.recurseIntoAttrs (pkgs.linuxPackagesFor linux-asahi) + linux-asahi = (callPackage linux-asahi-pkg { }); +in lib.recurseIntoAttrs (linuxPackagesFor linux-asahi) diff --git a/packages/m1n1/default.nix b/packages/m1n1/default.nix index 2977f9a7..da666640 100644 --- a/packages/m1n1/default.nix +++ b/packages/m1n1/default.nix @@ -1,5 +1,5 @@ -{ pkgs -, stdenv +{ stdenv +, buildPackages , lib , fetchFromGitHub , python3 @@ -15,11 +15,6 @@ assert withChainloading -> rust-bin != null; let - crossPkgs = import pkgs.path { - crossSystem.system = "aarch64-linux"; - localSystem.system = pkgs.stdenv.buildPlatform.system; - }; - pyenv = python3.withPackages (p: with p; [ construct pyserial @@ -47,7 +42,7 @@ in stdenv.mkDerivation rec { nativeBuildInputs = [ dtc - crossPkgs.buildPackages.gcc + buildPackages.gcc ] ++ lib.optional withChainloading rustenv ++ lib.optional (customLogo != null) imagemagick; @@ -91,8 +86,8 @@ EOF chmod +x $script done - GCC=${crossPkgs.buildPackages.gcc} - BINUTILS=${crossPkgs.buildPackages.binutils-unwrapped} + GCC=${buildPackages.gcc} + BINUTILS=${buildPackages.binutils-unwrapped} ln -s $GCC/bin/*-gcc $out/toolchain-bin/ ln -s $GCC/bin/*-ld $out/toolchain-bin/ diff --git a/packages/uboot-asahi/default.nix b/packages/uboot-asahi/default.nix index 457e8b15..d9126314 100644 --- a/packages/uboot-asahi/default.nix +++ b/packages/uboot-asahi/default.nix @@ -1,16 +1,11 @@ { lib , fetchFromGitHub , fetchpatch -, pkgs +, buildUBoot , m1n1 }: -let - crossPkgs = import pkgs.path { - crossSystem.system = "aarch64-linux"; - localSystem.system = pkgs.stdenv.buildPlatform.system; - }; -in (crossPkgs.buildUBoot rec { +(buildUBoot rec { src = fetchFromGitHub { # tracking: https://github.com/AsahiLinux/PKGBUILDs/blob/stable/uboot-asahi/PKGBUILD owner = "AsahiLinux";