forked from NixOS/patchelf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
124 lines (103 loc) · 4.43 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
{
description = "A tool for modifying ELF executables and libraries";
inputs.nixpkgs.url = "nixpkgs/nixpkgs-unstable";
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
version = nixpkgs.lib.removeSuffix "\n" (builtins.readFile ./version);
pkgs = nixpkgs.legacyPackages.x86_64-linux;
patchelfFor = pkgs: let
# this is only
in pkgs.callPackage ./patchelf.nix {
inherit version;
src = self;
};
in
{
overlays.default = final: prev: {
patchelf-new-musl = patchelfFor final.pkgsMusl;
patchelf-new = patchelfFor final;
};
hydraJobs = {
tarball =
pkgs.releaseTools.sourceTarball rec {
name = "patchelf-tarball";
inherit version;
versionSuffix = ""; # obsolete
src = self;
preAutoconf = "echo ${version} > version";
postDist = ''
cp README.md $out/
echo "doc readme $out/README.md" >> $out/nix-support/hydra-build-products
'';
};
coverage =
(pkgs.releaseTools.coverageAnalysis {
name = "patchelf-coverage";
src = self.hydraJobs.tarball;
lcovFilter = ["*/tests/*"];
}).overrideAttrs (old: {
preCheck = ''
# coverage cflag breaks this target
NIX_CFLAGS_COMPILE=''${NIX_CFLAGS_COMPILE//--coverage} make -C tests phdr-corruption.so
'';
});
build = forAllSystems (system: self.packages.${system}.patchelf);
build-sanitized = forAllSystems (system: self.packages.${system}.patchelf.overrideAttrs (old: {
configureFlags = [ "--with-asan " "--with-ubsan" ];
# -Wno-unused-command-line-argument is for clang, which does not like
# our cc wrapper arguments
CFLAGS = "-Werror -Wno-unused-command-line-argument";
}));
# x86_64-linux seems to be only working clangStdenv at the moment
build-sanitized-clang = nixpkgs.lib.genAttrs [ "x86_64-linux" ] (system: self.hydraJobs.build-sanitized.${system}.override {
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 =
[ self.hydraJobs.tarball
self.hydraJobs.build.x86_64-linux
self.hydraJobs.build.i686-linux
# FIXME: add aarch64 emulation to our github action...
#self.hydraJobs.build.aarch64-linux
self.hydraJobs.build-sanitized.x86_64-linux
#self.hydraJobs.build-sanitized.aarch64-linux
self.hydraJobs.build-sanitized.i686-linux
self.hydraJobs.build-sanitized-clang.x86_64-linux
];
meta.description = "Release-critical builds";
};
};
checks = forAllSystems (system: {
build = self.hydraJobs.build.${system};
});
devShells = forAllSystems (system: {
glibc = self.packages.${system}.patchelf;
default = self.devShells.${system}.glibc;
} // nixpkgs.lib.optionalAttrs (system != "i686-linux") {
musl = self.packages.${system}.patchelf-musl;
});
packages = forAllSystems (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
patchelf = patchelfFor pkgs;
default = self.packages.${system}.patchelf;
# This is a good test to see if packages can be cross-compiled. It also
# tests if our testsuite uses target-prefixed executable names.
patchelf-musl-cross = patchelfFor pkgs.pkgsCross.musl64;
patchelf-netbsd-cross = patchelfFor pkgs.pkgsCross.x86_64-netbsd;
patchelf-win32 = (patchelfFor pkgs.pkgsCross.mingw32).overrideAttrs (old: {
NIX_CFLAGS_COMPILE = "-static";
});
patchelf-win64 = (patchelfFor pkgs.pkgsCross.mingwW64).overrideAttrs (old: {
NIX_CFLAGS_COMPILE = "-static";
});
} // nixpkgs.lib.optionalAttrs (system != "i686-linux") {
patchelf-musl = patchelfFor nixpkgs.legacyPackages.${system}.pkgsMusl;
});
};
}