From 73a072ae4914af40c6c6fd46fad11e487ae4d69c Mon Sep 17 00:00:00 2001 From: James Walker Date: Tue, 3 May 2022 21:00:37 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20flakes=20+=20deploy-rs=20convers?= =?UTF-8?q?ion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flake.lock | 63 ++++++++++-- flake.nix | 111 ++++++++++++++++------ hosts/plato/configuration.nix | 10 +- hosts/socrates/configuration.nix | 10 +- hosts/socrates/hardware-configuration.nix | 4 +- 5 files changed, 141 insertions(+), 57 deletions(-) diff --git a/flake.lock b/flake.lock index 41a9989..cc927c3 100644 --- a/flake.lock +++ b/flake.lock @@ -20,6 +20,27 @@ "type": "github" } }, + "dotfiles": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1651201720, + "narHash": "sha256-nx4UKikzjZLunB1VUf5I8jFurn0rfc3y1xceb6deDmI=", + "owner": "walkah", + "repo": "dotfiles", + "rev": "a9529560bffd9d1093e957b9b5d7bdcedaa39f8e", + "type": "github" + }, + "original": { + "owner": "walkah", + "repo": "dotfiles", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -52,15 +73,36 @@ } }, "home-manager": { + "inputs": { + "nixpkgs": [ + "dotfiles", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1640592198, + "narHash": "sha256-F5dWVGQMscmGyLTzNLocPB1v8Ijp8ONx8Nq9Dmi5PSw=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "0b197562ab7bf114dd5f6716f41d4b5be6ccd357", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "home-manager_2": { "inputs": { "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1651007090, - "narHash": "sha256-C/OoQRzTUOWEr1sd3xTKA2GudA1YG1XB3MlL6KfTchg=", + "lastModified": 1651531343, + "narHash": "sha256-DBJFMNlWcht3jdKE2KVbcy1g/e/yryrSs1qSViQd4lE=", "owner": "nix-community", "repo": "home-manager", - "rev": "778af87a981eb2bfa3566dff8c3fb510856329ef", + "rev": "0304f0f58b4c538ff704c58d53a778b062810ec7", "type": "github" }, "original": { @@ -87,11 +129,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1651114127, - "narHash": "sha256-/lLC0wkMZkAdA5e1W76SnJzbhfOGDvync3VRHJMtAKk=", + "lastModified": 1651369430, + "narHash": "sha256-d86uUm0s11exU9zLo2K1AwtJQJDKubFpoF0Iw767uT4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6766fb6503ae1ebebc2a9704c162b2aef351f921", + "rev": "b283b64580d1872333a99af2b4cef91bb84580cf", "type": "github" }, "original": { @@ -101,11 +143,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1651007983, - "narHash": "sha256-GNay7yDPtLcRcKCNHldug85AhAvBpTtPEJWSSDYBw8U=", + "lastModified": 1651558728, + "narHash": "sha256-8HzyRnWlgZluUrVFNOfZAOlA1fghpOSezXvxhalGMUo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e10da1c7f542515b609f8dfbcf788f3d85b14936", + "rev": "cbe587c735b734405f56803e267820ee1559e6c1", "type": "github" }, "original": { @@ -118,8 +160,9 @@ "root": { "inputs": { "deploy-rs": "deploy-rs", + "dotfiles": "dotfiles", "flake-utils": "flake-utils", - "home-manager": "home-manager", + "home-manager": "home-manager_2", "nixpkgs": "nixpkgs_3" } }, diff --git a/flake.nix b/flake.nix index d27910e..f60fc1c 100644 --- a/flake.nix +++ b/flake.nix @@ -6,9 +6,30 @@ home-manager.url = "github:nix-community/home-manager"; flake-utils.url = "github:numtide/flake-utils"; deploy-rs.url = "github:serokell/deploy-rs"; + + # My stuff + dotfiles = { + url = "github:walkah/dotfiles"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs, deploy-rs, flake-utils, ... }: + outputs = { self, nixpkgs, deploy-rs, flake-utils, home-manager, dotfiles, ... }@attrs: + let + mkSystem = hostName: system: modules: + nixpkgs.lib.nixosSystem { + system = system; + modules = [ + home-manager.nixosModules.home-manager + ({ config, ... }: { + networking.hostName = hostName; + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + }) + ] + ++ modules; + }; + in flake-utils.lib.eachDefaultSystem (system: let @@ -16,35 +37,18 @@ in { devShells.default = pkgs.mkShell { - buildInputs = [ - deploy-rs.packages.${system}.deploy-rs - pkgs.sops - ]; + buildInputs = [ deploy-rs.packages.${system}.deploy-rs pkgs.sops ]; }; - } - ) - // { + }) // { nixosConfigurations = { - agent = nixpkgs.lib.nixosSystem { - system = "aarch64-linux"; - modules = [ - ./hosts/aristotle/configuration.nix - ({ config, ... }: { - networking.hostName = "agent"; - }) - ]; - }; - - form = nixpkgs.lib.nixosSystem { - system = "aarch64-linux"; - modules = [ - ./hosts/aristotle/configuration.nix - ({ config, ... }: { - networking.hostName = "form"; - }) - ]; - }; + # Aristotle + agent = mkSystem "agent" "aarch64-linux" [ ./hosts/aristotle/configuration.nix ]; + form = mkSystem "form" "aarch64-linux" [ ./hosts/aristotle/configuration.nix ]; + matter = mkSystem "matter" "aarch64-linux" [ ./hosts/aristotle/configuration.nix ]; + purpose = mkSystem "purpose" "aarch64-linux" [ ./hosts/aristotle/configuration.nix ]; + plato = mkSystem "plato" "x86_64-linux" [ ./hosts/plato/configuration.nix ]; + socrates = mkSystem "socrates" "x86_64-linux" [ ./hosts/socrates/configuration.nix ]; }; deploy.nodes = { @@ -67,6 +71,59 @@ self.nixosConfigurations.form; }; }; + + matter = { + hostname = "matter"; + sshUser = "root"; + profiles.system = { + user = "root"; + path = deploy-rs.lib.aarch64-linux.activate.nixos + self.nixosConfigurations.matter; + }; + }; + + purpose = { + hostname = "purpose"; + sshUser = "root"; + profiles.system = { + user = "root"; + path = deploy-rs.lib.aarch64-linux.activate.nixos + self.nixosConfigurations.purpose; + }; + }; + + plato = { + hostname = "plato"; + profiles = { + system = { + user = "root"; + path = deploy-rs.lib.x86_64-linux.activate.nixos + self.nixosConfigurations.plato; + }; + walkah = { + user = "walkah"; + path = deploy-rs.lib.x86_64-linux.activate.home-manager + dotfiles.homeConfigurations.x86_64-linux; + }; + }; + }; + + socrates = { + hostname = "socrates"; + sshUser = "root"; + profiles = { + system = { + user = "root"; + path = deploy-rs.lib.x86_64-linux.activate.nixos + self.nixosConfigurations.socrates; + }; + walkah = { + user = "walkah"; + path = deploy-rs.lib.x86_64-linux.activate.home-manager + dotfiles.homeConfigurations.x86_64-linux; + }; + }; + }; }; }; } diff --git a/hosts/plato/configuration.nix b/hosts/plato/configuration.nix index 17bf0aa..aaa32cf 100644 --- a/hosts/plato/configuration.nix +++ b/hosts/plato/configuration.nix @@ -1,14 +1,7 @@ -{ config, pkgs, ... }: - -let - dotfiles = builtins.fetchTarball - "https://github.com/walkah/dotfiles/archive/main.tar.gz"; -in -{ +{ config, pkgs, home-manager, ... }: { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix - ../../modules/coredns ../../modules/code-server @@ -52,7 +45,6 @@ in "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIM8YMax7PGIrcPNIHkpuNRFgn3HJK6Wepm+ycZWO6jfR walkah@walkah-ipadpro11" ]; }; - home-manager.users.walkah = import "${dotfiles}/home.nix"; system.autoUpgrade.enable = false; environment.systemPackages = with pkgs; [ docker-compose pinentry weechat ]; diff --git a/hosts/socrates/configuration.nix b/hosts/socrates/configuration.nix index 54c28f1..d200dca 100644 --- a/hosts/socrates/configuration.nix +++ b/hosts/socrates/configuration.nix @@ -1,14 +1,7 @@ -{ pkgs, ... }: - -let - dotfiles = builtins.fetchTarball - "https://github.com/walkah/dotfiles/archive/main.tar.gz"; -in -{ +{ pkgs, ... }: { imports = [ ./hardware-configuration.nix ./networking.nix # generated at runtime by nixos-infect - ../../modules/coredns ../../modules/code-server/nginx.nix @@ -47,7 +40,6 @@ in ]; }; }; - home-manager.users.walkah = import "${dotfiles}/home.nix"; system.autoUpgrade.enable = false; environment.systemPackages = with pkgs; [ ipfs-migrator ]; diff --git a/hosts/socrates/hardware-configuration.nix b/hosts/socrates/hardware-configuration.nix index 8c88cb7..484eb7c 100644 --- a/hosts/socrates/hardware-configuration.nix +++ b/hosts/socrates/hardware-configuration.nix @@ -1,6 +1,6 @@ -{ ... }: +{ modulesPath, ... }: { - imports = [ ]; + imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; boot.loader.grub.device = "/dev/vda"; fileSystems."/" = { device = "/dev/vda1"; fsType = "ext4"; }; }