Add a build for the yubikey management raspberry pi image.
This commit is contained in:
78
nix/yubipi/roles/optimized_build/default.nix
Normal file
78
nix/yubipi/roles/optimized_build/default.nix
Normal file
@@ -0,0 +1,78 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
pkgs-unoptimized,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
imports = [ ];
|
||||
|
||||
options.me = {
|
||||
optimizations.enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
example = true;
|
||||
description = "Whether we want to enable CPU optimizations (will trigger a rebuild from source).";
|
||||
};
|
||||
|
||||
optimizations.arch = lib.mkOption {
|
||||
type = 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 = [ ];
|
||||
example = [
|
||||
"gccarch-armv6l"
|
||||
"benchmark"
|
||||
"big-parallel"
|
||||
"kvm"
|
||||
"nixos-test"
|
||||
];
|
||||
description = "The list of CPU features that should be enabled on this machine.";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkMerge [
|
||||
(lib.mkIf (!config.me.optimizations.enable) (
|
||||
lib.mkMerge [
|
||||
{
|
||||
}
|
||||
]
|
||||
))
|
||||
(lib.mkIf config.me.optimizations.enable (
|
||||
lib.mkMerge [
|
||||
{
|
||||
nixpkgs.config.allowUnsupportedSystem = true;
|
||||
|
||||
nixpkgs.hostPlatform = {
|
||||
gcc.arch = config.me.optimizations.arch;
|
||||
gcc.tune = config.me.optimizations.arch;
|
||||
system = "armv6l-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";
|
||||
# };
|
||||
}
|
||||
]
|
||||
))
|
||||
(lib.mkIf (config.me.optimizations.system_features != [ ]) (
|
||||
lib.mkMerge [
|
||||
{
|
||||
nix.settings.system-features = lib.mkForce config.me.optimizations.system_features;
|
||||
}
|
||||
]
|
||||
))
|
||||
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user