Skip to content

Commit fe5819e

Browse files
authored
Merge pull request #602 from obsidiansystems/nixfmt
Format Nix code
2 parents a4b21a9 + 06beb68 commit fe5819e

File tree

4 files changed

+130
-96
lines changed

4 files changed

+130
-96
lines changed

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Manual nixfmt run
2+
706478750fc8574ed816ef746d3ad3790b2ea66a

default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
(import (fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) {
1+
(import (fetchTarball "https://github.com/edolstra/flake-compat/archive/master.tar.gz") {
22
src = ./.;
33
}).defaultNix

flake.nix

Lines changed: 109 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,29 @@
33

44
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
55

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

89
let
9-
supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
10+
supportedSystems = [
11+
"x86_64-linux"
12+
"i686-linux"
13+
"aarch64-linux"
14+
];
1015
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
1116

1217
version = nixpkgs.lib.removeSuffix "\n" (builtins.readFile ./version);
1318
pkgs = nixpkgs.legacyPackages.x86_64-linux;
1419

15-
16-
patchelfFor = pkgs: let
17-
# this is only
18-
in pkgs.callPackage ./patchelf.nix {
19-
inherit version;
20-
src = self;
21-
};
20+
patchelfFor =
21+
pkgs:
22+
let
23+
# this is only
24+
in
25+
pkgs.callPackage ./patchelf.nix {
26+
inherit version;
27+
src = self;
28+
};
2229

2330
in
2431

@@ -29,101 +36,119 @@
2936
};
3037

3138
hydraJobs = {
32-
tarball =
33-
pkgs.releaseTools.sourceTarball rec {
34-
name = "patchelf-tarball";
35-
inherit version;
36-
versionSuffix = ""; # obsolete
37-
src = self;
38-
preAutoconf = "echo ${version} > version";
39-
40-
# portable configure shouldn't have a shebang pointing to the nix store
41-
postConfigure = ''
42-
sed -i '1s|^.*$|#!/bin/sh|' ./configure
43-
'';
44-
postDist = ''
45-
cp README.md $out/
46-
echo "doc readme $out/README.md" >> $out/nix-support/hydra-build-products
47-
'';
48-
};
39+
tarball = pkgs.releaseTools.sourceTarball rec {
40+
name = "patchelf-tarball";
41+
inherit version;
42+
versionSuffix = ""; # obsolete
43+
src = self;
44+
preAutoconf = "echo ${version} > version";
45+
46+
# portable configure shouldn't have a shebang pointing to the nix store
47+
postConfigure = ''
48+
sed -i '1s|^.*$|#!/bin/sh|' ./configure
49+
'';
50+
postDist = ''
51+
cp README.md $out/
52+
echo "doc readme $out/README.md" >> $out/nix-support/hydra-build-products
53+
'';
54+
};
4955

5056
coverage =
5157
(pkgs.releaseTools.coverageAnalysis {
5258
name = "patchelf-coverage";
5359
src = self.hydraJobs.tarball;
54-
lcovFilter = ["*/tests/*"];
55-
}).overrideAttrs (old: {
56-
preCheck = ''
57-
# coverage cflag breaks this target
58-
NIX_CFLAGS_COMPILE=''${NIX_CFLAGS_COMPILE//--coverage} make -C tests phdr-corruption.so
59-
'';
60-
});
60+
lcovFilter = [ "*/tests/*" ];
61+
}).overrideAttrs
62+
(old: {
63+
preCheck = ''
64+
# coverage cflag breaks this target
65+
NIX_CFLAGS_COMPILE=''${NIX_CFLAGS_COMPILE//--coverage} make -C tests phdr-corruption.so
66+
'';
67+
});
6168

6269
build = forAllSystems (system: self.packages.${system}.patchelf);
63-
build-sanitized = forAllSystems (system: self.packages.${system}.patchelf.overrideAttrs (old: {
64-
configureFlags = [ "--with-asan " "--with-ubsan" ];
65-
# -Wno-unused-command-line-argument is for clang, which does not like
66-
# our cc wrapper arguments
67-
CFLAGS = "-Werror -Wno-unused-command-line-argument";
68-
}));
70+
build-sanitized = forAllSystems (
71+
system:
72+
self.packages.${system}.patchelf.overrideAttrs (old: {
73+
configureFlags = [
74+
"--with-asan "
75+
"--with-ubsan"
76+
];
77+
# -Wno-unused-command-line-argument is for clang, which does not like
78+
# our cc wrapper arguments
79+
CFLAGS = "-Werror -Wno-unused-command-line-argument";
80+
})
81+
);
6982

7083
# x86_64-linux seems to be only working clangStdenv at the moment
71-
build-sanitized-clang = nixpkgs.lib.genAttrs [ "x86_64-linux" ] (system: self.hydraJobs.build-sanitized.${system}.override {
72-
stdenv = nixpkgs.legacyPackages.${system}.llvmPackages_latest.libcxxStdenv;
73-
});
84+
build-sanitized-clang = nixpkgs.lib.genAttrs [ "x86_64-linux" ] (
85+
system:
86+
self.hydraJobs.build-sanitized.${system}.override {
87+
stdenv = nixpkgs.legacyPackages.${system}.llvmPackages_latest.libcxxStdenv;
88+
}
89+
);
7490

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

78-
release = pkgs.releaseTools.aggregate
79-
{ name = "patchelf-${self.hydraJobs.tarball.version}";
80-
constituents =
81-
[ self.hydraJobs.tarball
82-
self.hydraJobs.build.x86_64-linux
83-
self.hydraJobs.build.i686-linux
84-
# FIXME: add aarch64 emulation to our github action...
85-
#self.hydraJobs.build.aarch64-linux
86-
self.hydraJobs.build-sanitized.x86_64-linux
87-
#self.hydraJobs.build-sanitized.aarch64-linux
88-
self.hydraJobs.build-sanitized.i686-linux
89-
self.hydraJobs.build-sanitized-clang.x86_64-linux
90-
];
91-
meta.description = "Release-critical builds";
92-
};
94+
release = pkgs.releaseTools.aggregate {
95+
name = "patchelf-${self.hydraJobs.tarball.version}";
96+
constituents = [
97+
self.hydraJobs.tarball
98+
self.hydraJobs.build.x86_64-linux
99+
self.hydraJobs.build.i686-linux
100+
# FIXME: add aarch64 emulation to our github action...
101+
#self.hydraJobs.build.aarch64-linux
102+
self.hydraJobs.build-sanitized.x86_64-linux
103+
#self.hydraJobs.build-sanitized.aarch64-linux
104+
self.hydraJobs.build-sanitized.i686-linux
105+
self.hydraJobs.build-sanitized-clang.x86_64-linux
106+
];
107+
meta.description = "Release-critical builds";
108+
};
93109

94110
};
95111

96112
checks = forAllSystems (system: {
97113
build = self.hydraJobs.build.${system};
98114
});
99115

100-
devShells = forAllSystems (system: {
101-
glibc = self.packages.${system}.patchelf;
102-
default = self.devShells.${system}.glibc;
103-
} // nixpkgs.lib.optionalAttrs (system != "i686-linux") {
104-
musl = self.packages.${system}.patchelf-musl;
105-
});
106-
107-
packages = forAllSystems (system: let
108-
pkgs = nixpkgs.legacyPackages.${system};
109-
in {
110-
patchelf = patchelfFor pkgs;
111-
default = self.packages.${system}.patchelf;
112-
113-
# This is a good test to see if packages can be cross-compiled. It also
114-
# tests if our testsuite uses target-prefixed executable names.
115-
patchelf-musl-cross = patchelfFor pkgs.pkgsCross.musl64;
116-
patchelf-netbsd-cross = patchelfFor pkgs.pkgsCross.x86_64-netbsd;
117-
118-
patchelf-win32 = (patchelfFor pkgs.pkgsCross.mingw32).overrideAttrs (old: {
119-
NIX_CFLAGS_COMPILE = "-static";
120-
});
121-
patchelf-win64 = (patchelfFor pkgs.pkgsCross.mingwW64).overrideAttrs (old: {
122-
NIX_CFLAGS_COMPILE = "-static";
123-
});
124-
} // nixpkgs.lib.optionalAttrs (system != "i686-linux") {
125-
patchelf-musl = patchelfFor nixpkgs.legacyPackages.${system}.pkgsMusl;
126-
});
116+
devShells = forAllSystems (
117+
system:
118+
{
119+
glibc = self.packages.${system}.patchelf;
120+
default = self.devShells.${system}.glibc;
121+
}
122+
// nixpkgs.lib.optionalAttrs (system != "i686-linux") {
123+
musl = self.packages.${system}.patchelf-musl;
124+
}
125+
);
126+
127+
packages = forAllSystems (
128+
system:
129+
let
130+
pkgs = nixpkgs.legacyPackages.${system};
131+
in
132+
{
133+
patchelf = patchelfFor pkgs;
134+
default = self.packages.${system}.patchelf;
135+
136+
# This is a good test to see if packages can be cross-compiled. It also
137+
# tests if our testsuite uses target-prefixed executable names.
138+
patchelf-musl-cross = patchelfFor pkgs.pkgsCross.musl64;
139+
patchelf-netbsd-cross = patchelfFor pkgs.pkgsCross.x86_64-netbsd;
140+
141+
patchelf-win32 = (patchelfFor pkgs.pkgsCross.mingw32).overrideAttrs (old: {
142+
NIX_CFLAGS_COMPILE = "-static";
143+
});
144+
patchelf-win64 = (patchelfFor pkgs.pkgsCross.mingwW64).overrideAttrs (old: {
145+
NIX_CFLAGS_COMPILE = "-static";
146+
});
147+
}
148+
// nixpkgs.lib.optionalAttrs (system != "i686-linux") {
149+
patchelf-musl = patchelfFor nixpkgs.legacyPackages.${system}.pkgsMusl;
150+
}
151+
);
127152

128153
};
129154
}

patchelf.nix

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1-
{ stdenv, buildPackages, autoreconfHook, version, src, overrideCC }:
1+
{
2+
stdenv,
3+
buildPackages,
4+
autoreconfHook,
5+
version,
6+
src,
7+
overrideCC,
8+
}:
29
let
310
# on windows we use win32 threads to get a fully static binary
4-
gcc = buildPackages.wrapCC (buildPackages.gcc-unwrapped.override ({
5-
threadsCross = {
6-
model = "win32";
7-
package = null;
8-
};
9-
}));
11+
gcc = buildPackages.wrapCC (
12+
buildPackages.gcc-unwrapped.override ({
13+
threadsCross = {
14+
model = "win32";
15+
package = null;
16+
};
17+
})
18+
);
1019

11-
stdenv' = if (stdenv.cc.isGNU && stdenv.targetPlatform.isWindows) then
12-
overrideCC stdenv gcc
13-
else
14-
stdenv;
20+
stdenv' =
21+
if (stdenv.cc.isGNU && stdenv.targetPlatform.isWindows) then overrideCC stdenv gcc else stdenv;
1522
in
1623
stdenv'.mkDerivation {
1724
pname = "patchelf";

0 commit comments

Comments
 (0)