Skip to content

Commit

Permalink
remove nixpkgs re-imports
Browse files Browse the repository at this point in the history
  • Loading branch information
oati committed Jan 19, 2023
1 parent 74580e5 commit 5207acc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 38 deletions.
38 changes: 17 additions & 21 deletions packages/linux-asahi/default.nix
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
{ pkgs, _4KBuild ? false, withRust ? false, kernelPatches ? [ ] }:
{ lib
, callPackage
, runCommand
, 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
Expand All @@ -21,7 +17,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
Expand All @@ -35,12 +31,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
Expand Down Expand Up @@ -85,6 +81,6 @@ let
RUST_LIB_SRC = rustPlatform.rustLibSrc;
} 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)

15 changes: 5 additions & 10 deletions packages/m1n1/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ pkgs
, stdenv
{ stdenv
, buildPackages
, lib
, fetchFromGitHub
, python3
Expand All @@ -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
Expand Down Expand Up @@ -47,7 +42,7 @@ in stdenv.mkDerivation rec {

nativeBuildInputs = [
dtc
crossPkgs.buildPackages.gcc
buildPackages.gcc
] ++ lib.optional withChainloading rustenv
++ lib.optional (customLogo != null) imagemagick;

Expand Down Expand Up @@ -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/
Expand Down
9 changes: 2 additions & 7 deletions packages/uboot-asahi/default.nix
Original file line number Diff line number Diff line change
@@ -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";
Expand Down

0 comments on commit 5207acc

Please sign in to comment.