From abfbb5aa0979be2fd8da3567b5d14ca6678bcec6 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Wed, 2 Jul 2025 21:14:26 +0800 Subject: [PATCH] feat: rework hostSpec to use providers and machine definitions --- hostSpec.nix | 140 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 85 insertions(+), 55 deletions(-) diff --git a/hostSpec.nix b/hostSpec.nix index e07bcda..e2b6ec2 100644 --- a/hostSpec.nix +++ b/hostSpec.nix @@ -3,76 +3,106 @@ primary = true; email = "rafiq@rrv.sh"; alternate-emails = [ - "mohammadrafiq@rrv.sh" - "mohammadrafiq567@gmail.com" + "mohammadrafiq@rrv.sh" # Work + "googaabumtum@gmail.com" # Old Personal + "mohammadrafiq567@gmail.com" # Old Work ]; pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILdsZyY3gu8IGB8MzMnLdh+ClDxQQ2RYG9rkeetIKq8n"; }; - entrypoints = { - # For services that should only have one instance across the whole - # flake, define them here and they will get provisioned on those - # hosts, with whatever depends on them configured via that hostname. - nginx.host = "apollo"; - ssh.host = "apollo"; + # Services will use this to find where their configuration + # should point to and the providers will set up the needed + # configuration for each service. + providers = { + reverse-proxy = { + type = "nginx"; + host = "apollo"; + }; + mongodb.host = "helios"; }; # This will define all the hosts exposed by the flake and designate the # modules and services, along with defining the hardware configuration # for each host. # of each attr set will resolve to the host's hostname. + # Hosts can reach each other through their hostname (using Tailscale) hosts.nemesis = { - platform = "amd"; - gpu = "nvidia"; - ephemeralRoot = true; - boot-drive = "/dev/disk/by-id/nvme-CT2000P3SSD8_2325E6E77434"; - bootloader = "systemd-boot"; - # Enables dotfiles and desktop environment/services. - desktop.enable = true; - extraCfg = { }; - }; - hosts.apollo = { - platform = "intel"; - ephemeralRoot = true; - bootloader = "systemd-boot"; - boot-drive = "/dev/disk/by-id/nvme-eui.002538d221b47b01"; - # Public services will be exposed to the web server. - public-services = [ + machine = { + localIP = "10.10.0.11"; # Set up a static IP + platform = "amd"; # Set up CPU microcode etc + gpu = "nvidia"; # Set up nvidia drivers etc + # Partitioning and formatting config using disko + boot-drive = "/dev/disk/by-id/nvme-CT2000P3SSD8_2325E6E77434"; + }; + # Profiles will define configuration, such as graphical + # setting up window managers and web browsers + profiles = [ + "graphical" + "desktop" # might be a no-op? + ]; + services = [ { - name = "librechat"; + type = "stable-diffusion"; + public = false; # false by default + port = 7860; + } + ]; + # extraCfg will be added directly to the system's config + extraCfg = { + programs.steam.enable = true; + }; + }; + + hosts.apollo = { + machine = { + localIP = "10.10.0.102"; + platform = "intel"; + boot-drive = "/dev/disk/by-id/nvme-eui.002538d221b47b01"; + }; + profiles = [ + "server" # no-op as servers shouldnt have extra config but might change + ]; + services = [ + { + type = "librechat"; # Picks up the mongodb and nginx automatically + public = true; + port = 1234; domain = "chat.bwfiq.com"; } - { - name = "forgejo"; - domain = "git.rrv.sh"; - } - { - name = "rrv-sh"; - domain = "rrv.sh"; - } - { - name = "immich"; - domain = "photos.bwfiq.com"; - } - { - name = "aenyrathia-wiki"; - domain = "aenyrathia.wiki"; - } ]; - # Internal services will be exposed with tailscale only. - internal-services = [ - "mongodb" - "mariadb" - "postgresql" - "redis" - ]; - extraCfg = { }; }; - host.helios = { - platform = "intel"; - boot-drive = "nvme-eui.6479a784aad00284"; - ephemeralRoot = true; - bootloader = "systemd-boot"; - extraCfg = { }; + + hosts.helios = { + machine = { + localIP = "10.10.0.101"; + platform = "intel"; + boot-drive = "nvme-eui.6479a784aad00284"; + }; + profiles = [ "server" ]; + # Sets up network shares of the configured type under a folder + # e.g. /shares/{rafiqmedia, tv-shows} + # These are then consumed on other hosts under /mnt/{hostname}/{rafiqmedia,tv-shows} + shares = [ + { + folder = "rafiqmedia"; + type = [ + "nfs" + "smb" + ]; + } + ]; + }; + + hosts.iris = { + machine = { + localIP = "10.10.0.12"; + platform = "apple-silicon"; + boot-drive = ""; + }; + profiles = [ + "graphical" + "macbook" # asahi linux config etc - may not be needed + "laptop" # primarily power management + ]; }; }