mirror of
https://github.com/CHN-beta/nixos.git
synced 2026-01-12 04:19:22 +08:00
整理 system.nix
This commit is contained in:
16
flake.nix
16
flake.nix
@@ -131,8 +131,9 @@
|
||||
system =
|
||||
{
|
||||
march = "alderlake";
|
||||
extraMarch =
|
||||
nix.marches =
|
||||
[
|
||||
"alderlake"
|
||||
# CX16
|
||||
"sandybridge"
|
||||
# CX16 SAHF FXSR
|
||||
@@ -143,7 +144,7 @@
|
||||
"broadwell"
|
||||
];
|
||||
gui.enable = true;
|
||||
keepOutputs = true;
|
||||
nix.keepOutputs = true;
|
||||
};
|
||||
virtualization =
|
||||
{
|
||||
@@ -277,6 +278,7 @@
|
||||
sshd = { enable = true; hostKeys = [ "/nix/persistent/etc/ssh/initrd_ssh_host_ed25519_key" ]; };
|
||||
};
|
||||
system.march = "sandybridge";
|
||||
system.nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
|
||||
};})
|
||||
];
|
||||
"vps4" =
|
||||
@@ -317,6 +319,7 @@
|
||||
sshd = { enable = true; hostKeys = [ "/nix/persistent/etc/ssh/initrd_ssh_host_ed25519_key" ]; };
|
||||
};
|
||||
system.march = "znver3";
|
||||
system.nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
|
||||
};})
|
||||
];
|
||||
"vps7" =
|
||||
@@ -365,6 +368,7 @@
|
||||
sshd = { enable = true; hostKeys = [ "/nix/persistent/etc/ssh/initrd_ssh_host_ed25519_key" ]; };
|
||||
};
|
||||
system.march = "broadwell";
|
||||
system.nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
|
||||
};})
|
||||
];
|
||||
"nas" =
|
||||
@@ -405,6 +409,7 @@
|
||||
sshd = { enable = true; hostKeys = [ "/nix/persistent/etc/ssh/initrd_ssh_host_ed25519_key" ]; };
|
||||
};
|
||||
system.march = "silvermont";
|
||||
system.nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
|
||||
};})
|
||||
];
|
||||
"xmupc1" =
|
||||
@@ -454,9 +459,9 @@
|
||||
system =
|
||||
{
|
||||
march = "znver3";
|
||||
extraMarch =
|
||||
nix.marches =
|
||||
[
|
||||
"znver2"
|
||||
"znver3" "znver2"
|
||||
# PREFETCHW RDRND XSAVE XSAVEOPT PTWRITE SGX GFNI-SSE MOVDIRI MOVDIR64B CLDEMOTE WAITPKG LZCNT
|
||||
# PCONFIG SERIALIZE HRESET KL WIDEKL AVX-VNNI
|
||||
"alderlake"
|
||||
@@ -523,6 +528,7 @@
|
||||
postgresql.enable = true;
|
||||
};
|
||||
bugs = [ "xmunet" "firefox" "embree" ];
|
||||
system.nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
|
||||
};})
|
||||
];
|
||||
"yoga" =
|
||||
@@ -580,6 +586,7 @@
|
||||
firewall.trustedInterfaces = [ "virbr0" ];
|
||||
smartd.enable = true;
|
||||
};
|
||||
system.nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
|
||||
};})
|
||||
];
|
||||
"pe" =
|
||||
@@ -632,6 +639,7 @@
|
||||
firewall.trustedInterfaces = [ "virbr0" ];
|
||||
smartd.enable = true;
|
||||
};
|
||||
system.nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
|
||||
};})
|
||||
];
|
||||
}));
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
# TODO: enable zswap
|
||||
inputs:
|
||||
{
|
||||
imports = inputs.localLib.mkModules
|
||||
[
|
||||
./nix.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; };
|
||||
extraMarch = mkOption { type = types.listOf types.nonEmptyStr; default = []; };
|
||||
gui.enable = mkOption { type = types.bool; default = false; };
|
||||
keepOutputs = mkOption { type = types.bool; default = false; };
|
||||
};
|
||||
config =
|
||||
let
|
||||
@@ -19,31 +20,6 @@ inputs:
|
||||
[
|
||||
# generic
|
||||
{
|
||||
nix =
|
||||
{
|
||||
settings =
|
||||
{
|
||||
system-features = [ "big-parallel" "nixos-test" "benchmark" ];
|
||||
experimental-features = [ "nix-command" "flakes" ];
|
||||
keep-outputs = inputs.config.nixos.system.keepOutputs;
|
||||
keep-failed = true;
|
||||
auto-optimise-store = true;
|
||||
substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
|
||||
trusted-public-keys = [ "chn:Cc+nowW1LIpe1kyXOZmNaznFDiH1glXmpb4A+WD/DTE=" ];
|
||||
show-trace = true;
|
||||
max-jobs = 2;
|
||||
cores = 0;
|
||||
keep-going = true;
|
||||
};
|
||||
daemonIOSchedClass = "idle";
|
||||
daemonCPUSchedPolicy = "idle";
|
||||
registry =
|
||||
{
|
||||
nixpkgs.flake = inputs.topInputs.nixpkgs;
|
||||
nixos.flake = inputs.topInputs.self;
|
||||
};
|
||||
nixPath = [ "nixpkgs=${inputs.topInputs.nixpkgs}" ];
|
||||
};
|
||||
services =
|
||||
{
|
||||
udev.extraRules =
|
||||
@@ -73,11 +49,6 @@ inputs:
|
||||
}).pkgs;})];
|
||||
};
|
||||
time.timeZone = "Asia/Shanghai";
|
||||
system =
|
||||
{
|
||||
stateVersion = "22.11";
|
||||
configurationRevision = inputs.topInputs.self.rev or "dirty";
|
||||
};
|
||||
boot =
|
||||
{
|
||||
kernel.sysctl =
|
||||
@@ -118,22 +89,12 @@ inputs:
|
||||
DefaultLimitNOFILE=1048576:1048576
|
||||
'';
|
||||
user.extraConfig = "DefaultTimeoutStopSec=10s";
|
||||
services =
|
||||
{
|
||||
nix-daemon =
|
||||
{
|
||||
serviceConfig = { CacheDirectory = "nix"; Slice = "-.slice"; Nice = "19"; };
|
||||
environment = { TMPDIR = "/var/cache/nix"; };
|
||||
};
|
||||
systemd-tmpfiles-setup = { environment = { SYSTEMD_TMPFILES_FORCE_SUBVOL = "0"; }; };
|
||||
};
|
||||
services.systemd-tmpfiles-setup = { environment = { SYSTEMD_TMPFILES_FORCE_SUBVOL = "0"; }; };
|
||||
timers.systemd-tmpfiles-clean.enable = false;
|
||||
coredump.enable = false;
|
||||
};
|
||||
environment =
|
||||
{
|
||||
etc."channels/nixpkgs".source = inputs.topInputs.nixpkgs.outPath;
|
||||
etc."nixos".source = inputs.topInputs.self.outPath;
|
||||
sessionVariables = rec
|
||||
{
|
||||
XDG_CACHE_HOME = "$HOME/.cache";
|
||||
@@ -210,7 +171,6 @@ inputs:
|
||||
hostPlatform = { system = "x86_64-linux"; gcc = { arch = system.march; tune = system.march; }; };
|
||||
config.qchem-config.optArch = system.march;
|
||||
};
|
||||
nix.settings.system-features = [ "gccarch-${system.march}" ];
|
||||
boot.kernelPatches =
|
||||
[{
|
||||
name = "native kernel";
|
||||
@@ -235,8 +195,6 @@ inputs:
|
||||
}
|
||||
{ nixpkgs.hostPlatform = inputs.lib.mkDefault "x86_64-linux"; }
|
||||
)
|
||||
# extraMarch
|
||||
{ nix.settings.system-features = map (march: "gccarch-${march}") system.extraMarch; }
|
||||
# gui.enable
|
||||
(mkIf inputs.config.nixos.system.gui.enable
|
||||
{
|
||||
|
||||
65
modules/system/nix.nix
Normal file
65
modules/system/nix.nix
Normal file
@@ -0,0 +1,65 @@
|
||||
inputs:
|
||||
{
|
||||
options.nixos.system.nix = let inherit (inputs.lib) mkOption types; in
|
||||
{
|
||||
marches = mkOption { type = types.nullOr (types.listOf types.nonEmptyStr); default = null; };
|
||||
keepOutputs = mkOption { type = types.bool; default = false; };
|
||||
substituters = mkOption { type = types.nullOr (types.listOf types.nonEmptyStr); default = null; };
|
||||
};
|
||||
config =
|
||||
let
|
||||
inherit (inputs.config.nixos.system) nix;
|
||||
in
|
||||
{
|
||||
nix =
|
||||
{
|
||||
settings =
|
||||
{
|
||||
system-features = [ "big-parallel" "nixos-test" "benchmark" ] ++ (map
|
||||
(march: "gccarch-${march}")
|
||||
(
|
||||
if nix.marches == null then
|
||||
(if inputs.config.nixos.system.march == null then [] else [ inputs.config.nixos.system.march ])
|
||||
else nix.marches
|
||||
));
|
||||
experimental-features = [ "nix-command" "flakes" ];
|
||||
keep-outputs = nix.keepOutputs;
|
||||
keep-failed = true;
|
||||
auto-optimise-store = true;
|
||||
substituters = if nix.substituters == null then [ "https://cache.nixos.org/" ] else nix.substituters;
|
||||
trusted-public-keys = [ "chn:Cc+nowW1LIpe1kyXOZmNaznFDiH1glXmpb4A+WD/DTE=" ];
|
||||
show-trace = true;
|
||||
max-jobs = 2;
|
||||
cores = 0;
|
||||
keep-going = true;
|
||||
};
|
||||
daemonIOSchedClass = "idle";
|
||||
daemonCPUSchedPolicy = "idle";
|
||||
registry =
|
||||
{
|
||||
nixpkgs.flake = inputs.topInputs.nixpkgs;
|
||||
nixos.flake = inputs.topInputs.self;
|
||||
};
|
||||
nixPath = [ "nixpkgs=${inputs.topInputs.nixpkgs}" ];
|
||||
};
|
||||
system =
|
||||
{
|
||||
stateVersion = "22.11";
|
||||
configurationRevision = inputs.topInputs.self.rev or "dirty";
|
||||
};
|
||||
systemd.services.nix-daemon =
|
||||
{
|
||||
serviceConfig = { CacheDirectory = "nix"; Slice = "-.slice"; Nice = "19"; };
|
||||
environment = { TMPDIR = "/var/cache/nix"; };
|
||||
};
|
||||
environment.etc =
|
||||
{
|
||||
"channels/nixpkgs".source = inputs.topInputs.nixpkgs.outPath;
|
||||
"nixos".source = inputs.topInputs.self.outPath;
|
||||
};
|
||||
# environment.pathsToLink = [ "/include" ];
|
||||
# environment.variables.CPATH = "/run/current-system/sw/include";
|
||||
# environment.variables.LIBRARY_PATH = "/run/current-system/sw/lib";
|
||||
# gui.enable
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user