|
1 | 1 | {
|
2 | 2 | description = "A tool for modifying ELF executables and libraries";
|
3 | 3 |
|
4 |
| - inputs.nixpkgs.url = "nixpkgs/nixos-21.05"; |
| 4 | + inputs.nixpkgs.url = "nixpkgs/nixpkgs-unstable"; |
| 5 | + inputs.nixpkgs-mingw.url = "github:Mic92/nixpkgs/mingw"; |
5 | 6 |
|
6 |
| - outputs = { self, nixpkgs }: |
| 7 | + outputs = { self, nixpkgs, nixpkgs-mingw }: |
7 | 8 |
|
8 | 9 | let
|
9 | 10 | supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
|
10 |
| - forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system); |
11 |
| - |
12 |
| - nixpkgsFor = forAllSystems (system: |
13 |
| - import nixpkgs { |
14 |
| - inherit system; |
15 |
| - overlays = [ self.overlay ]; |
16 |
| - } |
17 |
| - ); |
18 |
| - version = builtins.readFile ./version; |
19 |
| - pkgs = nixpkgsFor.${"x86_64-linux"}; |
| 11 | + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; |
| 12 | + |
| 13 | + version = nixpkgs.lib.removeSuffix "\n" (builtins.readFile ./version); |
| 14 | + pkgs = nixpkgs.legacyPackages.x86_64-linux; |
| 15 | + |
| 16 | + patchelfFor = pkgs: pkgs.callPackage ./patchelf.nix { |
| 17 | + inherit version; |
| 18 | + src = self; |
| 19 | + }; |
| 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 | + |
20 | 34 | in
|
21 | 35 |
|
22 | 36 | {
|
23 |
| - overlay = final: prev: { |
24 |
| - patchelf-new-musl = final.pkgsMusl.callPackage ./patchelf.nix { |
25 |
| - inherit version; |
26 |
| - src = self; |
27 |
| - }; |
28 |
| - patchelf-new = final.callPackage ./patchelf.nix { |
29 |
| - inherit version; |
30 |
| - src = self; |
31 |
| - }; |
| 37 | + overlays.default = final: prev: { |
| 38 | + patchelf-new-musl = patchelfFor final.pkgsMusl; |
| 39 | + patchelf-new = patchelfFor final; |
32 | 40 | };
|
33 | 41 |
|
34 | 42 | hydraJobs = {
|
|
57 | 65 | '';
|
58 | 66 | });
|
59 | 67 |
|
60 |
| - build = forAllSystems (system: nixpkgsFor.${system}.patchelf-new); |
61 |
| - build-sanitized = forAllSystems (system: nixpkgsFor.${system}.patchelf-new.overrideAttrs (old: { |
| 68 | + build = forAllSystems (system: self.packages.${system}.patchelf); |
| 69 | + build-sanitized = forAllSystems (system: self.packages.${system}.patchelf.overrideAttrs (old: { |
62 | 70 | configureFlags = [ "--with-asan " "--with-ubsan" ];
|
63 | 71 | # -Wno-unused-command-line-argument is for clang, which does not like
|
64 | 72 | # our cc wrapper arguments
|
|
67 | 75 |
|
68 | 76 | # x86_64-linux seems to be only working clangStdenv at the moment
|
69 | 77 | build-sanitized-clang = nixpkgs.lib.genAttrs [ "x86_64-linux" ] (system: self.hydraJobs.build-sanitized.${system}.override {
|
70 |
| - stdenv = nixpkgsFor.${system}.llvmPackages_latest.libcxxStdenv; |
| 78 | + stdenv = nixpkgs.legacyPackages.${system}.llvmPackages_latest.libcxxStdenv; |
71 | 79 | });
|
72 | 80 |
|
| 81 | + # To get mingw compiler from hydra cache |
| 82 | + inherit (self.packages.x86_64-linux) patchelf-win32 patchelf-win64; |
| 83 | + |
73 | 84 | release = pkgs.releaseTools.aggregate
|
74 | 85 | { name = "patchelf-${self.hydraJobs.tarball.version}";
|
75 | 86 | constituents =
|
76 | 87 | [ self.hydraJobs.tarball
|
77 | 88 | self.hydraJobs.build.x86_64-linux
|
78 | 89 | self.hydraJobs.build.i686-linux
|
| 90 | + # FIXME: add aarch64 emulation to our github action... |
| 91 | + #self.hydraJobs.build.aarch64-linux |
79 | 92 | self.hydraJobs.build-sanitized.x86_64-linux
|
| 93 | + #self.hydraJobs.build-sanitized.aarch64-linux |
80 | 94 | self.hydraJobs.build-sanitized.i686-linux
|
81 | 95 | self.hydraJobs.build-sanitized-clang.x86_64-linux
|
82 | 96 | ];
|
|
89 | 103 | build = self.hydraJobs.build.${system};
|
90 | 104 | });
|
91 | 105 |
|
92 |
| - devShell = forAllSystems (system: self.devShells.${system}.glibc); |
| 106 | + devShells = forAllSystems (system: { |
| 107 | + glibc = self.packages.${system}.patchelf; |
| 108 | + default = self.devShells.${system}.glibc; |
| 109 | + } // nixpkgs.lib.optionalAttrs (system != "i686-linux") { |
| 110 | + musl = self.packages.${system}.patchelf-musl; |
| 111 | + }); |
93 | 112 |
|
94 |
| - devShells = forAllSystems (system: |
95 |
| - { |
96 |
| - glibc = self.packages.${system}.patchelf; |
97 |
| - musl = self.packages.${system}.patchelf-musl; |
98 |
| - }); |
| 113 | + packages = forAllSystems (system: { |
| 114 | + patchelf = patchelfFor nixpkgs.legacyPackages.${system}; |
| 115 | + default = self.packages.${system}.patchelf; |
99 | 116 |
|
100 |
| - defaultPackage = forAllSystems (system: |
101 |
| - self.packages.${system}.patchelf |
102 |
| - ); |
| 117 | + # This is a good test to see if packages can be cross-compiled. It also |
| 118 | + # tests if our testsuite uses target-prefixed executable names. |
| 119 | + patchelf-musl-cross = patchelfFor nixpkgs.legacyPackages.${system}.pkgsCross.musl64; |
103 | 120 |
|
104 |
| - packages = forAllSystems (system: |
105 |
| - { |
106 |
| - patchelf = nixpkgsFor.${system}.patchelf-new; |
107 |
| - patchelf-musl = nixpkgsFor.${system}.patchelf-new-musl; |
| 121 | + patchelf-win32 = (patchelfFor (pkgsCrossForMingw system).mingw32).overrideAttrs (old: { |
| 122 | + NIX_CFLAGS_COMPILE = "-static"; |
108 | 123 | });
|
| 124 | + patchelf-win64 = (patchelfFor (pkgsCrossForMingw system).mingwW64).overrideAttrs (old: { |
| 125 | + NIX_CFLAGS_COMPILE = "-static"; |
| 126 | + }); |
| 127 | + } // nixpkgs.lib.optionalAttrs (system != "i686-linux") { |
| 128 | + patchelf-musl = patchelfFor nixpkgs.legacyPackages.${system}.pkgsMusl; |
| 129 | + }); |
109 | 130 |
|
110 | 131 | };
|
111 | 132 | }
|
0 commit comments