From b526538610bd4336efa80535063ac80a2e301179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 6 Nov 2022 20:28:27 +0100 Subject: build patchelf on window --- flake.lock | 19 ++++++++++++++++++- flake.nix | 24 +++++++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/flake.lock b/flake.lock index 5b90b31..3c708e8 100644 --- a/flake.lock +++ b/flake.lock @@ -15,9 +15,26 @@ "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": "nixpkgs", + "nixpkgs-mingw": "nixpkgs-mingw" } } }, diff --git a/flake.nix b/flake.nix index b398468..37806ee 100644 --- a/flake.nix +++ b/flake.nix @@ -2,8 +2,9 @@ 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 }: + outputs = { self, nixpkgs, nixpkgs-mingw }: let supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ]; @@ -16,6 +17,20 @@ 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 { @@ -95,6 +110,13 @@ packages = forAllSystems (system: { patchelf = patchelfFor nixpkgs.legacyPackages.${system}; default = self.packages.${system}.patchelf; + + patchelf-win32 = (patchelfFor (pkgsCrossForMingw system).mingw32).overrideAttrs (old: { + NIX_CFLAGS_COMPILE = "-static"; + }); + patchelf-win64 = (patchelfFor (pkgsCrossForMingw system).mingwW64).overrideAttrs (old: { + NIX_CFLAGS_COMPILE = "-static"; + }); } // nixpkgs.lib.optionalAttrs (system != "i686-linux") { patchelf-musl = patchelfFor nixpkgs.legacyPackages.${system}.pkgsMusl; }); -- cgit v1.2.1