整理 system.march

This commit is contained in:
陈浩南 2023-07-22 12:45:26 +08:00
parent 6017698731
commit 485d107a3b
5 changed files with 27 additions and 6 deletions

View File

@ -214,6 +214,7 @@
system =
{
hostname = "chn-PC";
march = "alderlake";
};
};}
)

View File

@ -2,7 +2,6 @@ inputs:
{
config =
{
nixpkgs.hostPlatform = inputs.lib.mkDefault "x86_64-linux";
nix =
{
settings =

View File

@ -14,8 +14,6 @@ inputs:
patch = null;
extraStructuredConfig =
{
GENERIC_CPU = inputs.lib.kernel.no;
MALDERLAKE = inputs.lib.kernel.yes;
PREEMPT_VOLUNTARY = inputs.lib.mkForce inputs.lib.kernel.no;
PREEMPT = inputs.lib.mkForce inputs.lib.kernel.yes;
HZ_500 = inputs.lib.mkForce inputs.lib.kernel.no;

View File

@ -2,10 +2,9 @@
{
config =
{
nix.settings.system-features = [ "nixos-test" "benchmark" "kvm" "gccarch-alderlake" ];
nix.settings.system-features = [ "nixos-test" "benchmark" "kvm" ];
nixpkgs =
{
hostPlatform = { system = "x86_64-linux"; gcc = { arch = "alderlake"; tune = "alderlake"; }; };
config.allowUnfree = true;
overlays =
[(
@ -22,7 +21,6 @@
fwupd = generic-pkgs.fwupd;
}
)];
config.qchem-config.optArch = "alderlake";
};
services.dbus.implementation = "broker";
programs.dconf.enable = true;

View File

@ -3,6 +3,7 @@ inputs:
options.nixos.system = let inherit (inputs.lib) mkOption types; in
{
hostname = mkOption { type = types.nonEmptyStr; };
march = mkOption { type = types.nullOr types.nonEmptyStr; };
};
config = let inherit (inputs.lib) mkMerge mkIf; inherit (inputs.localLib) mkConditional stripeTabs; in mkMerge
[
@ -21,5 +22,29 @@ inputs:
}
# hostname
{ networking.hostName = inputs.config.nixos.system.hostname; }
# march
(
mkConditional (inputs.config.nixos.system.march != null)
{
nixpkgs =
{
hostPlatform = { system = "x86_64-linux"; gcc =
{ arch = inputs.config.nixos.system.march; tune = inputs.config.nixos.system.march; }; };
config.qchem-config.optArch = inputs.config.nixos.system.march;
};
nix.settings.system-features = [ "gccarch-${inputs.config.nixos.system.march}" ];
boot.kernelPatches =
[{
name = "native kernel";
patch = null;
extraStructuredConfig =
{
GENERIC_CPU = inputs.lib.kernel.no;
"M${inputs.lib.strings.toUpper inputs.config.nixos.system.march}" = inputs.lib.kernel.yes;
};
}];
}
{ nixpkgs.hostPlatform = inputs.lib.mkDefault "x86_64-linux"; }
)
];
}