dotfiles/modules/nixos/nix/default.nix

63 lines
1.4 KiB
Nix
Raw Permalink Normal View History

2023-03-12 03:59:11 +00:00
{
config,
pkgs,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption mkOption types;
2023-03-12 03:59:11 +00:00
cfg = config.aa.nix;
selfHostedCacheHost = "https://cache.kilonull.com/";
2023-03-12 03:59:11 +00:00
in {
options.aa.nix = {
2023-03-12 03:59:11 +00:00
enable = mkEnableOption "manage nix configuration.";
package = mkOption {
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 =
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";
};
};
};
}