From 155a9884ee4872b92fe85841c0a105b614c67bb2 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Mon, 18 Nov 2024 12:30:54 -0500 Subject: [PATCH] refactor: get rid of useless global vars --- common/home/neovim/langs/nix.nix | 4 +++- common/vars/default.nix | 16 ---------------- devices/README.md | 1 - devices/android/default.nix | 1 - devices/bbsteamie/default.nix | 5 ++--- devices/binto/default.nix | 5 ++--- devices/cluster/default.nix | 5 ++--- devices/cluster/modules/caddy.nix | 3 ++- devices/cluster/modules/headscale/default.nix | 3 ++- devices/cluster/modules/unbound.nix | 3 ++- devices/homie/default.nix | 5 ++--- devices/nos/default.nix | 5 ++--- devices/servivi/default.nix | 5 ++--- devices/wim/default.nix | 5 ++--- nixosModules/borgbackup/module.nix | 2 +- outputs.nix | 7 +------ 16 files changed, 25 insertions(+), 50 deletions(-) diff --git a/common/home/neovim/langs/nix.nix b/common/home/neovim/langs/nix.nix index b03c878c..1d4b2f7b 100644 --- a/common/home/neovim/langs/nix.nix +++ b/common/home/neovim/langs/nix.nix @@ -1,5 +1,6 @@ { config, + osConfig, pkgs, lib, nixd, @@ -7,7 +8,8 @@ ... }: let inherit (lib) getExe hasPrefix mkIf removePrefix; - inherit (config.vars) hostName mainUser neovimIde; + inherit (config.vars) mainUser neovimIde; + inherit (osConfig.networking) hostName; defaultFormatter = self.formatter.${pkgs.system}; diff --git a/common/vars/default.nix b/common/vars/default.nix index 91bce09c..ae10cd1e 100644 --- a/common/vars/default.nix +++ b/common/vars/default.nix @@ -4,7 +4,6 @@ ... }: let inherit (lib) mkDefault mkOption types; - flakeDir = config.environment.variables.FLAKE; cfg = config.vars; in { options.vars = { @@ -15,13 +14,6 @@ in { ''; }; - hostName = mkOption { - type = types.str; - description = '' - Hostname that was defined at the initial setup process - ''; - }; - promptMainColor = mkOption { type = types.enum (import ./prompt-schemes.nix {}); default = "purple"; @@ -48,14 +40,6 @@ in { }; }; - configDir = mkOption { - type = types.str; - default = "${flakeDir}/devices/${cfg.hostName}/config"; - description = '' - The path to where most of the devices' configs are in the .nix folder - ''; - }; - neovimIde = mkOption { type = types.bool; default = true; diff --git a/devices/README.md b/devices/README.md index 2b958784..6b552e35 100644 --- a/devices/README.md +++ b/devices/README.md @@ -24,7 +24,6 @@ In every device's `default.nix`, you'll find these [settings](https://git.nelim. vars = { mainUser = "matt"; - hostName = "wim"; ... }; ``` diff --git a/devices/android/default.nix b/devices/android/default.nix index 560de942..37523cf9 100644 --- a/devices/android/default.nix +++ b/devices/android/default.nix @@ -6,7 +6,6 @@ }: { vars = { mainUser = "nix-on-droid"; - hostName = "localhost"; neovimIde = false; }; diff --git a/devices/bbsteamie/default.nix b/devices/bbsteamie/default.nix index aa3cb406..31927050 100644 --- a/devices/bbsteamie/default.nix +++ b/devices/bbsteamie/default.nix @@ -3,7 +3,7 @@ self, ... }: let - inherit (config.vars) mainUser hostName; + inherit (config.vars) mainUser; in { # ------------------------------------------------ # Imports @@ -26,7 +26,6 @@ in { # ------------------------------------------------ vars = { mainUser = "mariah"; - hostName = "bbsteamie"; promptMainColor = "pink"; }; @@ -39,7 +38,7 @@ in { }; networking = { - inherit hostName; + hostName = "bbsteamie"; networkmanager.enable = true; }; diff --git a/devices/binto/default.nix b/devices/binto/default.nix index 2428ae57..8c1dc68f 100644 --- a/devices/binto/default.nix +++ b/devices/binto/default.nix @@ -3,7 +3,7 @@ self, ... }: let - inherit (config.vars) mainUser hostName; + inherit (config.vars) mainUser; in { # ------------------------------------------------ # Imports @@ -31,7 +31,6 @@ in { # ------------------------------------------------ vars = { mainUser = "matt"; - hostName = "binto"; promptMainColor = "purple"; }; @@ -48,7 +47,7 @@ in { }; networking = { - inherit hostName; + hostName = "binto"; networkmanager.enable = true; firewall.enable = false; }; diff --git a/devices/cluster/default.nix b/devices/cluster/default.nix index 351779c3..a4d16e82 100644 --- a/devices/cluster/default.nix +++ b/devices/cluster/default.nix @@ -3,7 +3,7 @@ deviceName: { self, ... }: let - inherit (config.vars) mainUser hostName; + inherit (config.vars) mainUser; clusterIP = config.services.pcsd.virtualIps.caddy-vip.ip; in { @@ -27,7 +27,6 @@ in { # ------------------------------------------------ vars = { mainUser = "matt"; - hostName = deviceName; promptMainColor = if deviceName == "thingone" then "green" @@ -45,7 +44,7 @@ in { }; networking = { - inherit hostName; + hostName = deviceName; resolvconf.enable = true; nameservers = [ clusterIP diff --git a/devices/cluster/modules/caddy.nix b/devices/cluster/modules/caddy.nix index de9818d0..8b8002ac 100644 --- a/devices/cluster/modules/caddy.nix +++ b/devices/cluster/modules/caddy.nix @@ -4,8 +4,9 @@ config, ... }: let - inherit (config.vars) hostName mainUser; inherit (config.sops) secrets; + inherit (config.vars) mainUser; + inherit (config.networking) hostName; caddy = caddy-plugins.packages.${pkgs.system}.default; in { diff --git a/devices/cluster/modules/headscale/default.nix b/devices/cluster/modules/headscale/default.nix index ad298658..b770e04d 100644 --- a/devices/cluster/modules/headscale/default.nix +++ b/devices/cluster/modules/headscale/default.nix @@ -1,5 +1,6 @@ {config, ...}: let - inherit (config.vars) mainUser hostName; + inherit (config.vars) mainUser; + inherit (config.networking) hostName; clusterIP = config.services.pcsd.virtualIps.caddy-vip.ip; in { diff --git a/devices/cluster/modules/unbound.nix b/devices/cluster/modules/unbound.nix index 55c1fd22..7d5e1724 100644 --- a/devices/cluster/modules/unbound.nix +++ b/devices/cluster/modules/unbound.nix @@ -11,7 +11,8 @@ else b)) {} list; - inherit (config.vars) mainUser hostName; + inherit (config.vars) mainUser; + inherit (config.networking) hostName; serviviIP = "100.64.0.7"; caddyIp = diff --git a/devices/homie/default.nix b/devices/homie/default.nix index 399fb54e..1441d066 100644 --- a/devices/homie/default.nix +++ b/devices/homie/default.nix @@ -3,7 +3,7 @@ self, ... }: let - inherit (config.vars) mainUser hostName; + inherit (config.vars) mainUser; in { # ------------------------------------------------ # Imports @@ -26,7 +26,6 @@ in { # ------------------------------------------------ vars = { mainUser = "matt"; - hostName = "homie"; promptMainColor = "yellow"; }; @@ -39,7 +38,7 @@ in { }; networking = { - inherit hostName; + hostName = "homie"; resolvconf.enable = true; firewall.enable = false; }; diff --git a/devices/nos/default.nix b/devices/nos/default.nix index e79aab81..79386d79 100644 --- a/devices/nos/default.nix +++ b/devices/nos/default.nix @@ -3,7 +3,7 @@ self, ... }: let - inherit (config.vars) mainUser hostName; + inherit (config.vars) mainUser; in { # ------------------------------------------------ # Imports @@ -26,7 +26,6 @@ in { # ------------------------------------------------ vars = { mainUser = "matt"; - hostName = "nos"; promptMainColor = "orange"; }; @@ -40,7 +39,7 @@ in { }; networking = { - inherit hostName; + hostName = "nos"; resolvconf.enable = true; firewall.enable = false; }; diff --git a/devices/servivi/default.nix b/devices/servivi/default.nix index 174de5a1..0050da18 100644 --- a/devices/servivi/default.nix +++ b/devices/servivi/default.nix @@ -3,7 +3,7 @@ self, ... }: let - inherit (config.vars) mainUser hostName; + inherit (config.vars) mainUser; in { # ------------------------------------------------ # Imports @@ -26,7 +26,6 @@ in { # ------------------------------------------------ vars = { mainUser = "matt"; - hostName = "servivi"; promptMainColor = "blue"; }; @@ -53,7 +52,7 @@ in { }; networking = { - inherit hostName; + hostName = "servivi"; resolvconf.enable = true; firewall.enable = false; }; diff --git a/devices/wim/default.nix b/devices/wim/default.nix index d9499171..a9dabcd7 100644 --- a/devices/wim/default.nix +++ b/devices/wim/default.nix @@ -4,7 +4,7 @@ pkgs, ... }: let - inherit (config.vars) mainUser hostName; + inherit (config.vars) mainUser; in { # ------------------------------------------------ # Imports @@ -34,7 +34,6 @@ in { # ------------------------------------------------ vars = { mainUser = "matt"; - hostName = "wim"; promptMainColor = "purple"; }; @@ -51,7 +50,7 @@ in { }; networking = { - inherit hostName; + hostName = "wim"; networkmanager = { enable = true; diff --git a/nixosModules/borgbackup/module.nix b/nixosModules/borgbackup/module.nix index e0ede4a0..3b0eaa95 100644 --- a/nixosModules/borgbackup/module.nix +++ b/nixosModules/borgbackup/module.nix @@ -9,7 +9,7 @@ inherit (lib.attrsets) attrValues hasAttr listToAttrs mapAttrs removeAttrs; inherit (config.sops) secrets; - inherit (config.vars) hostName; + inherit (config.networking) hostName; cfg = config.services.borgbackup; in { diff --git a/outputs.nix b/outputs.nix index 060505e6..a274e19b 100644 --- a/outputs.nix +++ b/outputs.nix @@ -120,12 +120,7 @@ live-image = mkNixOS { extraModules = [ "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix" - { - vars = { - mainUser = "nixos"; - hostName = "nixos"; - }; - } + {vars.mainUser = "nixos";} ]; }; };