mirror of
https://github.com/aviallon/nixos-lib.git
synced 2026-04-06 01:38:06 +00:00
[General/Nix] Improve nix config generation to remove warnings
This commit is contained in:
parent
2a9a326085
commit
00a62a9f34
1 changed files with 15 additions and 5 deletions
20
general.nix
20
general.nix
|
|
@ -5,15 +5,19 @@ let
|
||||||
nixConfigValue = value:
|
nixConfigValue = value:
|
||||||
if value == true then "true"
|
if value == true then "true"
|
||||||
else if value == false then "false"
|
else if value == false then "false"
|
||||||
else if isList value then (toString value)
|
else if isList value then toString value
|
||||||
else generators.mkValueStringDefault { } value;
|
else generators.mkValueStringDefault { } value;
|
||||||
|
|
||||||
nixConfig = settings: (generators.toKeyValue {
|
nixConfig = settings: (generators.toKeyValue {
|
||||||
listsAsDuplicateKeys = false;
|
|
||||||
mkKeyValue = generators.mkKeyValueDefault {
|
mkKeyValue = generators.mkKeyValueDefault {
|
||||||
mkValueString = nixConfigValue;
|
mkValueString = nixConfigValue;
|
||||||
} " = ";
|
} " = ";
|
||||||
} settings);
|
} (filterAttrs (n: v: !(
|
||||||
|
(v == null) ||
|
||||||
|
(isList v && (length v == 0))
|
||||||
|
))
|
||||||
|
settings)
|
||||||
|
);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.aviallon.general = {
|
options.aviallon.general = {
|
||||||
|
|
@ -36,6 +40,7 @@ in
|
||||||
type = types.str;
|
type = types.str;
|
||||||
};
|
};
|
||||||
unsafeOptimizations = mkEnableOption "unsafe system tuning";
|
unsafeOptimizations = mkEnableOption "unsafe system tuning";
|
||||||
|
flakes.enable = mkEnableOption "experimental flake support";
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
|
@ -97,11 +102,16 @@ in
|
||||||
];
|
];
|
||||||
nix.distributedBuilds = mkDefault false;
|
nix.distributedBuilds = mkDefault false;
|
||||||
|
|
||||||
nix.package = (if (builtins.compareVersions pkgs.nix.version "2.4" >= 0) then pkgs.nix else pkgs.nix_2_4);
|
nix.package = mkIf cfg.flakes.enable (if (builtins.compareVersions pkgs.nix.version "2.4" >= 0) then pkgs.nix else pkgs.nix_2_4);
|
||||||
nix.extraOptions = nixConfig {
|
nix.extraOptions = nixConfig {
|
||||||
builders-use-substitutes = true;
|
builders-use-substitutes = true;
|
||||||
experimental-features = [ "nix-command" "flakes" ];
|
experimental-features = concatLists [
|
||||||
|
(optionals cfg.flakes.enable ["nix-command" "flakes"])
|
||||||
|
];
|
||||||
|
download-attempts = 5;
|
||||||
|
stalled-download-timeout = 20;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue