From ecb79359bfe3fabef8eef30df74f8a93bde53e2c Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Fri, 17 Sep 2021 23:37:42 -0400 Subject: [PATCH] refactor --- features/distributed-build.nix | 24 +++--- flake.nix | 129 +++++++++++++++++---------------- 2 files changed, 78 insertions(+), 75 deletions(-) diff --git a/features/distributed-build.nix b/features/distributed-build.nix index 8e6639d..064127a 100644 --- a/features/distributed-build.nix +++ b/features/distributed-build.nix @@ -2,17 +2,19 @@ # https://nixos.wiki/wiki/Distributed_build { - nix.buildMachines = [{ - hostName = "162.55.241.231"; - system = "x86_64-linux"; - # if the builder supports building for multiple architectures, - # replace the previous line by, e.g., - # systems = ["x86_64-linux" "aarch64-linux"]; - maxJobs = 16; - speedFactor = 3; - supportedFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ]; - mandatoryFeatures = [ ]; - }]; + nix.buildMachines = [ + { + hostName = "162.55.89.216"; + system = "x86_64-linux"; + # if the builder supports building for multiple architectures, + # replace the previous line by, e.g., + # systems = ["x86_64-linux" "aarch64-linux"]; + maxJobs = 16; + speedFactor = 3; + supportedFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ]; + mandatoryFeatures = []; + } + ]; nix.distributedBuilds = true; # optional, useful when the builder has a faster internet connection than yours nix.extraOptions = '' diff --git a/flake.nix b/flake.nix index f69fa35..f212b29 100644 --- a/flake.nix +++ b/flake.nix @@ -21,17 +21,16 @@ outputs = inputs@{ self, home-manager, nixpkgs, ... }: let system = "x86_64-linux"; - # Make configuration for any computer I use in my home office. - mkHomeMachine = configurationNix: extraModules: nixpkgs.lib.nixosSystem { + mkComputer = configurationNix: extraModules: nixpkgs.lib.nixosSystem { inherit system; # Arguments to pass to all modules. specialArgs = { inherit system inputs; }; modules = ( [ - # System configuration + # System configuration for this host configurationNix - # common + # Configuration common to all of my systems (servers, desktops, laptops) ./features/self-ide.nix ./features/takemessh ./features/caches @@ -53,66 +52,68 @@ ); }; in - { - # The "name" in nixosConfigurations.${name} should match the `hostname` - # - nixosConfigurations = { - p71 = mkHomeMachine - ./hosts/p71.nix - [ - inputs.nixos-hardware.nixosModules.lenovo-thinkpad-p53 - ./features/desktopish - #./features/gnome.nix - ./features/desktopish/guiapps.nix - ./features/server/devserver.nix - ./features/ema/emanote.nix - #./features/virtualbox.nix - ./features/lxd.nix - #./features/server-mode.nix - # ./features/postgrest.nix - ./features/server/devserver.nix - ]; - x1c7 = mkHomeMachine - ./hosts/x1c7.nix - [ - inputs.nixos-hardware.nixosModules.lenovo-thinkpad-x1-7th-gen - ./features/distributed-build.nix - ./features/gnome.nix - ./features/desktopish/guiapps.nix - ]; - ryzen9 = mkHomeMachine - ./hosts/ryzen9.nix - [ - ./features/server/devserver.nix - ]; + { + # The "name" in nixosConfigurations.${name} should match the `hostname` + # + nixosConfigurations = { + p71 = mkComputer + ./hosts/p71.nix + [ + inputs.nixos-hardware.nixosModules.lenovo-thinkpad-p53 + ./features/desktopish + #./features/gnome.nix + ./features/desktopish/guiapps.nix + ./features/server/devserver.nix + ./features/ema/emanote.nix + #./features/virtualbox.nix + ./features/lxd.nix + #./features/server-mode.nix + # ./features/postgrest.nix + ./features/server/devserver.nix + ]; + x1c7 = mkComputer + ./hosts/x1c7.nix + [ + inputs.nixos-hardware.nixosModules.lenovo-thinkpad-x1-7th-gen + ./features/distributed-build.nix + ./features/gnome.nix + ./features/desktopish/guiapps.nix + ]; + ryzen9 = mkComputer + ./hosts/ryzen9.nix + [ + ./features/server/devserver.nix + ]; + }; + + # non-NixOS systems + homeConfigurations = + let + username = "srid"; + baseConfiguration = { + programs.home-manager.enable = true; + home.username = "srid"; + home.homeDirectory = "/home/srid"; + }; + mkHomeConfig = cfg: home-manager.lib.homeManagerConfiguration { + inherit username system; + homeDirectory = "/home/${username}"; + configuration = baseConfiguration // cfg; + }; + in + { + "P71" = mkHomeConfig ( + import ./home.nix { + inherit inputs system; + pkgs = import nixpkgs { inherit system; }; + } + ); + # FIXME: This is broken on Clear Linux + "x1c7" = mkHomeConfig { + programs.git = import ./home/git.nix; + programs.tmux = import ./home/tmux.nix; + }; + }; }; - # non-NixOS systems - homeConfigurations = - let - username = "srid"; - baseConfiguration = { - programs.home-manager.enable = true; - home.username = "srid"; - home.homeDirectory = "/home/srid"; - }; - mkHomeConfig = cfg: home-manager.lib.homeManagerConfiguration { - inherit username system; - homeDirectory = "/home/${username}"; - configuration = baseConfiguration // cfg; - }; - in - { - "P71" = mkHomeConfig (import ./home.nix { - inherit inputs system; - pkgs = import nixpkgs { inherit system; }; - }); - # FIXME: This is broken on Clear Linux - "x1c7" = mkHomeConfig { - programs.git = import ./home/git.nix; - programs.tmux = import ./home/tmux.nix; - }; - }; - }; - }