From f5e87d9be2a56f550de2efadc8ecb85c01ba40dc Mon Sep 17 00:00:00 2001 From: tuxdotrs Date: Sun, 27 Oct 2024 16:40:34 +0530 Subject: [PATCH] refactor: move email to global variable --- flake.nix | 19 ++++++++++--------- hosts/alpha/default.nix | 3 ++- hosts/arcturus/default.nix | 3 ++- hosts/common/default.nix | 5 +++-- hosts/vps/default.nix | 3 ++- modules/home-manager/bitwarden/default.nix | 8 ++++++-- modules/home-manager/git/default.nix | 4 ++-- modules/nixos/headscale.nix | 3 ++- modules/nixos/monitoring/grafana.nix | 3 ++- modules/nixos/plausible.nix | 3 ++- 10 files changed, 33 insertions(+), 21 deletions(-) diff --git a/flake.nix b/flake.nix index b1d7244..8329c29 100755 --- a/flake.nix +++ b/flake.nix @@ -41,6 +41,7 @@ "x86_64-linux" ]; username = "tux"; + email = "t@tux.rs"; in { packages = forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system}); formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra); @@ -52,42 +53,42 @@ # 'nixos-rebuild switch --flake .#your-hostname' nixosConfigurations = { arcturus = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs outputs username;}; + specialArgs = {inherit inputs outputs username email;}; modules = [./hosts/arcturus]; }; canopus = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs outputs username;}; + specialArgs = {inherit inputs outputs username email;}; modules = [./hosts/canopus]; }; alpha = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs outputs username;}; + specialArgs = {inherit inputs outputs username email;}; modules = [./hosts/alpha]; }; sirius = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs outputs username;}; + specialArgs = {inherit inputs outputs username email;}; modules = [./hosts/sirius]; }; vega = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs outputs username;}; + specialArgs = {inherit inputs outputs username email;}; modules = [./hosts/vega]; }; capella = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs outputs username;}; + specialArgs = {inherit inputs outputs username email;}; modules = [./hosts/capella]; }; vps = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs outputs username;}; + specialArgs = {inherit inputs outputs username email;}; modules = [./hosts/vps]; }; isoImage = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs outputs username;}; + specialArgs = {inherit inputs outputs username email;}; modules = [./hosts/isoImage]; }; }; @@ -97,7 +98,7 @@ homeConfigurations = { "${username}@canopus" = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.x86_64-linux; - extraSpecialArgs = {inherit inputs outputs username;}; + extraSpecialArgs = {inherit inputs outputs username email;}; modules = [ ./modules/home-manager ]; diff --git a/hosts/alpha/default.nix b/hosts/alpha/default.nix index 55877c9..df6f9b8 100644 --- a/hosts/alpha/default.nix +++ b/hosts/alpha/default.nix @@ -2,6 +2,7 @@ pkgs, username, config, + email, ... }: { imports = [ @@ -48,7 +49,7 @@ acme = { acceptTerms = true; - defaults.email = "0xtux@pm.me"; + defaults.email = "${email}"; certs = { "tux.rs" = { domain = "*.tux.rs"; diff --git a/hosts/arcturus/default.nix b/hosts/arcturus/default.nix index 6beff0e..4a84e30 100644 --- a/hosts/arcturus/default.nix +++ b/hosts/arcturus/default.nix @@ -2,6 +2,7 @@ pkgs, username, config, + email, ... }: { imports = [ @@ -84,7 +85,7 @@ acme = { acceptTerms = true; - defaults.email = "0xtux@pm.me"; + defaults.email = "${email}"; certs = { "tux.rs" = { domain = "*.tux.rs"; diff --git a/hosts/common/default.nix b/hosts/common/default.nix index 7e9846f..3c58b4a 100644 --- a/hosts/common/default.nix +++ b/hosts/common/default.nix @@ -5,6 +5,7 @@ config, lib, inputs, + email, ... }: let # Sops needs acess to the keys before the persist dirs are even mounted; so @@ -118,7 +119,7 @@ in { isNormalUser = true; extraGroups = ["networkmanager" "wheel" "storage"]; openssh.authorizedKeys.keys = [ - ''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIL+OzPUe2ECPC929DqpkM39tl/vdNAXfsRnmrGfR+X3D 0xtux@pm.me'' + ''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIL+OzPUe2ECPC929DqpkM39tl/vdNAXfsRnmrGfR+X3D ${email}'' ]; }; }; @@ -126,7 +127,7 @@ in { home-manager = { backupFileExtension = "backup"; useUserPackages = true; - extraSpecialArgs = {inherit inputs outputs username;}; + extraSpecialArgs = {inherit inputs outputs username email;}; users.${username} = { imports = [ ./home.nix diff --git a/hosts/vps/default.nix b/hosts/vps/default.nix index 2a3dd03..4e5cdfc 100644 --- a/hosts/vps/default.nix +++ b/hosts/vps/default.nix @@ -4,6 +4,7 @@ outputs, pkgs, username, + email, ... }: { imports = [ @@ -110,7 +111,7 @@ isNormalUser = true; extraGroups = ["networkmanager" "wheel" "storage"]; openssh.authorizedKeys.keys = [ - ''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIL+OzPUe2ECPC929DqpkM39tl/vdNAXfsRnmrGfR+X3D 0xtux@pm.me'' + ''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIL+OzPUe2ECPC929DqpkM39tl/vdNAXfsRnmrGfR+X3D ${email}'' ]; }; }; diff --git a/modules/home-manager/bitwarden/default.nix b/modules/home-manager/bitwarden/default.nix index 4c7b9da..ba0f39b 100644 --- a/modules/home-manager/bitwarden/default.nix +++ b/modules/home-manager/bitwarden/default.nix @@ -1,9 +1,13 @@ -{pkgs, ...}: { +{ + pkgs, + email, + ... +}: { programs.rbw = { enable = true; settings = { base_url = "https://bw.tux.rs"; - email = "0xtux@pm.me"; + email = "${email}"; }; }; diff --git a/modules/home-manager/git/default.nix b/modules/home-manager/git/default.nix index 5ebe2b9..90789dd 100755 --- a/modules/home-manager/git/default.nix +++ b/modules/home-manager/git/default.nix @@ -1,8 +1,8 @@ -{...}: { +{email, ...}: { programs.git = { enable = true; userName = "tuxdotrs"; - userEmail = "t@tux.rs"; + userEmail = "${email}"; signing = { key = "~/.ssh/id_ed25519.pub"; signByDefault = true; diff --git a/modules/nixos/headscale.nix b/modules/nixos/headscale.nix index ab3d9f7..c430f5e 100644 --- a/modules/nixos/headscale.nix +++ b/modules/nixos/headscale.nix @@ -2,11 +2,12 @@ config, pkgs, lib, + email, ... }: { security = { acme = { - defaults.email = "0xtux@pm.me"; + defaults.email = "${email}"; acceptTerms = true; }; }; diff --git a/modules/nixos/monitoring/grafana.nix b/modules/nixos/monitoring/grafana.nix index 46d6251..fc18920 100644 --- a/modules/nixos/monitoring/grafana.nix +++ b/modules/nixos/monitoring/grafana.nix @@ -1,6 +1,7 @@ { lib, username, + email, ... }: { services = { @@ -10,7 +11,7 @@ server.http_port = 8888; security = { admin_user = "${username}"; - admin_email = "0xtux@pm.me"; + admin_email = "${email}"; }; }; }; diff --git a/modules/nixos/plausible.nix b/modules/nixos/plausible.nix index a43837a..321a0e1 100644 --- a/modules/nixos/plausible.nix +++ b/modules/nixos/plausible.nix @@ -1,6 +1,7 @@ { config, lib, + email, ... }: { services = { @@ -16,8 +17,8 @@ adminUser = { activate = true; + email = "${email}"; name = "tux"; - email = "0xtux@pm.me"; passwordFile = config.sops.secrets.plausible_password.path; };