nixos/modules/system/nix.nix

71 lines
2.8 KiB
Nix
Raw Normal View History

2023-09-02 14:04:03 +08:00
inputs:
{
options.nixos.system.nix = let inherit (inputs.lib) mkOption types; in
{
2023-09-02 14:21:27 +08:00
# marches allowed to be compiled on this machine
2023-09-02 14:04:03 +08:00
marches = mkOption { type = types.nullOr (types.listOf types.nonEmptyStr); default = null; };
includeBuildDependencies = mkOption { type = types.bool; default = inputs.topInputs.self.config.production; };
2023-09-02 14:04:03 +08:00
substituters = mkOption { type = types.nullOr (types.listOf types.nonEmptyStr); default = null; };
autoOptimiseStore = mkOption { type = types.bool; default = false; };
2023-09-02 14:04:03 +08:00
};
config =
let
inherit (inputs.config.nixos.system) nix;
in
{
nix =
{
settings =
{
system-features = [ "big-parallel" "nixos-test" "benchmark" ] ++ (map
2023-09-02 14:04:03 +08:00
(march: "gccarch-${march}")
(
if nix.marches == null then
2023-09-02 21:21:29 +08:00
(with inputs.config.nixos.system.nixpkgs; if march == null then [] else [ march ])
2023-09-02 14:04:03 +08:00
else nix.marches
));
experimental-features = [ "nix-command" "flakes" ];
keep-outputs = nix.includeBuildDependencies;
2023-09-02 14:04:03 +08:00
keep-failed = true;
auto-optimise-store = nix.autoOptimiseStore;
2023-09-02 14:04:03 +08:00
substituters = if nix.substituters == null then [ "https://cache.nixos.org/" ] else nix.substituters;
max-substitution-jobs = 1;
2023-09-02 14:04:03 +08:00
trusted-public-keys = [ "chn:Cc+nowW1LIpe1kyXOZmNaznFDiH1glXmpb4A+WD/DTE=" ];
show-trace = true;
max-jobs = 1;
2023-09-02 14:04:03 +08:00
cores = 0;
keep-going = true;
};
daemonIOSchedClass = "idle";
daemonCPUSchedPolicy = "idle";
registry =
{
nixpkgs.flake = inputs.topInputs.nixpkgs;
2023-10-25 14:01:30 +08:00
nixpkgs-unstable.flake = inputs.topInputs.nixpkgs-unstable;
2023-09-02 14:04:03 +08:00
nixos.flake = inputs.topInputs.self;
};
nixPath = [ "nixpkgs=${inputs.topInputs.nixpkgs}" ];
};
systemd.services.nix-daemon =
{
serviceConfig = { CacheDirectory = "nix"; Slice = "-.slice"; Nice = "19"; };
environment = { TMPDIR = "/var/cache/nix"; };
};
environment =
2023-09-02 14:04:03 +08:00
{
etc =
{
"channels/nixpkgs".source = inputs.topInputs.nixpkgs.outPath;
"channels/nixpkgs-unstable".source = inputs.topInputs.nixpkgs-unstable.outPath;
"nixos".source = inputs.topInputs.self.outPath;
};
variables.COMMA_NIXPKGS_FLAKE = "nixpkgs-unstable";
2023-09-02 14:04:03 +08:00
};
system.includeBuildDependencies = nix.includeBuildDependencies;
2023-09-02 14:04:03 +08:00
# environment.pathsToLink = [ "/include" ];
# environment.variables.CPATH = "/run/current-system/sw/include";
# environment.variables.LIBRARY_PATH = "/run/current-system/sw/lib";
# gui.enable
};
}