Skip to content

Commit

Permalink
Merge pull request #439 from NixOS/mingw
Browse files Browse the repository at this point in the history
build patchelf on windows
  • Loading branch information
Mic92 authored Nov 6, 2022
2 parents 07bbf47 + efeec8d commit a1f7aa8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
19 changes: 18 additions & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 26 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" ];
Expand All @@ -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

{
Expand Down Expand Up @@ -63,6 +78,9 @@
stdenv = nixpkgs.legacyPackages.${system}.llvmPackages_latest.libcxxStdenv;
});

# To get mingw compiler from hydra cache
inherit (self.packages.x86_64-linux) patchelf-win32 patchelf-win64;

release = pkgs.releaseTools.aggregate
{ name = "patchelf-${self.hydraJobs.tarball.version}";
constituents =
Expand Down Expand Up @@ -95,6 +113,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;
});
Expand Down

0 comments on commit a1f7aa8

Please sign in to comment.