split home-manager into their own submodules

This commit is contained in:
Danilo Reyes
2026-03-16 15:49:43 -06:00
parent 14eed4f7f6
commit 28c8db6cb7
43 changed files with 1011 additions and 626 deletions

View File

@@ -1,88 +0,0 @@
{
config,
inputs,
lib,
pkgs,
...
}:
{
options.my.emacs = {
enable = lib.mkEnableOption "Doom Emacs configuration";
users = lib.mkOption {
type = inputs.self.lib.usersOptionType lib;
default = config.my.toggleUsers.dev;
description = "Users to install Emacs packages for";
};
};
config = lib.mkIf config.my.emacs.enable {
home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.emacs.users (_user: {
xdg.dataFile = {
"doom/templates/events.org".source = ../../dotfiles/doom/templates/events.org;
"doom/templates/default.org".source = ../../dotfiles/doom/templates/default.org;
"doom/templates/programming.org".source = ../../dotfiles/doom/templates/programming.org;
};
services.lorri.enable = true;
programs.${config.my.shell.type}.shellAliases =
inputs.self.lib.mergeAliases inputs.self.lib.commonAliases
{
edit = "emacsclient -t";
e = "edit";
};
});
users.users =
let
packages = builtins.attrValues {
inherit (pkgs.xorg) xwininfo;
inherit (pkgs)
#emacs everywhere
xdotool
xclip
wl-clipboard-rs
fd # modern find, faster searches
fzf # fuzzy finder! super cool and useful
ripgrep # modern grep
tree-sitter # code parsing based on symbols and shit, I do not get it
graphviz # graphs
tetex # export pdf
languagetool # proofreader for English
# lsps
yaml-language-server
markdownlint-cli
;
inherit (pkgs.nodePackages)
vscode-json-languageserver
prettier # multi-language linter
;
};
in
inputs.self.lib.mkUserPackages lib config.my.emacs.users packages;
services.emacs = {
enable = true;
defaultEditor = true;
package = pkgs.emacsWithDoom {
doomDir = ../../dotfiles/doom;
doomLocalDir = "/home/${inputs.self.lib.getFirstUser config.my.emacs.users}/.local/share/nix-doom";
tangleArgs = "--all config.org";
extraPackages =
epkgs:
let
inherit
(config.home-manager.users.${inputs.self.lib.getFirstUser config.my.emacs.users}.programs.emacs)
extraPackages
extraConfig
;
extra = extraPackages epkgs;
themes = lib.optional config.my.stylix.enable [
(epkgs.trivialBuild {
pname = "stylix-theme";
src = pkgs.writeText "stylix-theme.el" extraConfig;
version = "0.1.0";
packageRequires = extra;
})
];
in
extra ++ themes;
};
};
};
}

View File

@@ -0,0 +1,44 @@
{
lib,
pkgs,
stylixEnabled,
emacsExtraConfig,
emacsExtraPackages,
}:
{
packages = builtins.attrValues {
inherit (pkgs.xorg) xwininfo;
inherit (pkgs)
xdotool
xclip
wl-clipboard-rs
fd
fzf
ripgrep
tree-sitter
graphviz
tetex
languagetool
yaml-language-server
markdownlint-cli
;
inherit (pkgs.nodePackages)
vscode-json-languageserver
prettier
;
};
extraPackages =
epkgs:
let
extra = emacsExtraPackages epkgs;
themes = lib.optional stylixEnabled [
(epkgs.trivialBuild {
pname = "stylix-theme";
src = pkgs.writeText "stylix-theme.el" emacsExtraConfig;
version = "0.1.0";
packageRequires = extra;
})
];
in
extra ++ themes;
}

View File

