Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
{ 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