system/modules/home-manager/programs/dev-tools.nix

141 lines
4.1 KiB
Nix

{ config, lib, pkgs, ... }:
let
cfg = config.local.programs.dev-tools;
kubectlCompletionsZsh = pkgs.runCommand "kubectl-completion.zsh" {} ''
${lib.getExe pkgs.kubectl} completion zsh > $out
'';
# https://github.com/NixOS/nixpkgs/pull/384524/files
apacheDirectoryStudio = with pkgs.unstable; (apache-directory-studio.overrideAttrs (attrs: {
installPhase = ''
dest="$out/libexec/ApacheDirectoryStudio"
mkdir -p "$dest"
cp -r . "$dest"
mkdir -p "$out/bin"
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
"$dest/ApacheDirectoryStudio"
# About `/tmp/SWT-GDBusServer`, see
# https://github.com/adoptium/adoptium-support/issues/785#issuecomment-1866680133
# and
# https://github.com/adoptium/adoptium-support/issues/785#issuecomment-2387481967.
makeWrapper "$dest/ApacheDirectoryStudio" \
"$out/bin/ApacheDirectoryStudio" \
--prefix PATH : "${jdk}/bin" \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ glib webkitgtk_4_0 ] } \
--run "mkdir -p /tmp/SWT-GDBusServer"
install -D icon.xpm "$out/share/pixmaps/apache-directory-studio.xpm"
install -D -t "$out/share/applications" ${attrs.desktopItem}/share/applications/*
'';
}));
in
{
options.local.programs.dev-tools = with lib; {
base.enable = mkEnableOption "base tools";
nix.enable = mkEnableOption "tools for nix developer";
erlang.enable = mkEnableOption "tools for erlang developer";
web.enable = mkEnableOption "tools for web developer";
k8s.enable = mkEnableOption "k8s tools";
psql = {
enable = mkEnableOption "psql";
package = mkOption {
type = types.package;
default = pkgs.postgresql;
};
};
eza.enable = mkEnableOption "eza. ls replacement";
direnv.enable = mkEnableOption "direnv";
zoxide.enable = mkEnableOption "zoxide";
ldap.enable = mkEnableOption "ldap";
};
config = lib.mkMerge [
(lib.mkIf cfg.base.enable {
home.packages = with pkgs; [
gnumake
bat # a cat clone with syntax highlighting and git integration
fd # a simple, fast and user-friendly alternative to find
ripgrep # a fuzzy finder
libnotify # tool to send notifications via cli
];
})
(lib.mkIf cfg.eza.enable {
programs.eza = {
enable = true;
package = pkgs.unstable.eza.override { gitSupport = false; };
};
programs.zsh.shellAliases =
let
defaultArgs = "--icons --classify --group-directories-first --all";
bin = "${config.programs.eza.package}/bin/exa ${defaultArgs}";
in
lib.mkIf config.programs.zsh.enable {
ls = "${bin} --oneline";
lt = "${bin} --tree --level=3";
ll = "${bin} --long --header";
};
})
(lib.mkIf cfg.direnv.enable {
programs.direnv = {
enable = true;
nix-direnv.enable = true;
};
})
(lib.mkIf cfg.zoxide.enable {
programs.zoxide = {
enable = true;
enableZshIntegration = config.programs.zsh.enable;
};
})
(lib.mkIf cfg.web.enable {
home.packages = with pkgs.unstable; [
xh # friendly and fast tool for sending HTTP requests
deno
docker-compose
];
})
(lib.mkIf cfg.erlang.enable {
home.packages = with pkgs.unstable; [
erlang
erlfmt
];
})
(lib.mkIf cfg.nix.enable {
home.packages = with pkgs.unstable; [
nixpkgs-fmt # nix formatter
nil # nix lsp server
];
})
(lib.mkIf cfg.k8s.enable {
home.packages = with pkgs; [
(google-cloud-sdk.withExtraComponents (
let gc = google-cloud-sdk.components; in [
gc.gke-gcloud-auth-plugin
gc.kubectl
]
))
];
programs.zsh.initExtra = ''
source ${kubectlCompletionsZsh}
'';
})
(lib.mkIf cfg.psql.enable {
home.packages = [ cfg.psql.package ];
})
(lib.mkIf cfg.ldap.enable {
home.packages = [ apacheDirectoryStudio ];
})
];
}