@@ -0,0 +1,61 @@
{
config,
inputs,
lib,
osConfig ? null,
pkgs,
...
}:
let
shellType = inputs.self.lib.hmShellType config osConfig;
hm = inputs.self.lib.hmModule {
inherit
config
inputs
osConfig
;
optionPath = [ "emacs" ];
};
cfg = config.my.emacs;
emacs = import ./common.nix {
inherit lib pkgs;
stylixEnabled = if osConfig == null then false else osConfig.my.stylix.enable;
emacsExtraConfig = config.programs.emacs.extraConfig;
emacsExtraPackages = config.programs.emacs.extraPackages;
};
in
{
imports = [ inputs.doom-emacs.homeModule ];
options.my.emacs.enable = lib.mkEnableOption "Doom Emacs configuration";
config = lib.mkMerge [
{
my.emacs.enable = lib.mkDefault hm.enabledByDefault;
}
(lib.mkIf cfg.enable {
home.packages = emacs.packages;
xdg.dataFile = {
"doom/templates/events.org".source = ../../../dotfiles/doom/templates/events.org;
"doom/templates/default.org".source = ../../../dotfiles/doom/templates/default.org;
"doom/templates/programming.org".source = ../../../dotfiles/doom/templates/programming.org;
};
services = {
lorri.enable = true;
emacs = {
enable = true;
defaultEditor = true;
};
};
programs.${shellType}.shellAliases = inputs.self.lib.mergeAliases inputs.self.lib.commonAliases {
edit = "emacsclient -t";
e = "edit";
};
programs.doom-emacs = {
enable = true;
doomDir = ../../../dotfiles/doom;
doomLocalDir = "${config.xdg.dataHome}/nix-doom";
tangleArgs = "--all config.org";
inherit (emacs) extraPackages;
};
})
];
}

View File

@@ -0,0 +1,16 @@
{
config,
inputs,
lib,
...
}:
{
options.my.emacs = {
enable = lib.mkEnableOption "Doom Emacs configuration";
users = lib.mkOption {
type = inputs.self.lib.usersOptionType lib;
default = config.my.toggleUsers.dev;
description = "Users to install Emacs packages for";
};
};
}

View File

@@ -1,60 +0,0 @@
{
config,
inputs,
lib,
pkgs,
...
}:
let
packages = builtins.attrValues {
inherit (pkgs) nodejs; # Node.js runtime
inherit (pkgs.nodePackages) pnpm; # Fast package manager alternative to npm
};
in
{
options = {
my.dev.javascript = {
enable = lib.mkEnableOption "Install JavaScript tooling globally";
users = lib.mkOption {
type = inputs.self.lib.usersOptionType lib;
default = config.my.toggleUsers.dev;
description = "Users to install JavaScript packages for";
};
};
devShells.javascript = lib.mkOption {
type = lib.types.package;
default = pkgs.mkShell {
inherit packages;
name = "javascript-dev-shell";
shellHook = ''
echo "📦 JavaScript dev environment"
'';
};
description = "JavaScript/Node development shell with npm/pnpm support";
};
};
config = lib.mkMerge [
(lib.mkIf config.my.dev.javascript.enable {
users.users = inputs.self.lib.mkUserAttrs lib config.my.dev.javascript.users { inherit packages; };
})
{
home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.dev.javascript.users (_user: {
xdg.configFile = {
"npm/npmrc".source = ../../dotfiles/npmrc;
"configstore/update-notifier-npm-check.json".text = builtins.toJSON {
optOut = false;
lastUpdateCheck = 1646662583446;
};
};
});
environment.variables = {
NPM_CONFIG_USERCONFIG = "\${XDG_CONFIG_HOME}/npm/npmrc";
PNPM_HOME = "\${XDG_DATA_HOME}/pnpm";
PATH = [
"\${XDG_DATA_HOME}/npm/bin"
"\${XDG_DATA_HOME}/pnpm"
];
};
}
];
}

View File

@@ -0,0 +1,25 @@
{ pkgs }:
let
packages = builtins.attrValues {
inherit (pkgs) nodejs;
inherit (pkgs.nodePackages) pnpm;
};
in
{
inherit packages;
devShell = pkgs.mkShell {
inherit packages;
name = "javascript-dev-shell";
shellHook = ''
echo "📦 JavaScript dev environment"
'';
};
sessionVariables = {
NPM_CONFIG_USERCONFIG = "\${XDG_CONFIG_HOME}/npm/npmrc";
PNPM_HOME = "\${XDG_DATA_HOME}/pnpm";
};
sessionPath = [
"\${XDG_DATA_HOME}/npm/bin"
"\${XDG_DATA_HOME}/pnpm"
];
}

View File

@@ -0,0 +1,43 @@
{
config,
inputs,
lib,
osConfig ? null,
pkgs,
...
}:
let
hm = inputs.self.lib.hmModule {
inherit
config
inputs
osConfig
;
optionPath = [
"dev"
"javascript"
];
};
cfg = config.my.dev.javascript;
javascript = import ./common.nix { inherit pkgs; };
in
{
options.my.dev.javascript.enable = lib.mkEnableOption "Install JavaScript tooling globally";
config = lib.mkMerge [
{
my.dev.javascript.enable = lib.mkDefault hm.enabledByDefault;
}
(lib.mkIf cfg.enable {
home.packages = javascript.packages;
xdg.configFile = {
"npm/npmrc".source = ../../../dotfiles/npmrc;
"configstore/update-notifier-npm-check.json".text = builtins.toJSON {
optOut = false;
lastUpdateCheck = 1646662583446;
};
};
home.sessionVariables = javascript.sessionVariables;
home.sessionPath = javascript.sessionPath;
})
];
}

