diff --git a/.gitignore b/.gitignore index 69d12f6..c18401e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,9 @@ !/nix /nix/* +!/nix/wm +!/nix/shell +!/nix/progs !/nix/home.nix !/nix/*.example.nix diff --git a/nix/home.nix b/nix/home.nix index 5850f1e..801d907 100644 --- a/nix/home.nix +++ b/nix/home.nix @@ -4,16 +4,15 @@ let secrets = import ./secrets.nix; in { - nixpkgs.overlays = [ - (self: super: { - haskellPackages = super.haskellPackages.override { - overrides = hself: hsuper: { - xmonad = hsuper.xmonad_0_17_0; - xmonad-contrib = hsuper.xmonad-contrib_0_17_0; - xmonad-extras = hsuper.xmonad-extras_0_17_0; - }; - }; - }) + imports = [ + ./wm/xmonad.nix + ./shell/zsh.nix + ./progs/git.nix + ./progs/pass.nix + ./progs/himalaya.nix + ./progs/nvim.nix + ./progs/exa.nix + ./progs/zoxide.nix ]; targets.genericLinux.enable = true; @@ -30,27 +29,13 @@ in options = ["grp:win_space_toggle"]; }; - # This value determines the Home Manager release that your - # configuration is compatible with. This helps avoid breakage - # when a new Home Manager release introduces backwards - # incompatible changes. - # - # You can update Home Manager without changing this value. See - # the Home Manager release notes for a list of state version - # changes in each release. - home.stateVersion = "21.11"; - home.packages = with pkgs; [ - # system - xclip # access x clipboard from a console - dmenu # menu for x window system - flameshot # powerful yet simple to use screenshot software + # TODO: move packages to separate modules # tools xh # friendly and fast tool for sending HTTP requests fd # a simple, fast and user-friendly alternative to find bat # a cat clone with syntax highlighting and git integration - pass # cli password manager # haskell stylish-haskell # formatter @@ -62,38 +47,43 @@ in librewolf # a fork of firefox, focused on privacy, security and freedom ]; - home.sessionVariables = - let - pass_data_dir = "${config.home.sessionVariables.XDG_DATA_HOME}/pass"; - in - { - EDITOR = "nvim"; - # for 'pass' tool - PASSWORD_STORE_DIR = "${pass_data_dir}/store"; - PASSWORD_STORE_EXTENSIONS_DIR = "${pass_data_dir}/extensions"; + # window manager + wm.xmonad.enable = true; + + # shell + shell.zsh.enable = true; + + # programs + progs = { + git = with secrets.git; { + enable = true; + inherit userName; + inherit userEmail; }; + # password manager + pass.enable = true; + + # email manager + himalaya.enable = true; + + # editor + nvim = { + enable = true; + default = true; + }; + + # tools + exa.enable = true; + zoxide.enable = true; + }; + accounts.email = { + # TODO: add module for email account accounts = secrets.emailAccounts; }; - programs.himalaya = { - enable = true; - settings = { - default-page-size = 10; - downloads-dir = "${config.home.homeDirectory}/downloads/email"; - }; - }; - - xsession = { - enable = true; - - windowManager.xmonad = { - enable = true; - enableContribAndExtras = true; - }; - }; - + # TODO: add module for lock screen services.screen-locker = { enable = true; @@ -102,112 +92,6 @@ in inactiveInterval = 5; }; - services.gpg-agent.enable = true; - - # Let Home Manager install and manage itself. - programs.home-manager.enable = true; - - # used for pass - programs.gpg.enable = true; - - # enable z shell - programs.zsh = { - enable = true; - enableAutosuggestions = true; - defaultKeymap = "viins"; - dotDir = ".config/zsh"; - - history = { - path = "${config.xdg.dataHome}/zsh/zsh_history"; - expireDuplicatesFirst = true; - ignorePatterns = [ - "rm *" - "kill *" - ]; - }; - - oh-my-zsh = { - enable = true; - theme = "robbyrussell"; - }; - - initExtraFirst = '' - # nix - if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then - source $HOME/.nix-profile/etc/profile.d/nix.sh; - fi - - source $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh - - export NIX_PATH=$HOME/.nix-defexpr/channels''${NIX_PATH:+:$NIX_PATH} - - # ghcup - if [ -f "$HOME/.ghcup/env" ]; then - source "$HOME/.ghcup/env" - fi - ''; - - shellAliases = - let - exa = "${pkgs.exa}/bin/exa"; - in { - # exa - ls = "${exa} -1"; - ll = "${exa} -l"; - lt = "${exa} --tree"; - # nvim - vi = "nvim"; - vim = "nvim"; - # himalaya - himp = "himalaya -a personal"; - himf = "himalaya -a family"; - himw = "himalaya -a work"; - }; - }; - - # enable git VCS - programs.git = { - enable = true; - userName = secrets.git.name; - userEmail = secrets.git.email; - extraConfig = { - init.defaultBranch = "main"; - pull.rebase = true; - }; - aliases = { - co = "checkout"; - cob = "checkout -b"; - cobf = "checkout -B"; - st = "status -sb"; - d = "diff"; - dc = "diff --cached"; - aa = "add ."; - ai = "add -i"; - c = "commit"; - cm = "commit -m"; - ca = "commit --amend"; - cam = "commit --amend -m"; - can = "commit --amend --no-edit"; - p = "push"; - po = "push origin"; - pf = "push --force-with-lease"; - pfo = "push --force-with-lease origin"; - pl = "pull"; - plo = "pull origin"; - rb = "rebase"; - rbi = "rebase -i"; - }; - }; - - # replacement for 'ls' written in rust - programs.exa.enable = true; - - # a fast cd command that learns your habbits - programs.zoxide = { - enable = true; - enableZshIntegration = true; - }; - home.file = { "scripts" = { source = ../scripts; @@ -226,11 +110,19 @@ in # add config for alacritty terminal "alacritty/alacritty.yml".source = ../programs/alacritty/alacritty.yml; - # add config for xmonad window manager - # "xmonad/xmonad.hs".source = ../programs/xmonad/xmonad.hs; - # "xmobar/xmobar.hs".source = ../programs/xmonad/xmobar.hs; - "stylish-haskell/config.yaml".source = ../programs/stylish-haskell/config.yml; }; }; + + # This value determines the Home Manager release that your + # configuration is compatible with. This helps avoid breakage + # when a new Home Manager release introduces backwards + # incompatible changes. + # + # You can update Home Manager without changing this value. See + # the Home Manager release notes for a list of state version + # changes in each release. + home.stateVersion = "21.11"; + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; } diff --git a/nix/progs/exa.nix b/nix/progs/exa.nix new file mode 100644 index 0000000..8a499eb --- /dev/null +++ b/nix/progs/exa.nix @@ -0,0 +1,28 @@ +{ lib, config, pkgs, ... }: + +with lib; + +let + cfg = config.progs.exa; + bin = "${pkgs.exa}/bin/exa"; +in +{ + options.progs.exa = { + enable = mkOption { + type = types.bool; + default = false; + description = "Add and configure exa, a modern replacement for ls"; + }; + }; + + config = mkIf cfg.enable { + programs.exa.enable = true; + + programs.zsh.shellAliases = mkIf config.shell.zsh.enable { + ls = "${bin} -1"; + ll = "${bin} -l"; + lt = "${bin} --tree"; + }; + }; +} + diff --git a/nix/progs/git.nix b/nix/progs/git.nix new file mode 100644 index 0000000..1fd542d --- /dev/null +++ b/nix/progs/git.nix @@ -0,0 +1,61 @@ +{ lib, config, pkgs, ... }: + +with lib; + +let + cfg = config.progs.git; +in +{ + options.progs.git = { + enable = mkOption { + type = types.bool; + default = false; + description = "Add git with my personal settings"; + }; + + userName = mkOption { + type = types.str; + description = "Set your global name"; + }; + + userEmail = mkOption { + type = types.str; + description = "Set your global email"; + }; + }; + + config = mkIf cfg.enable { + programs.git = { + enable = true; + userName = cfg.userName; + userEmail = cfg.userEmail; + extraConfig = { + init.defaultBranch = "main"; + pull.rebase = true; + }; + aliases = { + co = "checkout"; + cob = "checkout -b"; + cobf = "checkout -B"; + st = "status -sb"; + d = "diff"; + dc = "diff --cached"; + aa = "add ."; + ai = "add -i"; + c = "commit"; + cm = "commit -m"; + ca = "commit --amend"; + cam = "commit --amend -m"; + can = "commit --amend --no-edit"; + p = "push"; + po = "push origin"; + pf = "push --force-with-lease"; + pfo = "push --force-with-lease origin"; + pl = "pull"; + plo = "pull origin"; + rb = "rebase"; + rbi = "rebase -i"; + }; + }; + }; +} diff --git a/nix/progs/himalaya.nix b/nix/progs/himalaya.nix new file mode 100644 index 0000000..9e1ea2a --- /dev/null +++ b/nix/progs/himalaya.nix @@ -0,0 +1,35 @@ +{ lib, config, pkgs, ... }: + +with lib; + +let + cfg = config.progs.himalaya; + bin = "${pkgs.himalaya}/bin/exa"; +in +{ + options.progs.himalaya = { + enable = mkOption { + type = types.bool; + default = false; + description = "Add himalaya with my personal configuration"; + }; + }; + + config = mkIf cfg.enable { + programs.himalaya = { + enable = true; + settings = { + default-page-size = 10; + downloads-dir = "${config.home.homeDirectory}/downloads/email"; + }; + }; + + programs.zsh.shellAliases = mkIf config.shell.zsh.enable { + him = bin; + himp = "${bin} -a personal"; + himf = "${bin} -a family"; + himw = "${bin} -a work"; + }; + }; +} + diff --git a/nix/progs/nvim.nix b/nix/progs/nvim.nix new file mode 100644 index 0000000..e451b22 --- /dev/null +++ b/nix/progs/nvim.nix @@ -0,0 +1,37 @@ +{ lib, config, pkgs, ... }: + +with lib; + +let + cfg = config.progs.nvim; + bin = "nvim"; +in +{ + options.progs.nvim = { + enable = mkOption { + type = types.bool; + default = false; + description = "Add and configure exa, a modern replacement for ls"; + }; + + default = mkOption { + type = types.bool; + default = false; + description = "Set neovim as default editor"; + }; + }; + + config = mkIf cfg.enable { + # TODO: install and configure neovim from home-manager + + home.sessionVariables = mkIf cfg.default { + EDITOR = bin; + }; + + programs.zsh.shellAliases = mkIf config.shell.zsh.enable { + vi = bin; + vim = bin; + }; + }; +} + diff --git a/nix/progs/pass.nix b/nix/progs/pass.nix new file mode 100644 index 0000000..9b98a28 --- /dev/null +++ b/nix/progs/pass.nix @@ -0,0 +1,31 @@ +{ lib, config, pkgs, ... }: + +with lib; + +let + cfg = config.progs.pass; + pass_data_dir = "${config.home.sessionVariables.XDG_DATA_HOME}/pass"; +in +{ + options.progs.pass = { + enable = mkOption { + type = types.bool; + default = false; + description = "Add and configure pass tool to manager your passwords"; + }; + }; + + config = mkIf cfg.enable { + home.packages = [pkgs.pass]; + + home.sessionVariables = { + PASSWORD_STORE_DIR = "${pass_data_dir}/store"; + PASSWORD_STORE_EXTENSIONS_DIR = "${pass_data_dir}/extensions"; + }; + + programs.gpg.enable = true; + + services.gpg-agent.enable = true; + }; +} + diff --git a/nix/progs/zoxide.nix b/nix/progs/zoxide.nix new file mode 100644 index 0000000..50fe219 --- /dev/null +++ b/nix/progs/zoxide.nix @@ -0,0 +1,24 @@ +{ lib, config, pkgs, ... }: + +with lib; + +let + cfg = config.progs.zoxide; +in +{ + options.progs.zoxide = { + enable = mkOption { + type = types.bool; + default = false; + description = "Add zoxide, a modern replacement for cd"; + }; + }; + + config = mkIf cfg.enable { + programs.zoxide = { + enable = true; + enableZshIntegration = config.shell.zsh.enable; + }; + }; +} + diff --git a/nix/secrets.example.nix b/nix/secrets.example.nix index 9bcb5e8..e6a184b 100644 --- a/nix/secrets.example.nix +++ b/nix/secrets.example.nix @@ -5,7 +5,7 @@ }; git = { - name = "Bob Ross"; - email = "bross@example.com"; + userName = "Bob Ross"; + userEmail = "bross@example.com"; }; } diff --git a/nix/shell/zsh.nix b/nix/shell/zsh.nix new file mode 100644 index 0000000..9f525f9 --- /dev/null +++ b/nix/shell/zsh.nix @@ -0,0 +1,56 @@ +{ lib, config, pkgs, ... }: + +with lib; + +let + cfg = config.shell.zsh; +in +{ + options.shell.zsh = { + enable = mkOption { + type = types.bool; + default = false; + description = "Add z shell"; + }; + }; + + config = mkIf cfg.enable { + programs.zsh = { + enable = true; + enableAutosuggestions = true; + defaultKeymap = "viins"; + dotDir = ".config/zsh"; + + history = { + path = "${config.xdg.dataHome}/zsh/zsh_history"; + expireDuplicatesFirst = true; + ignorePatterns = [ + "rm *" + "kill *" + ]; + }; + + oh-my-zsh = { + enable = true; + theme = "robbyrussell"; + }; + + initExtraFirst = '' + # nix + if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then + source $HOME/.nix-profile/etc/profile.d/nix.sh; + fi + + source $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh + + export NIX_PATH=$HOME/.nix-defexpr/channels''${NIX_PATH:+:$NIX_PATH} + + # ghcup + if [ -f "$HOME/.ghcup/env" ]; then + source "$HOME/.ghcup/env" + fi + ''; + }; + }; +} + diff --git a/nix/wm/xmonad.nix b/nix/wm/xmonad.nix new file mode 100644 index 0000000..6a0fb00 --- /dev/null +++ b/nix/wm/xmonad.nix @@ -0,0 +1,51 @@ +{ lib, config, pkgs, ...}: + +with lib; + +let + cfg = config.wm.xmonad; +in +{ + options.wm.xmonad = { + enable = mkOption { + type = types.bool; + default = false; + description = "Enable xsessions and xmonad window manager"; + }; + }; + + config = mkIf cfg.enable { + nixpkgs.overlays = [ + (self: super: { + haskellPackages = super.haskellPackages.override { + overrides = hself: hsuper: { + xmonad = hsuper.xmonad_0_17_0; + xmonad-contrib = hsuper.xmonad-contrib_0_17_0; + xmonad-extras = hsuper.xmonad-extras_0_17_0; + }; + }; + }) + ]; + + home.packages = with pkgs; [ + xclip # access x clipboard from a console + dmenu # menu for x window system + flameshot # powerful yet simple to use screenshot software + ]; + + xsession = { + enable = true; + + windowManager.xmonad = { + enable = true; + enableContribAndExtras = true; + }; + }; + + xdg.configFile = { + # add config for xmonad window manager + # "xmonad/xmonad.hs".source = ../programs/xmonad/xmonad.hs; + # "xmobar/xmobar.hs".source = ../programs/xmonad/xmobar.hs; + }; + }; +}