This repository has been archived on 2025-10-08. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
nixos-config/options/home/dev.nix

198 lines
5.1 KiB
Nix

{
lib,
pkgs,
config,
...
}:
let
cfg = config.home.dev;
in
{
options = {
home.dev = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Development settings.";
};
additionalDevPackages = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [ ];
description = "Development additional packages: cli/tui/utils";
};
git = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Git settings.";
};
userName = lib.mkOption {
type = lib.types.str;
default = config.home.username;
description = "Git user name.";
};
userEmail = lib.mkOption {
type = lib.types.str;
default = "";
description = "Git user email.";
};
};
python = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Python base settings & packages.";
};
packages = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [
pkgs.python314
pkgs.uv
];
description = "List of user python packages.";
};
};
rust = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Rust base settings & packages.";
};
packages = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [
pkgs.gcc
pkgs.cargo
pkgs.rustc
];
description = "List of user rust packages.";
};
};
terminal = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Terminal settings & other stuff.";
};
shell = lib.mkOption {
type = lib.types.str;
default = if cfg.terminal.zsh.enable then "zsh" else "bash";
description = "Change standart shell for kitty";
};
aliases = lib.mkOption {
type = lib.types.attrsOf lib.types.str;
default = {
gc = "sudo nix-collect-garbage -d";
dev = "nix develop --command ${cfg.terminal.shell}";
"..." = "cd ../..";
};
description = "Terminal aliases.";
};
kitty.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Configure kitty - terminal emulator.";
};
zsh = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Configure zsh - terminal shell.";
};
oh-my-zsh = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Configure oh-my-zsh.";
};
plugins = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
description = "Plugins for oh-my-zsh";
};
};
};
};
};
};
config = lib.mkIf cfg.enable {
programs.git = lib.mkIf cfg.git.enable {
enable = true;
package = pkgs.gitAndTools.gitFull;
userName = cfg.git.userName;
userEmail = cfg.git.userEmail;
lfs.enable = true;
aliases = {
aa = "add --all";
c = "commit";
cm = "commit -m";
br = "branch";
s = "status";
uncommit = "reset --soft HEAD^";
unadd = "reset";
d = "diff";
ds = "diff --staged";
};
extraConfig = {
init = {
defaultbranch = "main";
};
branch = {
soft = "-committerdate";
};
pull.rebase = true;
};
};
programs.kitty = lib.mkIf cfg.terminal.kitty.enable {
enable = true;
package = pkgs.kitty;
shellIntegration = lib.mkIf (cfg.terminal.shell == "zsh") {
enableZshIntegration = true;
};
settings = {
shell = cfg.terminal.shell;
confirm_os_window_close = 0;
enable_audio_bell = false;
scrollback_lines = 10000;
mouse_hide_wait = "-1.0";
};
keybindings = {
"ctrl+=" = "increase_font_size";
"ctrl+-" = "decrease_font_size";
};
};
programs.zsh = lib.mkIf cfg.terminal.zsh.enable {
enable = true;
package = pkgs.zsh;
autocd = true;
autosuggestion = {
enable = true;
strategy = [ "history" ];
};
history = {
saveNoDups = true;
size = 10000;
save = 10000;
};
oh-my-zsh = lib.mkIf cfg.terminal.zsh.oh-my-zsh.enable {
enable = true;
plugins = cfg.terminal.zsh.oh-my-zsh.plugins;
};
syntaxHighlighting = {
enable = true;
};
shellAliases = cfg.terminal.aliases;
};
home.packages =
cfg.additionalDevPackages
++ lib.optionals cfg.python.enable cfg.python.packages
++ lib.optionals cfg.rust.enable cfg.rust.packages;
};
}