[Overlays/Optimizations] Make optimizations disable-able

This commit is contained in:
Antoine Viallon 2022-03-27 14:47:48 +02:00
parent 5b5bb79228
commit f0ac8c8151
Signed by: aviallon
GPG key ID: 186FC35EDEB25716

View file

@ -8,7 +8,7 @@ let
NIX_CFLAGS_COMPILE = toString ([ (attrs.NIX_CFLAGS_COMPILE or "") ] ++ flags); NIX_CFLAGS_COMPILE = toString ([ (attrs.NIX_CFLAGS_COMPILE or "") ] ++ flags);
doCheck = false; doCheck = false;
}); });
optimizeForThisHost = pkg: _optimizeForThisHost = pkg:
pkg.overrideAttrs (attrs: let pkg.overrideAttrs (attrs: let
cflags = [ (attrs.NIX_CFLAGS_COMPILE or "") ] ++ config.aviallon.programs.compileFlags; cflags = [ (attrs.NIX_CFLAGS_COMPILE or "") ] ++ config.aviallon.programs.compileFlags;
cxxflags = [ (attrs.CXXFLAGS or "") ] ++ config.aviallon.programs.compileFlags; cxxflags = [ (attrs.CXXFLAGS or "") ] ++ config.aviallon.programs.compileFlags;
@ -26,6 +26,7 @@ let
cmakeFlags = mytrace "cmakeFlags" cmakeflags; cmakeFlags = mytrace "cmakeFlags" cmakeflags;
doCheck = false; doCheck = false;
}); });
optimizeForThisHost = if (cfg.optimizations) then (pkg: _optimizeForThisHost pkg) else (pkg: pkg);
in in
{ {
options.aviallon.overlays = { options.aviallon.overlays = {
@ -35,6 +36,12 @@ in
description = "Wether to enable system-wide overlays or not"; description = "Wether to enable system-wide overlays or not";
type = types.bool; type = types.bool;
}; };
optimizations = mkOption {
default = true;
example = false;
description = "Wether to enable CPU-specific optimizations for some packages or not";
type = types.bool;
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
nix.nixPath = nix.nixPath =