From 7771c880403418e3c2d533fd5c4e3e554303b130 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 15 Jan 2025 08:00:00 +0000 Subject: [PATCH] Refactor Home Manager modules --- flake.nix | 2 ++ nix/home/common/default.nix | 12 ++++++++++++ nix/home/opdavies/default.nix | 6 +++++- nix/lib/shared/home-manager.nix | 25 ++----------------------- nix/modules/home-manager/default.nix | 5 +---- todo.txt | 1 - 6 files changed, 22 insertions(+), 29 deletions(-) create mode 100644 nix/home/common/default.nix diff --git a/flake.nix b/flake.nix index d8b82ff..3e2dc51 100644 --- a/flake.nix +++ b/flake.nix @@ -62,6 +62,8 @@ nixosModules.default = ./nix/modules/nixos; + homeManagerModules.default = ./nix/modules/home-manager; + nixosConfigurations = { lemp11 = nixpkgs.lib.nixosSystem { specialArgs = specialArgs // { diff --git a/nix/home/common/default.nix b/nix/home/common/default.nix new file mode 100644 index 0000000..b004924 --- /dev/null +++ b/nix/home/common/default.nix @@ -0,0 +1,12 @@ +{ + outputs, + hostname, + username, + ... +}: + +{ + imports = builtins.attrValues outputs.homeManagerModules ++ [ + ../../home/${username}/hosts/${hostname}.nix + ]; +} diff --git a/nix/home/opdavies/default.nix b/nix/home/opdavies/default.nix index 1056634..228c981 100644 --- a/nix/home/opdavies/default.nix +++ b/nix/home/opdavies/default.nix @@ -44,7 +44,10 @@ let }; in { - imports = [ shared-config ]; + imports = [ + ../common + shared-config + ]; home.packages = shared-packages @@ -64,6 +67,7 @@ in ); home.sessionVariables = { + DOCUMENTS = "$HOME/Documents"; EDITOR = "nvim"; LANG = "en_GB.UTF-8"; LC_ALL = "en_GB.UTF-8"; diff --git a/nix/lib/shared/home-manager.nix b/nix/lib/shared/home-manager.nix index 0cae366..4120346 100644 --- a/nix/lib/shared/home-manager.nix +++ b/nix/lib/shared/home-manager.nix @@ -1,12 +1,5 @@ -{ - config, - hostname, - inputs, - lib, - pkgs, - username, - self, -}: +{ lib, username, ... }: + { home.username = "${username}"; home.homeDirectory = "/home/${username}"; @@ -41,18 +34,4 @@ }; } ]; - - imports = [ - (import ../../modules/home-manager { - inherit - config - inputs - lib - self - pkgs - ; - }) - - ../../home/${username}/hosts/${hostname}.nix - ]; } diff --git a/nix/modules/home-manager/default.nix b/nix/modules/home-manager/default.nix index 6f67cc9..075bcdb 100644 --- a/nix/modules/home-manager/default.nix +++ b/nix/modules/home-manager/default.nix @@ -18,10 +18,7 @@ pkgs ; }) + ./features/desktop ]; - - home.sessionVariables = { - DOCUMENTS = "$HOME/Documents"; - }; } diff --git a/todo.txt b/todo.txt index 97bc021..c8b8d6e 100644 --- a/todo.txt +++ b/todo.txt @@ -1,4 +1,3 @@ -Use nixosModules and homeManagerModules outputs in flake.nix to simplify importing modules Add daily script Add create-podcast-tasks script Replace doppler with agenix