nix: add NixOS module

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I0d8e0ed21f7b565123312cbdffa8a5e36a6a6964
This commit is contained in:
raf 2026-03-16 14:54:19 +03:00
commit af25dd46c7
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF

44
nix/modules/nixos.nix Normal file
View file

@ -0,0 +1,44 @@
self: {
config,
pkgs,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.options) mkEnableOption mkPackageOption;
inherit (lib.strings) optionalString;
cfg = config.programs.eh;
in {
options.programs.eh = {
enable = mkEnableOption "eh - Ergonomic Nix CLI helper";
package = mkPackageOption self.packages.${pkgs.hostPlatform.system} ["eh"] {};
hooks = {
bash.enable = mkEnableOption "Bash shell hook for EH" // {default = config.programs.bash.enable;};
zsh.enable = mkEnableOption "ZSH shell hook for EH" // {default = config.programs.zsh.enable;};
};
};
config = mkIf cfg.enable {
environment.systemPackages = [cfg.package];
programs = {
bash.interactiveShellInit = optionalString cfg.hooks.bash.enable ''
# Aliases added by EH
alias nr='eh run'
alias ns='eh shell'
alias nb='eh build'
alias nu='eh update'
'';
zsh.interactiveShellInit = optionalString cfg.hooks.zsh.enable ''
# Aliases added by EH
alias nr='eh run'
alias ns='eh shell'
alias nb='eh build'
alias nu='eh update'
'';
};
};
}