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

@@ -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";
};
};
}