From 6daee587912bb596597c0b71879b8e31a91bf2b3 Mon Sep 17 00:00:00 2001 From: Alexander Sosedkin Date: Sat, 17 Feb 2024 14:22:51 +0100 Subject: [PATCH] update nixpkgs; applyPatches to fix toolchain (nixpkgs!269077) --- flake.lock | 14 +++++++------- flake.nix | 4 ++-- modules/environment/login/default.nix | 2 +- modules/environment/networking.nix | 10 +++++----- overlays/lib/nixpkgs.nix | 6 +++--- pkgs/cross-compiling/compiler-rt.patch | 16 ++++++++++++++++ pkgs/cross-compiling/cross-pkgs-args.nix | 4 ++-- pkgs/cross-compiling/cross-pkgs.nix | 18 ++++++++++++++++++ pkgs/cross-compiling/libunwind.patch | 13 +++++++++++++ pkgs/cross-compiling/proot-termux.nix | 4 ++-- pkgs/cross-compiling/talloc-static.nix | 3 +-- pkgs/proot-termux/default.nix | 6 +++++- tests/on-device/config-flake-h-m.flake.nix | 8 +++++--- 13 files changed, 80 insertions(+), 28 deletions(-) create mode 100644 pkgs/cross-compiling/compiler-rt.patch create mode 100644 pkgs/cross-compiling/cross-pkgs.nix create mode 100644 pkgs/cross-compiling/libunwind.patch diff --git a/flake.lock b/flake.lock index 06a36b7..c6fe9a9 100644 --- a/flake.lock +++ b/flake.lock @@ -45,11 +45,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1664019863, - "narHash": "sha256-nXRRSPr2Jntx2hdZZMkds1fSDNUyw9N/wMtdcQ8VElU=", + "lastModified": 1708172716, + "narHash": "sha256-3M94oln0b61m3dUmLyECCA9hYAHXZEszM4saE3CmQO4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9c64b91d14268cf20ea07ea7930479a75325af9f", + "rev": "5d874ac46894c896119bce68e758e9e80bdb28f1", "type": "github" }, "original": { @@ -60,17 +60,17 @@ }, "nixpkgs-for-bootstrap": { "locked": { - "lastModified": 1686921029, - "narHash": "sha256-J1bX9plPCFhTSh6E3TWn9XSxggBh/zDD4xigyaIQBy8=", + "lastModified": 1708105575, + "narHash": "sha256-sS4AItZeUnAei6v8FqxNlm+/27MPlfoGym/TZP0rmH0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "c7ff1b9b95620ce8728c0d7bd501c458e6da9e04", + "rev": "1d1817869c47682a6bee85b5b0a6537b6c0fba26", "type": "github" }, "original": { "owner": "NixOS", "repo": "nixpkgs", - "rev": "c7ff1b9b95620ce8728c0d7bd501c458e6da9e04", + "rev": "1d1817869c47682a6bee85b5b0a6537b6c0fba26", "type": "github" } }, diff --git a/flake.nix b/flake.nix index d2e0e66..9f341f1 100644 --- a/flake.nix +++ b/flake.nix @@ -5,9 +5,9 @@ nixpkgs.url = "github:NixOS/nixpkgs"; # for bootstrap zip ball creation and proot-termux builds, we use a fixed version of nixpkgs to ease maintanence. - # head of nixos-23.05 as of 2023-06-18 + # head of nixos-23.11 as of 2024-02-17 # note: when updating nixpkgs-for-bootstrap, update store paths of proot-termux in modules/environment/login/default.nix - nixpkgs-for-bootstrap.url = "github:NixOS/nixpkgs/c7ff1b9b95620ce8728c0d7bd501c458e6da9e04"; + nixpkgs-for-bootstrap.url = "github:NixOS/nixpkgs/1d1817869c47682a6bee85b5b0a6537b6c0fba26"; home-manager = { url = "github:nix-community/home-manager"; diff --git a/modules/environment/login/default.nix b/modules/environment/login/default.nix index e51fa6c..437dff3 100644 --- a/modules/environment/login/default.nix +++ b/modules/environment/login/default.nix @@ -82,7 +82,7 @@ in environment.files = { inherit login loginInner; - prootStatic = "/nix/store/yrrs22jsl1y8niwzs2vvk0vblicr3903-proot-termux-static-aarch64-unknown-linux-android-unstable-2023-05-13"; + prootStatic = "/nix/store/42q6yf0x0ka6jxxbprmrkzimqi4rvi6d-proot-termux-static-aarch64-unknown-linux-android-unstable-2023-05-13"; }; }; diff --git a/modules/environment/networking.nix b/modules/environment/networking.nix index 1c16b0f..7820659 100644 --- a/modules/environment/networking.nix +++ b/modules/environment/networking.nix @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2023, see AUTHORS. Licensed under MIT License, see LICENSE. +# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE. # Inspired by # https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/config/networking.nix @@ -19,9 +19,9 @@ in ###### interface - options = { + options.networking = { - networking.hosts = lib.mkOption { + hosts = lib.mkOption { type = types.attrsOf (types.listOf types.str); default = { }; example = literalExpression '' @@ -35,7 +35,7 @@ in ''; }; - networking.hostFiles = lib.mkOption { + hostFiles = lib.mkOption { type = types.listOf types.path; defaultText = literalMD "Hosts from {option}`networking.hosts` and {option}`networking.extraHosts`"; example = literalExpression ''[ "''${pkgs.my-blocklist-package}/share/my-blocklist/hosts" ]''; @@ -44,7 +44,7 @@ in ''; }; - networking.extraHosts = lib.mkOption { + extraHosts = lib.mkOption { type = types.lines; default = ""; example = "192.168.0.1 lanlocalhost"; diff --git a/overlays/lib/nixpkgs.nix b/overlays/lib/nixpkgs.nix index 324f474..21674d4 100644 --- a/overlays/lib/nixpkgs.nix +++ b/overlays/lib/nixpkgs.nix @@ -3,12 +3,12 @@ { super }: let - # head of nixos-23.05 as of 2023-06-18 + # head of nixos-23.11 as of 2024-02-17 pinnedPkgsSrc = super.fetchFromGitHub { owner = "NixOS"; repo = "nixpkgs"; - rev = "c7ff1b9b95620ce8728c0d7bd501c458e6da9e04"; - sha256 = "sha256-J1bX9plPCFhTSh6E3TWn9XSxggBh/zDD4xigyaIQBy8="; + rev = "1d1817869c47682a6bee85b5b0a6537b6c0fba26"; + sha256 = "sha256-sS4AItZeUnAei6v8FqxNlm+/27MPlfoGym/TZP0rmH0="; }; in diff --git a/pkgs/cross-compiling/compiler-rt.patch b/pkgs/cross-compiling/compiler-rt.patch new file mode 100644 index 0000000..a7d9d19 --- /dev/null +++ b/pkgs/cross-compiling/compiler-rt.patch @@ -0,0 +1,16 @@ +diff --git a/pkgs/development/compilers/llvm/16/compiler-rt/default.nix b/pkgs/d +evelopment/compilers/llvm/16/compiler-rt/default.nix +index 0f15a9e12cde..a32533e5285c 100644 +--- a/pkgs/development/compilers/llvm/16/compiler-rt/default.nix ++++ b/pkgs/development/compilers/llvm/16/compiler-rt/default.nix +@@ -130,8 +130,8 @@ stdenv.mkDerivation { + # The presence of crtbegin_shared has been added and removed; it's possible + # people have added/removed it to get it working on their platforms. + # Try each in turn for now. +- ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbeginS.o +- ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtendS.o ++ #ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbeginS.o ++ #ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtendS.o + ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o + ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o + '' + lib.optionalString doFakeLibgcc '' diff --git a/pkgs/cross-compiling/cross-pkgs-args.nix b/pkgs/cross-compiling/cross-pkgs-args.nix index 7b134ab..c0c1bba 100644 --- a/pkgs/cross-compiling/cross-pkgs-args.nix +++ b/pkgs/cross-compiling/cross-pkgs-args.nix @@ -1,6 +1,6 @@ -# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE. +# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE. -{ config, nixpkgs, system }: +{ config, system }: { inherit system; diff --git a/pkgs/cross-compiling/cross-pkgs.nix b/pkgs/cross-compiling/cross-pkgs.nix new file mode 100644 index 0000000..66c29af --- /dev/null +++ b/pkgs/cross-compiling/cross-pkgs.nix @@ -0,0 +1,18 @@ +# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE. + +{ callPackage, nixpkgs, system }: + +let + args = callPackage ./cross-pkgs-args.nix { }; + pkgsCross-imported = import nixpkgs args; + pkgsCross-patched = pkgsCross-imported.applyPatches { + name = "nixpkgs-crosscompilation-patched"; + src = nixpkgs; + patches = [ + ./compiler-rt.patch + ./libunwind.patch + ]; + }; + pkgsCross = import pkgsCross-patched args; +in +pkgsCross diff --git a/pkgs/cross-compiling/libunwind.patch b/pkgs/cross-compiling/libunwind.patch new file mode 100644 index 0000000..c174614 --- /dev/null +++ b/pkgs/cross-compiling/libunwind.patch @@ -0,0 +1,13 @@ +diff --git a/pkgs/development/compilers/llvm/16/libunwind/default.nix b/pkgs/development/compilers/llvm/16/libunwind/default.nix +index 1b677a7a2c0d..6c16e869a085 100644 +--- a/pkgs/development/compilers/llvm/16/libunwind/default.nix ++++ b/pkgs/development/compilers/llvm/16/libunwind/default.nix +@@ -49,6 +49,8 @@ stdenv.mkDerivation rec { + + nativeBuildInputs = [ cmake ninja python3 ]; + ++ LDFLAGS = "-unwindlib=none"; ++ + cmakeFlags = [ + "-DLLVM_ENABLE_RUNTIMES=libunwind" + ] ++ lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF"; diff --git a/pkgs/cross-compiling/proot-termux.nix b/pkgs/cross-compiling/proot-termux.nix index 7a441a1..8bbce24 100644 --- a/pkgs/cross-compiling/proot-termux.nix +++ b/pkgs/cross-compiling/proot-termux.nix @@ -1,9 +1,9 @@ # Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE. -{ callPackage, nixpkgs, tallocStatic }: +{ callPackage, tallocStatic }: let - pkgsCross = import nixpkgs (callPackage ./cross-pkgs-args.nix { }); + pkgsCross = callPackage ./cross-pkgs.nix { }; stdenv = pkgsCross.stdenvAdapters.makeStaticBinaries pkgsCross.stdenv; in diff --git a/pkgs/cross-compiling/talloc-static.nix b/pkgs/cross-compiling/talloc-static.nix index ffb8eb3..9c7f159 100644 --- a/pkgs/cross-compiling/talloc-static.nix +++ b/pkgs/cross-compiling/talloc-static.nix @@ -1,7 +1,6 @@ # Copyright (c) 2019-2023, see AUTHORS. Licensed under MIT License, see LICENSE. { callPackage -, nixpkgs , fetchurl , python3 , pkg-config @@ -9,7 +8,7 @@ }: let - pkgsCross = import nixpkgs (callPackage ./cross-pkgs-args.nix { }); + pkgsCross = callPackage ./cross-pkgs.nix { }; in pkgsCross.stdenv.mkDerivation rec { diff --git a/pkgs/proot-termux/default.nix b/pkgs/proot-termux/default.nix index f14c4ef..51b5aa1 100644 --- a/pkgs/proot-termux/default.nix +++ b/pkgs/proot-termux/default.nix @@ -23,14 +23,18 @@ stdenv.mkDerivation { mkdir -p fake-ashmem/linux; cat > fake-ashmem/linux/ashmem.h << EOF #include #include + #include #define __ASHMEMIOC 0x77 #define ASHMEM_NAME_LEN 256 #define ASHMEM_SET_NAME _IOW(__ASHMEMIOC, 1, char[ASHMEM_NAME_LEN]) #define ASHMEM_SET_SIZE _IOW(__ASHMEMIOC, 3, size_t) #define ASHMEM_GET_SIZE _IO(__ASHMEMIOC, 4) EOF + substituteInPlace src/arch.h --replace \ + '#define HAS_LOADER_32BIT true' \ + "" + ! (grep -F '#define HAS_LOADER_32BIT' src/arch.h) ''; - buildInputs = [ talloc ]; patches = [ ./detranslate-empty.patch ]; makeFlags = [ "-Csrc" "V=1" ]; diff --git a/tests/on-device/config-flake-h-m.flake.nix b/tests/on-device/config-flake-h-m.flake.nix index c8cbce4..8a2f3e2 100644 --- a/tests/on-device/config-flake-h-m.flake.nix +++ b/tests/on-device/config-flake-h-m.flake.nix @@ -4,9 +4,11 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/release-23.11"; home-manager.url = "github:nix-community/home-manager/release-23.11"; - nix-on-droid.url = "<>"; - nix-on-droid.inputs.nixpkgs.follows = "nixpkgs"; - nix-on-droid.inputs.home-manager.follows = "home-manager"; + nix-on-droid = { + url = "<>"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.home-manager.follows = "home-manager"; + }; }; outputs = { nix-on-droid, ... }: {