Add simd module
This commit is contained in:
parent
91775e2b63
commit
aa98422210
|
@ -0,0 +1,8 @@
|
|||
{ lib, ... }:
|
||||
|
||||
{
|
||||
# taken from https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/misc/nix-daemon.nix#L828-L832
|
||||
# a builder can run code for `gcc.arch` and inferior architectures
|
||||
gcc-system-features = arch: [ "gccarch-${arch}" ]
|
||||
++ map (x: "gccarch-${x}") lib.systems.architectures.inferiors.${arch};
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
{ 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: ``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.sandro.simd.arch;
|
||||
inherit (config.nixpkgs) system;
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue