2023-12-23 06:55:27 +01:00

28 lines
761 B
Nix

{ config, lib, libS, ... }:
let
cfg = config.simd;
in
{
options.simd = {
enable = lib.mkEnableOption "optimized builds with simd instructions";
arch = lib.mkOption {
type = with lib.types; nullOr str;
default = null;
description = ''
Microarchitecture string for nixpkgs.hostPlatform.gcc.march and to generate system-features.
Can be determined with: ``nix shell nixpkgs#gcc -c gcc -march=native -Q --help=target | grep march``
'';
};
};
config = {
nix.settings.system-features = lib.mkIf (cfg.arch != null) (libS.nix.gcc-system-features config.simd.arch);
nixpkgs.hostPlatform = lib.mkIf cfg.enable {
gcc.arch = config.simd.arch;
inherit (config.nixpkgs) system;
};
};
}