nixos-config/modules/nix-common/default.nix

74 lines
1.7 KiB
Nix
Raw Normal View History

{ lib
, pkgs
, config
, ...
2022-03-01 22:19:03 +01:00
}:
with lib; let
cfg = config.eboskma.nix-common;
in
{
2021-11-16 00:22:18 +01:00
options.eboskma.nix-common = {
enable = mkEnableOption "activate nix-common";
2022-08-14 16:38:25 +02:00
remote-builders = mkEnableOption "enable remote builders";
2021-11-16 00:22:18 +01:00
};
2022-08-14 16:38:25 +02:00
imports = [
2022-08-18 16:37:26 +02:00
(mkRemovedOptionModule [ "eboskma" "nix-common" "disable-cache" ]
2022-08-14 16:38:25 +02:00
"The option `disable-cache` is no longer used")
];
2021-11-16 00:22:18 +01:00
config = mkIf cfg.enable {
nixpkgs = {
config.allowUnfree = true;
};
nix = {
2022-09-28 08:11:25 +02:00
package = pkgs.nixVersions.stable;
2021-11-16 00:22:18 +01:00
extraOptions = ''
2022-03-01 22:19:03 +01:00
experimental-features = nix-command flakes
2021-11-16 00:22:18 +01:00
'';
2022-08-14 16:38:25 +02:00
buildMachines = mkIf cfg.remote-builders [
{
hostName = "loki";
systems = [ "x86_64-linux" ];
maxJobs = 8;
speedFactor = 2;
supportedFeatures = [ "kvm" "big-parallel" "nixos-test" "benchmark" ];
}
];
distributedBuilds = cfg.remote-builders;
2022-02-02 21:26:39 +01:00
settings = {
auto-optimise-store = true;
allowed-users = [ "root" ];
2022-08-14 16:38:25 +02:00
trusted-users = [ "root" ];
2022-02-15 16:03:36 +01:00
substituters = [
"https://nix-community.cachix.org"
2022-06-10 20:19:24 +02:00
"https://marcus7070.cachix.org"
2022-08-18 16:37:26 +02:00
];
2022-02-15 16:03:36 +01:00
trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
2022-06-10 20:19:24 +02:00
"marcus7070.cachix.org-1:JawxHSgnYsgNYJmNqZwvLjI4NcOwrcEZDToWlT3WwXw="
2022-08-14 16:38:25 +02:00
];
2022-02-02 21:26:39 +01:00
};
2021-11-16 00:22:18 +01:00
gc = {
automatic = true;
dates = "daily";
2021-11-16 00:22:18 +01:00
options = "--delete-older-than=30d";
};
};
2022-08-14 16:38:25 +02:00
programs.ssh.extraConfig = mkIf cfg.remote-builders ''
2022-08-18 16:37:26 +02:00
Host loki
HostName 10.0.0.4
Port 22
User builder
IdentitiesOnly yes
IdentityFile /root/.ssh/id_builder
'';
2021-11-16 00:22:18 +01:00
};
}