整理 system.nixpkgs

This commit is contained in:
2023-09-02 21:21:29 +08:00
parent 6305555760
commit b2ccf88adc
5 changed files with 65 additions and 52 deletions

View File

@@ -122,7 +122,7 @@
];
keepOutputs = true;
};
march = "alderlake";
nixpkgs.march = "alderlake";
gui.enable = true;
kernel =
{
@@ -248,7 +248,7 @@
rollingRootfs = { device = "/dev/mapper/root"; path = "/nix/rootfs"; };
};
grub.installDevice = "/dev/disk/by-path/pci-0000:00:05.0-scsi-0:0:0:0";
march = "sandybridge";
nixpkgs.march = "sandybridge";
nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
initrd =
{
@@ -314,7 +314,7 @@
rollingRootfs = { device = "/dev/mapper/root"; path = "/nix/rootfs"; };
};
grub.installDevice = "/dev/disk/by-path/pci-0000:00:04.0";
march = "znver3";
nixpkgs.march = "znver3";
nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
initrd =
{
@@ -359,7 +359,7 @@
rollingRootfs = { device = "/dev/mapper/root"; path = "/nix/rootfs"; };
};
grub.installDevice = "/dev/disk/by-path/pci-0000:00:05.0-scsi-0:0:0:0";
march = "broadwell";
nixpkgs.march = "broadwell";
nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
initrd =
{
@@ -412,7 +412,7 @@
rollingRootfs = { device = "/dev/mapper/root"; path = "/nix/rootfs"; };
};
grub.installDevice = "/dev/disk/by-path/pci-0000:00:04.0";
march = "silvermont";
nixpkgs.march = "silvermont";
nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
initrd =
{
@@ -460,7 +460,7 @@
rollingRootfs = { device = "/dev/mapper/root"; path = "/nix/rootfs"; };
};
grub.installDevice = "efi";
march = "znver3";
nixpkgs.march = "znver3";
nix =
{
marches =
@@ -575,7 +575,7 @@
swap = [ "/nix/swap/swap" ];
rollingRootfs = { device = "/dev/mapper/root"; path = "/nix/rootfs"; };
};
march = "silvermont";
nixpkgs.march = "silvermont";
gui.enable = true;
grub.installDevice = "efi";
nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];

View File

@@ -41,7 +41,7 @@ inputs:
{
RUSTFLAGS = prev.RUSTFLAGS or [] ++ [ "-Clto=true" "-Cpanic=abort" "-Cembed-bitcode=yes"]
++ (
let inherit (inputs.config.nixos.system) march;
let inherit (inputs.config.nixos.system.nixpkgs) march;
in (if march != null then [ "-Ctarget-cpu=${march}" ] else [])
);
});

View File

@@ -9,11 +9,11 @@ inputs:
./kernel.nix
./impermanence.nix
./gui.nix
./nixpkgs.nix
];
options.nixos.system = let inherit (inputs.lib) mkOption types; in
{
hostname = mkOption { type = types.nonEmptyStr; };
march = mkOption { type = types.nullOr types.nonEmptyStr; default = null; };
};
config =
let
@@ -44,15 +44,6 @@ inputs:
keep-configuration=no
'';
};
nixpkgs =
{
config.allowUnfree = true;
overlays = [(final: prev: { genericPackages = (inputs.topInputs.nixpkgs.lib.nixosSystem
{
system = "x86_64-linux";
modules = [{ config.nixpkgs.config.allowUnfree = true; }];
}).pkgs;})];
};
time.timeZone = "Asia/Shanghai";
boot =
{
@@ -167,38 +158,5 @@ inputs:
}
# hostname
{ networking.hostName = system.hostname; }
# march
(
mkConditional (system.march != null)
{
nixpkgs =
{
hostPlatform = { system = "x86_64-linux"; gcc = { arch = system.march; tune = system.march; }; };
config.qchem-config.optArch = system.march;
};
boot.kernelPatches =
[{
name = "native kernel";
patch = null;
extraStructuredConfig =
let
kernelConfig =
{
alderlake = "MALDERLAKE";
sandybridge = "MSANDYBRIDGE";
silvermont = "MSILVERMONT";
broadwell = "MBROADWELL";
znver2 = "MZEN2";
znver3 = "MZEN3";
};
in
{
GENERIC_CPU = inputs.lib.kernel.no;
${kernelConfig.${system.march}} = inputs.lib.kernel.yes;
};
}];
}
{ nixpkgs.hostPlatform = inputs.lib.mkDefault "x86_64-linux"; }
)
];
}

View File

@@ -20,7 +20,7 @@ inputs:
(march: "gccarch-${march}")
(
if nix.marches == null then
(if inputs.config.nixos.system.march == null then [] else [ inputs.config.nixos.system.march ])
(with inputs.config.nixos.system.nixpkgs; if march == null then [] else [ march ])
else nix.marches
));
experimental-features = [ "nix-command" "flakes" ];

View File

@@ -0,0 +1,55 @@
inputs:
{
options.nixos.system.nixpkgs = let inherit (inputs.lib) mkOption types; in
{
march = mkOption { type = types.nullOr types.nonEmptyStr; default = null; };
};
config =
let
inherit (inputs.lib) mkMerge mkIf;
inherit (inputs.localLib) mkConditional;
inherit (inputs.config.nixos.system) nixpkgs;
in mkMerge
[
{
nixpkgs =
{
config.allowUnfree = true;
overlays = [(final: prev: { genericPackages =
import inputs.topInputs.nixpkgs { system = "x86_64-linux"; config.allowUnfree = true; };})];
};
}
(
mkConditional (nixpkgs.march != null)
{
nixpkgs =
{
hostPlatform = { system = "x86_64-linux"; gcc = { arch = nixpkgs.march; tune = nixpkgs.march; }; };
config.qchem-config.optArch = nixpkgs.march;
};
boot.kernelPatches =
[{
name = "native kernel";
patch = null;
extraStructuredConfig =
let
kernelConfig =
{
alderlake = "MALDERLAKE";
sandybridge = "MSANDYBRIDGE";
silvermont = "MSILVERMONT";
broadwell = "MBROADWELL";
znver2 = "MZEN2";
znver3 = "MZEN3";
};
in
{
GENERIC_CPU = inputs.lib.kernel.no;
${kernelConfig.${nixpkgs.march}} = inputs.lib.kernel.yes;
};
}];
}
{ nixpkgs.hostPlatform = "x86_64-linux"; }
)
];
}