diff options
author | Jörg Thalheim <joerg@thalheim.io> | 2022-11-17 18:33:59 +0100 |
---|---|---|
committer | Jörg Thalheim <joerg@thalheim.io> | 2022-11-17 18:33:59 +0100 |
commit | 0826d9d4a83711932165865eff816c26f2423b4f (patch) | |
tree | b57d5d4e554ce09f70506352f0dbad2b61cd0f6b | |
parent | adf5c05a5e6fb8a9159ced9930f4bc809b1a4c2f (diff) | |
download | patchelf-0826d9d4a83711932165865eff816c26f2423b4f.tar.gz |
switch back to upstream nixpkgs for windows build
-rw-r--r-- | flake.lock | 25 | ||||
-rw-r--r-- | flake.nix | 25 | ||||
-rw-r--r-- | patchelf.nix | 17 |
3 files changed, 26 insertions, 41 deletions
@@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1667639549, - "narHash": "sha256-frqZKSG/933Ctwl9voSZnXDwo8CqddXcjQhnCzwNqaM=", + "lastModified": 1668650906, + "narHash": "sha256-JuiYfDO23O8oxUUOmhQflmOoJovyC5G4RjcYQMQjrRE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "cae3751e9f74eea29c573d6c2f14523f41c2821a", + "rev": "3a86856a13c88c8c64ea32082a851fefc79aa700", "type": "github" }, "original": { @@ -15,26 +15,9 @@ "type": "indirect" } }, - "nixpkgs-mingw": { - "locked": { - "lastModified": 1667761825, - "narHash": "sha256-QpgLyjLoXJzAdLJCNpjYQy7A+varW5gwvEToqggf5D8=", - "owner": "Mic92", - "repo": "nixpkgs", - "rev": "cbcbadafec4f01ea21e905aad14a493cef5fad81", - "type": "github" - }, - "original": { - "owner": "Mic92", - "ref": "mingw", - "repo": "nixpkgs", - "type": "github" - } - }, "root": { "inputs": { - "nixpkgs": "nixpkgs", - "nixpkgs-mingw": "nixpkgs-mingw" + "nixpkgs": "nixpkgs" } } }, @@ -2,9 +2,8 @@ description = "A tool for modifying ELF executables and libraries"; inputs.nixpkgs.url = "nixpkgs/nixpkgs-unstable"; - inputs.nixpkgs-mingw.url = "github:Mic92/nixpkgs/mingw"; - outputs = { self, nixpkgs, nixpkgs-mingw }: + outputs = { self, nixpkgs }: let supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ]; @@ -13,24 +12,14 @@ version = nixpkgs.lib.removeSuffix "\n" (builtins.readFile ./version); pkgs = nixpkgs.legacyPackages.x86_64-linux; - patchelfFor = pkgs: pkgs.callPackage ./patchelf.nix { + + patchelfFor = pkgs: let + # this is only + in pkgs.callPackage ./patchelf.nix { inherit version; src = self; }; - # https://github.com/NixOS/nixpkgs/pull/199883 - pkgsCrossForMingw = system: (import nixpkgs-mingw { - inherit system; - overlays = [ - (final: prev: { - threadsCross = { - model = "win32"; - package = null; - }; - }) - ]; - }).pkgsCross; - in { @@ -121,10 +110,10 @@ patchelf-musl-cross = patchelfFor pkgs.pkgsCross.musl64; patchelf-netbsd-cross = patchelfFor pkgs.pkgsCross.x86_64-netbsd; - patchelf-win32 = (patchelfFor (pkgsCrossForMingw system).mingw32).overrideAttrs (old: { + patchelf-win32 = (patchelfFor pkgs.pkgsCross.mingw32).overrideAttrs (old: { NIX_CFLAGS_COMPILE = "-static"; }); - patchelf-win64 = (patchelfFor (pkgsCrossForMingw system).mingwW64).overrideAttrs (old: { + patchelf-win64 = (patchelfFor pkgs.pkgsCross.mingwW64).overrideAttrs (old: { NIX_CFLAGS_COMPILE = "-static"; }); } // nixpkgs.lib.optionalAttrs (system != "i686-linux") { diff --git a/patchelf.nix b/patchelf.nix index fdeba6b..6e8e59d 100644 --- a/patchelf.nix +++ b/patchelf.nix @@ -1,6 +1,19 @@ -{ stdenv, autoreconfHook, version, src }: +{ stdenv, buildPackages, autoreconfHook, version, src, overrideCC }: +let + # on windows we use win32 threads to get a fully static binary + gcc = buildPackages.wrapCC (buildPackages.gcc-unwrapped.override ({ + threadsCross = { + model = "win32"; + package = null; + }; + })); -stdenv.mkDerivation { + stdenv' = if (stdenv.cc.isGNU && stdenv.targetPlatform.isWindows) then + overrideCC stdenv gcc + else + stdenv; +in +stdenv'.mkDerivation { pname = "patchelf"; inherit version src; nativeBuildInputs = [ autoreconfHook ]; |