2023-03-12 03:59:11 +00:00
|
|
|
{
|
|
|
|
options,
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
|
|
|
cfg = config.aa.nix;
|
2023-07-16 17:53:02 +00:00
|
|
|
selfHostedCacheHost = "https://cache.kilonull.com/";
|
2023-03-12 03:59:11 +00:00
|
|
|
in {
|
|
|
|
options.aa.nix = with types; {
|
|
|
|
enable = mkEnableOption "manage nix configuration.";
|
|
|
|
package = mkOption {
|
|
|
|
type = package;
|
|
|
|
default = pkgs.nixVersions.unstable;
|
|
|
|
description = "Which nix package to use.";
|
|
|
|
};
|
2023-04-09 02:13:00 +00:00
|
|
|
|
|
|
|
useSelfhostedCache = mkEnableOption "use self-hosted nix cache (currently hosted on gospel)";
|
2023-03-12 03:59:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
alejandra
|
2023-03-26 16:55:13 +00:00
|
|
|
nix-prefetch
|
2023-03-12 03:59:11 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
nix = let
|
|
|
|
users = ["root" config.aa.user.name];
|
|
|
|
in {
|
|
|
|
package = cfg.package;
|
|
|
|
|
|
|
|
settings = {
|
|
|
|
experimental-features = "nix-command flakes";
|
|
|
|
trusted-users = users;
|
|
|
|
allowed-users = users;
|
2023-04-09 02:13:00 +00:00
|
|
|
|
|
|
|
builders-use-substitutes = cfg.useSelfhostedCache;
|
|
|
|
substituters =
|
|
|
|
if cfg.useSelfhostedCache
|
|
|
|
then [
|
|
|
|
selfHostedCacheHost
|
2023-04-16 17:07:42 +00:00
|
|
|
"https://cache.nixos.org/"
|
2023-04-09 02:13:00 +00:00
|
|
|
]
|
|
|
|
else [];
|
|
|
|
trusted-public-keys =
|
|
|
|
if cfg.useSelfhostedCache
|
|
|
|
then ["gospelCache:9cbn8Wm54BbwpPS0TXw+15wrYZBpfOJt4Fzfbfcq/pc="]
|
|
|
|
else [];
|
2023-03-12 03:59:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
gc = {
|
|
|
|
automatic = true;
|
|
|
|
dates = "weekly";
|
|
|
|
options = "--delete-older-than 30d";
|
|
|
|
};
|
|
|
|
|
|
|
|
# TODO: Not sure if I want this
|
|
|
|
# flake-utils-plus
|
|
|
|
# generateRegistryFromInputs = true;
|
|
|
|
# generateNixPathFromInputs = true;
|
|
|
|
# linkInputs = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|