From 84eef98fa88e42a4bf34b2e3ab804d787f0feb84 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Sat, 28 Sep 2024 14:47:23 -0400 Subject: [PATCH] modules/home --- configurations/home/srid@ubuntu.nix | 3 +- flake-module.nix | 10 +++++ flake.nix | 1 - home/default.nix | 43 ------------------- {home => modules/home/all}/_1password.nix | 0 {home => modules/home/all}/bash.nix | 0 {home => modules/home/all}/direnv.nix | 0 {home => modules/home/all}/git.nix | 0 {home => modules/home/all}/helix.nix | 0 {home => modules/home/all}/himalaya.nix | 0 {home => modules/home/all}/juspay.nix | 0 {home => modules/home/all}/just.nix | 0 {home => modules/home/all}/kitty.nix | 0 {home => modules/home/all}/neovim.nix | 0 {home => modules/home/all}/nix.nix | 0 {home => modules/home/all}/nushell.nix | 0 {home => modules/home/all}/nushell/config.nu | 0 {home => modules/home/all}/nushell/env.nu | 0 {home => modules/home/all}/powershell.nix | 0 {home => modules/home/all}/ssh.nix | 0 {home => modules/home/all}/starship.nix | 0 {home => modules/home/all}/terminal.nix | 0 {home => modules/home/all}/tmux.nix | 0 {home => modules/home/all}/vscode-server.nix | 0 .../home/all}/wezterm/default.nix | 0 .../home/all}/wezterm/wezterm.lua | 0 {home => modules/home/all}/zellij.nix | 0 {home => modules/home/all}/zsh.nix | 0 modules/home/darwin-only.nix | 8 ++++ modules/home/default.nix | 19 ++++++++ modules/home/linux-only.nix | 6 +++ nix-darwin/default.nix | 3 +- nixos/default.nix | 3 +- 33 files changed, 49 insertions(+), 47 deletions(-) delete mode 100644 home/default.nix rename {home => modules/home/all}/_1password.nix (100%) rename {home => modules/home/all}/bash.nix (100%) rename {home => modules/home/all}/direnv.nix (100%) rename {home => modules/home/all}/git.nix (100%) rename {home => modules/home/all}/helix.nix (100%) rename {home => modules/home/all}/himalaya.nix (100%) rename {home => modules/home/all}/juspay.nix (100%) rename {home => modules/home/all}/just.nix (100%) rename {home => modules/home/all}/kitty.nix (100%) rename {home => modules/home/all}/neovim.nix (100%) rename {home => modules/home/all}/nix.nix (100%) rename {home => modules/home/all}/nushell.nix (100%) rename {home => modules/home/all}/nushell/config.nu (100%) rename {home => modules/home/all}/nushell/env.nu (100%) rename {home => modules/home/all}/powershell.nix (100%) rename {home => modules/home/all}/ssh.nix (100%) rename {home => modules/home/all}/starship.nix (100%) rename {home => modules/home/all}/terminal.nix (100%) rename {home => modules/home/all}/tmux.nix (100%) rename {home => modules/home/all}/vscode-server.nix (100%) rename {home => modules/home/all}/wezterm/default.nix (100%) rename {home => modules/home/all}/wezterm/wezterm.lua (100%) rename {home => modules/home/all}/zellij.nix (100%) rename {home => modules/home/all}/zsh.nix (100%) create mode 100644 modules/home/darwin-only.nix create mode 100644 modules/home/default.nix create mode 100644 modules/home/linux-only.nix diff --git a/configurations/home/srid@ubuntu.nix b/configurations/home/srid@ubuntu.nix index 5bdf3cd7..10e3af02 100644 --- a/configurations/home/srid@ubuntu.nix +++ b/configurations/home/srid@ubuntu.nix @@ -5,7 +5,8 @@ let in { imports = [ - self.homeModules.common-linux + self.homeModules.default + self.homeModules.linux-only ]; home.username = "srid"; home.homeDirectory = "/home/srid"; diff --git a/flake-module.nix b/flake-module.nix index 5f3a51ab..dce371c2 100644 --- a/flake-module.nix +++ b/flake-module.nix @@ -31,6 +31,16 @@ in ) (builtins.readDir "${self}/configurations/nixos"); + homeModules = inputs.nixpkgs.lib.mapAttrs' + (fn: _: + let + inherit (inputs.nixpkgs) lib; + name = lib.removeSuffix ".nix" fn; + in + lib.nameValuePair name "${self}/modules/home/${fn}" + ) + (builtins.readDir "${self}/modules/home"); + overlays = lib.mapAttrs' (fn: _: let name = lib.removeSuffix ".nix" fn; in diff --git a/flake.nix b/flake.nix index 99c64199..01ce563f 100644 --- a/flake.nix +++ b/flake.nix @@ -43,7 +43,6 @@ [ ./flake-module.nix ./users - ./home ./nixos ./nix-darwin ]; diff --git a/home/default.nix b/home/default.nix deleted file mode 100644 index dbbc96a7..00000000 --- a/home/default.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ self, ... }: -{ - flake = { - homeModules = { - # Common to both Linux and Darwin - common = { - home.stateVersion = "22.11"; - imports = [ - ./tmux.nix - ./neovim.nix - # ./helix.nix - ./ssh.nix - ./starship.nix - ./terminal.nix - ./nix.nix - ./git.nix - ./direnv.nix - ./zellij.nix - # ./nushell.nix - ./just.nix - # ./powershell.nix - ./juspay.nix - ]; - }; - common-linux = { - imports = [ - self.homeModules.common - ./bash.nix - ./vscode-server.nix - ]; - }; - common-darwin = { - imports = [ - self.homeModules.common - ./zsh.nix - ./wezterm - ./himalaya.nix - ./_1password.nix - ]; - }; - }; - }; -} diff --git a/home/_1password.nix b/modules/home/all/_1password.nix similarity index 100% rename from home/_1password.nix rename to modules/home/all/_1password.nix diff --git a/home/bash.nix b/modules/home/all/bash.nix similarity index 100% rename from home/bash.nix rename to modules/home/all/bash.nix diff --git a/home/direnv.nix b/modules/home/all/direnv.nix similarity index 100% rename from home/direnv.nix rename to modules/home/all/direnv.nix diff --git a/home/git.nix b/modules/home/all/git.nix similarity index 100% rename from home/git.nix rename to modules/home/all/git.nix diff --git a/home/helix.nix b/modules/home/all/helix.nix similarity index 100% rename from home/helix.nix rename to modules/home/all/helix.nix diff --git a/home/himalaya.nix b/modules/home/all/himalaya.nix similarity index 100% rename from home/himalaya.nix rename to modules/home/all/himalaya.nix diff --git a/home/juspay.nix b/modules/home/all/juspay.nix similarity index 100% rename from home/juspay.nix rename to modules/home/all/juspay.nix diff --git a/home/just.nix b/modules/home/all/just.nix similarity index 100% rename from home/just.nix rename to modules/home/all/just.nix diff --git a/home/kitty.nix b/modules/home/all/kitty.nix similarity index 100% rename from home/kitty.nix rename to modules/home/all/kitty.nix diff --git a/home/neovim.nix b/modules/home/all/neovim.nix similarity index 100% rename from home/neovim.nix rename to modules/home/all/neovim.nix diff --git a/home/nix.nix b/modules/home/all/nix.nix similarity index 100% rename from home/nix.nix rename to modules/home/all/nix.nix diff --git a/home/nushell.nix b/modules/home/all/nushell.nix similarity index 100% rename from home/nushell.nix rename to modules/home/all/nushell.nix diff --git a/home/nushell/config.nu b/modules/home/all/nushell/config.nu similarity index 100% rename from home/nushell/config.nu rename to modules/home/all/nushell/config.nu diff --git a/home/nushell/env.nu b/modules/home/all/nushell/env.nu similarity index 100% rename from home/nushell/env.nu rename to modules/home/all/nushell/env.nu diff --git a/home/powershell.nix b/modules/home/all/powershell.nix similarity index 100% rename from home/powershell.nix rename to modules/home/all/powershell.nix diff --git a/home/ssh.nix b/modules/home/all/ssh.nix similarity index 100% rename from home/ssh.nix rename to modules/home/all/ssh.nix diff --git a/home/starship.nix b/modules/home/all/starship.nix similarity index 100% rename from home/starship.nix rename to modules/home/all/starship.nix diff --git a/home/terminal.nix b/modules/home/all/terminal.nix similarity index 100% rename from home/terminal.nix rename to modules/home/all/terminal.nix diff --git a/home/tmux.nix b/modules/home/all/tmux.nix similarity index 100% rename from home/tmux.nix rename to modules/home/all/tmux.nix diff --git a/home/vscode-server.nix b/modules/home/all/vscode-server.nix similarity index 100% rename from home/vscode-server.nix rename to modules/home/all/vscode-server.nix diff --git a/home/wezterm/default.nix b/modules/home/all/wezterm/default.nix similarity index 100% rename from home/wezterm/default.nix rename to modules/home/all/wezterm/default.nix diff --git a/home/wezterm/wezterm.lua b/modules/home/all/wezterm/wezterm.lua similarity index 100% rename from home/wezterm/wezterm.lua rename to modules/home/all/wezterm/wezterm.lua diff --git a/home/zellij.nix b/modules/home/all/zellij.nix similarity index 100% rename from home/zellij.nix rename to modules/home/all/zellij.nix diff --git a/home/zsh.nix b/modules/home/all/zsh.nix similarity index 100% rename from home/zsh.nix rename to modules/home/all/zsh.nix diff --git a/modules/home/darwin-only.nix b/modules/home/darwin-only.nix new file mode 100644 index 00000000..9a1c4a5c --- /dev/null +++ b/modules/home/darwin-only.nix @@ -0,0 +1,8 @@ +{ + imports = [ + ./all/zsh.nix + ./all/wezterm + ./all/himalaya.nix + ./all/_1password.nix + ]; +} diff --git a/modules/home/default.nix b/modules/home/default.nix new file mode 100644 index 00000000..af2ec478 --- /dev/null +++ b/modules/home/default.nix @@ -0,0 +1,19 @@ +{ + home.stateVersion = "22.11"; + imports = [ + ./all/tmux.nix + ./all/neovim.nix + # ./helix.nix + ./all/ssh.nix + ./all/starship.nix + ./all/terminal.nix + ./all/nix.nix + ./all/git.nix + ./all/direnv.nix + ./all/zellij.nix + # ./nushell.nix + ./all/just.nix + # ./powershell.nix + ./all/juspay.nix + ]; +} diff --git a/modules/home/linux-only.nix b/modules/home/linux-only.nix new file mode 100644 index 00000000..11dc7b7a --- /dev/null +++ b/modules/home/linux-only.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./all/bash.nix + ./all/vscode-server.nix + ]; +} diff --git a/nix-darwin/default.nix b/nix-darwin/default.nix index d803fc74..44aa8a92 100644 --- a/nix-darwin/default.nix +++ b/nix-darwin/default.nix @@ -7,7 +7,8 @@ { home-manager.users.${config.people.myself} = { imports = [ - self.homeModules.common-darwin + self.homeModules.default + self.homeModules.darwin-only ]; }; } diff --git a/nixos/default.nix b/nixos/default.nix index 675cf57a..365440e1 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -13,7 +13,8 @@ users.users.${config.people.myself}.isNormalUser = true; home-manager.users.${config.people.myself} = { imports = [ - self.homeModules.common-linux + self.homeModules.default + self.homeModules.linux-only ]; }; }