View File

@@ -0,0 +1,27 @@
{
config,
inputs,
lib,
pkgs,
...
}:
let
javascript = import ./common.nix { inherit pkgs; };
in
{
options = {
my.dev.javascript = {
enable = lib.mkEnableOption "Install JavaScript tooling globally";
users = lib.mkOption {
type = inputs.self.lib.usersOptionType lib;
default = config.my.toggleUsers.dev;
description = "Users to install JavaScript packages for";
};
};
devShells.javascript = lib.mkOption {
type = lib.types.package;
default = javascript.devShell;
description = "JavaScript/Node development shell with npm/pnpm support";
};
};
}

View File

@@ -1,60 +0,0 @@
{
config,
inputs,
lib,
pkgs,
...
}:
let
shellType = config.my.shell.type;
packages = builtins.attrValues {
inherit (pkgs)
nixfmt-rfc-style # formatting
cachix # binary cache management
nixd # language server for Nix
deadnix # detext unused/uneeded dependencies
statix # linter for Nix expressions
mcp-nixos # mcp server
;
};
in
{
options = {
my.dev.nix = {
enable = lib.mkEnableOption "Install Nix tooling globally";
users = lib.mkOption {
type = inputs.self.lib.usersOptionType lib;
default = config.my.toggleUsers.dev;
description = "Users to install Nix packages for";
};
};
devShells.nix = lib.mkOption {
type = lib.types.package;
default = pkgs.mkShell {
inherit packages;
name = "nix-dev-shell";
shellHook = ''
echo " Nix dev environment"
'';
};
description = "Nix/NixOS development shell with formatter, linter, LSP, and Cachix";
};
};
config = lib.mkIf config.my.dev.nix.enable {
users.users = inputs.self.lib.mkUserAttrs lib config.my.dev.nix.users { inherit packages; };
home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.dev.nix.users (_user: {
programs.${shellType}.shellAliases = inputs.self.lib.mergeAliases inputs.self.lib.commonAliases {
nixformat = ''
deadnix -e && \
nix run nixpkgs#nixfmt-tree && \
statix fix
'';
nix-push-cache = ''
nix build $NH_FLAKE#nixosConfigurations.${config.networking.hostName}.config.system.build.toplevel \
--print-out-paths --fallback --max-jobs 100 --cores 0 |
nix run nixpkgs#attic-client -- push lan:nixos --stdin
'';
};
});
};
}

View File

@@ -0,0 +1,45 @@
{
pkgs,
hostName ? null,
}:
let
packages = builtins.attrValues {
inherit (pkgs)
nixfmt-rfc-style
cachix
nixd
deadnix
statix
mcp-nixos
;
};
in
{
inherit packages;
devShell = pkgs.mkShell {
inherit packages;
name = "nix-dev-shell";
shellHook = ''
echo " Nix dev environment"
'';
};
shellAliases = {
nixformat = ''
deadnix -e && \
nix run nixpkgs#nixfmt-tree && \
statix fix
'';
}
// (
if hostName == null then
{ }
else
{
nix-push-cache = ''
nix build $NH_FLAKE#nixosConfigurations.${hostName}.config.system.build.toplevel \
--print-out-paths --fallback --max-jobs 100 --cores 0 |
nix run nixpkgs#attic-client -- push lan:nixos --stdin
'';
}
);
}

40
modules/dev/nix/home.nix Normal file
View File

@@ -0,0 +1,40 @@
{
config,
inputs,
lib,
osConfig ? null,
pkgs,
...
}:
let
shellType = inputs.self.lib.hmShellType config osConfig;
hm = inputs.self.lib.hmModule {
inherit
config
inputs
osConfig
;
optionPath = [
"dev"
"nix"
];
};
cfg = config.my.dev.nix;
nix = import ./common.nix {
inherit pkgs;
hostName = if osConfig == null then null else osConfig.networking.hostName;
};
in
{
options.my.dev.nix.enable = lib.mkEnableOption "Install Nix tooling globally";
config = lib.mkMerge [
{
my.dev.nix.enable = lib.mkDefault hm.enabledByDefault;
}
(lib.mkIf cfg.enable {
home.packages = nix.packages;
programs.${shellType}.shellAliases =
inputs.self.lib.mergeAliases inputs.self.lib.commonAliases nix.shellAliases;
})
];
}

