diff --git a/flake.nix b/flake.nix index 8f9a108..af156d7 100644 --- a/flake.nix +++ b/flake.nix @@ -58,7 +58,7 @@ }; in { nixosConfigurations = { - # Microsoft Surface Laptop Go + # Microsoft Surface Laptop Go Dimaga = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = defaultModules.base ++ [ @@ -94,7 +94,7 @@ ]; }; - # Lenovo Legion Slim 7 Gen 7 AMD + # Lenovo Legion Slim 7 Gen 7 AMD Shura = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = defaultModules.base ++ [ diff --git a/hosts/Khanda/default.nix b/hosts/Khanda/default.nix index 5200ab7..1794fa1 100644 --- a/hosts/Khanda/default.nix +++ b/hosts/Khanda/default.nix @@ -39,12 +39,8 @@ }; }; - # Limit number of simultaneous builds so we have two free cores. - # 5 max jobs * 2 cores each = 10 cores in total. - nix.settings = { - max-jobs = 2; - cores = 10; - }; + # Build remotely + nix.distributedBuilds = true; # Configure the virtual machine created by nixos-rebuild build-vm virtualisation.vmVariant.virtualisation = { diff --git a/modules/base/default.nix b/modules/base/default.nix index fe9ebfd..b3dfa38 100644 --- a/modules/base/default.nix +++ b/modules/base/default.nix @@ -3,6 +3,7 @@ ./bluetooth.nix ./bootloader.nix ./network.nix + ./nix.nix ./shell.nix ./system.nix ]; diff --git a/modules/base/nix.nix b/modules/base/nix.nix new file mode 100644 index 0000000..7beb0e7 --- /dev/null +++ b/modules/base/nix.nix @@ -0,0 +1,42 @@ +# Nix configuration +{ pkgs, config, lib, inputs, ... }: { + nix = { + # Use the latest and greatest Nix + package = pkgs.nixVersions.unstable; + + settings = { + # Enables Flakes + experimental-features = [ "nix-command" "flakes" ]; + + # Avoid signature verification messages when doing remote builds + trusted-users = [ "${config.users.users.aires.name}" ]; + }; + + # Enable periodic nix store optimization + optimise.automatic = true; + + # Configure NixOS to use the same software channel as Flakes + registry = lib.mapAttrs (_: value: { flake = value; }) inputs; + nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry; + + # Configure remote build machines (mainly Haven) + # To enable remote builds for a specific host, add `nix.distributedBuilds = true;` to its config + buildMachines = [{ + hostName = "haven"; + systems = [ + "x86_64-linux" + "aarch64-linux" + ]; + protocol = "ssh-ng"; + supportedFeatures = [ + "nixos-test" + "kvm" + ]; + }]; + + # When using a builder, use its package store + extraOptions = '' + builders-use-substitutes = true + ''; + }; +} \ No newline at end of file diff --git a/modules/base/system.nix b/modules/base/system.nix index 9076183..ce4f3df 100644 --- a/modules/base/system.nix +++ b/modules/base/system.nix @@ -69,27 +69,6 @@ with lib; }; }; - # Configure nix - nix = { - # Use the latest and greatest Nix - package = pkgs.nixVersions.unstable; - - settings = { - # Enables Flakes - experimental-features = [ "nix-command" "flakes" ]; - - # Avoid signature verification messages when doing remote builds - trusted-users = [ "${config.users.users.aires.name}" ]; - }; - - # Enable periodic nix store optimization - optimise.automatic = true; - - # Configure NixOS to use the same software channel as Flakes - registry = lib.mapAttrs (_: value: { flake = value; }) inputs; - nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry; - }; - # Set up base apps programs = { direnv.enable = true;