From b0a08d549f47ee2413c169379cf0607e888cae4c Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 9 May 2024 01:10:26 +0200 Subject: [PATCH] Allow dynamically loading user home configs --- flake.nix | 9 ++------- lib/utils/user-config.nix | 11 +++++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 lib/utils/user-config.nix diff --git a/flake.nix b/flake.nix index 27bbe08..a208145 100644 --- a/flake.nix +++ b/flake.nix @@ -112,13 +112,8 @@ "${username}@${hostname}" = { modules = let - userConfigPath = ( - tryFiles [ - ./lib/users/${username}/${hostname}.nix - ./lib/users/${username}/common.nix - ./lib/users/${username}.nix - ] - null); + getUserConfig = import ./lib/utils/user-config.nix { inherit lib; }; + userConfigPath = getUserConfig { inherit hostname username; }; in [ ( { pkgs, ... }: { diff --git a/lib/utils/user-config.nix b/lib/utils/user-config.nix new file mode 100644 index 0000000..d63b3ff --- /dev/null +++ b/lib/utils/user-config.nix @@ -0,0 +1,11 @@ +{ lib, ... }: + let + tryFiles = import ./try-files.nix { inherit lib; }; + in + { hostname, username, ... }: + tryFiles [ + ../users/${username}/${hostname}.nix + ../users${username}/common.nix + ../users/${username}.nix + ] + null \ No newline at end of file