From 2013b0cf2ded3048861942bb6b1a8a84119fc71a Mon Sep 17 00:00:00 2001 From: Ariel Sosnovsky Date: Tue, 6 Feb 2024 21:41:14 -0500 Subject: [PATCH] universal nixos --- os/nixos/configuration.nix | 21 +++++++++++++-------- os/nixos/k3s.nix | 12 ++++++++---- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/os/nixos/configuration.nix b/os/nixos/configuration.nix index 9867edd..0446b41 100644 --- a/os/nixos/configuration.nix +++ b/os/nixos/configuration.nix @@ -1,14 +1,19 @@ -# Edit this configuration file to define what should be installed on -# your system. Help is available in the configuration.nix(5) man page -# and in the NixOS manual (accessible by running ‘nixos-help’). - +{ + hostName, + stateVersion = "23.05", + dbConnectionStr, + K3SToken +}: { config, pkgs, ... }: - { imports = [ ./hardware-configuration.nix - "./k3s.nix" + (import "./k3s.nix" { + hostName = hostName; + dbConnectionStr = dbConnectionStr; + K3SToken = K3SToken; + }) "./users.nix" "./settings.nix" ]; @@ -16,6 +21,6 @@ # Bootloader. boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/sda"; - networking.hostName = "changeme"; # Define your hostname. - system.stateVersion = "23.05"; + networking.hostName = hostName; + system.stateVersion = stateVersion; } diff --git a/os/nixos/k3s.nix b/os/nixos/k3s.nix index 363024f..45cb377 100644 --- a/os/nixos/k3s.nix +++ b/os/nixos/k3s.nix @@ -1,7 +1,11 @@ # Edit this configuration file to define what should be installed on # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). - +{ + hostName, + dbConnectionStr, + K3SToken +}: { config, pkgs, ... }: { @@ -21,9 +25,9 @@ services.k3s.role = "server"; services.k3s.extraFlags = toString [ "--tls-san" - "192.168.0.26" - "--datastore-endpoint" "postgres://postgres:3wtvrd5KdQYUXE@192.168.0.28:5432/k3sdb?sslmode=disable" - "--token" "Upi+DZa++9DiAc1po4LkPKPx6Ed1IRrg1VRsglGjp2ERhOssDXaKCWLY8Enk3GIOGyWHHlHKz1dIofXpgkRV2w==" + hostName + "--datastore-endpoint" dbConnectionStr + "--token" K3SToken ]; networking.firewall.allowedTCPPorts = [ 22 80 443 ]; networking.firewall.allowedUDPPorts = [ 80 443 ];