From 8e1ccc47722fd8a852ab7e77b7edd35383d82bea Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Thu, 24 Oct 2024 09:50:55 +0300 Subject: [PATCH] Home Manager: Rewrite to NixOS-like config. --- flake.nix | 32 +++++++++------------ home/NixOs.nix | 3 +- home/user/x86_64-linux/root/default.nix | 9 ++++++ home/user/x86_64-linux/voronind/default.nix | 9 ++++++ {home/user => user}/Dasha.nix | 0 {home/user => user}/Root.nix | 0 {home/user => user}/Voronind.nix | 0 7 files changed, 33 insertions(+), 20 deletions(-) create mode 100644 home/user/x86_64-linux/root/default.nix create mode 100644 home/user/x86_64-linux/voronind/default.nix rename {home/user => user}/Dasha.nix (100%) rename {home/user => user}/Root.nix (100%) rename {home/user => user}/Voronind.nix (100%) diff --git a/flake.nix b/flake.nix index 82cbc3c..23390d6 100644 --- a/flake.nix +++ b/flake.nix @@ -268,7 +268,7 @@ util = import ./lib/Util.nix { inherit lib; }; mkCommonHome = - username: homeDirectory: system: modules: + username: system: let pkgs = nixpkgs.legacyPackages.${system}; pkgsStable = nixpkgsStable.legacyPackages.${system}; @@ -295,11 +295,8 @@ ./home/HomeManager.nix { home.hm = { - inherit username homeDirectory; + inherit username; enable = true; - package = { - core.enable = true; - }; }; } @@ -314,23 +311,20 @@ } inputs.stylix.homeManagerModules.stylix - ] ++ modules ++ (self.findFiles ./config); + ] ++ (self.findFiles ./home/user/${system}/${username}) ++ (self.findFiles ./config); }; }; - - x86LinuxHome = username: modules: mkCommonHome username "/home/${username}" "x86_64-linux" modules; - x86LinuxRoot = mkCommonHome "root" "/root" "x86_64-linux" [ ]; in - nixpkgs.lib.foldl' (acc: h: acc // h) { } [ - x86LinuxRoot - (x86LinuxHome "voronind" [ - { - home.hm.package = { - common.enable = true; - }; - } - ]) - ]; + nixpkgs.lib.foldl' (acc: h: acc // h) { } ( + map ( + system: + nixpkgs.lib.foldl' (acc: h: acc // h) { } ( + map (username: mkCommonHome username system) ( + builtins.attrNames (builtins.readDir ./home/user/${system}) + ) + ) + ) (builtins.attrNames (builtins.readDir ./home/user)) + ); # Android. nixOnDroidConfigurations.default = diff --git a/home/NixOs.nix b/home/NixOs.nix index 01aef6b..733e5b6 100644 --- a/home/NixOs.nix +++ b/home/NixOs.nix @@ -5,6 +5,7 @@ util, lib, pkgs, + __findFile, ... }@args: with lib; @@ -13,7 +14,7 @@ let programs = import ./program args; in { - imports = (util.ls ./user); + imports = (util.ls ); options = { home.nixos = { diff --git a/home/user/x86_64-linux/root/default.nix b/home/user/x86_64-linux/root/default.nix new file mode 100644 index 0000000..780c1a2 --- /dev/null +++ b/home/user/x86_64-linux/root/default.nix @@ -0,0 +1,9 @@ +{ ... }: +{ + home.hm = { + homeDirectory = "/root"; + package = { + core.enable = true; + }; + }; +} diff --git a/home/user/x86_64-linux/voronind/default.nix b/home/user/x86_64-linux/voronind/default.nix new file mode 100644 index 0000000..fdaa16d --- /dev/null +++ b/home/user/x86_64-linux/voronind/default.nix @@ -0,0 +1,9 @@ +{ ... }: +{ + home.hm = { + homeDirectory = "/home/voronind"; + package = { + core.enable = true; + }; + }; +} diff --git a/home/user/Dasha.nix b/user/Dasha.nix similarity index 100% rename from home/user/Dasha.nix rename to user/Dasha.nix diff --git a/home/user/Root.nix b/user/Root.nix similarity index 100% rename from home/user/Root.nix rename to user/Root.nix diff --git a/home/user/Voronind.nix b/user/Voronind.nix similarity index 100% rename from home/user/Voronind.nix rename to user/Voronind.nix