2024-02-05 11:46:52 +01:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
...
|
2022-03-01 22:19:03 +01:00
|
|
|
}:
|
2024-02-05 11:46:52 +01:00
|
|
|
with lib;
|
|
|
|
let
|
2022-03-01 22:19:03 +01:00
|
|
|
cfg = config.eboskma.nix-common;
|
2022-04-27 00:21:19 +02:00
|
|
|
in
|
|
|
|
{
|
2021-11-16 00:22:18 +01:00
|
|
|
options.eboskma.nix-common = {
|
2022-10-10 18:35:50 +02:00
|
|
|
enable = mkEnableOption "nix-common";
|
|
|
|
remote-builders = mkEnableOption "remote builders";
|
|
|
|
cross-systems = mkOption {
|
|
|
|
description = "list of systems to cross compile for";
|
|
|
|
type = with types; listOf str;
|
2022-10-13 14:14:30 +02:00
|
|
|
default = [ ];
|
2022-10-10 18:35:50 +02:00
|
|
|
};
|
2024-06-12 21:42:01 +02:00
|
|
|
gc-interval = mkOption {
|
|
|
|
description = "How often to run nix-collect-garbage";
|
|
|
|
type = types.str;
|
2024-07-18 10:47:15 +02:00
|
|
|
default = "03:15";
|
2024-06-12 21:42:01 +02:00
|
|
|
};
|
2021-11-16 00:22:18 +01:00
|
|
|
};
|
|
|
|
|
2022-08-14 16:38:25 +02:00
|
|
|
imports = [
|
2024-04-16 19:32:32 +02:00
|
|
|
(mkRemovedOptionModule [
|
|
|
|
"eboskma"
|
|
|
|
"nix-common"
|
|
|
|
"disable-cache"
|
|
|
|
] "The option `disable-cache` is no longer used")
|
2022-08-14 16:38:25 +02:00
|
|
|
];
|
|
|
|
|
2021-11-16 00:22:18 +01:00
|
|
|
config = mkIf cfg.enable {
|
2022-11-11 17:07:24 +01:00
|
|
|
# nixpkgs = {
|
|
|
|
# config.allowUnfree = true;
|
|
|
|
# };
|
2021-11-16 00:22:18 +01:00
|
|
|
|
|
|
|
nix = {
|
2024-05-07 08:47:22 +02:00
|
|
|
package = pkgs.nixVersions.latest;
|
2021-11-16 00:22:18 +01:00
|
|
|
|
2022-08-14 16:38:25 +02:00
|
|
|
buildMachines = mkIf cfg.remote-builders [
|
|
|
|
{
|
|
|
|
hostName = "loki";
|
2022-10-10 18:35:50 +02:00
|
|
|
systems = [ "x86_64-linux" ] ++ cfg.cross-systems;
|
2022-08-14 16:38:25 +02:00
|
|
|
maxJobs = 8;
|
|
|
|
speedFactor = 2;
|
2024-02-05 11:46:52 +01:00
|
|
|
supportedFeatures = [
|
|
|
|
"kvm"
|
|
|
|
"big-parallel"
|
|
|
|
"nixos-test"
|
|
|
|
"benchmark"
|
|
|
|
];
|
2022-08-14 16:38:25 +02:00
|
|
|
}
|
|
|
|
];
|
|
|
|
distributedBuilds = cfg.remote-builders;
|
|
|
|
|
2022-02-02 21:26:39 +01:00
|
|
|
settings = {
|
|
|
|
auto-optimise-store = true;
|
2022-04-27 00:21:19 +02:00
|
|
|
allowed-users = [ "root" ];
|
2024-02-05 11:46:52 +01:00
|
|
|
trusted-users = [
|
|
|
|
"root"
|
|
|
|
"@wheel"
|
|
|
|
];
|
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-11-19 17:24:57 +01:00
|
|
|
"https://devenv.cachix.org"
|
2024-01-17 09:41:56 +01:00
|
|
|
"https://elixir-tools.cachix.org"
|
2024-01-29 10:29:09 +01:00
|
|
|
"https://staging.attic.rs/attic-ci"
|
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-11-19 17:24:57 +01:00
|
|
|
"devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="
|
2024-01-17 09:41:56 +01:00
|
|
|
"elixir-tools.cachix.org-1:GfK9E139Ysi+YWeS1oNN9OaTfQjqpLwlBaz+/73tBjU="
|
2024-01-29 10:29:09 +01:00
|
|
|
"attic-ci:U5Sey4mUxwBXM3iFapmP0/ogODXywKLRNgRPQpEXxbo="
|
2024-01-17 09:41:56 +01:00
|
|
|
];
|
|
|
|
experimental-features = [
|
|
|
|
"nix-command"
|
|
|
|
"flakes"
|
|
|
|
"auto-allocate-uids"
|
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;
|
2024-06-12 21:42:01 +02:00
|
|
|
dates = cfg.gc-interval;
|
2022-12-23 09:21:44 +01:00
|
|
|
options = "--delete-older-than 30d";
|
2021-11-16 00:22:18 +01:00
|
|
|
};
|
|
|
|
};
|
2022-08-14 16:38:25 +02:00
|
|
|
|
2022-10-10 18:35:50 +02:00
|
|
|
boot.binfmt.emulatedSystems = cfg.cross-systems;
|
|
|
|
|
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
|
|
|
};
|
|
|
|
}
|