2024-08-25 09:45:58 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2024-07-17 07:52:30 +00:00
|
|
|
|
|
|
|
let
|
2024-08-25 09:45:58 +00:00
|
|
|
inherit (lib)
|
|
|
|
mkIf
|
|
|
|
mkEnableOption
|
|
|
|
mkOption
|
|
|
|
types
|
|
|
|
;
|
2024-07-17 07:52:30 +00:00
|
|
|
|
|
|
|
cfg = config.commonSettings.nix;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.commonSettings.nix = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
enableMirrors = mkEnableOption "cache.nixos.org mirrors in Mainland China";
|
2024-07-18 03:44:09 +00:00
|
|
|
signing = {
|
|
|
|
enable = mkEnableOption "Sign locally-built paths";
|
|
|
|
keyFile = mkOption {
|
|
|
|
default = "/etc/nix/key.private";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
};
|
2024-07-17 07:52:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
nix.package = pkgs.nixVersions.latest;
|
|
|
|
|
|
|
|
nix.gc = {
|
|
|
|
automatic = true;
|
|
|
|
dates = "weekly";
|
|
|
|
options = "--delete-older-than 30d";
|
|
|
|
};
|
|
|
|
|
|
|
|
nix.optimise.automatic = true;
|
|
|
|
|
|
|
|
nix.settings = {
|
2024-08-25 09:45:58 +00:00
|
|
|
experimental-features = [
|
|
|
|
"nix-command"
|
|
|
|
"flakes"
|
|
|
|
];
|
2024-07-17 07:52:30 +00:00
|
|
|
auto-optimise-store = true;
|
|
|
|
trusted-users = [ "root" ];
|
|
|
|
|
|
|
|
substituters = [
|
|
|
|
"https://nix-community.cachix.org"
|
|
|
|
"https://cache.garnix.io"
|
|
|
|
];
|
|
|
|
|
|
|
|
extra-substituters = mkIf cfg.enableMirrors [
|
2024-08-21 03:05:49 +00:00
|
|
|
"https://mirrors.cernet.edu.cn/nix-channels/store?priority=20"
|
2024-07-17 07:52:30 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
trusted-public-keys = [
|
|
|
|
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
|
|
|
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
|
2024-07-18 03:44:09 +00:00
|
|
|
"xin-1:8/ul1IhdWLswERF/8RfeAw8VZqjwHrJ1x55y1yjxQ+Y="
|
|
|
|
];
|
|
|
|
|
2024-08-25 09:45:58 +00:00
|
|
|
secret-key-files = mkIf cfg.signing.enable [ cfg.signing.keyFile ];
|
2024-07-17 07:52:30 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|