diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000..1392aa88 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# Manual nixfmt run +706478750fc8574ed816ef746d3ad3790b2ea66a diff --git a/default.nix b/default.nix index 71d1a80a..00ec5b61 100644 --- a/default.nix +++ b/default.nix @@ -1,3 +1,3 @@ -(import (fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) { +(import (fetchTarball "https://github.com/edolstra/flake-compat/archive/master.tar.gz") { src = ./.; }).defaultNix diff --git a/flake.nix b/flake.nix index 84c6f6db..b95fa265 100644 --- a/flake.nix +++ b/flake.nix @@ -3,22 +3,29 @@ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - outputs = { self, nixpkgs }: + outputs = + { self, nixpkgs }: let - supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ]; + 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; - }; + patchelfFor = + pkgs: + let + # this is only + in + pkgs.callPackage ./patchelf.nix { + inherit version; + src = self; + }; in @@ -29,67 +36,76 @@ }; hydraJobs = { - tarball = - pkgs.releaseTools.sourceTarball rec { - name = "patchelf-tarball"; - inherit version; - versionSuffix = ""; # obsolete - src = self; - preAutoconf = "echo ${version} > version"; - - # portable configure shouldn't have a shebang pointing to the nix store - postConfigure = '' - sed -i '1s|^.*$|#!/bin/sh|' ./configure - ''; - postDist = '' - cp README.md $out/ - echo "doc readme $out/README.md" >> $out/nix-support/hydra-build-products - ''; - }; + tarball = pkgs.releaseTools.sourceTarball rec { + name = "patchelf-tarball"; + inherit version; + versionSuffix = ""; # obsolete + src = self; + preAutoconf = "echo ${version} > version"; + + # portable configure shouldn't have a shebang pointing to the nix store + postConfigure = '' + sed -i '1s|^.*$|#!/bin/sh|' ./configure + ''; + 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 - ''; - }); + 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"; - })); + 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; - }); + 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"; - }; + 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"; + }; }; @@ -97,33 +113,42 @@ 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; - }); + 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; + } + ); }; } diff --git a/patchelf.nix b/patchelf.nix index 6e8e59d3..169f456c 100644 --- a/patchelf.nix +++ b/patchelf.nix @@ -1,17 +1,24 @@ -{ stdenv, buildPackages, autoreconfHook, version, src, overrideCC }: +{ + stdenv, + buildPackages, + autoreconfHook, + version, + src, + overrideCC, +}: let # on windows we use win32 threads to get a fully static binary - gcc = buildPackages.wrapCC (buildPackages.gcc-unwrapped.override ({ - threadsCross = { - model = "win32"; - package = null; - }; - })); + gcc = buildPackages.wrapCC ( + buildPackages.gcc-unwrapped.override ({ + threadsCross = { + model = "win32"; + package = null; + }; + }) + ); - stdenv' = if (stdenv.cc.isGNU && stdenv.targetPlatform.isWindows) then - overrideCC stdenv gcc - else - stdenv; + stdenv' = + if (stdenv.cc.isGNU && stdenv.targetPlatform.isWindows) then overrideCC stdenv gcc else stdenv; in stdenv'.mkDerivation { pname = "patchelf";