Add support for specifying a build arch.

This commit is contained in:
Tom Alexander 2025-10-25 19:45:06 -04:00
parent e4225a82bb
commit 2f05b9e600
Signed by: talexander
GPG Key ID: 36C99E8B3C39D85F
4 changed files with 22 additions and 9 deletions

View File

@ -30,6 +30,7 @@
me.optimizations = {
enable = true;
arch = "znver4";
# build_arch = "x86-64-v3";
system_features = [
"gccarch-znver4"
"gccarch-skylake"

View File

@ -28,6 +28,7 @@
me.optimizations = {
enable = true;
arch = "znver4";
# build_arch = "x86-64-v3";
system_features = [
"gccarch-znver4"
"gccarch-znver5"

View File

@ -24,6 +24,13 @@
description = "The CPU arch for which programs should be optimized.";
};
optimizations.build_arch = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "znver4";
description = "The CPU arch for which programs should be optimized.";
};
optimizations.system_features = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
@ -61,14 +68,6 @@
system = "x86_64-linux";
};
# Uncomment on of these to enable cross compiling:
# nixpkgs.buildPlatform = builtins.currentSystem;
# nixpkgs.buildPlatform = {
# gcc.arch = "znver4";
# gcc.tune = "znver4";
# system = "x86_64-linux";
# };
nixpkgs.overlays = [
(
final: prev:
@ -108,6 +107,18 @@
}
]
))
(lib.mkIf (config.me.optimizations.build_arch != null) (
lib.mkMerge [
{
# Enable cross-compiling
nixpkgs.buildPlatform = {
gcc.arch = config.me.optimizations.build_arch;
gcc.tune = "generic";
system = "x86_64-linux";
};
}
]
))
(lib.mkIf (config.me.optimizations.system_features != [ ]) (
lib.mkMerge [
{

View File

@ -171,7 +171,7 @@ in
waybar = pkgs.symlinkJoin {
name = prev.waybar.name;
paths = [ prev.waybar ];
buildInputs = [ pkgs.makeWrapper ];
nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/waybar --prefix PATH : ${
lib.makeBinPath [