diff --git a/diffr.nix b/diffr.nix new file mode 100644 index 0000000..f47243c --- /dev/null +++ b/diffr.nix @@ -0,0 +1,13 @@ +{ config, pkgs, lib, ... }: +pkgs.writeShellScriptBin "diffr" '' + exec ${pkgs.diffr}/bin/diffr \ + --colors 'refine-added:foreground:green:underline' \ + --colors 'refine-added:background:none' \ + --colors 'refine-removed:foreground:red:underline' \ + --colors 'refine-removed:background:none' \ + --colors 'added:foreground:green' \ + --colors 'added:background:none' \ + --colors 'removed:foreground:red' \ + --colors 'removed:background:none' \ + $@ +'' diff --git a/flake.nix b/flake.nix index 1b47c9f..8b2137b 100644 --- a/flake.nix +++ b/flake.nix @@ -35,6 +35,8 @@ (_: _: { dhist = dhist.packages.${system}.dhist; bmenu = import ./bmenu.nix { inherit config pkgs lib; }; + _diffr = import ./diffr.nix { inherit config pkgs lib; }; + kak-pager = import ./kak-pager.nix { inherit config pkgs lib; }; }) ]; }) diff --git a/kak-pager.nix b/kak-pager.nix new file mode 100644 index 0000000..ebe7de4 --- /dev/null +++ b/kak-pager.nix @@ -0,0 +1,36 @@ +{ config, pkgs, lib, ... }: +pkgs.writeScriptBin "kak-pager" '' + #!/usr/bin/env fish + + if test (count $argv) -ne 0 + for i in $argv + cat "$i" + end | eval (status filename) + exit 0 + end + + set term_line_count (tput lines) + + while read line + set -a input_lines "$line" + + set input_line_count (printf "%s\n" $input_lines | wc -l) + + if test "$term_line_count" -lt "$input_line_count" + begin + printf "%s\n" $input_lines + cat + end | kak -e ' + exec + map global normal q :q; + rmhl global/number-lines; + set global scrolloff 10,0; + ' + + exit 0 + end + + end + + printf "%s\n" $input_lines +'' diff --git a/user/git.nix b/user/git.nix new file mode 100644 index 0000000..3aa8c6e --- /dev/null +++ b/user/git.nix @@ -0,0 +1,34 @@ +{ config, pkgs, lib, ... }: +let inherit (import ./variables.nix) username mail; +in { + config = { + programs.git = { + enable = true; + extraConfig = { + user = { + name = username; + email = mail.personal.user; + }; + init.defaultBranch = "main"; + commit.verbose = true; + pull.rebase = true; + merge.conflictStyle = "diff3"; + rerere.enabled = true; + rebase = { + abbreviateCommands = true; + autoSquash = true; + autoStash = true; + }; + pager = { + log = "${pkgs._diffr}/bin/diffr | ${pkgs.kak-pager}/bin/kak-pager"; + show = "${pkgs._diffr}/bin/diffr | ${pkgs.kak-pager}/bin/kak-pager"; + diff = "${pkgs._diffr}/bin/diffr | ${pkgs.kak-pager}/bin/kak-pager"; + }; + alias = { + graph = "log --graph --oneline --all"; + root = "rev-parse --show-toplevel"; + }; + }; + }; + }; +} diff --git a/user/home.nix b/user/home.nix index 7d3f21f..5c8ca9b 100644 --- a/user/home.nix +++ b/user/home.nix @@ -10,12 +10,7 @@ let volumesh = pkgs.writeShellScriptBin "volumesh" (builtins.readFile ./scripts/volumesh); in { - imports = [ - ./waybar.nix - ./helix.nix - ./kakoune.nix - ./sway.nix - ]; + imports = [ ./waybar.nix ./helix.nix ./kakoune.nix ./sway.nix ./git.nix ]; # Home Manager needs a bit of information about you and the # paths it should manage. home.username = "lelgenio"; @@ -35,6 +30,8 @@ in { alacritty exa fd + _diffr + kak-pager # text manipulation sd ripgrep diff --git a/user/kakoune.nix b/user/kakoune.nix index 789c77c..2146650 100644 --- a/user/kakoune.nix +++ b/user/kakoune.nix @@ -125,6 +125,8 @@ in { ]; home.sessionVariables = { EDITOR = "kak"; + # Some plugins(kak_ansi) like to compile stuff + CC = "cc"; }; }; } diff --git a/user/variables.nix b/user/variables.nix index 0c58282..0b9e5db 100644 --- a/user/variables.nix +++ b/user/variables.nix @@ -66,4 +66,28 @@ in rec { big = 16; }; }; + + username = "lelgenio"; + mail = { + personal = { + from = "Leonardo EugĂȘnio"; + user = "lelgenio@disroot.org"; + imap = "disroot.org"; + smtp = "disroot.org"; + pass = "disroot.org"; + }; + work = { + from = "Leonardo EugĂȘnio"; + user = "leonardo@wopus.com.br"; + imap = "imap.wopus.com.br"; + smtp = "smtp.wopus.com.br"; + pass = "Work/wopus_email"; + }; + }; + nextcloud = { + name = "disroot"; + user = "lelgenio"; + host = "cloud.disroot.org"; + pass = "disroot.org"; + }; }