From 374d00c9414c56f781dad470fde48252c4bdb5d9 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Fri, 10 May 2024 02:37:26 +0300 Subject: [PATCH] refac: pass paths as extra args instead --- flake.nix | 6 ++++++ hosts/asus-gl553vd/configs/wireguard/default.nix | 4 ++-- hosts/asus-gl553vd/users/jan.nix | 8 ++++---- hosts/home/configs/wireguard/default.nix | 4 ++-- hosts/home/users/default.nix | 4 ++-- hosts/home/users/jan.nix | 8 ++++---- hosts/istal/services/wireguard/default.nix | 7 +++---- hosts/tatos/services/wireguard/default.nix | 7 +++---- users/jan/git/default.nix | 4 ++-- 9 files changed, 28 insertions(+), 24 deletions(-) diff --git a/flake.nix b/flake.nix index 20928a2..14899d7 100644 --- a/flake.nix +++ b/flake.nix @@ -115,6 +115,9 @@ specialArgs = { inherit inputs; globalData = import ./data.nix; + usersPath = ./users; + hostsPath = ./hosts; + packagesPath = ./packages; } // specialArgs; modules = @@ -138,6 +141,9 @@ ({ ... }: { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; + home-manager.extraSpecialArgs = { + packagesPath = ./packages; + }; home-manager.sharedModules = [ { imports = [ diff --git a/hosts/asus-gl553vd/configs/wireguard/default.nix b/hosts/asus-gl553vd/configs/wireguard/default.nix index 6d91edf..057757e 100644 --- a/hosts/asus-gl553vd/configs/wireguard/default.nix +++ b/hosts/asus-gl553vd/configs/wireguard/default.nix @@ -1,7 +1,7 @@ -{ config, ... }: +{ config, hostsPath, ... }: let - serverData = import ../../../tatos/data.secret.nix; + serverData = import (hostsPath + "/tatos/data.secret.nix"); in { age.secrets.wireguard-asus-gl553vd-private = { diff --git a/hosts/asus-gl553vd/users/jan.nix b/hosts/asus-gl553vd/users/jan.nix index 188d643..a3c618e 100644 --- a/hosts/asus-gl553vd/users/jan.nix +++ b/hosts/asus-gl553vd/users/jan.nix @@ -1,11 +1,11 @@ -{ ... }: +{ hostsPath, usersPath, ... }: let - asusData = import ../data.secret.nix; - homeData = import ../../home/data.secret.nix; + asusData = import (hostsPath + "/asus-gl553vd/data.secret.nix"); + homeData = import (hostsPath + "/home/data.secret.nix"); in { - imports = [ ../../../users/jan ]; + imports = [ (usersPath + "/jan") ]; home-manager.users.jan = { local.window-manager = { diff --git a/hosts/home/configs/wireguard/default.nix b/hosts/home/configs/wireguard/default.nix index ae79fa9..3e8bf07 100644 --- a/hosts/home/configs/wireguard/default.nix +++ b/hosts/home/configs/wireguard/default.nix @@ -1,7 +1,7 @@ -{ config, ... }: +{ config, hostsPath, ... }: let - serverData = import ../../../tatos/data.secret.nix; + serverData = import (hostsPath + "/tatos/data.secret.nix"); in { age.secrets.wireguard-home-private = { diff --git a/hosts/home/users/default.nix b/hosts/home/users/default.nix index 327e307..cd3e31f 100644 --- a/hosts/home/users/default.nix +++ b/hosts/home/users/default.nix @@ -1,9 +1,9 @@ -{ ... }: +{ usersPath, ... }: { imports = [ ./jan.nix - ../../../users/nas + (usersPath + "/nas") ]; home-manager.sharedModules = [ diff --git a/hosts/home/users/jan.nix b/hosts/home/users/jan.nix index 4a9247c..e41006d 100644 --- a/hosts/home/users/jan.nix +++ b/hosts/home/users/jan.nix @@ -1,11 +1,11 @@ -{ pkgs, ... }: +{ pkgs, hostsPath, usersPath, ... }: let - homeData = import ../data.secret.nix; - asusData = import ../../asus-gl553vd/data.secret.nix; + homeData = import (hostsPath + "/home/data.secret.nix"); + asusData = import (hostsPath + "/asus-gl553vd/data.secret.nix"); in { - imports = [ ../../../users/jan ]; + imports = [ (usersPath + "/jan") ]; home-manager.users.jan = { local.window-manager = { diff --git a/hosts/istal/services/wireguard/default.nix b/hosts/istal/services/wireguard/default.nix index d15c70b..1ad7989 100644 --- a/hosts/istal/services/wireguard/default.nix +++ b/hosts/istal/services/wireguard/default.nix @@ -1,9 +1,8 @@ -{ config, pkgs, ... }: +{ config, pkgs, hostsPath, ... }: let - tatosData = import ../../../tatos/data.secret.nix; - - istalData = import ../../data.secret.nix; + tatosData = import (hostsPath + "/tatos/data.secret.nix"); + istalData = import (hostsPath + "/istal/data.secret.nix"); inherit (istalData.wireguard) port; in { diff --git a/hosts/tatos/services/wireguard/default.nix b/hosts/tatos/services/wireguard/default.nix index d410a4e..f21e7ff 100644 --- a/hosts/tatos/services/wireguard/default.nix +++ b/hosts/tatos/services/wireguard/default.nix @@ -1,11 +1,10 @@ -{ config, pkgs, ... }: +{ config, pkgs, hostsPath, ... }: # Source: https://habr.com/ru/companies/xakep/articles/699000/ let - istalData = import ../../../istal/data.secret.nix; - - tatosData = import ../../data.secret.nix; + istalData = import (hostsPath + "/istal/data.secret.nix"); + tatosData = import (hostsPath + "/tatos/data.secret.nix"); port = tatosData.wireguard.port; in { diff --git a/users/jan/git/default.nix b/users/jan/git/default.nix index 342e9af..e4cffe4 100644 --- a/users/jan/git/default.nix +++ b/users/jan/git/default.nix @@ -1,9 +1,9 @@ -{ pkgs, ... }: +{ pkgs, packagesPath, ... }: { home.packages = [ pkgs.git-crypt - (pkgs.callPackage ../../../packages/git-crypt-rm-gpg-user { }) + (pkgs.callPackage (packagesPath + /git-crypt-rm-gpg-user) { }) ]; programs.git = {