Compare commits

...

7 commits

Author SHA1 Message Date
7d98dd2edd
feat(abbrs): New module for home.shellAbbrs
Allows setting home.shellAbbrs that either get set as Fish shell
abbreviations or converted to shell aliases depending on if Fish is
active.

Abbrs that depend on Fish-specific features get automatically filtered
out.
2024-11-03 18:48:50 -08:00
ee02b803c2
feat(go): Properly set GOPATH 2024-11-03 18:48:30 -08:00
6e2602a75f
feat(journalctl): Journalctl aliases 2024-11-03 16:33:28 -08:00
0db80951a2
feat(go): Configure go 2024-11-03 16:33:13 -08:00
fc0b9e3d13
feat(fish): Add abbrs/aliases 2024-11-03 15:00:19 -08:00
917e1377c1
🚚 refactor(profile): Move profile-related settings to subdir 2024-11-03 14:50:02 -08:00
2585df4e81
feat(fzf): Install fzf 2024-11-03 14:49:09 -08:00
11 changed files with 235 additions and 6 deletions

View file

@ -46,8 +46,9 @@
};
modules = [
./home
inputs.rose-pine.homeManagerModules.rose-pine
./modules/home/shellAbbrs.nix
./home
];
};
};

View file

@ -1,7 +1,13 @@
{ ... }:
{ pkgs, ... }:
{
home.packages = with pkgs; [
maple-mono-NF
];
rose-pine.pointerCursor.enable = true;
fonts.fontconfig.defaultFonts.monospace = [ "Maple Mono NF" ];
imports = [
./gtk.nix
./qt.nix

View file

@ -39,16 +39,13 @@
nixfmt-rfc-style
nil
just
maple-mono-NF
];
fonts.fontconfig.defaultFonts.monospace = [ "Maple Mono NF" ];
imports = [
./appearance
./profile
./programs
./services
./xdg.nix
./xorg
];

27
home/profile/default.nix Normal file
View file

@ -0,0 +1,27 @@
{ config, ... }:
{
home = {
sessionPath = [
"${config.home.homeDirectory}/.local/bin"
];
sessionVariables = rec {
HACK = "${config.home.homeDirectory}/hackin";
# TODO: remove this when neovim is installed.
EDITOR = "nvim";
VISUAL = "${EDITOR}";
SUDO_EDITOR = "${EDITOR}";
};
shellAliases = {
c = "clear";
e = "${config.home.sessionVariables.EDITOR}";
v = "${config.home.sessionVariables.EDITOR}";
};
};
imports = [
./xdg.nix
];
}

View file

@ -8,7 +8,9 @@
./curl.nix
./eza.nix
./fish.nix
./fzf.nix
./gh.nix
./go.nix
./hyfetch.nix
./lazygit.nix
./less.nix

View file

@ -29,5 +29,37 @@
src = autopair;
}
];
shellInit = # fish
''
set -g fish_key_bindings fish_vi_key_bindings
'';
shellAbbrs = {
cp = {
position = "command";
expansion = "cp -iv";
};
mkdir = {
position = "command";
expansion = "mkdir -pv";
};
mv = {
position = "command";
expansion = "mv -iv";
};
rm = {
position = "command";
expansion = "rm -r";
};
grep = {
position = "command";
expansion = "grep --color=auto";
};
};
};
}

37
home/programs/fzf.nix Normal file
View file

@ -0,0 +1,37 @@
{ lib, config, ... }:
{
programs.fzf = {
enable = true;
rose-pine.enable = true;
defaultOptions = [
"--margin=10%,5%"
"--border=sharp"
"--pointer= "
"--marker= "
"--prompt= "
"--preview-label-pos='bottom'"
"--preview-window='border-sharp'"
];
# TODO: Check that rg is installed.
defaultCommand = "rg --files --hidden --glob \"!.git\"";
# TODO: Check that fd is installed.
changeDirWidgetCommand = "fd --type d";
changeDirWidgetOptions = lib.mkIf config.programs.eza.enable [
"--preview 'eza --all --color=always --sort=name --group-directories-first --level=3 {}'"
];
# TODO: Check that fd is installed.
fileWidgetCommand = "fd --type f";
fileWidgetOptions = lib.mkIf config.programs.bat.enable [
"--preview 'bat {}'"
];
tmux.enableShellIntegration = lib.mkIf config.programs.tmux.enable true;
};
home.sessionVariables.fzf_diff_highlighter = "delta --paging=never --features=arctic-fox";
}

14
home/programs/go.nix Normal file
View file

@ -0,0 +1,14 @@
{ config, ... }:
{
programs.go = {
enable = true;
};
home.sessionPath =
let
goPath = config.programs.go.goPath;
in
[
"${if (goPath == null) then "go" else goPath}"
];
}

View file

@ -1,5 +1,16 @@
{ ... }:
{
home.shellAbbrs = {
jf = {
position = "command";
expansion = "sudo journalctl --follow --unit";
};
je = {
position = "command";
expansion = "sudo journalctl --pager-end --unit";
};
};
imports = [
./clipboard.nix
./dunst.nix

102
modules/home/shellAbbrs.nix Normal file
View file

@ -0,0 +1,102 @@
{
config,
lib,
...
}:
with lib;
let
# https://github.com/nix-community/home-manager/blob/master/modules/programs/fish.nix
abbrModule = types.submodule {
options = {
expansion = mkOption {
type = with types; nullOr str;
default = null;
description = ''
The command expanded by an abbreviation.
'';
};
position = mkOption {
type = with types; nullOr str;
default = null;
example = "anywhere";
description = ''
If the position is "command", the abbreviation expands only if
the position is a command. If it is "anywhere", the abbreviation
expands anywhere.
'';
};
regex = mkOption {
type = with types; nullOr str;
default = null;
description = ''
The regular expression pattern matched instead of the literal name.
'';
};
setCursor = mkOption {
type = with types; (either bool str);
default = false;
description = ''
The marker indicates the position of the cursor when the abbreviation
is expanded. When setCursor is true, the marker is set with a default
value of "%".
'';
};
function = mkOption {
type = with types; nullOr str;
default = null;
description = ''
The fish function expanded instead of a literal string.
'';
};
};
};
removeFishOnly = attrsets.filterAttrs (
_: v: if (builtins.isAttrs v) then !((v ? regex) || (v ? setCursor) || (v ? function)) else true
);
abbrToAlias = attrsets.mapAttrs (
_: v: if (builtins.isAttrs v) then v.expansion else v
) removeFishOnly;
in
{
options = {
# https://github.com/nix-community/home-manager/blob/master/modules/programs/fish.nix
home.shellAbbrs = mkOption {
type = with types; attrsOf (either str abbrModule);
default = { };
example = literalExpression ''
{
l = "less";
gco = "git checkout";
"-C" = {
position = "anywhere";
expansion = "--color";
};
}
'';
description = ''
An attribute set that maps aliases (the top level attribute names
in this option) to abbreviations. Abbreviations are expanded with
the longer phrase after they are entered.
'';
};
};
config =
let
fishCfg = config.programs.fish;
shellAbbrs = config.home.shellAbbrs;
in
{
programs.fish.shellAbbrs = mkIf fishCfg.enable shellAbbrs;
home.shellAliases = mkIf (!fishCfg.enable) (abbrToAlias shellAbbrs);
};
}