diff --git a/.gitignore b/.gitignore index af0bd12e..818190bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ /result secrets.nix -!config/profiles/common/nixos/secrets.nix \ No newline at end of file +*.swp +*.swo +w +!config/profiles/common/nixos/secrets.nix diff --git a/config/hosts/boline/configuration.nix b/config/hosts/boline/configuration.nix index 9c85fa7e..9249c4c8 100644 --- a/config/hosts/boline/configuration.nix +++ b/config/hosts/boline/configuration.nix @@ -3,6 +3,7 @@ { imports = [ ./hardware.nix + ../../services/nginx.nix #./wireguard.nix ]; @@ -25,6 +26,7 @@ defaultGateway = "104.244.73.1"; nameservers = [ "1.1.1.1" ]; }; + networking.firewall.allowedTCPPorts = [ 80 443 ]; system.stateVersion = "20.09"; } diff --git a/config/hosts/samhain/configuration.nix b/config/hosts/samhain/configuration.nix index 17cc3e58..e5c85b5e 100644 --- a/config/hosts/samhain/configuration.nix +++ b/config/hosts/samhain/configuration.nix @@ -25,7 +25,7 @@ networking.useDHCP = false; networking.interfaces.enp34s0.useDHCP = true; networking.firewall.allowPing = true; - networking.firewall.allowedTCPPorts = [ 445 139 9091 ]; # smb transmission + networking.firewall.allowedTCPPorts = [ 80 445 139 9091 ]; # smb transmission networking.firewall.allowedUDPPorts = [ 137 138 4010 ]; # smb scream system.stateVersion = "20.09"; diff --git a/config/hosts/samhain/torrenting.nix b/config/hosts/samhain/torrenting.nix index 56bd81ca..ace324d1 100644 --- a/config/hosts/samhain/torrenting.nix +++ b/config/hosts/samhain/torrenting.nix @@ -17,8 +17,8 @@ home = "/disks/pool-raw/transmission"; downloadDirPermissions = "777"; settings = { - download-dir = "/disks/pool-raw/Public/Media/"; - incomplete-dir = "/disks/pool-raw/Public/Media/.incomplete"; + download-dir = "/disks/pool-raw/media/"; + incomplete-dir = "/disks/pool-raw/media/.incomplete"; incomplete-dir-enabled = true; rpc-bind-address = "0.0.0.0"; rpc-whitelist = "127.0.0.1,192.168.1.*,192.168.122.*"; @@ -47,7 +47,7 @@ ''; shares = { media = { - path = "/disks/pool-raw/Public/Media"; + path = "/disks/pool-raw/media"; browseable = "yes"; "read only" = "no"; "guest ok" = "yes"; @@ -62,7 +62,13 @@ services.nginx.virtualHosts = { "192.168.1.135" = { locations."/share/" = { - alias = "/disks/pool-raw/Public/Media/"; + alias = "/disks/pool-raw/media/"; + extraConfig = "autoindex on;"; + }; + }; + "100.103.111.44" = { + locations."/share/" = { + alias = "/disks/pool-raw/media/"; extraConfig = "autoindex on;"; }; }; diff --git a/config/nixos.nix b/config/nixos.nix index f5fdb169..d8661ef0 100644 --- a/config/nixos.nix +++ b/config/nixos.nix @@ -15,6 +15,7 @@ in { specialArgs = { inherit sources witch; superConfig = config; + modulesPath = sources.home-manager + "/modules"; }; }); }; diff --git a/config/profiles/gui/home/default.nix b/config/profiles/gui/home/default.nix index 53eeedc4..e2b68d9d 100644 --- a/config/profiles/gui/home/default.nix +++ b/config/profiles/gui/home/default.nix @@ -5,6 +5,7 @@ ./firefox ./kitty.nix ./packages.nix + ./email.nix ./nextcloud.nix ./gpg.nix ./gtk.nix diff --git a/config/profiles/gui/home/email.nix b/config/profiles/gui/home/email.nix new file mode 100644 index 00000000..e70547f9 --- /dev/null +++ b/config/profiles/gui/home/email.nix @@ -0,0 +1,33 @@ +{ config, lib, pkgs, ... }: + +{ + programs.notmuch = { + enable = true; + hooks = { + preNew = "mbsync --all"; + }; + }; + programs.mbsync.enable = true; + programs.msmtp.enable = true; + accounts.email = { + maildirBasePath = "${config.home.homeDirectory}/mail"; + accounts.kat = { + address = "kat@kittywit.ch"; + primary = true; + realName = "kat witch"; + userName = "kat@kittywit.ch"; + passwordCommand = ''bitw -p gpg://${../../../private/files/master.gpg} get "kittywitch email"''; + msmtp.enable = true; + mbsync.enable = true; + mbsync.create = "maildir"; + notmuch.enable = true; + imap.host = "kittywit.ch"; + smtp.host = "kittywit.ch"; + gpg = { + signByDefault = true; + key = "01F50A29D4AA91175A11BDB17248991EFA8EFBEE"; + }; + }; +}; + programs.vim.plugins = [ pkgs.arc.pkgs.vimPlugins.notmuch-vim ]; +} diff --git a/config/profiles/gui/home/music.nix b/config/profiles/gui/home/music.nix index acf0141a..d2a8b821 100644 --- a/config/profiles/gui/home/music.nix +++ b/config/profiles/gui/home/music.nix @@ -4,7 +4,7 @@ config = lib.mkIf config.deploy.profile.gui { programs.ncmpcpp = { enable = true; - mpdMusicDir = "/home/kat/music"; + mpdMusicDir = "/home/kat/media/music"; settings = { visualizer_data_source = "/tmp/mpd.fifo"; visualizer_output_name = "my_fifo"; @@ -16,23 +16,25 @@ discard_colors_if_item_is_selected = "no"; header_window_color = "250"; volume_color = "250"; - state_line_color = "cyan"; + state_line_color = "cyan"; state_flags_color = "cyan"; + alternative_ui_separator_color = "yellow"; statusbar_color = "yellow"; progressbar_color = "black"; progressbar_elapsed_color = "blue"; + window_border_color = "yellow"; playlist_display_mode = "classic"; song_columns_list_format = "(3f)[cyan]{n} (40)[default]{t|f} (25)[red]{a} (30)[blue]{b} (4f)[cyan]{l}"; now_playing_prefix = "$b"; song_list_format = - "$1$9%l$1$9 $8¦$9 $6%a$9 $8¦$9 $5%b$9 $R$1$9%t$1$9 $8¦$9 $7%n$9"; + " $7%n$9 $8-$9 $1$9%l$1$9 $8-$9 $6%a$9 $8-$9 $5%b$9 $R$8%t$9 "; song_library_format = "{%n > }{%t}|{%f}"; song_status_format = "{%a - }{%t - }{%b}"; titles_visibility = "no"; header_visibility = "no"; statusbar_visibility = "no"; - now_playing_suffix = "$8$/b"; + now_playing_suffix = "$/b"; progressbar_look = "▄▄ "; }; }; @@ -40,7 +42,7 @@ enable = true; package = pkgs.unstable.beets; settings = { - directory = "~/music"; + directory = "~/media/music"; library = "~/.local/share/beets.db"; plugins = lib.concatStringsSep " " [ "mpdstats" @@ -53,7 +55,7 @@ services.mpd = { enable = true; network.startWhenNeeded = true; - musicDirectory = "/home/kat/music"; + musicDirectory = "/home/kat/media/music"; extraConfig = '' audio_output { type "fifo" diff --git a/config/profiles/gui/home/packages.nix b/config/profiles/gui/home/packages.nix index c5b492ad..229f5eae 100644 --- a/config/profiles/gui/home/packages.nix +++ b/config/profiles/gui/home/packages.nix @@ -5,12 +5,14 @@ home.packages = with pkgs; [ _1password bitwarden + arc.pkgs.rbw-bitw mpv element-desktop mumble obs-studio niv - xfce.ristretto + feh + duc audacity avidemux vlc diff --git a/config/profiles/kat/home/default.nix b/config/profiles/kat/home/default.nix index ebdfae8a..1ecdffba 100644 --- a/config/profiles/kat/home/default.nix +++ b/config/profiles/kat/home/default.nix @@ -3,7 +3,7 @@ { imports = [ ./shell.nix - ./neovim + ./vim ./git.nix ./tmux.nix ./ssh.nix diff --git a/config/profiles/kat/home/neovim/default.nix b/config/profiles/kat/home/neovim/default.nix deleted file mode 100644 index 23e1c1ce..00000000 --- a/config/profiles/kat/home/neovim/default.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ config, lib, pkgs, witch, ... }: - -{ - config = lib.mkIf config.deploy.profile.kat { - home.sessionVariables.EDITOR = "nvim"; - programs.neovim = { - enable = true; - withPython3 = true; - plugins = with pkgs.vimPlugins; [ - nerdtree - vim-nix - coc-nvim - coc-yank - coc-python - coc-json - coc-yaml - coc-git - vim-fugitive - { - plugin = vim-startify; - config = "let g:startify_change_to_vcs_root = 0"; - } - ]; - extraPackages = with pkgs; - [ (python3.withPackages (ps: with ps; [ black flake8 ])) ]; - extraPython3Packages = (ps: with ps; [ jedi pylint ]); - extraConfig = import ./vimrc.nix { inherit pkgs; }; - }; - xdg.configFile."nvim/coc-settings.json".text = - builtins.readFile ./coc-settings.json; - }; -} diff --git a/config/profiles/kat/home/neovim/coc-settings.json b/config/profiles/kat/home/vim/coc-settings.json similarity index 100% rename from config/profiles/kat/home/neovim/coc-settings.json rename to config/profiles/kat/home/vim/coc-settings.json diff --git a/config/profiles/kat/home/vim/default.nix b/config/profiles/kat/home/vim/default.nix new file mode 100644 index 00000000..c50ddf6f --- /dev/null +++ b/config/profiles/kat/home/vim/default.nix @@ -0,0 +1,34 @@ +{ config, lib, pkgs, witch, ... }: + +{ + config = lib.mkIf config.deploy.profile.kat { + home.sessionVariables.EDITOR = "vim"; + programs.vim = { + enable = true; + package = pkgs.arc.pkgs.vim_configurable-pynvim; + #withPython3 = true; + plugins = with pkgs.vimPlugins; [ + nerdtree + vim-nix + coc-nvim + coc-yank + coc-python + coc-json + coc-yaml + coc-git + vim-fugitive + vim-startify + ]; + #extraPackages = with pkgs; + # [ (python3.withPackages (ps: with ps; [ black flake8 ])) ]; + #extraPython3Packages = (ps: with ps; [ jedi pylint ]); + extraConfig = import ./vimrc.nix { inherit pkgs config; }; + }; + xdg.configFile = { + "vim/undo/.keep".text = ""; + "vim/swap/.keep".text = ""; + "vim/backup/.keep".text = ""; + "nvim/coc-settings.json".text = builtins.readFile ./coc-settings.json; + }; + }; +} diff --git a/config/profiles/kat/home/neovim/vimrc.nix b/config/profiles/kat/home/vim/vimrc.nix similarity index 91% rename from config/profiles/kat/home/neovim/vimrc.nix rename to config/profiles/kat/home/vim/vimrc.nix index 21ac1b35..b93a6264 100644 --- a/config/profiles/kat/home/neovim/vimrc.nix +++ b/config/profiles/kat/home/vim/vimrc.nix @@ -1,4 +1,4 @@ -{ pkgs }: +{ config, pkgs }: '' " Set internal encoding of vim, not needed on neovim, since coc.nvim using some @@ -8,11 +8,28 @@ " Enable mouse set mouse=a + " notmuch! + let g:notmuch_config_file='${config.xdg.configHome}/notmuch/notmuchrc' + let g:notmuch_folders_count_threads=0 + let g:notmuch_date_format='%y-%m-%d %H:%M' + let g:notmuch_datetime_format='%y-%m-%d %H:%M' + let g:notmuch_show_date_format='%Y/%m/%d %H:%M' + let g:notmuch_search_date_format='%Y/%m/%d %H:%M' + let g:notmuch_html_converter='${pkgs.elinks}/bin/elinks --dump' + + " Line numbers! + set number + " Open NERDTree at start autocmd VimEnter * NERDTree | wincmd p let g:coc_node_path='${pkgs.nodejs}/bin/node' + " idk but this means .swp isn't everywhere + set undodir=$XDG_DATA_HOME/vim/undo + set directory=$XDG_DATA_HOME/vim/swap// + set backupdir=$XDG_DATA_HOME/vim/backup + " TextEdit might fail if hidden is not set. set hidden diff --git a/modules/home/default.nix b/modules/home/default.nix index eae475c3..cc3d5700 100644 --- a/modules/home/default.nix +++ b/modules/home/default.nix @@ -1,7 +1,11 @@ { sources, ... }: { + disabledModules = [ + "programs/vim.nix" + ]; imports = [ + ./vim.nix (sources.tf-nix + "/modules/home/secrets.nix") (sources.arc-nixexprs + "/modules/home/weechat.nix") ]; diff --git a/modules/home/vim.nix b/modules/home/vim.nix new file mode 100644 index 00000000..7fa97f8f --- /dev/null +++ b/modules/home/vim.nix @@ -0,0 +1,180 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.vim; + defaultPlugins = [ pkgs.vimPlugins.vim-sensible ]; + + knownSettings = { + background = types.enum [ "dark" "light" ]; + backupdir = types.listOf types.str; + copyindent = types.bool; + directory = types.listOf types.str; + expandtab = types.bool; + hidden = types.bool; + history = types.int; + ignorecase = types.bool; + modeline = types.bool; + mouse = types.enum [ "n" "v" "i" "c" "h" "a" "r" ]; + mousefocus = types.bool; + mousehide = types.bool; + mousemodel = types.enum [ "extend" "popup" "popup_setpos" ]; + number = types.bool; + relativenumber = types.bool; + shiftwidth = types.int; + smartcase = types.bool; + tabstop = types.int; + undodir = types.listOf types.str; + undofile = types.bool; + }; + + vimSettingsType = types.submodule { + options = let + opt = name: type: + mkOption { + type = types.nullOr type; + default = null; + visible = false; + }; + in mapAttrs opt knownSettings; + }; + + setExpr = name: value: + let + v = if isBool value then + (if value then "" else "no") + name + else + "${name}=${ + if isList value then concatStringsSep "," value else toString value + }"; + in optionalString (value != null) ("set " + v); + + plugins = let + vpkgs = pkgs.vimPlugins; + getPkg = p: + if isDerivation p then + [ p ] + else + optional (isString p && hasAttr p vpkgs) vpkgs.${p}; + in concatMap getPkg cfg.plugins; + +in { + options = { + programs.vim = { + enable = mkEnableOption "Vim"; + + package = mkOption { + type = types.package; + default = pkgs.vim_configurable; + defaultText = literalExample "pkgs.vim_configurable"; + description = "The package to use for the vim binary."; + }; + + finalPackage = mkOption { + type = types.package; + visible = false; + readOnly = true; + description = "Resulting customized vim package."; + }; + + plugins = mkOption { + type = with types; listOf (either str package); + default = defaultPlugins; + example = literalExample "[ pkgs.vimPlugins.YankRing ]"; + description = '' + List of vim plugins to install. To get a list of supported plugins run: + nix-env -f '<nixpkgs>' -qaP -A vimPlugins. + + + + Note: String values are deprecated, please use actual packages. + ''; + }; + + settings = mkOption { + type = vimSettingsType; + default = { }; + example = literalExample '' + { + expandtab = true; + history = 1000; + background = "dark"; + } + ''; + description = '' + At attribute set of Vim settings. The attribute names and + corresponding values must be among the following supported + options. + + + ${concatStringsSep "\n" (mapAttrsToList (n: v: '' + + ${n} + ${v.description} + + '') knownSettings)} + + + See the Vim documentation for detailed descriptions of these + options. Note, use extraConfig to + manually set any options not listed above. + ''; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + example = '' + set nocompatible + set nobackup + ''; + description = "Custom .vimrc lines"; + }; + + }; + }; + + config = (let + customRC = '' + ${concatStringsSep "\n" (filter (v: v != "") (mapAttrsToList setExpr + (builtins.intersectAttrs knownSettings cfg.settings)))} + + ${cfg.extraConfig} + ''; + + vim = cfg.package.customize { + name = "vim"; + vimrcConfig = { + inherit customRC; + + packages.home-manager.start = plugins; + }; + }; + in mkIf cfg.enable { + assertions = let + packagesNotFound = + filter (p: isString p && (!hasAttr p pkgs.vimPlugins)) cfg.plugins; + in [{ + assertion = packagesNotFound == [ ]; + message = "Following VIM plugin not found in pkgs.vimPlugins: ${ + concatMapStringsSep ", " (p: ''"${p}"'') packagesNotFound + }"; + }]; + + warnings = let stringPlugins = filter isString cfg.plugins; + in optional (stringPlugins != [ ]) '' + Specifying VIM plugins using strings is deprecated, found ${ + concatMapStringsSep ", " (p: ''"${p}"'') stringPlugins + } as strings. + ''; + + home.packages = [ cfg.finalPackage ]; + + programs.vim = { + finalPackage = vim; + plugins = defaultPlugins; + }; + }); +} diff --git a/pkgs/default.nix b/pkgs/default.nix index 2c3a8525..740a66ac 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -15,6 +15,8 @@ let clockSupport = true; }; + notmuch = super.callPackage ./notmuch { inherit (super) notmuch; }; + arc = import sources.arc-nixexprs { pkgs = super; }; unstable = import sources.nixpkgs-unstable { inherit (self) config; }; nur = import sources.NUR { diff --git a/pkgs/notmuch/default.nix b/pkgs/notmuch/default.nix new file mode 100644 index 00000000..f4d51f96 --- /dev/null +++ b/pkgs/notmuch/default.nix @@ -0,0 +1,26 @@ +{ lib, notmuch, coreutils }@args: let + notmuch = args.notmuch.super or args.notmuch; + drv = notmuch.override { + withEmacs = false; + }; + in drv.overrideAttrs (old: { + doCheck = false; + + postInstall = '' + ${old.postInstall or ""} + make -C bindings/ruby exec_prefix=$out \ + SHELL=$SHELL \ + $makeFlags ''${makeFlagsArray+"''${makeFlagsArray[@]}"} \ + $installFlags ''${installFlagsArray+"''${installFlagsArray[@]}"} \ + install + mv $out/lib/ruby/vendor_ruby/* $out/lib/ruby/ + rmdir $out/lib/ruby/vendor_ruby + ''; + + meta = old.meta or {} // { + broken = old.meta.broken or false || notmuch.stdenv.isDarwin; + }; + passthru = old.passthru or {} // { + super = notmuch; + }; + })