Skip to content

Instantly share code, notes, and snippets.

@matthiasbeyer
Created March 14, 2018 19:15
Show Gist options
  • Save matthiasbeyer/cba5559a0bed6058f469426687bf307d to your computer and use it in GitHub Desktop.
Save matthiasbeyer/cba5559a0bed6058f469426687bf307d to your computer and use it in GitHub Desktop.
{ pkgs }:
rec {
optimizeWithFlag = pkg: flag:
pkg.overrideAttrs (attrs: {
NIX_CFLAGS_COMPILE = (attrs.NIX_CFLAGS_COMPILE or "") + " ${flag}";
});
optimizeWithFlags = pkg: flags:
pkgs.lib.foldl' (pkg: flag: optimizeWithFlag pkg flag) pkg flags;
optimizeForThisHost = pkg:
optimizeWithFlags pkg [ "-O3" "-march=native" "-fPIC" ];
withDebuggingCompiled = pkg:
optimizeWithFlag pkg "-DDEBUG";
applyOptimizations = opts: pkg:
pkgs.lib.foldl (pkg: optfun: optfun pkg) pkg opts;
withoutConfigureFlag = flag: pkg:
pkgs.lib.overrideDerivation pkg (old: {
configureFlags = pkgs.lib.filter (x: x != flag) old.configureFlags;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment