From c80598d4e4ffea73647b2ea8440a6080596968fe Mon Sep 17 00:00:00 2001 From: Azat Bahawi Date: Mon, 3 Jul 2023 11:27:19 +0300 Subject: 2023-07-03 --- darwinConfigurations/mairon/default.nix | 2 + flake.lock | 83 +++++++++--------- flake.nix | 3 +- modules/common/common/home-manager.nix | 7 +- modules/common/git.nix | 6 +- modules/common/profiles/default.nix | 3 - modules/common/vim/default.nix | 62 +++++++------- modules/common/vim/rc.vim | 140 +++++++------------------------ modules/darwin/default.nix | 1 + modules/darwin/profiles/headful.nix | 9 ++ modules/darwin/vim/default.nix | 26 ++++++ modules/nixos/default.nix | 1 + modules/nixos/ntfy.nix | 9 -- modules/nixos/vim/default.nix | 39 +++++++++ nixosConfigurations/manwe/mailserver.nix | 2 +- 15 files changed, 188 insertions(+), 205 deletions(-) create mode 100644 modules/darwin/vim/default.nix create mode 100644 modules/nixos/vim/default.nix diff --git a/darwinConfigurations/mairon/default.nix b/darwinConfigurations/mairon/default.nix index 6f129ac..27b0895 100644 --- a/darwinConfigurations/mairon/default.nix +++ b/darwinConfigurations/mairon/default.nix @@ -17,9 +17,11 @@ with lib; { homebrew.casks = [ {name = "burp-suite";} {name = "docker";} + {name = "jetbrains-toolbox";} {name = "obs";} {name = "openlens";} {name = "postman";} + {name = "vial";} {name = "wireshark";} {name = "xcodes";} ]; diff --git a/flake.lock b/flake.lock index c6cb238..0c41e9f 100644 --- a/flake.lock +++ b/flake.lock @@ -124,11 +124,11 @@ ] }, "locked": { - "lastModified": 1687110393, - "narHash": "sha256-SnkdWeZ8PZd3Dc74iFF8xiE7qDp5+z3Yps2mE79tsM0=", + "lastModified": 1688307440, + "narHash": "sha256-7PTjbN+/+b799YN7Tk2SS5Vh8A0L3gBo8hmB7Y0VXug=", "owner": "LnL7", "repo": "nix-darwin", - "rev": "8a5af0da9d8dab8a188436750489e304ac682085", + "rev": "b06bab83bdf285ea0ae3c8e145a081eb95959047", "type": "github" }, "original": { @@ -186,11 +186,11 @@ ] }, "locked": { - "lastModified": 1685662779, - "narHash": "sha256-cKDDciXGpMEjP1n6HlzKinN0H+oLmNpgeCTzYnsA2po=", + "lastModified": 1688254665, + "narHash": "sha256-8FHEgBrr7gYNiS/NzCxIO3m4hvtLRW9YY1nYo1ivm3o=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "71fb97f0d875fd4de4994dfb849f2c75e17eb6c3", + "rev": "267149c58a14d15f7f81b4d737308421de9d7152", "type": "github" }, "original": { @@ -222,11 +222,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1687171271, - "narHash": "sha256-BJlq+ozK2B1sJDQXS3tzJM5a+oVZmi1q0FlBK/Xqv7M=", + "lastModified": 1687709756, + "narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=", "owner": "numtide", "repo": "flake-utils", - "rev": "abfb11bd1aec8ced1c9bb9adfe68018230f4fb3c", + "rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7", "type": "github" }, "original": { @@ -264,11 +264,11 @@ ] }, "locked": { - "lastModified": 1687257796, - "narHash": "sha256-jWF0LtG4GczLGLsBvXIGaCX+JvTLfawVLLJPtB5CMW0=", + "lastModified": 1688302761, + "narHash": "sha256-YIYKeX3YfoAIg9DTe6cl1ga87rDCNDZugdGuqsvEN30=", "owner": "nix-community", "repo": "home-manager", - "rev": "e8b5f8f9b3368dcc4814129d6f66c1af7cf3b6e5", + "rev": "c85d9137db45a1c9c161f4718b13cc3bd4cbd173", "type": "github" }, "original": { @@ -323,11 +323,11 @@ ] }, "locked": { - "lastModified": 1687139085, - "narHash": "sha256-iZHeSZ/F9PRl9WI/ZuQ0EiKI2knnIvdUVz/wUGB9MZY=", + "lastModified": 1688349470, + "narHash": "sha256-90tE0wszarJ3hp93SUWmZ0CMXr1MVR4xVHyZobbvzQo=", "owner": "Infinidoge", "repo": "nix-minecraft", - "rev": "b37d37bf2cba6942250e1bbae74d4c4237f9737d", + "rev": "4dcf55d23ca64136877766a1df5056ad2ba5702b", "type": "github" }, "original": { @@ -350,11 +350,11 @@ ] }, "locked": { - "lastModified": 1687224042, - "narHash": "sha256-X28G+05iIBvjJ+wU/5YwwUWdiQ6q/YVz2Teqf6WmH0g=", + "lastModified": 1688348068, + "narHash": "sha256-zfqzsSrJP7C0zgZjIllLb6ZXi5vatDsizFHRL8XJ/Fk=", "owner": "nix-community", "repo": "nix-vscode-extensions", - "rev": "fe3a5d48c128315df763e957eb3c4c4eeea66506", + "rev": "0d3490d9ab18d777a0d20c62f40efabfd6263111", "type": "github" }, "original": { @@ -382,11 +382,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1687245362, - "narHash": "sha256-+f9tH+k3u9lSS136M2LCsl5NJTNPvhmHEiVOcypiu1E=", + "lastModified": 1688221086, + "narHash": "sha256-cdW6qUL71cNWhHCpMPOJjlw0wzSRP0pVlRn2vqX/VVg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "205ee073b053fc4d87d5adf2ebd44ebbef7bca4d", + "rev": "cd99c2b3c9f160cd004318e0697f90bbd5960825", "type": "github" }, "original": { @@ -398,11 +398,11 @@ }, "nixpkgs-master": { "locked": { - "lastModified": 1687281549, - "narHash": "sha256-6kWrEZyPWKXg337zz2l4/m9r26gjaxWYQEATQVSjKek=", + "lastModified": 1688370749, + "narHash": "sha256-4es2tyjkLJL+EDmMTUl/LOtM/ytp+2PH/uGd5CKNeNo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "eafa1fd10d709fb2e5b85865cb475f1c074c33f8", + "rev": "13718e97ec434de08285c72d937a54d3ecf03dc4", "type": "github" }, "original": { @@ -414,11 +414,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1687274842, - "narHash": "sha256-Pb/3StsAVr5ysU/haCU1tcfbq62gLp58wJuPeQwmbvc=", + "lastModified": 1688363206, + "narHash": "sha256-/vGiYeXjgzWCBNbA1JTPU8xpCSwFr3ENZXGtX26Nmkc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "c38961c681b546eb4bedc6ea6e5fb19b012a1612", + "rev": "eaec6e428ea79bf803301d4bc989f1fc2c891fb7", "type": "github" }, "original": { @@ -464,11 +464,11 @@ }, "nur": { "locked": { - "lastModified": 1687273560, - "narHash": "sha256-81S7O06OCoTsHAlpIaD85pgSfvQrYtNvFvKrPYkABOM=", + "lastModified": 1688369118, + "narHash": "sha256-ieJfKcJ/ky19zvyTASYCCmPvXQ6QRF/XY9aWLi5cmkA=", "owner": "nix-community", "repo": "NUR", - "rev": "3f2ed752140508beb4ca8d21ba7b4a1d83df24a7", + "rev": "1fec0607786d389341c0a9e565673b5af595ff6a", "type": "github" }, "original": { @@ -495,16 +495,16 @@ ] }, "locked": { - "lastModified": 1686318133, - "narHash": "sha256-IyoqIt+RNUxvIC1KrGe2d0rB7J78eU0wh/fEaJ80Cew=", + "lastModified": 1687357249, + "narHash": "sha256-8rURFpy6pyYbPEjqw8Q+CR5NBXSE0m7bDJm2Xkiy4zE=", "owner": "fn2006", "repo": "PollyMC", - "rev": "392822ec7aab149e965842f2701d37b1ab643d3b", + "rev": "13b2c15abc8e0416f60e64c1a630edb3dd59325c", "type": "github" }, "original": { "owner": "fn2006", - "ref": "7.0", + "ref": "7.1", "repo": "PollyMC", "type": "github" } @@ -528,11 +528,11 @@ ] }, "locked": { - "lastModified": 1687251716, - "narHash": "sha256-+sFS41thsB5U+lY/dBYPSmU4AJ7nz/VdM1WD35fXVeM=", + "lastModified": 1688137124, + "narHash": "sha256-ramG4s/+A5+t/QG2MplTNPP/lmBWDtbW6ilpwb9sKVo=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "7807e1851d95828ed98491930d2d9e7ddbe65da4", + "rev": "522fd47af79b66cdd04b92618e65c7a11504650a", "type": "github" }, "original": { @@ -584,16 +584,19 @@ "nixpkgs-22_11": [ "nixpkgs-stable" ], + "nixpkgs-23_05": [ + "nixpkgs-stable" + ], "utils": [ "flake-utils" ] }, "locked": { - "lastModified": 1686468558, - "narHash": "sha256-K69Ojlx3N8I6tRTZsrKFMIqK4yrnJ6/PjfKZi3wchYg=", + "lastModified": 1688064897, + "narHash": "sha256-Q3CZc6ZfC4KpjGWVPsrofFgxor+UjqhbFBSi7YmHVvI=", "owner": "simple-nixos-mailserver", "repo": "nixos-mailserver", - "rev": "290d00f6db4e80467013728819ad73dd4a394d9a", + "rev": "0c1801b48995ec6909e040abedaa56a64f0db430", "type": "gitlab" }, "original": { diff --git a/flake.nix b/flake.nix index ece18ad..dd9473e 100644 --- a/flake.nix +++ b/flake.nix @@ -116,7 +116,7 @@ type = "github"; owner = "fn2006"; repo = "PollyMC"; - ref = "7.0"; + ref = "7.1"; inputs = { flake-compat.follows = "flake-compat"; flake-parts.follows = "flake-parts"; @@ -144,6 +144,7 @@ inputs = { flake-compat.follows = "flake-compat"; nixpkgs-22_11.follows = "nixpkgs-stable"; + nixpkgs-23_05.follows = "nixpkgs-stable"; nixpkgs.follows = "nixpkgs"; utils.follows = "flake-utils"; }; diff --git a/modules/common/common/home-manager.nix b/modules/common/common/home-manager.nix index 7fa21f8..44b0eaa 100644 --- a/modules/common/common/home-manager.nix +++ b/modules/common/common/home-manager.nix @@ -1,5 +1,5 @@ { - config, + inputs, lib, localUsername ? lib.my.username, ... @@ -11,7 +11,10 @@ with lib; { hm = { news.display = "silent"; - home = {inherit (config.system) stateVersion;}; + # NOTE Inheriting directly from `system.stateVersion` does not work on MacOS for + # some reason. + home.stateVersion = with builtins; + head (split "\n" (readFile "${inputs.nixpkgs}/.version")); }; home-manager = { diff --git a/modules/common/git.nix b/modules/common/git.nix index ce4e505..0bd7720 100644 --- a/modules/common/git.nix +++ b/modules/common/git.nix @@ -14,7 +14,7 @@ in { config = mkIf cfg.client.enable { secrets = let - # HACK Darwin doesn't support XDG specifications. + # HACK MacOS doesn't support XDG specifications. configHome = "${config.my.home}/.config"; in { glab-cli-config = { @@ -97,8 +97,8 @@ in { wtc = "!${curl} -sq whatthecommit.com/index.txt | ${git} commit -F -"; }; - # All helper tools/editor generated files should go here. This must - # be kept relatively clean and void of any project-specific residual + # All helper tools/editor generated files should go here. This must be + # kept relatively clean and void of any project-specific residual # files. ignores = [ "*~" diff --git a/modules/common/profiles/default.nix b/modules/common/profiles/default.nix index 4f8fa4d..ad5e841 100644 --- a/modules/common/profiles/default.nix +++ b/modules/common/profiles/default.nix @@ -81,10 +81,7 @@ in { time.timeZone = "Europe/Moscow"; environment.systemPackages = with pkgs; [ - ddrescue file - git - gnupg tree ]; }; diff --git a/modules/common/vim/default.nix b/modules/common/vim/default.nix index 2ee8a0b..3755201 100644 --- a/modules/common/vim/default.nix +++ b/modules/common/vim/default.nix @@ -7,43 +7,37 @@ with lib; let cfg = config.nixfiles.modules.vim; in { - options.nixfiles.modules.vim.enable = mkEnableOption "Vim"; + options.nixfiles.modules.vim = { + enable = mkEnableOption "Vim"; + + rc = mkOption { + type = types.str; + default = readFile ./rc.vim; + description = "Configuration file."; + }; + + plugins = mkOption { + type = with types; listOf package; + default = with pkgs.vimPlugins; [ + editorconfig-vim + vim-eunuch + vim-nix + vim-sensible + vim-sleuth + vim-surround + vim-unimpaired + ]; + description = "Plugins."; + }; + }; config = mkIf cfg.enable { - programs.vim.package = with pkgs; - (vim_configurable.override { - features = "normal"; - cscopeSupport = false; - darwinSupport = pkgs.stdenv.isDarwin; - guiSupport = false; - luaSupport = false; - multibyteSupport = false; - netbeansSupport = false; - nlsSupport = false; - perlSupport = false; - pythonSupport = false; - rubySupport = false; - tclSupport = false; - ximSupport = false; - }) - .customize { - name = "vim"; - vimrcConfig = { - customRC = readFile ./rc.vim; - packages.myVimPackage.start = with vimPlugins; [ - editorconfig-vim - vim-eunuch - vim-nix - vim-sleuth - vim-surround - vim-unimpaired - ]; - }; + environment = with config.programs.vim; { + systemPackages = [package]; + variables = rec { + EDITOR = mkOverride 100 "${package}/bin/vim"; + VISUAL = EDITOR; }; - - environment = { - systemPackages = [config.programs.vim.package]; - variables.EDITOR = mkOverride 100 "vim"; }; }; } diff --git a/modules/common/vim/rc.vim b/modules/common/vim/rc.vim index 945643a..3bd9eb7 100644 --- a/modules/common/vim/rc.vim +++ b/modules/common/vim/rc.vim @@ -1,38 +1,31 @@ -set nocompatible - let $VIMFILES = expand(':p:h') let g:skip_defaults_vim = 1 let g:netrw_dirhistmax = 0 -set autoread -set backspace=indent,eol,start +if has('unnamedplus') + set clipboard^=unnamedplus +else + set clipboard^=unnamed +endif -set clipboard=unnamedplus +set backspace=indent,eol,start set diffopt+=iwhite set hidden -set history=256 set lazyredraw set mouse= set path+=** -set tabpagemax=50 set viminfo= set cmdheight=1 -set display+=lastline set fillchars=vert:\ " -set laststatus=2 set modeline set noshowmode -set ruler set shortmess+=I set textwidth=0 set title -set sessionoptions-=options -set viewoptions-=options - set noerrorbells set novisualbell @@ -49,7 +42,6 @@ set completeopt+=longest set gdefault set hlsearch -set incsearch set iskeyword+=- set magic @@ -75,7 +67,6 @@ if v:version >= 700 endif set wildignorecase -set wildmenu set wildignore= set nobackup @@ -97,65 +88,10 @@ set smarttab set softtabstop=4 set tabstop=4 -autocmd BufEnter *.* :set colorcolumn= - -if &t_Co == 8 && $TERM !~# '^Eterm' - set t_Co=16 -endif - -if &listchars ==# 'eol:$' - set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+ -endif +set colorcolumn= +let g:EditorConfig_max_line_indicator = "none" -if v:version > 703 || v:version == 703 && has("patch541") - set formatoptions+=j -endif - -if has('path_extra') - setglobal tags-=./tags tags-=./tags; tags^=./tags; -endif - -if !has('nvim') && &ttimeoutlen == -1 - set ttimeout - set ttimeoutlen=100 -endif - -try - set encoding=utf-8 - scriptencoding utf-8 -catch -endtry - -try - if &fileencodings !~? "utf-8" - let g:added_fenc_utf8 = 1 - set fileencodings+=utf-8 - endif -catch -endtry - -if has('autocmd') - filetype plugin indent on - - if exists("+omnifunc") - autocmd Filetype * - \ if &omnifunc == "" | - \ setlocal omnifunc=syntaxcomplete#Complete | - \ endif - endif - - autocmd BufEnter * set noreadonly -endif - -if has('syntax') && !exists('g:syntax_on') - syntax enable -endif - -if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# '' - runtime! macros/matchit.vim -endif - -nnoremap +nnoremap let mapleader=" " nnoremap :W :w @@ -163,27 +99,27 @@ nnoremap :W! :w! nnoremap :Q :q nnoremap :Q! :q! -nnoremap j v:count ? 'j' : 'gj' -nnoremap k v:count ? 'k' : 'gk' +nnoremap j v:count ? 'j' : 'gj' +nnoremap k v:count ? 'k' : 'gk' nnoremap J gt nnoremap K gT -nnoremap ^h -vnoremap ^h +nnoremap ^h +vnoremap ^h nnoremap H ^h vnoremap H ^h -nnoremap $ -vnoremap $ +nnoremap $ +vnoremap $ nnoremap L $ vnoremap L $ nnoremap N Nzzzv nnoremap n nzzzv -inoremap u -inoremap u +inoremap u +inoremap u vnoremap < >gv @@ -192,24 +128,22 @@ vnoremap >>_ nnoremap <<_ -nnoremap ]b :bnext -nnoremap [b :bprevious +nnoremap ]b :bnext +nnoremap [b :bprevious -nnoremap h -nnoremap j -nnoremap k -nnoremap l +nnoremap h +nnoremap j +nnoremap k +nnoremap l nnoremap * /\<=expand('')\> nnoremap # ?\<=expand('')\> -nnoremap :nohlsearch=has('diff')?'diffupdate':'' - cnoremap ;/ =expand('%:p:h').'/' cnoremap ;; =expand('%:t') cnoremap ;. =expand('%:p:r') -nnoremap . :lcd %:p:h +nnoremap . :lcd %:p:h nnoremap Q @q @@ -225,29 +159,11 @@ nnoremap P "+P inoremap "+pi cnoremap + -nmap w :w! -nmap wq :wq! +nmap w :w! +nmap wq :wq! -nnoremap ZX :qa! +nnoremap ZX :qa! -nnoremap q :q +nnoremap q :q command WS w !sudo tee "%" >/dev/null - -function! SwitchCase() - normal! ~ - if strlen(getline('.')) != virtcol('.') - normal! h - endif -endfunction -nnoremap ~ :call SwitchCase() - -function! s:GM() - execute 'normal! ^' - let first_col = virtcol('.') - execute 'normal! g_' - let last_col = virtcol('.') - execute 'normal! ' . (first_col + last_col) / 2 . '|' -endfunction -nnoremap gm :call GM() -onoremap gm :call GM() diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix index 153c857..6ea9663 100644 --- a/modules/darwin/default.nix +++ b/modules/darwin/default.nix @@ -6,5 +6,6 @@ _: { ./gnupg.nix ./homebrew.nix ./profiles + ./vim ]; } diff --git a/modules/darwin/profiles/headful.nix b/modules/darwin/profiles/headful.nix index 2a4c773..c50c657 100644 --- a/modules/darwin/profiles/headful.nix +++ b/modules/darwin/profiles/headful.nix @@ -1,6 +1,7 @@ { config, lib, + pkgs, ... }: with lib; let @@ -9,6 +10,14 @@ in { config = mkIf cfg.enable { nixfiles.modules.homebrew.enable = true; + hm.home.packages = with pkgs; [ + coreutils + findutils + gnugrep + gnused + gnutar + ]; + homebrew.casks = [ {name = "chromium";} {name = "firefox";} diff --git a/modules/darwin/vim/default.nix b/modules/darwin/vim/default.nix new file mode 100644 index 0000000..519f120 --- /dev/null +++ b/modules/darwin/vim/default.nix @@ -0,0 +1,26 @@ +{ + config, + lib, + pkgs, + ... +}: +with lib; let + cfg = config.nixfiles.modules.vim; +in { + config = mkIf cfg.enable { + programs.vim.package = + (pkgs.macvim.overrideAttrs (_: final: { + # TODO https://github.com/NixOS/nixpkgs/pull/239842 + configureFlags = + final.configureFlags + ++ [ + "--disable-perlinterp" + "--disable-rubyinterp" + ]; + })) + .configure (with cfg; { + customRC = rc; + packages.myVimPackage.start = plugins; + }); + }; +} diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index f8347cf..466e2e0 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -62,6 +62,7 @@ _: { ./throttled.nix ./unbound.nix ./vaultwarden.nix + ./vim ./wireguard.nix ./x11.nix ./xmonad.nix diff --git a/modules/nixos/ntfy.nix b/modules/nixos/ntfy.nix index edbe7e5..1682b7e 100644 --- a/modules/nixos/ntfy.nix +++ b/modules/nixos/ntfy.nix @@ -64,20 +64,11 @@ in { settings = { listen-http = "127.0.0.1:${toString cfg.port}"; base-url = "https://${cfg.domain}"; - cache-file = "/var/cache/ntfy/cache.db"; behind-proxy = true; - attachment-cache-dir = "/var/cache/ntfy/attachments"; - auth-file = "/var/lib/ntfy/user.db"; enable-metrics = cfg.prometheus.enable; metrics-listen-http = with cfg.prometheus; optionalString cfg.prometheus.enable "${address}:${toString port}"; }; }; - - systemd.tmpfiles.rules = with config.services.ntfy-sh; [ - "d /var/lib/ntfy 0700 ${user} ${group} - -" - "d /var/cache/ntfy 0700 ${user} ${group} - -" - "d /var/cache/ntfy/attachments 0700 ${user} ${group} - -" - ]; }; } diff --git a/modules/nixos/vim/default.nix b/modules/nixos/vim/default.nix new file mode 100644 index 0000000..16e2d51 --- /dev/null +++ b/modules/nixos/vim/default.nix @@ -0,0 +1,39 @@ +{ + config, + lib, + pkgs, + this, + ... +}: +with lib; let + cfg = config.nixfiles.modules.vim; +in { + config = mkIf cfg.enable { + programs.vim.package = + (pkgs.vim-full.override { + features = "normal"; + cscopeSupport = false; + darwinSupport = false; + guiSupport = + if this.isHeadful + then "gtk3" + else false; + luaSupport = false; + multibyteSupport = false; + netbeansSupport = false; + nlsSupport = false; + perlSupport = false; + pythonSupport = false; + rubySupport = false; + tclSupport = false; + ximSupport = false; + }) + .customize { + name = "vim"; + vimrcConfig = with cfg; { + customRC = rc; + packages.myVimPackage.start = plugins; + }; + }; + }; +} diff --git a/nixosConfigurations/manwe/mailserver.nix b/nixosConfigurations/manwe/mailserver.nix index acd625b..e87e34b 100644 --- a/nixosConfigurations/manwe/mailserver.nix +++ b/nixosConfigurations/manwe/mailserver.nix @@ -58,7 +58,7 @@ with lib; { localDnsResolver = false; - certificateScheme = 1; + certificateScheme = "manual"; certificateFile = "${cert.directory}/fullchain.pem"; keyFile = "${cert.directory}/key.pem"; -- cgit 1.4.1