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 79156e5 commit a1e2ef9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 39 deletions.
41 changes: 19 additions & 22 deletions packages/linux-asahi/default.nix
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 "$@"
'')
];
Expand All @@ -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)

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 a1e2ef9

Please sign in to comment.