2024-11-19 10:31:29 +01:00
|
|
|
{
|
|
|
|
options,
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
inputs,
|
|
|
|
...
|
|
|
|
}:
|
2024-03-21 15:00:36 +01:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
with lib.metacfg;
|
|
|
|
let
|
|
|
|
cfg = config.metacfg.nix;
|
|
|
|
|
2024-11-19 10:31:29 +01:00
|
|
|
substituters-submodule = types.submodule (
|
|
|
|
{ name, ... }:
|
|
|
|
{
|
|
|
|
options = with types; {
|
|
|
|
key = mkOpt (nullOr str) null "The trusted public key for this substituter.";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|
2024-03-21 15:00:36 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.metacfg.nix = with types; {
|
|
|
|
enable = mkBoolOpt false "Whether or not to manage nix configuration.";
|
|
|
|
package = mkOpt package pkgs.nix "Which nix package to use.";
|
|
|
|
|
|
|
|
default-substituter = {
|
|
|
|
url = mkOpt str "https://cache.nixos.org" "The url for the substituter.";
|
2024-11-19 10:31:29 +01:00
|
|
|
key =
|
|
|
|
mkOpt str "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
|
|
|
|
"The trusted public key for the substituter.";
|
2024-03-21 15:00:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extra-substituters = mkOpt (attrsOf substituters-submodule) { } "Extra substituters to configure.";
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2024-11-19 10:31:29 +01:00
|
|
|
assertions = mapAttrsToList (name: value: {
|
|
|
|
assertion = value.key != null;
|
|
|
|
message = "metacfg.nix.extra-substituters.${name}.key must be set";
|
|
|
|
}) cfg.extra-substituters;
|
2024-03-21 15:00:36 +01:00
|
|
|
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
metacfg.nixos-revision
|
2024-11-19 10:31:29 +01:00
|
|
|
(metacfg.nixos-hosts.override { hosts = inputs.self.nixosConfigurations; })
|
2024-03-21 15:00:36 +01:00
|
|
|
deploy-rs
|
|
|
|
nixfmt
|
|
|
|
nix-index
|
|
|
|
nix-prefetch-git
|
|
|
|
nix-output-monitor
|
|
|
|
];
|
|
|
|
|
2024-03-28 10:30:42 +01:00
|
|
|
systemd.services.nix-daemon.environment.TMPDIR = "/var/tmp";
|
|
|
|
|
2024-03-21 15:00:36 +01:00
|
|
|
nix =
|
|
|
|
let
|
2024-11-19 10:31:29 +01:00
|
|
|
users = [
|
|
|
|
"root"
|
|
|
|
config.metacfg.user.name
|
|
|
|
] ++ optional config.services.hydra.enable "hydra";
|
2024-03-21 15:00:36 +01:00
|
|
|
extra-substituters = cfg.extra-substituters // {
|
2024-06-28 14:33:05 +02:00
|
|
|
"https://attic.teepot.org/tee-pot".key = "tee-pot:SS6HcrpG87S1M6HZGPsfo7d1xJccCGev7/tXc5+I4jg=";
|
2024-03-21 15:00:36 +01:00
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
package = cfg.package;
|
|
|
|
|
2024-11-19 10:31:29 +01:00
|
|
|
settings =
|
|
|
|
{
|
|
|
|
experimental-features = "nix-command flakes";
|
|
|
|
http-connections = 50;
|
|
|
|
warn-dirty = false;
|
|
|
|
log-lines = 50;
|
|
|
|
sandbox = true;
|
|
|
|
auto-optimise-store = true;
|
|
|
|
trusted-users = users;
|
|
|
|
allowed-users = users;
|
2024-03-21 15:00:36 +01:00
|
|
|
|
2024-11-19 10:31:29 +01:00
|
|
|
substituters = [
|
|
|
|
cfg.default-substituter.url
|
|
|
|
] ++ (mapAttrsToList (name: value: name) extra-substituters);
|
|
|
|
trusted-public-keys = [
|
|
|
|
cfg.default-substituter.key
|
|
|
|
] ++ (mapAttrsToList (name: value: value.key) extra-substituters);
|
2024-03-21 15:00:36 +01:00
|
|
|
|
2024-11-19 10:31:29 +01:00
|
|
|
}
|
|
|
|
// (lib.optionalAttrs config.metacfg.tools.direnv.enable {
|
|
|
|
keep-outputs = true;
|
|
|
|
keep-derivations = true;
|
|
|
|
});
|
2024-03-21 15:00:36 +01:00
|
|
|
|
|
|
|
gc = {
|
|
|
|
automatic = true;
|
2024-06-25 10:09:51 +02:00
|
|
|
dates = lib.mkDefault "weekly";
|
|
|
|
options = lib.mkDefault "--delete-older-than 14d";
|
2024-03-21 15:00:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
# flake-utils-plus
|
|
|
|
generateRegistryFromInputs = true;
|
|
|
|
generateNixPathFromInputs = true;
|
|
|
|
linkInputs = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|