30
modules/dev/nix/nixos.nix Normal file
View File

@@ -0,0 +1,30 @@
{
config,
inputs,
lib,
pkgs,
...
}:
let
nix = import ./common.nix {
inherit pkgs;
inherit (config.networking) hostName;
};
in
{
options = {
my.dev.nix = {
enable = lib.mkEnableOption "Install Nix tooling globally";
users = lib.mkOption {
type = inputs.self.lib.usersOptionType lib;
default = config.my.toggleUsers.dev;
description = "Users to install Nix packages for";
};
};
devShells.nix = lib.mkOption {
type = lib.types.package;
default = nix.devShell;
description = "Nix/NixOS development shell with formatter, linter, LSP, and Cachix";
};
};
}

View File

@@ -1,66 +0,0 @@
{
config,
inputs,
lib,
pkgs,
...
}:
let
python = pkgs.python3.withPackages (
ps:
builtins.attrValues {
inherit (ps)
black # Python code formatter
editorconfig # follow rules of contributin
flake8 # wraper for pyflakes, pycodestyle and mccabe
isort # sort Python imports
pyflakes # checks source code for errors
pylint # bug and style checker for python
pytest # tests
speedtest-cli # check internet speed from the comand line
;
}
);
packages = builtins.attrValues {
inherit python;
inherit (pkgs)
pipenv # python development workflow for humans
pyright # LSP
;
};
in
{
options = {
my.dev.python = {
enable = lib.mkEnableOption "Install Python tools globally";
users = lib.mkOption {
type = inputs.self.lib.usersOptionType lib;
default = config.my.toggleUsers.dev;
description = "Users to install Python packages for";
};
};
devShells.python = lib.mkOption {
type = lib.types.package;
default = pkgs.mkShell {
inherit packages;
name = "python-dev-shell";
shellHook = ''
echo "🐍 Python dev environment"
which python
'';
description = "Python development shell";
};
};
};
config = lib.mkMerge [
(lib.mkIf config.my.dev.python.enable {
users.users = inputs.self.lib.mkUserAttrs lib config.my.dev.python.users { inherit packages; };
})
{
home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.dev.python.users (_user: {
xdg.configFile."python/pythonrc".source = ../../dotfiles/pythonrc;
});
environment.variables.PYTHONSTARTUP = "\${XDG_CONFIG_HOME}/python/pythonrc";
}
];
}

View File

@@ -0,0 +1,31 @@
{ pkgs }:
let
packages = builtins.attrValues {
inherit (pkgs)
pipenv
pyright
;
inherit (pkgs.python3Packages)
black
editorconfig
flake8
isort
pyflakes
pylint
pytest
speedtest-cli
;
};
in
{
inherit packages;
devShell = pkgs.mkShell {
inherit packages;
name = "python-dev-shell";
shellHook = ''
echo "🐍 Python dev environment"
which python
'';
description = "Python development shell";
};
}

View File

@@ -0,0 +1,36 @@
{
config,
inputs,
lib,
osConfig ? null,
pkgs,
...
}:
let
python = import ./common.nix { inherit pkgs; };
hm = inputs.self.lib.hmModule {
inherit
config
inputs
osConfig
;
optionPath = [
"dev"
"python"
];
};
cfg = config.my.dev.python;
in
{
options.my.dev.python.enable = lib.mkEnableOption "Install Python tools globally";
config = lib.mkMerge [
{
my.dev.python.enable = lib.mkDefault hm.enabledByDefault;
}
(lib.mkIf cfg.enable {
home.packages = python.packages;
xdg.configFile."python/pythonrc".source = ../../../dotfiles/pythonrc;
home.sessionVariables.PYTHONSTARTUP = "\${XDG_CONFIG_HOME}/python/pythonrc";
})
];
}

View File

@@ -0,0 +1,26 @@
{
config,
inputs,
lib,
pkgs,
...
}:
let
python = import ./common.nix { inherit pkgs; };
in
{
options = {
my.dev.python = {
enable = lib.mkEnableOption "Install Python tools globally";
users = lib.mkOption {
type = inputs.self.lib.usersOptionType lib;
default = config.my.toggleUsers.dev;
description = "Users to install Python packages for";
};
};
devShells.python = lib.mkOption {
type = lib.types.package;
default = python.devShell;
};
};
}