From 33cab3051153ed77663474801aaff4a4c3287124 Mon Sep 17 00:00:00 2001 From: "quentin@aristote.fr" Date: Sun, 8 Dec 2024 23:02:44 +0100 Subject: nix: enable remote building --- config/default.nix | 2 +- config/nix.nix | 31 ------------------------------- config/nix/default.nix | 33 +++++++++++++++++++++++++++++++++ config/nix/remote-builds.nix | 30 ++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 32 deletions(-) delete mode 100644 config/nix.nix create mode 100644 config/nix/default.nix create mode 100644 config/nix/remote-builds.nix diff --git a/config/default.nix b/config/default.nix index dd22e26..4078e47 100644 --- a/config/default.nix +++ b/config/default.nix @@ -5,7 +5,7 @@ ./boot.nix ./environment.nix ./networking.nix - ./nix.nix + ./nix ./services ./users.nix ]; diff --git a/config/nix.nix b/config/nix.nix deleted file mode 100644 index a3d2da2..0000000 --- a/config/nix.nix +++ /dev/null @@ -1,31 +0,0 @@ -{lib, ...}: { - personal.nix = { - enable = true; - autoUpgrade = { - enable = true; - autoUpdateInputs = ["nixpkgs" "nixpkgs-unstable"]; - }; - gc.enable = true; - flake = "git+file:///etc/nixos/"; - }; - nix.settings.max-jobs = lib.mkDefault 1; - nixpkgs.flake = { - setNixPath = true; - setFlakeRegistry = true; - }; - - systemd.services.nixos-upgrade = let - mkForce = lib.mkOverride 51; - in { - # restart at most once every hour - serviceConfig = { - Restart = "on-failure"; - RestartSec = "5sec"; - MemoryAccounting = true; - MemoryHigh = "1G"; - MemoryMax = "1.5G"; - }; - startLimitBurst = mkForce 1; - startLimitIntervalSec = mkForce 3600; - }; -} diff --git a/config/nix/default.nix b/config/nix/default.nix new file mode 100644 index 0000000..c930095 --- /dev/null +++ b/config/nix/default.nix @@ -0,0 +1,33 @@ +{lib, ...}: { + imports = [./remote-builds.nix]; + + personal.nix = { + enable = true; + autoUpgrade = { + enable = true; + autoUpdateInputs = ["nixpkgs" "nixpkgs-unstable"]; + }; + gc.enable = true; + flake = "git+file:///etc/nixos/"; + }; + nix.settings.max-jobs = lib.mkDefault 1; + nixpkgs.flake = { + setNixPath = true; + setFlakeRegistry = true; + }; + + systemd.services.nixos-upgrade = let + mkForce = lib.mkOverride 51; + in { + # restart at most once every hour + serviceConfig = { + Restart = "on-failure"; + RestartSec = "5sec"; + MemoryAccounting = true; + MemoryHigh = "1G"; + MemoryMax = "1.5G"; + }; + startLimitBurst = mkForce 1; + startLimitIntervalSec = mkForce 3600; + }; +} diff --git a/config/nix/remote-builds.nix b/config/nix/remote-builds.nix new file mode 100644 index 0000000..5f23108 --- /dev/null +++ b/config/nix/remote-builds.nix @@ -0,0 +1,30 @@ +{...}: { + networking.hosts."10.13.42.2" = ["hephaistos.local"]; + programs.ssh = { + extraConfig = '' + Host hephaistos.local + # Prevent using ssh-agent or another keyfile, useful for testing + IdentitiesOnly yes + IdentityFile /etc/ssh/nixremote + # The weakly privileged user on the remote builder – if not set, 'root' is used – which will hopefully fail + User nixremote + ''; + knownHosts."hephaistos.local".publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHvtqi8tziBuviUV8LDK2ddQQUbHdJYB02dgWTK5Olxq"; + }; + + nix = { + distributedBuilds = true; + buildMachines = [ + { + hostName = "hephaistos.local"; + system = "x86_64-linux"; + # Nix custom ssh-variant that avoids lots of "trusted-users" settings pain + protocol = "ssh-ng"; + maxJobs = 4; + speedFactor = 4; + supportedFeatures = ["nixos-test" "benchmark" "big-parallel" "kvm"]; + mandatoryFeatures = []; + } + ]; + }; +} -- cgit v1.2.3