2023-03-12 03:59:11 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
2024-08-03 17:32:02 +00:00
|
|
|
}: let
|
|
|
|
inherit (lib) mkIf mkEnableOption mkOption types;
|
|
|
|
|
2023-03-12 03:59:11 +00:00
|
|
|
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 {
|
2024-08-03 17:32:02 +00:00
|
|
|
options.aa.nix = {
|
2023-03-12 03:59:11 +00:00
|
|
|
enable = mkEnableOption "manage nix configuration.";
|
|
|
|
package = mkOption {
|
2024-08-03 17:32:02 +00:00
|
|
|
type = types.package;
|
2024-05-04 02:59:19 +00:00
|
|
|
default = pkgs.nixVersions.git;
|
2023-03-12 03:59:11 +00:00
|
|
|
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 [
|
2024-03-10 23:06:58 +00:00
|
|
|
# TESTING
|
|
|
|
"https://minio.kilonull.com/nix-store"
|
2023-04-09 02:13:00 +00:00
|
|
|
selfHostedCacheHost
|
|
|
|
]
|
|
|
|
else [];
|
|
|
|
trusted-public-keys =
|
2024-08-03 17:32:02 +00:00
|
|
|
mkIf cfg.useSelfhostedCache
|
|
|
|
["gospelCache:9cbn8Wm54BbwpPS0TXw+15wrYZBpfOJt4Fzfbfcq/pc="];
|
2023-03-12 03:59:11 +00:00
|
|
|
};
|
|
|
|
|
2023-10-05 03:36:21 +00:00
|
|
|
# TODO: Configure distributedBuilds and buildMachines?
|
|
|
|
|
2023-03-12 03:59:11 +00:00
|
|
|
gc = {
|
|
|
|
automatic = true;
|
|
|
|
dates = "weekly";
|
|
|
|
options = "--delete-older-than 30d";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|