From d6b94213d4379b62be11082e2dbd285dc200825d Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Sat, 1 Jul 2023 17:45:08 +0530 Subject: [PATCH] refactor secrets --- common/users/default.nix | 2 +- flake.nix | 9 +++++---- home/programs/git.nix | 8 ++++++-- hosts/rico2/services/caddy.nix | 4 +--- hosts/rico2/services/frpc.nix | 8 ++++++-- hosts/skipper/services/default.nix | 4 ++-- 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/common/users/default.nix b/common/users/default.nix index 4faff4e..7d57210 100644 --- a/common/users/default.nix +++ b/common/users/default.nix @@ -3,7 +3,7 @@ secrets, ... }: let - user = (import ../../secrets.nix).users; + user = secrets.users; in { users.mutableUsers = false; users.users = { diff --git a/flake.nix b/flake.nix index beb91fe..53a22c7 100644 --- a/flake.nix +++ b/flake.nix @@ -34,7 +34,7 @@ lanzaboote, nixneovimplugins, } @ inputs: let - user = (import ./secrets.nix).users; + secrets = import ./secrets.nix; in { formatter."x86_64-linux" = nixpkgs.legacyPackages."x86_64-linux".alejandra; nixosConfigurations = { @@ -47,7 +47,7 @@ }; overlays = [(import ./packages) nixneovimplugins.overlays.default]; }; - specialArgs = inputs; + specialArgs = inputs // {inherit secrets;}; modules = [ { system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; @@ -64,7 +64,8 @@ home-manager = { useUserPackages = true; useGlobalPkgs = true; - users.${user.primary.userName} = {pkgs, ...}: { + extraSpecialArgs = {inherit secrets;}; + users.${secrets.users.primary.userName} = {pkgs, ...}: { imports = [ impermanence.nixosModules.home-manager.impermanence ./home @@ -82,7 +83,7 @@ allowUnfree = true; }; }; - specialArgs = inputs; + specialArgs = inputs // {inherit secrets;}; modules = [ { system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; diff --git a/home/programs/git.nix b/home/programs/git.nix index b4a642b..c5e1637 100644 --- a/home/programs/git.nix +++ b/home/programs/git.nix @@ -1,5 +1,9 @@ -{pkgs, ...}: let - user = (import ../../secrets.nix).users; +{ + pkgs, + secrets, + ... +}: let + user = secrets.users; in { programs.git = { enable = true; diff --git a/hosts/rico2/services/caddy.nix b/hosts/rico2/services/caddy.nix index 5762372..d7442e5 100644 --- a/hosts/rico2/services/caddy.nix +++ b/hosts/rico2/services/caddy.nix @@ -1,6 +1,4 @@ -{...}: let - secrets = import ../../../secrets.nix; -in { +{secrets, ...}: { services.caddy = { enable = true; email = secrets.caddy_config.email; diff --git a/hosts/rico2/services/frpc.nix b/hosts/rico2/services/frpc.nix index 7b1b955..46d99ef 100644 --- a/hosts/rico2/services/frpc.nix +++ b/hosts/rico2/services/frpc.nix @@ -1,5 +1,9 @@ -{pkgs, ...}: let - frp_config = (import ../../../secrets.nix).frp_config; +{ + pkgs, + secrets, + ... +}: let + frp_config = secrets.frp_config; in { systemd.services.frpc = { enable = true; diff --git a/hosts/skipper/services/default.nix b/hosts/skipper/services/default.nix index e2a0271..68435d3 100644 --- a/hosts/skipper/services/default.nix +++ b/hosts/skipper/services/default.nix @@ -1,5 +1,5 @@ -{ ... }: let - user = (import ../../../secrets.nix).users; +{secrets, ...}: let + user = secrets.users; in { imports = [ ./dbus.nix