From fdf1c788488534825abdbfe8f8c0e8e95a876d57 Mon Sep 17 00:00:00 2001 From: Shubham Saini Date: Fri, 29 Sep 2023 21:02:23 -0700 Subject: nix: reorg programs into modules --- darwin/home.nix | 61 +----------------------------------------------------- home.nix | 38 +++------------------------------- modules/common.nix | 17 +++++++++++++++ modules/fzf.nix | 9 ++++++++ modules/git.nix | 24 +++++++++++++++++++++ modules/lf.nix | 41 ++++++++++++++++++++++++++++++++++++ modules/zsh.nix | 2 ++ 7 files changed, 97 insertions(+), 95 deletions(-) create mode 100644 modules/common.nix create mode 100644 modules/fzf.nix create mode 100644 modules/git.nix create mode 100644 modules/lf.nix diff --git a/darwin/home.nix b/darwin/home.nix index 5e24a76..1188c65 100644 --- a/darwin/home.nix +++ b/darwin/home.nix @@ -45,65 +45,6 @@ }; imports = [ - ../modules/zsh.nix + ../modules/common.nix ]; - - home.sessionVariables = { - PATH = "$PATH:$HOME/.bin"; - EDITOR = "nvim"; - MANPAGER = "nvim +Man!"; - }; - - programs.home-manager.enable = true; - programs.fzf = { - enable = true; - enableZshIntegration = false; - defaultOptions = [ "--height 40%" "--layout=reverse" "--border" ]; - }; - programs.git = { - enable = true; - userEmail = "ssaini@fispan.com"; - userName = "Shubham Saini"; - signing = { - key = "E0404DDE4BCF9DB5"; - signByDefault = true; - }; - }; - programs.lf = { - enable = true; - settings = { - shell = "sh"; - icons = true; - drawbox = true; - scrolloff = 10; - shellopts = "-eu"; - }; - commands = { - extract = '' - %{{ - set -f - case $f in - *.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf $f;; - *.tar.gz|*.tgz) tar xzvf $f;; - *.tar.xz|*.txz) tar xJvf $f;; - *.zip) unzip $f;; - *.rar) unrar x $f;; - *.7z) 7z x $f;; - esac - }} - ''; - open = '' - %{{ - case $(file --mime-type -Lb $f) in - text/*) lf -remote "send $id \$$EDITOR \$fx";; - *) for f in $fx; do $OPENER $f > /dev/null 2> /dev/null & done;; - esac - }} - ''; - }; - keybindings = { - "" = "shell"; - "." = "set hidden!"; - }; - }; } diff --git a/home.nix b/home.nix index 7de67a9..0ec8399 100644 --- a/home.nix +++ b/home.nix @@ -24,41 +24,9 @@ # (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; }) ]; - programs.home-manager.enable = true; - programs.zsh = { - enable = true; - enableCompletion = true; - shellAliases = { - ll = "ls -l"; - v = "nvim"; - o = "xdg-open"; - t = "tmux"; - update = "sudo nixos-rebuild switch --flake ~/nix"; - }; - history = { - size = 10000; - path = "${config.xdg.dataHome}/zsh/history"; - }; - oh-my-zsh = { - enable = true; - plugins = [ "git" "kubectl" "sudo" ]; - theme = "robbyrussell"; - }; - }; - programs.fzf = { - enable = true; - enableZshIntegration = true; - defaultOptions = [ "--height 40%" "--layout=reverse" "--border" ]; - }; - programs.git = { - enable = true; - userEmail = "me@ubh.sh"; - userName = "Shubham Saini"; - signing = { - key = "E0404DDE4BCF9DB5"; - signByDefault = true; - }; - }; + imports = [ + ./modules/common.nix + ]; services.gpg-agent = { enable = true; diff --git a/modules/common.nix b/modules/common.nix new file mode 100644 index 0000000..747a9cc --- /dev/null +++ b/modules/common.nix @@ -0,0 +1,17 @@ +{ config, pkgs, ... }: + +{ + programs.home-manager.enable = true; + home.sessionVariables = { + PATH = "$PATH:$HOME/.bin"; + EDITOR = "nvim"; + MANPAGER = "nvim +Man!"; + }; + + imports = [ + ./lf.nix + ./fzf.nix + ./git.nix + ./zsh.nix + ]; +} diff --git a/modules/fzf.nix b/modules/fzf.nix new file mode 100644 index 0000000..98e3ff9 --- /dev/null +++ b/modules/fzf.nix @@ -0,0 +1,9 @@ +{ config, pkgs, ... }: + +{ + programs.fzf = { + enable = true; + enableZshIntegration = false; + defaultOptions = [ "--height 40%" "--layout=reverse" "--border" ]; + }; +} diff --git a/modules/git.nix b/modules/git.nix new file mode 100644 index 0000000..87f6e73 --- /dev/null +++ b/modules/git.nix @@ -0,0 +1,24 @@ +{ config, pkgs, ... }: + +{ + programs.git = { + enable = true; + userEmail = "me@ubh.sh"; + userName = "Shubham Saini"; + signing = { + key = "E0404DDE4BCF9DB5"; + signByDefault = true; + }; + extraConfig = { + commit.verbose = true; + init.defaultBranch = "master"; + pull.rebase = "true"; + }; + includes = [ + { + "path" = "~/dev/gitconfig"; + "condition" = "gitdir:~/dev/"; + } + ]; + }; +} diff --git a/modules/lf.nix b/modules/lf.nix new file mode 100644 index 0000000..b0dd304 --- /dev/null +++ b/modules/lf.nix @@ -0,0 +1,41 @@ +{ config, pkgs, ... }: + +{ + programs.lf = { + enable = true; + settings = { + shell = "sh"; + icons = true; + drawbox = true; + scrolloff = 10; + shellopts = "-eu"; + }; + commands = { + extract = '' + %{{ + set -f + case $f in + *.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf $f;; + *.tar.gz|*.tgz) tar xzvf $f;; + *.tar.xz|*.txz) tar xJvf $f;; + *.zip) unzip $f;; + *.rar) unrar x $f;; + *.7z) 7z x $f;; + esac + }} + ''; + open = '' + %{{ + case $(file --mime-type -Lb $f) in + text/*) lf -remote "send $id \$$EDITOR \$fx";; + *) for f in $fx; do $OPENER $f > /dev/null 2> /dev/null & done;; + esac + }} + ''; + }; + keybindings = { + "" = "shell"; + "." = "set hidden!"; + }; + }; +} diff --git a/modules/zsh.nix b/modules/zsh.nix index bd7a30f..8f05af4 100644 --- a/modules/zsh.nix +++ b/modules/zsh.nix @@ -1,3 +1,5 @@ +{ config, pkgs, ... }: + { programs.zsh = { enable = true; -- cgit v1.2.3