Skip to content

Commit a1f7aa8

Browse files
authored
Merge pull request #439 from NixOS/mingw
build patchelf on windows
2 parents 07bbf47 + efeec8d commit a1f7aa8

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

flake.lock

Lines changed: 18 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
description = "A tool for modifying ELF executables and libraries";
33

44
inputs.nixpkgs.url = "nixpkgs/nixpkgs-unstable";
5+
inputs.nixpkgs-mingw.url = "github:Mic92/nixpkgs/mingw";
56

6-
outputs = { self, nixpkgs }:
7+
outputs = { self, nixpkgs, nixpkgs-mingw }:
78

89
let
910
supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
@@ -16,6 +17,20 @@
1617
inherit version;
1718
src = self;
1819
};
20+
21+
# https://github.com/NixOS/nixpkgs/pull/199883
22+
pkgsCrossForMingw = system: (import nixpkgs-mingw {
23+
inherit system;
24+
overlays = [
25+
(final: prev: {
26+
threadsCross = {
27+
model = "win32";
28+
package = null;
29+
};
30+
})
31+
];
32+
}).pkgsCross;
33+
1934
in
2035

2136
{
@@ -63,6 +78,9 @@
6378
stdenv = nixpkgs.legacyPackages.${system}.llvmPackages_latest.libcxxStdenv;
6479
});
6580

81+
# To get mingw compiler from hydra cache
82+
inherit (self.packages.x86_64-linux) patchelf-win32 patchelf-win64;
83+
6684
release = pkgs.releaseTools.aggregate
6785
{ name = "patchelf-${self.hydraJobs.tarball.version}";
6886
constituents =
@@ -95,6 +113,13 @@
95113
packages = forAllSystems (system: {
96114
patchelf = patchelfFor nixpkgs.legacyPackages.${system};
97115
default = self.packages.${system}.patchelf;
116+
117+
patchelf-win32 = (patchelfFor (pkgsCrossForMingw system).mingw32).overrideAttrs (old: {
118+
NIX_CFLAGS_COMPILE = "-static";
119+
});
120+
patchelf-win64 = (patchelfFor (pkgsCrossForMingw system).mingwW64).overrideAttrs (old: {
121+
NIX_CFLAGS_COMPILE = "-static";
122+
});
98123
} // nixpkgs.lib.optionalAttrs (system != "i686-linux") {
99124
patchelf-musl = patchelfFor nixpkgs.legacyPackages.${system}.pkgsMusl;
100125
});

0 commit comments

Comments
 (0)