mirror of
https://github.com/aviallon/nixos-lib.git
synced 2026-04-05 17:27:50 +00:00
[Packages/Overlays] Greatly tune and improve package automatic optimization
This commit is contained in:
parent
a3f7ca24b8
commit
c2d8689dc4
2 changed files with 49 additions and 5 deletions
36
overlays.nix
36
overlays.nix
|
|
@ -3,13 +3,29 @@ with lib;
|
||||||
let
|
let
|
||||||
cfg = config.aviallon.overlays;
|
cfg = config.aviallon.overlays;
|
||||||
unstable = import (builtins.fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz") { config = config.nixpkgs.config; };
|
unstable = import (builtins.fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz") { config = config.nixpkgs.config; };
|
||||||
optimizeWithFlag = pkg: flag:
|
optimizeWithFlags = pkg: flags:
|
||||||
pkg.overrideAttrs (attrs: {
|
pkg.overrideAttrs (attrs: {
|
||||||
NIX_CFLAGS_COMPILE = (attrs.NIX_CFLAGS_COMPILE or "") + " ${flag}";
|
NIX_CFLAGS_COMPILE = toString ([ (attrs.NIX_CFLAGS_COMPILE or "") ] ++ flags);
|
||||||
|
doCheck = false;
|
||||||
|
});
|
||||||
|
optimizeForThisHost = pkg:
|
||||||
|
pkg.overrideAttrs (attrs: let
|
||||||
|
cflags = [ (attrs.NIX_CFLAGS_COMPILE or "") ] ++ config.aviallon.programs.compileFlags;
|
||||||
|
cxxflags = [ (attrs.CXXFLAGS or "") ] ++ config.aviallon.programs.compileFlags;
|
||||||
|
rustflags = [ (attrs.RUSTFLAGS or "") "-C target-cpu=${config.aviallon.general.cpuArch}" ];
|
||||||
|
pkgname = getName pkg;
|
||||||
|
cmakeflags = [ (attrs.cmakeFlags or "") ] ++ [ "-DCMAKE_CXX_FLAGS=\"${toString cxxflags}\"" ];
|
||||||
|
mytrace = name: value: builtins.trace "${pkgname}: ${name}: ${toString value}" (toString value);
|
||||||
|
in {
|
||||||
|
NIX_CFLAGS_COMPILE = mytrace "CFLAGS" cflags;
|
||||||
|
CXXFLAGS = mytrace "CXXFLAGS" cxxflags;
|
||||||
|
RUSTFLAGS = mytrace "RUSTFLAGS" rustflags;
|
||||||
|
configureFlags = mytrace "configureFlags" ([ (attrs.configureFlags or "") ] ++ [
|
||||||
|
"--enable-lto" "--enable-offload-targets=nvptx-none" "--disable-libunwind-exceptions"
|
||||||
|
]);
|
||||||
|
cmakeFlags = mytrace "cmakeFlags" cmakeflags;
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
});
|
});
|
||||||
optimizeWithFlags = pkg: flags: pkgs.lib.foldl' (pkg: flag: optimizeWithFlag pkg flag) pkg flags;
|
|
||||||
optimizeForThisHost = pkg: optimizeWithFlags pkg (builtins.trace "${getName pkg}: ${toString config.aviallon.programs.compileFlags}" config.aviallon.programs.compileFlags);
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.aviallon.overlays = {
|
options.aviallon.overlays = {
|
||||||
|
|
@ -43,6 +59,16 @@ in
|
||||||
]);
|
]);
|
||||||
}));
|
}));
|
||||||
})
|
})
|
||||||
|
(self: super: {
|
||||||
|
libsForQt5 = super.libsForQt5.overrideScope' (mself: msuper: {
|
||||||
|
kwin = optimizeForThisHost msuper.kwin;
|
||||||
|
dolphin = optimizeForThisHost (msuper.dolphin.overrideAttrs (old: {
|
||||||
|
propagatedBuildInputs = old.propagatedBuildInputs ++ (with super; [
|
||||||
|
kio-fuse
|
||||||
|
]);
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
})
|
||||||
(self: super: {
|
(self: super: {
|
||||||
opensshOptimized = optimizeForThisHost super.openssh;
|
opensshOptimized = optimizeForThisHost super.openssh;
|
||||||
rsyncOptimized = optimizeForThisHost super.rsync;
|
rsyncOptimized = optimizeForThisHost super.rsync;
|
||||||
|
|
@ -63,6 +89,8 @@ in
|
||||||
hwloc
|
hwloc
|
||||||
]);
|
]);
|
||||||
}));
|
}));
|
||||||
|
mesa = optimizeForThisHost super.mesa;
|
||||||
|
xorgserver = optimizeForThisHost super.xorg.xorgserver;
|
||||||
steam = super.steam.override {
|
steam = super.steam.override {
|
||||||
withJava = true;
|
withJava = true;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
18
packages.nix
18
packages.nix
|
|
@ -22,7 +22,23 @@ in
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
};
|
};
|
||||||
compileFlags = mkOption {
|
compileFlags = mkOption {
|
||||||
default = [ "-O3" "-march=${generalCfg.cpuArch}" "-mtune=${generalCfg.cpuTune}" ];
|
default = [
|
||||||
|
"-O3" "-march=${generalCfg.cpuArch}" "-mtune=${generalCfg.cpuTune}"
|
||||||
|
"-feliminate-unused-debug-types" "--param=ssp-buffer-size=32"
|
||||||
|
# "-Wl,--copy-dt-needed-entries-m64-fasynchronous-unwind-tables"
|
||||||
|
"-fasynchronous-unwind-tables"
|
||||||
|
"-fno-semantic-interposition"
|
||||||
|
"-ffat-lto-objects"
|
||||||
|
"-fno-signed-zeros"
|
||||||
|
"-fno-trapping-math"
|
||||||
|
"-fassociative-math"
|
||||||
|
"-fexceptions"
|
||||||
|
"-ftree-loop-distribute-patterns"
|
||||||
|
"-Wl,-sort-common"
|
||||||
|
"-fno-semantic-interposition"
|
||||||
|
"-fipa-pta"
|
||||||
|
"-fdevirtualize-at-ltrans"
|
||||||
|
];
|
||||||
example = [ "-O2" "-mavx" ];
|
example = [ "-O2" "-mavx" ];
|
||||||
description = "Add specific compile flags";
|
description = "Add specific compile flags";
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue