~kaction/config

8f1bb4676697797e338f3c5721a4915561475038 — Dmitry Bogatov 2 years ago 148d52f + e050b86 master
Merge branch 'feature/configure-email'
213 files changed, 1115 insertions(+), 1583 deletions(-)

R universe/git/gitconfig.in => .config/git/config
R universe/githooks/post-commit/git-bug.sh => .config/git/hooks/post-commit
R universe/git/gitignore => .config/git/ignore
R universe/mpop/mpop.conf => .config/mpop/config
R universe/neovim/boot/after/ftplugin/c.vim => .config/nvim/after/ftplugin/c.vim
R universe/neovim/boot/after/ftplugin/debchangelog.vim => .config/nvim/after/ftplugin/debchangelog.vim
R universe/neovim/boot/after/ftplugin/dhall.vim => .config/nvim/after/ftplugin/dhall.vim
R universe/neovim/boot/after/ftplugin/execline.vim => .config/nvim/after/ftplugin/execline.vim
R universe/neovim/boot/after/ftplugin/gitcommit.vim => .config/nvim/after/ftplugin/gitcommit.vim
R universe/neovim/boot/after/ftplugin/gmi.vim => .config/nvim/after/ftplugin/gmi.vim
R universe/neovim/boot/after/ftplugin/haskell.vim => .config/nvim/after/ftplugin/haskell.vim
R universe/neovim/boot/after/ftplugin/html.vim => .config/nvim/after/ftplugin/html.vim
R universe/neovim/boot/after/ftplugin/lua.vim => .config/nvim/after/ftplugin/lua.vim
R universe/neovim/boot/after/ftplugin/purescript.vim => .config/nvim/after/ftplugin/plaintex.vim
R universe/neovim/boot/after/syntax/sql.vim => .config/nvim/after/ftplugin/purescript.vim
R universe/neovim/boot/after/ftplugin/python.vim => .config/nvim/after/ftplugin/python.vim
R universe/neovim/boot/after/ftplugin/sh.vim => .config/nvim/after/ftplugin/sh.vim
R universe/neovim/boot/after/ftplugin/vim.vim => .config/nvim/after/ftplugin/vim.vim
R universe/neovim/boot/after/ftplugin/yaml.vim => .config/nvim/after/ftplugin/yaml.vim
R universe/neovim/boot/after/syntax/execline.vim => .config/nvim/after/syntax/execline.vim
R universe/neovim/boot/after/syntax/gitcommit.vim => .config/nvim/after/syntax/gitcommit.vim
R universe/neovim/boot/after/syntax/sh.vim => .config/nvim/after/syntax/sh.vim
R universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/purescript.vim => .config/nvim/after/syntax/sql.vim
R universe/neovim/init.vim => .config/nvim/init.vim
R universe/neovim/boot/lua/boot.lua => .config/nvim/lua/boot.lua
A .config/nvim/lua/boot/snippets/haskell.lua
A .config/tig/config
A .gitignore
R universe/uenv/inputrc => .inputrc
A .mitmproxy/mitmproxy-ca.pem
R universe/mutt/muttrc => .muttrc
R universe/newsboat/urls.txt => .newsboat/urls
A .rcrc
R universe/w3m/w3m.conf => .w3m/config
A bin/.gitignore
A bin/ask
A bin/gist-buildlog
A bin/git-logp
A bin/issue-stdin
A bin/nix-edit
A bin/open
A bin/reformat-lua
A bin/sh
A envdir/.gitignore
A envdir/BROWSER
A envdir/EDITOR
A envdir/EMAIL
A envdir/GITHUB_PROTOCOL
A envdir/GITHUB_USER
A envdir/LANG
A envdir/LESS
A envdir/NNN_OPENER
A envdir/PAGER
A envdir/REALNAME
A envdir/SURFRAW_browser
A envdir/TZ
D flake.lock
A flake/.gitignore
R flake.nix => flake/default.nix
A flake/nix/sources.json
A flake/nix/sources.nix
A flake/universe/Documentation/default.nix
R universe/Documentation/doc-autoconf.nix => flake/universe/Documentation/doc-autoconf.nix
R universe/Documentation/doc-laminar.nix => flake/universe/Documentation/doc-laminar.nix
R universe/Documentation/doc-m4.nix => flake/universe/Documentation/doc-m4.nix
R universe/Documentation/doc-nginx.nix => flake/universe/Documentation/doc-nginx.nix
R universe/Documentation/doc-nixpkgs.nix => flake/universe/Documentation/doc-nixpkgs.nix
R universe/Documentation/doc-posix.nix => flake/universe/Documentation/doc-posix.nix
A flake/universe/Documentation/doc-terraform-aws.nix
A flake/universe/Documentation/doc-terraform.nix
R universe/Documentation/patches/nginx.org-1.patch => flake/universe/Documentation/patches/nginx.org-1.patch
R universe/attach-shell/default.nix => flake/universe/attach-shell/default.nix
R universe/blurdate/blurdate.c => flake/universe/blurdate/blurdate.c
R universe/blurdate/default.nix => flake/universe/blurdate/default.nix
R universe/default.nix => flake/universe/default.nix
R universe/doas/default.nix => flake/universe/doas/default.nix
R universe/dvtm/default.nix => flake/universe/dvtm/default.nix
R universe/dvtm/patches/fix-spelling-errors.patch => flake/universe/dvtm/patches/fix-spelling-errors.patch
R universe/dvtm/patches/highlight-selected-tag.patch => flake/universe/dvtm/patches/highlight-selected-tag.patch
R universe/dvtm/patches/increase-number-of-tags-to-9.patch => flake/universe/dvtm/patches/increase-number-of-tags-to-9.patch
R universe/dvtm/patches/patch-do-not-install-terminal-descriptio.patch => flake/universe/dvtm/patches/patch-do-not-install-terminal-descriptio.patch
R universe/dvtm/patches/restore-signal-handlers.patch => flake/universe/dvtm/patches/restore-signal-handlers.patch
R universe/dvtm/patches/support-nowrap.patch => flake/universe/dvtm/patches/support-nowrap.patch
R universe/fasm-arch/Makefile => flake/universe/fasm-arch/Makefile
R universe/fasm-arch/constants.txt => flake/universe/fasm-arch/constants.txt
R universe/fasm-arch/default.nix => flake/universe/fasm-arch/default.nix
R universe/fasm-arch/install.sh => flake/universe/fasm-arch/install.sh
R universe/fasm-arch/stage1.c => flake/universe/fasm-arch/stage1.c
R universe/fasm-arch/stage2.c => flake/universe/fasm-arch/stage2.c
R universe/firewall/.gitignore => flake/universe/firewall/.gitignore
R universe/firewall/Tupfile => flake/universe/firewall/Tupfile
R universe/firewall/Tupfile.ini => flake/universe/firewall/Tupfile.ini
R universe/firewall/default.nix => flake/universe/firewall/default.nix
R universe/firewall/ifdown.ferm => flake/universe/firewall/ifdown.ferm
R universe/firewall/ifup.ferm => flake/universe/firewall/ifup.ferm
R universe/git-merge-pr/default.nix => flake/universe/git-merge-pr/default.nix
R universe/git-recall/default.nix => flake/universe/git-recall/default.nix
R universe/git-recall/foreign.txt => flake/universe/git-recall/foreign.txt
R universe/htop/default.nix => flake/universe/htop/default.nix
R universe/htop/htop.exec => flake/universe/htop/htop.exec
R universe/htop/htoprc => flake/universe/htop/htoprc
R universe/mk-runscript/default.nix => flake/universe/mk-runscript/default.nix
R universe/mk-runscript/mk-runscript.hs => flake/universe/mk-runscript/mk-runscript.hs
R universe/mk-runscript/templates/logscript.mustache => flake/universe/mk-runscript/templates/logscript.mustache
R universe/msmtp/default.nix => flake/universe/msmtp/default.nix
R universe/msmtp/generator.py => flake/universe/msmtp/generator.py
R universe/msmtp/wrapper.in => flake/universe/msmtp/wrapper.in
R universe/mutt/default.nix => flake/universe/mutt/default.nix
R universe/neovim/default.nix => flake/universe/neovim/default.nix
A flake/universe/neovim/src/nvim-cmp-git.json
A flake/universe/neovim/src/nvim-luapad.json
A flake/universe/neovim/src/nvim-luasnip.json
R universe/neovim/src/neovim.json => flake/universe/neovim/src/vim-asymptote.json
A flake/universe/neovim/src/vim-autoformat.json
R universe/neovim/src/vim-bookmarks.json => flake/universe/neovim/src/vim-bookmarks.json
R universe/neovim/src/vim-gemini.json => flake/universe/neovim/src/vim-gemini.json
R universe/neovim/src/vim-lspconfig.json => flake/universe/neovim/src/vim-ghcid.json
A flake/universe/neovim/src/vim-mustache.json
R universe/neovim/src/vim-nginx.json => flake/universe/neovim/src/vim-nginx.json
R universe/neovim/src/vim-nnn.json => flake/universe/neovim/src/vim-nnn.json
R universe/neovim/src/vim-pgsql.json => flake/universe/neovim/src/vim-pgsql.json
A flake/universe/neovim/src/vim-rcshell.json
A flake/universe/neovim/src/vim-terraform.json
R universe/neovim/src/vim-timestamp.json => flake/universe/neovim/src/vim-timestamp.json
R universe/neovim/src/vim-vidir.json => flake/universe/neovim/src/vim-vidir.json
R universe/nix/default.nix => flake/universe/nix/default.nix
R universe/nixfmt/default.nix => flake/universe/nixfmt/default.nix
R universe/psql/default.nix => flake/universe/psql/default.nix
R universe/python3/default.nix => flake/universe/python3/default.nix
R universe/python3/overrides.nix => flake/universe/python3/overrides.nix
A flake/universe/rc/default.nix
R universe/rewrite-paths/default.nix => flake/universe/rewrite-paths/default.nix
R universe/scripts/default.nix => flake/universe/scripts/default.nix
R universe/scripts/release.py => flake/universe/scripts/release.py
R universe/selectors/default.nix => flake/universe/selectors/default.nix
R universe/srht-ui/default.nix => flake/universe/srht-ui/default.nix
R universe/surfraw/default.nix => flake/universe/surfraw/default.nix
R universe/tempfile/Makefile => flake/universe/tempfile/Makefile
R universe/tempfile/default.nix => flake/universe/tempfile/default.nix
R universe/tempfile/tempfile.1.scd => flake/universe/tempfile/tempfile.1.scd
R universe/tempfile/tempfile.c => flake/universe/tempfile/tempfile.c
R universe/uenv/default.nix => flake/universe/uenv/default.nix
A flake/universe/uenv/env.conf
R universe/uenv/uenv.exec => flake/universe/uenv/uenv.exec
R universe/vidir/default.nix => flake/universe/vidir/default.nix
R universe/w3m/default.nix => flake/universe/w3m/default.nix
D manifest/.gitattributes
D manifest/.gitignore
D manifest/activate/default.nix
D manifest/default.nix
D manifest/doas.conf
D manifest/hosts/default.nix
D manifest/hosts/internal.txt
D manifest/nix-daemon/openrc.nix
D manifest/nix-daemon/runit.nix
D manifest/nix.conf
D manifest/nsswitch.conf
D manifest/openvpn/.gitignore
D manifest/openvpn/resolv.conf
D manifest/passwd.dhall
D manifest/secret/auth.sh
D manifest/secret/dbx.json
D manifest/secret/foo.txt
D manifest/sysctl.conf
D manifest/xbps.conf
D universe/Documentation/default.nix
D universe/Documentation/doc-dropbox.nix
D universe/Documentation/doc-jsonschema.nix
D universe/Documentation/doc-py-attrs.nix
D universe/Documentation/doc-py-click.nix
D universe/Documentation/doc-python.nix
D universe/Documentation/doc-uwsgi.nix
D universe/Documentation/script.nix
D universe/dbxcli/default.nix
D universe/git-bug/default.nix
D universe/git/builder.bash
D universe/git/default.nix
D universe/githooks/build.py
D universe/githooks/default.nix
D universe/githooks/run-directory.c
D universe/githooks/run-parts.sh
D universe/hub/default.nix
D universe/mpop/default.nix
D universe/newsboat/default.nix
D universe/newsboat/wrapper.exec
D universe/passphrase2pgp/default.nix
D universe/posixrc/default.nix
D universe/posixrc/init.sh
D universe/tig/default.nix
D universe/uenv/env.conf
D universe/vim/default.nix
D universe/vim/src/nnn.vim.json
D universe/vim/src/vim-bookmarks.json
D universe/vim/vim/bin/.keepit
D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/c.vim
D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/debchangelog.vim
D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/dhall.vim
D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/execline.vim
D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/gitcommit.vim
D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/gmi.vim
D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/haskell.vim
D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/html.vim
D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/lua.vim
D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/python.vim
D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/sh.vim
D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/vim.vim
D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/yaml.vim
D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/syntax/execline.vim
D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/syntax/gitcommit.vim
D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/syntax/sh.vim
D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/syntax/sql.vim
D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/autoload/hsymbol.vim
D universe/vim/vim/share/vim/vim82/vimrc
R universe/git/gitconfig.in => .config/git/config +5 -5
@@ 7,7 7,6 @@
[alias]
	log-fetched = log ORIG_HEAD.. --stat --no-merges
	new = !sh -c 'git log $1@{1}..$1@{0} "$@"'
	logp = !@logp@
	co = checkout
	pretend = diff --cached
	stat = !git --no-pager diff --stat


@@ 39,17 38,17 @@
[gc]
	writeCommitGraph = true
[core]
	hooksPath = ~/.config/git/hooks
	commitGraph = true
	autolf = true
	hooksPath = @githooks@
[url "ssh://git@git.sr.ht"]
	pushInsteadOf = https://git.sr.ht
[url "ssh://git@github.com"]
	pushInsteadOf = https://github.com
[pager]
	diff = @perl@/bin/perl @git@/share/git/contrib/diff-highlight/diff-highlight
	show = @perl@/bin/perl @git@/share/git/contrib/diff-highlight/diff-highlight
	log  = @perl@/bin/perl @git@/share/git/contrib/diff-highlight/diff-highlight
	diff = perl ~/.nix-profile/share/git/contrib/diff-highlight/diff-highlight
	show = perl ~/.nix-profile/share/git/contrib/diff-highlight/diff-highlight
	log  = perl ~/.nix-profile/share/git/contrib/diff-highlight/diff-highlight
[include]
	path = ~/.gitconfig.email
	path = ~/.gitconfig.override


@@ 59,6 58,7 @@
	vertical-split = false
[tig "bind"]
	main = R !git revert %(commit)
	main = _ !git tag -f _ %(commit)
[tar "tar.xz"]
	command = xz -c
[tar "tar.gz"]

R universe/githooks/post-commit/git-bug.sh => .config/git/hooks/post-commit +1 -1
@@ 1,4 1,4 @@
#!@shell@
#!/bin/sh
set -eu
process_line() {
	IFS=": ,"

R universe/git/gitignore => .config/git/ignore +0 -0
R universe/mpop/mpop.conf => .config/mpop/config +2 -3
@@ 3,11 3,10 @@ delivery maildir ~/Mail
uidls_file ~/Mail/new/.uidls
received_header off
host pop.migadu.com
@account@
user demigod@kaction.cc
port 995
keep on
tls on
tls_starttls off
tls_trust_file /etc/ssl/certs/ca-certificates.crt
passwordeval cat /dev/shm/kaction/volatile/kaction.cc

passwordeval ask mpop://demigod@kaction.cc

R universe/neovim/boot/after/ftplugin/c.vim => .config/nvim/after/ftplugin/c.vim +0 -0
R universe/neovim/boot/after/ftplugin/debchangelog.vim => .config/nvim/after/ftplugin/debchangelog.vim +0 -0
R universe/neovim/boot/after/ftplugin/dhall.vim => .config/nvim/after/ftplugin/dhall.vim +0 -0
R universe/neovim/boot/after/ftplugin/execline.vim => .config/nvim/after/ftplugin/execline.vim +0 -0
R universe/neovim/boot/after/ftplugin/gitcommit.vim => .config/nvim/after/ftplugin/gitcommit.vim +0 -0
R universe/neovim/boot/after/ftplugin/gmi.vim => .config/nvim/after/ftplugin/gmi.vim +0 -1
@@ 1,5 1,4 @@
set colorcolumn=0
set textwidth=0
set wrap
set wrapmargin=0
set linebreak

R universe/neovim/boot/after/ftplugin/haskell.vim => .config/nvim/after/ftplugin/haskell.vim +0 -0
R universe/neovim/boot/after/ftplugin/html.vim => .config/nvim/after/ftplugin/html.vim +0 -0
R universe/neovim/boot/after/ftplugin/lua.vim => .config/nvim/after/ftplugin/lua.vim +3 -1
@@ 1,3 1,5 @@
setlocal shiftwidth=2
setlocal expandtab
setlocal noexpandtab
setlocal tabstop=2
setlocal softtabstop=2
setlocal equalprg=reformat-lua

R universe/neovim/boot/after/ftplugin/purescript.vim => .config/nvim/after/ftplugin/plaintex.vim +1 -1
@@ 1,3 1,3 @@
set expandtab
set shiftwidth=2
set tabstop=2
set expandtab

R universe/neovim/boot/after/syntax/sql.vim => .config/nvim/after/ftplugin/purescript.vim +0 -0
R universe/neovim/boot/after/ftplugin/python.vim => .config/nvim/after/ftplugin/python.vim +0 -0
R universe/neovim/boot/after/ftplugin/sh.vim => .config/nvim/after/ftplugin/sh.vim +0 -5
@@ 1,7 1,2 @@
setlocal tabstop=4
setlocal shiftwidth=4

if expand("%:t") ==# '.posixrc'
  let &path = printf("%s/prefix/config/posix", expand("%:h"))
  setlocal suffixesadd+=.sh
endif

R universe/neovim/boot/after/ftplugin/vim.vim => .config/nvim/after/ftplugin/vim.vim +0 -0
R universe/neovim/boot/after/ftplugin/yaml.vim => .config/nvim/after/ftplugin/yaml.vim +0 -0
R universe/neovim/boot/after/syntax/execline.vim => .config/nvim/after/syntax/execline.vim +0 -0
R universe/neovim/boot/after/syntax/gitcommit.vim => .config/nvim/after/syntax/gitcommit.vim +0 -0
R universe/neovim/boot/after/syntax/sh.vim => .config/nvim/after/syntax/sh.vim +0 -0
R universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/purescript.vim => .config/nvim/after/syntax/sql.vim +0 -0
R universe/neovim/init.vim => .config/nvim/init.vim +32 -15
@@ 6,11 6,13 @@ set keymap=russian-jcukenwin
set iminsert=0
set imsearch=0

" Having $SHELL=rc in environment drives crazy a lot of plugins, and
" even basic !%par
set shell=/bin/sh
set autoindent
set cmdwinheight=4
" This teaches vim to find files references by Python's pkgutil.get_data
set path+=.;.git
set cindent
set complete+=t "tag completion
set copyindent
set exrc


@@ 19,7 21,7 @@ set foldlevel=0
set foldmethod=marker
set incsearch
set list
set listchars=trail:-,tab:>.
set listchars=tab:→\ ,trail:-
" panic action to prevent cve-2019-12735
set nomodeline
set magic


@@ 32,15 34,16 @@ set smartcase
set wildmenu
set wildmode=list:longest,list:longest
set infercase
set colorcolumn=80
set laststatus=0
set number

" There is no reason for .viminfo file to survive reboot. This way it
" does not clutter ~/.
let &viminfofile = "/dev/shm/" . getenv("USER") . "/.neovim.info"
let g:netrw_home = "/dev/shm/" . getenv("USER")

let g:terraform_align = 1
let g:terraform_fmt_on_save = 1

let g:sql_type_default = 'pgsql'
let g:pgsql_pl = ['python']



@@ 53,12 56,24 @@ let g:timestamp_modelines=8
let g:timestamp_regexp = '\v\c%(Time-stamp:\s+).*'
let g:timestamp_rep='Time-stamp: <%Y-%m-%d %H:%M:%S dbogatov>'

let g:formatdef_indent = '"indent -linux -psl -bad"'
let g:formatdef_yapf = '"yapf"'
let g:formatters_c = ['indent']
let g:formatters_python = ['yapf']
" Otherwise it does stupid things with regard to git-commit buffers.
let g:autoformat_autoindent = 0
let g:autoformat_retab = 0
let g:autoformat_remove_trailing_spaces = 0

map Q gq
tnoremap <C-_><C-_> <C-\><C-N>
imap <silent><expr> <Tab> luasnip#expand_or_jumpable() ? '<Plug>luasnip-expand-or-jump' : '<Tab>' 
inoremap <silent> <S-Tab> <cmd>lua require'luasnip'.jump(-1)<Cr>
noremap j gj
noremap k gk
noremap $ g$
noremap 0 g0
noremap =/ mz1G=G`z
set tags+=../tags,../../tags,../../../tags,../../../../tags

au BufNewFile,BufRead *.asy setf asy


@@ 78,23 93,25 @@ au BufNewFile,BufRead *.exec set filetype=execline
" Used by redo(1) build system.
au BufNewFile,BufRead *.do set filetype=sh
au BufNewFile,BufRead *.fasm setfiletype fasm
au BufNewFile,BufRead,BufWritePost *.gmi set columns=80
au BufNewFile,BufRead */mail/*/[0123456789]* setfiletype mail
au BufNewFile,BufRead syntax sync minlines=200 "slower but more correct highlighting
au BufWritePre * :silent !mkdir -p %:p:h
"au BufWritePre *.nix :Autoformat
"au BufWrite * :silent lua vim.lsp.buf.formatting()

imap <Tab> <Plug>snipMateNextOrTrigger
smap <Tab> <Plug>snipMateNextOrTrigger
vmap <Tab> <Plug>snipMateVisual

imap <S-Tab> <Plug>snipMateBack
smap <S-Tab> <Plug>snipMateBack

imap <C-s> <Plug>snipMateShow
let g:snipMate = { 'snippet_version': 1 }
let g:nnn#action = {
      \ '<c-t>': 'tab split',
      \ '<c-x>': 'split',
      \ '<c-v>': 'vsplit' }
let g:nnn#replace_netrw = 1
colorscheme wombat256
colorscheme delek

" This works, but only as long substitution is not included in region, e.g
" comment or string constant. From my reading of syntax rules documentation,
" it is not possible to change this behaviour without altering code that
" defines region.
aug hightlight_substitution
  au!
  au BufNewFile,BufRead * syntax match Special /\v\@[_a-z]+\@/
  au BufNewFile,BufRead * syntax match Special /\v\@[_A-Z]+\@/
aug END

R universe/neovim/boot/lua/boot.lua => .config/nvim/lua/boot.lua +52 -1
@@ 1,3 1,7 @@
-- Workaround for rafcamlet/nvim-luapad#12
local patched = require 'luapad.tools'
patched.path = function (...) return '/' .. table.concat({...}, '/') end

local M = {}

local lspconfig = require 'lspconfig'


@@ 49,21 53,68 @@ local lsp_on_attach = function(client, bufnr)
  end
end

local function setup_snippets()
  local ls = require("luasnip")
  ls.config.setup {
    updateevents = "TextChanged,TextChangedI"
  }

  ls.snippets.haskell = require("boot.snippets.haskell")
end

local function setup_completion()
	local cmp = require("cmp")
	cmp.setup({
		snippet = {
			expand = function(args)
				require('luasnip').lsp_expand(args.body)
			end,
		},
		mapping = {
			['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
			['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
			['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
			-- Specify `cmp.config.disable` if you want to remove the default `<C-y>`
			-- mapping.
			['<C-y>'] = cmp.config.disable,
			['<C-e>'] = cmp.mapping({
				i = cmp.mapping.abort(),
				c = cmp.mapping.close(),
			}),
			-- Accept currently selected item. Set `select` to `false` to only
			-- confirm explicitly selected items.
			['<CR>'] = cmp.mapping.confirm({ select = true }),
		},
		sources = cmp.config.sources({
			{ name = 'nvim_lsp' },
			{ name = 'luasnip' },
			{ name = 'cmp_git' },
		}, {{ name = 'buffer' }})
	})
	
	require("cmp_git").setup()
end

function M.main()
  opts = { on_attach = lsp_on_attach }

  lspconfig.ccls.setup(opts)
  lspconfig.dhall_lsp_server.setup(opts)
  lspconfig.texlab.setup(opts)
  lspconfig.pyls.setup(opts)
  lspconfig.pylsp.setup(opts)
  lspconfig.gopls.setup(opts)
  lspconfig.hls.setup {
      on_attach = lsp_on_attach,
      root_dir = lspconfig.util.find_git_ancestor
  }
  lspconfig.terraformls.setup(opts)

  vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
    vim.lsp.diagnostic.on_publish_diagnostics, { virtual_text = false })

  vim.g.vimwiki_list = {{path="~/state/vimwiki"}}
  setup_snippets()
  setup_completion()
end

return M

A .config/nvim/lua/boot/snippets/haskell.lua => .config/nvim/lua/boot/snippets/haskell.lua +35 -0
@@ 0,0 1,35 @@
local ls = require("luasnip")
local e = require("luasnip.extras")
local s = ls.snippet
local sn = ls.snippet_node
local isn = ls.indent_snippet_node
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local r = ls.restore_node
local events = require("luasnip.util.events")

local s_import_qualified = s("iq", {
  t("import qualified Data."), e.rep(1), t(" as "), i(1, "Set"),
  t({"", "import Data."}), e.rep(1), t(" ("), e.rep(1), t({")", ""})
})

local s_data = s("data", {
  t("data "), i(1, "Foo"), t(" = "), e.rep(1), t({"", "  {"}), t(" "), i(0),
  t({"", "  }"})
})

local s_mod = s("mod", {
  t("module "), f(function()
    local name = vim.api.nvim_buf_get_name(0)
    local res = {}
    for part in name:gmatch("[^/]+") do
      if part:match("^%u") then table.insert(res, part:match("[^.]+")) end
    end
    return table.concat(res, ".")
  end, {}), t({" where", "", ""})
})

return {s_import_qualified, s_data, s_mod}

A .config/tig/config => .config/tig/config +3 -0
@@ 0,0 1,3 @@
set main-view-date = custom
set main-view-date-format = %Y-%m-%d
set main-view-author-display = abbreviated

A .gitignore => .gitignore +5 -0
@@ 0,0 1,5 @@
*
!.gitignore
!flake
!bin
!envdir/

R universe/uenv/inputrc => .inputrc +0 -0
A .mitmproxy/mitmproxy-ca.pem => .mitmproxy/mitmproxy-ca.pem +1 -0
@@ 0,0 1,1 @@
/etc/mitm.pem
\ No newline at end of file

R universe/mutt/muttrc => .muttrc +0 -0
R universe/newsboat/urls.txt => .newsboat/urls +13 -4
@@ 1,7 1,16 @@
https://sourcehut.org/blog/index.xml
https://drewdevault.com/blog/index.xml
https://joeyh.name/blog/index.rss
https://haskellweekly.news/newsletter.atom
https://fakenous.net?feed=rss2
https://ro-che.info/articles/rss.xml
https://haskellweekly.news/newsletter.atom
https://joeyh.name/blog/index.rss
https://neilmitchell.blogspot.com/feeds/posts/default
https://ro-che.info/articles/rss.xml
https://sourcehut.org/blog/index.xml
https://taylor.fausak.me/sitemap.atom
https://flak.tedunangst.com/rss
https://nullprogram.com/feed/
https://alyssa.is/feed.xml
https://go.dev/blog/feed.atom
https://ldpreload.com/feeds/all.atom.xml
http://habitatchronicles.com/feed/
https://danluu.com/atom.xml
https://adamdrake.com/index.xml

A .rcrc => .rcrc +50 -0
@@ 0,0 1,50 @@
if (~ $__envdir ()) {
	__envdir=1
	path = ($home/scripts $path)
	path = ($home/bin $path)
	path = ($home/data/bin $path)
	path = ($home/go/bin $path)
	path = ($home/.nix-profile/bin $path)
	path = ($home/.nix-profile/bin/override $path)
	path = (/suid $path)
	exec chpst -e $home/envdir rc -l
}
fn Documentation { builtin nnn -c $home/.nix-profile/Documentation $* }
fn HaskellDocumentation {
	# workaround for nixos/nixpkgs#150686
	$BROWSER `{echo $NIX_GHC_DOCDIR|sed 's,/ghc/html,/hoogle/index.html,'}
}

fn nnn { builtin nnn -c $* }
fn vi { builtin nvim $* }
fn vim { builtin nvim $* }
fn today { builtin date +%Y-%m-%d }
fn uuid { builtin cat /proc/sys/kernel/random/uuid }
fn ls { builtin busybox ls --color -lF $* }
fn todo { $EDITOR $home/state/todo/software.diff }
fn with.aws {
	AWS_ACCESS_KEY_ID=`{ ask https://dbogatov@aws.amazon.com/public }      \
	AWS_SECRET_ACCESS_KEY=`{ ask https://dbogatov@aws.amazon.com/private } \
	AWS_DEFAULT_REGION=us-west-2                                           \
	$*
}
fn with.github { GITHUB_TOKEN=`{ask https://kaction@github.com} $* }
fn environ { cached-nix-shell $* --command 'exec rc -l' }

fn aws { with.aws builtin aws $* }
fn terraform { with.aws builtin terraform $* }
fn ssh { TERM=linux with.aws builtin ssh $* }
fn jira {
	JIRA_API_TOKEN=`{ask https://dbogatov@interfacefinancial.atlassian.net} \
	builtin jira $*
}
fn tea {
	GITEA_TOKEN=`{ask https://dbogatov@gitea.west.devifg.com}              \
	builtin tea $*
}
fn gh { with.github builtin gh $* }
fn export { } # makes rc(1) behave like sh(1)

if (! ~ $IN_NIX_SHELL ()) { prompt = ''' ' }
if (test -e $home/.cfg-rc) { . $home/.cfg-rc }
if (test -e $home/.rcrc.override) { . $home/.rcrc.override }

R universe/w3m/w3m.conf => .w3m/config +6 -32
@@ 1,14 1,13 @@
tabstop 8
indent_incr 4
pixel_per_char 7
pixel_per_line 14
frame 0
target_self 0
open_tab_blank 0
open_tab_dl_list 0
display_link 0
display_link_number 0
decode_url 0
decode_url 1
display_lineinfo 0
ext_dirlist 1
dirlist_cmd file:///$LIB/dirlist.cgi


@@ 22,14 21,8 @@ fold_textarea 0
display_ins_del 1
ignore_null_img_alt 1
view_unseenobject 1
display_image 1
display_image 0
pseudo_inlines 1
auto_image 0
max_load_image 4
ext_image_viewer 0
image_scale 100
imgdisplay w3mimgdisplay
image_map_list 1
fold_line 0
show_lnum 0
show_srch_str 1


@@ 42,14 35,11 @@ image_color green
form_color red
mark_color cyan
bg_color terminal
active_style 0
active_style 1
active_color cyan
visited_anchor 0
visited_anchor 1
visited_color magenta
pagerline 10000
use_history 1
history 100
save_hist 1
confirm_qq 1
close_tab_back 0
mark 0


@@ 58,13 48,6 @@ vi_prec_num 0
mark_all_pages 0
wrap_search 0
ignorecase_search 1
use_migemo 1
migemo_command cmigemo -q -d /usr/share/cmigemo/utf-8/migemo-dict
use_mouse 1
reverse_mouse 0
relative_wheel_scroll 0
relative_wheel_scroll_ratio 30
fixed_wheel_scroll_count 5
clear_buffer 1
decode_cte 0
auto_uncompress 0


@@ 77,7 60,7 @@ index_file
mime_types ~/.w3m/mime.types, /etc/mime.types
mailcap ~/.w3m/mailcap, /etc/w3m/mailcap, /etc/mailcap
urimethodmap ~/.w3m/urimethodmap, /etc/w3m/urimethodmap
editor @editor@
editor nvim
mailto_options 1
mailer xdg-open mailto:%s
extbrowser git clone %s


@@ 107,14 90,12 @@ retry_http 1
default_url 1
follow_redirection 10
meta_refresh 0
dns_order 0
nntpserver 
nntpmode 
max_news 50
use_proxy 1
use_proxy 0
http_proxy 
https_proxy 
gopher_proxy 
ftp_proxy 
no_proxy 
noproxy_netaddr 0


@@ 125,13 106,6 @@ ssl_cert_file
ssl_key_file 
ssl_ca_path /etc/ssl/certs
ssl_ca_file 
use_cookie 0
show_cookie 0
accept_cookie 0
accept_bad_cookie 0
cookie_reject_domains 
cookie_accept_domains 
cookie_avoid_wrong_number_of_dots 
display_charset UTF-8
document_charset UTF-8
auto_detect 2

A bin/.gitignore => bin/.gitignore +1 -0
@@ 0,0 1,1 @@
!*

A bin/ask => bin/ask +4 -0
@@ 0,0 1,4 @@
#!/bin/sh -eu
: "${1?no secret name parameter}"
mangled=$(echo "$1" | sed -e 's#://#%#' -e 's#/#!#g')
exec age --decrypt -i ~/.ssh/id_ed25519 ~/state/auth/$mangled

A bin/gist-buildlog => bin/gist-buildlog +28 -0
@@ 0,0 1,28 @@
#!/bin/sh -eu
# Post buildlog of derivation on GitHub Gist, building locally if
# necessary. Print URL of gist generated on stdout. Do not create
# multiple gists for subsequent invocations with same derivation.
readonly cachedir=~/.cache/gist-buildlog

drv=$1
case "$drv" in
(/nix/store/*.drv) : ;;
(*)
	echo 2>&1 "Argument $drv is not path to derivation"
	exit 1
	;;
esac
hash=$(echo $drv | cut -b12-43)

if ! test -f "${cachedir}/${hash}" ; then
	mkdir -p "${cachedir}"
	buildlog() { sed -r -e 's#/nix/store/(..)#/nix/var/log/nix/drvs/\1/#'; }
	log=$(echo "$drv" | buildlog).bz2
	if ! test -f "$log" ; then
		nix-store -r "$drv" --check
	fi
	gist=$(bzcat $log | sed 's/\x1b\[[0-9;]*m//g' \
	                  | gh gist create -p -f buildlog.$hash -)
	echo "$gist" > "${cachedir}/${hash}"
fi
cat "${cachedir}/${hash}"

A bin/git-logp => bin/git-logp +2 -0
@@ 0,0 1,2 @@
#!/bin/sh
git log -p --color=always --decorate=short $@ | less -R -p"^commit [0-9a-f]{40}"

A bin/issue-stdin => bin/issue-stdin +4 -0
@@ 0,0 1,4 @@
#!/bin/sh
title=$(sed 1q)
body=$(cat)
exec gh issue create --title "${title}" --body "${body}" "$@"

A bin/nix-edit => bin/nix-edit +20 -0
@@ 0,0 1,20 @@
#!/bin/sh -eu
# Nix provides convenient "nix edit" command that opens file containing
# definition of specified attribute (package). Unfortunately, it works very
# slow on "espero" box (probably due a i/o activity and hdd drive), so this
# script caches result and opens cached path in editor on subsequent calls.
#
# Cache invalidation is hard problem, and I don't even attempt to solve it.
# Luckily, stuff rarely moves around in nixpkgs.
readonly cachedir=~/.cache/nix-edit
name=$1
cache="${cachedir}/${name}"

if ! test -f "${cache}" ; then
	mkdir -p "${cachedir}"
	if ! EDITOR=echo nix edit ".#${name}" > "${cache}" ; then
		rm -f "${cache}"
		exit 1
	fi
fi
exec $EDITOR "$(cat "${cache}")"

A bin/open => bin/open +10 -0
@@ 0,0 1,10 @@
#!/bin/sh
set -eu
: ${BROWSER:=w3m}
: ${EDITOR:=vi}

path=$(readlink -f "$1")
case $1 in
(*.html) exec $BROWSER "$path" ;;
(*) exec $EDITOR "$path" ;;
esac

A bin/reformat-lua => bin/reformat-lua +11 -0
@@ 0,0 1,11 @@
#!/usr/bin/execlineb -WS0
lua-format --column-limit=79
           --indent-width=1
           --no-keep-simple-control-block-one-line
           --keep-simple-function-one-line
           --align-table-field
           --extra-sep-at-table-end
           --single-quote-to-double-quote
           --use-tab
           --tab-width=1
           $@

A bin/sh => bin/sh +3 -0
@@ 0,0 1,3 @@
#!/bin/sh
test $# != 0 && exec /bin/sh "$@"
exec ~/.nix-profile/bin/rc -l "$@"

A envdir/.gitignore => envdir/.gitignore +1 -0
@@ 0,0 1,1 @@
!*

A envdir/BROWSER => envdir/BROWSER +1 -0
@@ 0,0 1,1 @@
w3m

A envdir/EDITOR => envdir/EDITOR +1 -0
@@ 0,0 1,1 @@
nvim

A envdir/EMAIL => envdir/EMAIL +1 -0
@@ 0,0 1,1 @@
pgp#v1@kaction.cc

A envdir/GITHUB_PROTOCOL => envdir/GITHUB_PROTOCOL +1 -0
@@ 0,0 1,1 @@
https

A envdir/GITHUB_USER => envdir/GITHUB_USER +1 -0
@@ 0,0 1,1 @@
kaction

A envdir/LANG => envdir/LANG +1 -0
@@ 0,0 1,1 @@
C.UTF-8

A envdir/LESS => envdir/LESS +1 -0
@@ 0,0 1,1 @@
-RS

A envdir/NNN_OPENER => envdir/NNN_OPENER +1 -0
@@ 0,0 1,1 @@
open

A envdir/PAGER => envdir/PAGER +1 -0
@@ 0,0 1,1 @@
less

A envdir/REALNAME => envdir/REALNAME +1 -0
@@ 0,0 1,1 @@
Dmitry Bogatov

A envdir/SURFRAW_browser => envdir/SURFRAW_browser +1 -0
@@ 0,0 1,1 @@
w3m

A envdir/TZ => envdir/TZ +1 -0
@@ 0,0 1,1 @@
UTC+4

D flake.lock => flake.lock +0 -95
@@ 1,95 0,0 @@
{
  "nodes": {
    "mk-passwd": {
      "inputs": {
        "nixpkgs": "nixpkgs"
      },
      "locked": {
        "lastModified": 1613779200,
        "narHash": "sha256-3Z3BtREqllENy6kNF8gNxtiQu3idI3D01VKA9tgjBDU=",
        "ref": "master",
        "rev": "d39cad8c36acf882b05be1a392499817b97af074",
        "revCount": 18,
        "type": "git",
        "url": "https://git.sr.ht/~kaction/mk-passwd?tag=0.1.1"
      },
      "original": {
        "type": "git",
        "url": "https://git.sr.ht/~kaction/mk-passwd?tag=0.1.1"
      }
    },
    "nix-sys": {
      "inputs": {
        "nixpkgs": "nixpkgs_2"
      },
      "locked": {
        "lastModified": 1615248000,
        "narHash": "sha256-xNHTlWIjG5jXNzUhQHiWnhcfaUF9hB9bz6sAlbWE/n4=",
        "ref": "master",
        "rev": "0a6caa99b8a47c99bdbccd96155e5ba85072009c",
        "revCount": 8,
        "type": "git",
        "url": "https://git.sr.ht/~kaction/nix-sys"
      },
      "original": {
        "rev": "0a6caa99b8a47c99bdbccd96155e5ba85072009c",
        "type": "git",
        "url": "https://git.sr.ht/~kaction/nix-sys"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1612914251,
        "narHash": "sha256-Zt9j4kaWA9Hfrna4lOIjmO4Gq95NTJlRg/giE5RpVw4=",
        "ref": "master",
        "rev": "8d7a505faf9976a80551c20159abc729caea189d",
        "revCount": 269186,
        "type": "git",
        "url": "https://github.com/nixos/nixpkgs?tag=20.09"
      },
      "original": {
        "type": "git",
        "url": "https://github.com/nixos/nixpkgs?tag=20.09"
      }
    },
    "nixpkgs_2": {
      "locked": {
        "lastModified": 1612914251,
        "narHash": "sha256-Zt9j4kaWA9Hfrna4lOIjmO4Gq95NTJlRg/giE5RpVw4=",
        "ref": "master",
        "rev": "8d7a505faf9976a80551c20159abc729caea189d",
        "revCount": 269186,
        "type": "git",
        "url": "https://github.com/nixos/nixpkgs?tag=20.09"
      },
      "original": {
        "type": "git",
        "url": "https://github.com/nixos/nixpkgs?tag=20.09"
      }
    },
    "nixpkgs_3": {
      "locked": {
        "lastModified": 1612057845,
        "narHash": "sha256-FslNuG72XCR+Sbxl0jgw71ccSgdLm2iTVI7h/LtUDM0=",
        "ref": "master",
        "rev": "3682b2d9affc30f1fa02028ed8e8cfae88ef5cc2",
        "revCount": 267091,
        "type": "git",
        "url": "https://github.com/nixos/nixpkgs?tag=20.09"
      },
      "original": {
        "type": "git",
        "url": "https://github.com/nixos/nixpkgs?tag=20.09"
      }
    },
    "root": {
      "inputs": {
        "mk-passwd": "mk-passwd",
        "nix-sys": "nix-sys",
        "nixpkgs": "nixpkgs_3"
      }
    }
  },
  "root": "root",
  "version": 7
}

A flake/.gitignore => flake/.gitignore +3 -0
@@ 0,0 1,3 @@
!*
result
result-*

R flake.nix => flake/default.nix +72 -107
@@ 1,117 1,82 @@
# On supported architectures
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
# Some code is written in amd64 assembler, so we hard-code arch. I do
# not have access to any non-amd64 device, even virtual one, so fine for
# me. Maybe I will regret it, who knows?
{
  description = "Personal flake of ~kaction";
  inputs.nixpkgs.url = "git+https://github.com/nixos/nixpkgs?tag=20.09";
  inputs.mk-passwd.url = "git+https://git.sr.ht/~kaction/mk-passwd?tag=0.1.1";
  inputs.nix-sys.url = "git+https://git.sr.ht/~kaction/nix-sys?rev=0a6caa99b8a47c99bdbccd96155e5ba85072009c";
  outputs = { self, nixpkgs, mk-passwd, nix-sys }:
    let
      system = "x86_64-linux"; # See note [On supported architectures]
      pkgs = import nixpkgs { inherit system; };
{ sources ? import ./nix/sources.nix # set
, nixpkgs ? sources.nixpkgs # path
, pkgs ? import nixpkgs { } # set. only {pkgs} is used below
}:

let
  nixfmt-src = pkgs.fetchgit {
    url = "https://git.sr.ht/~kaction/nixfmt";
    rev = "0b072798453ee1edfd15a37c9c55d2e9dbb1666b";
    sha256 = "1iwc91gx6s22dr1ivhvxllm8dnvdxhbf9sm2daxga1izhxm3bcvj";
  };

  # Set of packages provided by nixpkgs with all atrribute names
  # prefixed with "pristine-". Makes writing derivations that need
  # access to both new and pristine version of dependency (for raw
  # rewriting, for example) much more uniform.

      # Set of packages provided by nixpkgs with all atrribute names
      # prefixed with "pristine-". Makes writing derivations that need
      # access to both new and pristine version of dependency (for raw
      # rewriting, for example) much more uniform.
  pristine = let
    inherit (pkgs.lib) nameValuePair mapAttrs';
    f = name: value: nameValuePair "pristine-${name}" value;
  in mapAttrs' f pkgs;

  layer = pkgs.lib.makeScope pkgs.newScope (self':
    let
      inherit (self') callPackage;
      call = f: callPackage f { };
      do-rebuild = packages: path: rec {
        name = builtins.baseNameOf path;
        value = callPackage path { "${name}" = packages."${name}"; };
      };

      pristine = let
        inherit (pkgs.lib) nameValuePair mapAttrs';
        f = name: value: nameValuePair "pristine-${name}" value;
      in mapAttrs' f pkgs;
    in {
      # This incantaion creates something like overlay: new definitions
      # override values from nixpkgs and used to build dependencies.
      #
      # Unlike overlay (e.g import nixpkgs { overlays = [...]; }) it
      # allows caching of nixpkgs, significantly increasing speed of
      # builds. [https://todo.sr.ht/~kaction/config/1]
      #
      # Also, it allows simple access to pristine versions of packages
      # from nixpkgs.
      packages."${system}" = pkgs.lib.makeScope pkgs.newScope (self':
        let
          inherit (self') callPackage;
          call = f: callPackage f { };
          do-rebuild = packages: path: rec {
            name = builtins.baseNameOf path;
            value = callPackage path { "${name}" = packages."${name}"; };
          };
      # In order of increasing preference and decreasing upstream
      # support. Sigh.
      rebuildGlibc = do-rebuild pkgs;
      rebuildMusl = do-rebuild pkgs.pkgsMusl;
      rebuildStatic = do-rebuild pkgs.pkgsStatic;

          # In order of increasing preference and decreasing upstream
          # support. Sigh.
          rebuildGlibc = do-rebuild pkgs;
          rebuildMusl = do-rebuild pkgs.pkgsMusl;
          rebuildStatic = do-rebuild pkgs.pkgsStatic;
      rebuilded = builtins.listToAttrs (map rebuildGlibc [
        ./universe/msmtp
        ./universe/python3
        ./universe/surfraw
        ./universe/w3m
        ./universe/doas
        ./universe/mutt
      ]);

          rebuilded = builtins.listToAttrs (map rebuildGlibc [
            ./universe/mpop
            ./universe/msmtp
            ./universe/newsboat
            ./universe/python3
            ./universe/surfraw
            ./universe/w3m
            ./universe/doas
            ./universe/mutt
            ./universe/hub
            ./universe/vim
          ]);
    in pkgs // pristine // rebuilded // { # nixfmt: sort

        in pkgs // pristine // rebuilded // { # nixfmt: sort
          inherit (pkgs.pkgsStatic) execline;
          inherit system;
          Documentation =
            callPackage ./universe/Documentation { inherit nixpkgs; };
          attach-shell = call ./universe/attach-shell;
          blurdate = callPackage ./universe/blurdate { };
          dbxcli = callPackage ./universe/dbxcli { };
          neovim = callPackage ./universe/neovim { };
          dvtm =
            import ./universe/dvtm { inherit (pkgs.pkgsStatic) dvtm-unstable; };
          fasm-arch = call ./universe/fasm-arch;
          firewall = call ./universe/firewall;
      Documentation = callPackage ./universe/Documentation { inherit nixpkgs; };

          git = callPackage ./universe/git {
            # Imperfect, but compatible with old overlay-based code.
            git = pkgs.git.override { inherit (self') openssh curl; };
          };
          git-bug = callPackage ./universe/git-bug {
            inherit (pkgs.gitAndTools) git-bug;
          };
          git-recall = call ./universe/git-recall;
          git-merge-pr = call ./universe/git-merge-pr;
          githooks = call ./universe/githooks;
      attach-shell = call ./universe/attach-shell;
      blurdate = callPackage ./universe/blurdate { };
      dvtm =
        import ./universe/dvtm { inherit (pkgs.pkgsStatic) dvtm-unstable; };
      fasm-arch = call ./universe/fasm-arch;
      firewall = call ./universe/firewall;
      git-merge-pr = call ./universe/git-merge-pr;

          mk-runscript = call ./universe/mk-runscript;
      git-recall = call ./universe/git-recall;

          nix = pkgs.nixFlakes;
          psql = pkgs.postgresql_10;
          rewrite-paths =
            { drv, rules ? [ ], buildInputs ? [ ], postBuild ? "" }:
            callPackage ./universe/rewrite-paths {
              inherit drv rules buildInputs postBuild;
            };
          srht-ui = call ./universe/srht-ui;
          selectors = call ./universe/selectors;
          scripts = call ./universe/scripts;
          git-crypt = pkgs.git-crypt.override { inherit (self') git; };
      mk-runscript = call ./universe/mk-runscript;
      neovim-custom = callPackage ./universe/neovim { };

          passphrase2pgp = call ./universe/passphrase2pgp;
          posixrc = callPackage ./universe/posixrc { };
          mk-passwd = mk-passwd.defaultPackage.${system};
          manifest = callPackage ./manifest { };
          system-wide = nix-sys.defaultPackage.${system}.overrideAttrs (_: {
            inherit (self') manifest;
          });
          tempfile = pkgs.pkgsStatic.callPackage ./universe/tempfile { };
          vidir = callPackage ./universe/vidir { };
          uenv = call ./universe/uenv;
          universe = import ./universe { pkgs = self.packages."${system}"; };
        });
      nixfmt = with pkgs.haskell;
        lib.doJailbreak (packages.ghc884.callCabal2nix "nixfmt" nixfmt-src { });

      defaultPackage."${system}" = self.packages."${system}".universe;
    };
}
      psql = pkgs.postgresql_10;
      rc = callPackage ./universe/rc { inherit (pkgs.pkgsStatic) rc; };
      rewrite-paths = { drv, rules ? [ ], buildInputs ? [ ], postBuild ? "" }:
        callPackage ./universe/rewrite-paths {
          inherit drv rules buildInputs postBuild;
        };
      scripts = call ./universe/scripts;
      selectors = call ./universe/selectors;
      srht-ui = call ./universe/srht-ui;
      tempfile = pkgs.pkgsStatic.callPackage ./universe/tempfile { };
      uenv = call ./universe/uenv;
      universe = import ./universe { pkgs = layer; };
      vidir = callPackage ./universe/vidir { };
      inherit (pkgs.pkgsStatic) execline;
    });
in layer.universe // { inherit pkgs; }

A flake/nix/sources.json => flake/nix/sources.json +26 -0
@@ 0,0 1,26 @@
{
    "niv": {
        "branch": "master",
        "description": "Easy dependency management for Nix projects",
        "homepage": "https://github.com/nmattia/niv",
        "owner": "nmattia",
        "repo": "niv",
        "rev": "5830a4dd348d77e39a0f3c4c762ff2663b602d4c",
        "sha256": "1d3lsrqvci4qz2hwjrcnd8h5vfkg8aypq3sjd4g3izbc8frwz5sm",
        "type": "tarball",
        "url": "https://github.com/nmattia/niv/archive/5830a4dd348d77e39a0f3c4c762ff2663b602d4c.tar.gz",
        "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
    },
    "nixpkgs": {
        "branch": "master",
        "description": "Nix Packages collection",
        "homepage": "",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "87a43a4b2212bbf071a20a11b61f030a12f3ab4c",
        "sha256": "19hssmrynf5rqcak9bwxapfwy41lrrmv2kzjn7zflb0sn50z68np",
        "type": "tarball",
        "url": "https://github.com/NixOS/nixpkgs/archive/87a43a4b2212bbf071a20a11b61f030a12f3ab4c.tar.gz",
        "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
    }
}

A flake/nix/sources.nix => flake/nix/sources.nix +174 -0
@@ 0,0 1,174 @@
# This file has been generated by Niv.

let

  #
  # The fetchers. fetch_<type> fetches specs of type <type>.
  #

  fetch_file = pkgs: name: spec:
    let
      name' = sanitizeName name + "-src";
    in
      if spec.builtin or true then
        builtins_fetchurl { inherit (spec) url sha256; name = name'; }
      else
        pkgs.fetchurl { inherit (spec) url sha256; name = name'; };

  fetch_tarball = pkgs: name: spec:
    let
      name' = sanitizeName name + "-src";
    in
      if spec.builtin or true then
        builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
      else
        pkgs.fetchzip { name = name'; inherit (spec) url sha256; };

  fetch_git = name: spec:
    let
      ref =
        if spec ? ref then spec.ref else
          if spec ? branch then "refs/heads/${spec.branch}" else
            if spec ? tag then "refs/tags/${spec.tag}" else
              abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
    in
      builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; };

  fetch_local = spec: spec.path;

  fetch_builtin-tarball = name: throw
    ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
        $ niv modify ${name} -a type=tarball -a builtin=true'';

  fetch_builtin-url = name: throw
    ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
        $ niv modify ${name} -a type=file -a builtin=true'';

  #
  # Various helpers
  #

  # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
  sanitizeName = name:
    (
      concatMapStrings (s: if builtins.isList s then "-" else s)
        (
          builtins.split "[^[:alnum:]+._?=-]+"
            ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
        )
    );

  # The set of packages used when specs are fetched using non-builtins.
  mkPkgs = sources: system:
    let
      sourcesNixpkgs =
        import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
      hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
      hasThisAsNixpkgsPath = <nixpkgs> == ./.;
    in
      if builtins.hasAttr "nixpkgs" sources
      then sourcesNixpkgs
      else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
        import <nixpkgs> {}
      else
        abort
          ''
            Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
            add a package called "nixpkgs" to your sources.json.
          '';

  # The actual fetching function.
  fetch = pkgs: name: spec:

    if ! builtins.hasAttr "type" spec then
      abort "ERROR: niv spec ${name} does not have a 'type' attribute"
    else if spec.type == "file" then fetch_file pkgs name spec
    else if spec.type == "tarball" then fetch_tarball pkgs name spec
    else if spec.type == "git" then fetch_git name spec
    else if spec.type == "local" then fetch_local spec
    else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
    else if spec.type == "builtin-url" then fetch_builtin-url name
    else
      abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";

  # If the environment variable NIV_OVERRIDE_${name} is set, then use
  # the path directly as opposed to the fetched source.
  replace = name: drv:
    let
      saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
      ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
    in
      if ersatz == "" then drv else
        # this turns the string into an actual Nix path (for both absolute and
        # relative paths)
        if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";

  # Ports of functions for older nix versions

  # a Nix version of mapAttrs if the built-in doesn't exist
  mapAttrs = builtins.mapAttrs or (
    f: set: with builtins;
    listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
  );

  # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
  range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1);

  # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
  stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));

  # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
  stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
  concatMapStrings = f: list: concatStrings (map f list);
  concatStrings = builtins.concatStringsSep "";

  # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
  optionalAttrs = cond: as: if cond then as else {};

  # fetchTarball version that is compatible between all the versions of Nix
  builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
    let
      inherit (builtins) lessThan nixVersion fetchTarball;
    in
      if lessThan nixVersion "1.12" then
        fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
      else
        fetchTarball attrs;

  # fetchurl version that is compatible between all the versions of Nix
  builtins_fetchurl = { url, name ? null, sha256 }@attrs:
    let
      inherit (builtins) lessThan nixVersion fetchurl;
    in
      if lessThan nixVersion "1.12" then
        fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
      else
        fetchurl attrs;

  # Create the final "sources" from the config
  mkSources = config:
    mapAttrs (
      name: spec:
        if builtins.hasAttr "outPath" spec
        then abort
          "The values in sources.json should not have an 'outPath' attribute"
        else
          spec // { outPath = replace name (fetch config.pkgs name spec); }
    ) config.sources;

  # The "config" used by the fetchers
  mkConfig =
    { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
    , sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
    , system ? builtins.currentSystem
    , pkgs ? mkPkgs sources system
    }: rec {
      # The sources, i.e. the attribute set of spec name to spec
      inherit sources;

      # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
      inherit pkgs;
    };

in
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }

A flake/universe/Documentation/default.nix => flake/universe/Documentation/default.nix +149 -0
@@ 0,0 1,149 @@
{ nix, stdenv, python3, nixpkgs, postgresql_10, ghc, execline, bash, fasm
, runCommand, mutt, haskellPackages, callPackage, zsh, fetchgit }:
let
  buildSphinx = { src, buildInputs ? [ ], subdir ? "docs" }:
    stdenv.mkDerivation {
      inherit src subdir;
      phases = [ "unpackPhase" "installPhase" ];
      nativeBuildInputs = buildInputs ++ (with python3.pkgs; [ sphinx ]);

      name = "sphinx-html";
      installPhase = ''
        (
          cd $subdir
          if ! test -f conf.py ; then
            echo "conf.py is not found in $subdir"
            exit 1
          fi

          echo 'html_sidebars = {"**": []}' >> conf.py
          echo 'html_use_index = False' >> conf.py
          sphinx-build -b html . $out
        )
      '';
    };

  doc-nginx = callPackage ./doc-nginx.nix { };
  doc-nixpkgs = callPackage ./doc-nixpkgs.nix { inherit nixpkgs; };
  doc-posix = callPackage ./doc-posix.nix { };

  #   env.python.attr = buildSphinx {
  #     inherit (python3.pkgs.attrs) src;
  #     buildInputs = with python3.pkgs; [ attrs sphinx-furo ];
  #   };

  env.python.dropbox = buildSphinx {
    src = fetchgit {
      url = "https://github.com/dropbox/dropbox-sdk-python";
      rev = "fdd342befa002c79d7eefc6e75fc8a93f2ec4c15";
      sha256 = "sha256-JWFVVHvDkGTLYxmT9m54gd6OAw6WtnsbYWTGgjSj95o=";
    };
  };

  env.python.psycopg2 = buildSphinx {
    inherit (python3.pkgs.psycopg2) src;
    subdir = "doc/src";
    buildInputs = with python3.pkgs; [ sphinx-better ];
  };

  env.python.click = buildSphinx {
    src = fetchgit {
      url = "https://github.com/pallets/click";
      rev = "1784558ed7c75c65764d2a434bd9cbb206ca939d"; # rev 7.1.2
      sha256 = "sha256-N6G0PDgfe2I0UbG7/4KqiA4Pj68uN0GuEYrnyUpNdPY=";
    };
    buildInputs = with python3.pkgs; [
      python3.pkgs.click
      python3.pkgs.sphinx-issues
      python3.pkgs.sphinx_pallets_theme
      python3.pkgs.sphinxcontrib-logcabinet
    ];
  };
  env.python.beautifulsoup4 = buildSphinx {
    src = python3.pkgs.beautifulsoup4.src;
    subdir = "doc/source";
  };

  env.python.uwsgi = buildSphinx {
    src = fetchgit {
      url = "https://github.com/unbit/uwsgi-docs";
      rev = "aedf58d86094f36576bffe21eb9016db079697df";
      sha256 = "sha256-V+BdpWJACc5dIeMPYp0IovPhRP1Xog8u5ee7uuOXMa0=";
    };
    subdir = ".";
  };

  env.python.jsonschema = buildSphinx {
    src = fetchgit {
      url = "https://github.com/json-schema-org/understanding-json-schema";
      rev = "861bd676c5fa921f3454ba4c31da25b82f0db1d1";
      sha256 = "sha256-4NA06RxJxIUwQvtEFEOPd7w31bN5FApbG0b6ShTmQ/I=";
    };
    subdir = "source";
    buildInputs = with python3.pkgs; [ jsonschema sphinx_bootstrap_theme ];
  };

  env.python.Language = buildSphinx {
    inherit (python3) src;
    buildInputs = with python3.pkgs; [ python_docs_theme ];
    subdir = "Doc";
  };

  doc-laminar = callPackage ./doc-laminar.nix { };
  doc-autoconf = callPackage ./doc-autoconf.nix { };
  doc-terraform-aws = callPackage ./doc-terraform-aws.nix { };
  doc-terraform = callPackage ./doc-terraform.nix { };
  doc-m4 = callPackage ./doc-m4.nix { };
  haskell-package = name: ''
    ln -sf ${haskellPackages."${name}".doc}/share/doc/*/html/index.html \
      haskell/${name}.html
  '';
in runCommand "Documentation" { } ''
  base=$out/Documentation
  mkdir -p $base; cd $base
  ln -sf ${doc-nginx}/index.html nginx.html

  mkdir -p posix python haskell
  ln -sf ${doc-posix}/mindex.html posix.html
  ln -sf ${doc-posix}/basedefs/toc.html  posix/posix-definitions.html
  ln -sf ${doc-posix}/functions/toc.html posix/posix-functions.html
  ln -sf ${doc-posix}/utilities/toc.html posix/posix-commands.html
  ln -sf ${doc-posix}/idx/headers.html   posix/posix-headers.html
  ln -sf ${bash.doc}/share/doc/bash/bashref.html Bash.html
  ln -sf ${execline.doc}/share/doc/execline/html/index.html execline.html
  ln -sf ${nix.doc}/share/doc/nix/manual/index.html nix.html
  ln -sf ${ghc.doc}/share/doc/ghc/html/users_guide/index.html GHC.html
  ln -sf ${ghc.doc}/share/doc/ghc/html/libraries/index.html haskell-platform.html
  ln -sf ${postgresql_10.doc}/share/doc/postgresql/html/bookindex.html postgresql-10.html
  ln -sf ${doc-nixpkgs}/share/doc/nixpkgs/manual.html NixPkgs.html

  ln -sf ${env.python.Language}/index.html    python/Language.html
  # ln -sf env.python.attr/index.html        python/attr.html
  ln -sf ${env.python.click}/index.html       python/click.html
  ln -sf ${env.python.dropbox}/index.html     python/dropbox.html
  ln -sf ${env.python.jsonschema}/index.html  python/jsonschema.html
  ln -sf ${env.python.uwsgi}/index.html       python/uwsgi.html
  ln -sf ${env.python.psycopg2}/index.html    python/psycopg2.html
  ln -sf ${env.python.beautifulsoup4}/index.html  python/beautifulsoup4.html

  ${haskell-package "dhall"}
  ${haskell-package "lens"}
  ${haskell-package "megaparsec"}
  ${haskell-package "optparse-applicative"}
  ${haskell-package "aeson"}
  ln -sf ${zsh}/share/zsh-*/Doc/index.html zsh.html
  cp ${mutt}/share/doc/mutt/manual.html mutt.html
  cp ${doc-laminar} laminar.html
  cp ${doc-m4} m4.html
  cp ${doc-autoconf} Autoconf.html
  cp -r ${doc-terraform-aws} terraform-aws
  ln -sf ${doc-terraform} terraform

  cp ${fasm.doc}/share/doc/fasm/fasm.txt fasm.txt

  broken=$(find $out -xtype l)
  if [ -n "$broken" ] ; then
    echo "Broken links: $broken"
    exit 1
  fi
''

R universe/Documentation/doc-autoconf.nix => flake/universe/Documentation/doc-autoconf.nix +0 -0
R universe/Documentation/doc-laminar.nix => flake/universe/Documentation/doc-laminar.nix +0 -0
R universe/Documentation/doc-m4.nix => flake/universe/Documentation/doc-m4.nix +0 -0
R universe/Documentation/doc-nginx.nix => flake/universe/Documentation/doc-nginx.nix +0 -0
R universe/Documentation/doc-nixpkgs.nix => flake/universe/Documentation/doc-nixpkgs.nix +1 -2
@@ 1,4 1,3 @@
{ nixpkgs, pkgs }:
let
  doc = builtins.toPath "${nixpkgs}/doc";
let doc = builtins.toPath "${nixpkgs}/doc";
in import doc { inherit pkgs; }

R universe/Documentation/doc-posix.nix => flake/universe/Documentation/doc-posix.nix +0 -0
A flake/universe/Documentation/doc-terraform-aws.nix => flake/universe/Documentation/doc-terraform-aws.nix +23 -0
@@ 0,0 1,23 @@
{ lib, stdenv, fetchFromGitHub, pandoc }:

stdenv.mkDerivation {
  name = "doc-terraform-aws";
  src = fetchFromGitHub {
    owner = "hashicorp";
    repo = "terraform-provider-aws";
    rev = "ac8882a98e96e41f4204f822abf306df08f1491f";
    sha256 = "sha256-LfRP6+0WXg9Mm8gMvsy+6a91MbLj+h8xSyrERRzPE1w=";
  };
  nativeBuildInputs = [ pandoc ];
  buildPhase = ''
    mkdir -p out
    for x in website/docs/r/*.markdown ; do
      name=$(basename $x .markdown)
      pandoc -s --to=html $x > out/$name
    done
  '';
  installPhase = ''
    mkdir -p $out
    cp -v out/*.html $out
  '';
}

A flake/universe/Documentation/doc-terraform.nix => flake/universe/Documentation/doc-terraform.nix +26 -0
@@ 0,0 1,26 @@
{ lib, stdenv, fetchFromGitHub, pandoc }:

stdenv.mkDerivation {
  name = "doc-terraform";
  src = fetchFromGitHub {
    owner = "hashicorp";
    repo = "terraform";
    rev = "2496bc2b1e47a2fb967045db44cf9ec7cf4297b7";
    sha256 = "sha256-yz+djIkgCK9mDBzKWuDFPj68FECT3UYoRipHOAX3vrc";
  };
  nativeBuildInputs = [ pandoc ];
  buildPhase = ''
    cp -sr $PWD/website/docs out
    for x in $(find out -name '*.md') ; do
      pandoc -s --to=html $x \
        | sed -e 's,utm_source=WEBSITE&amp;utm_medium=WEB_IO&amp;utm_offer=ARTICLE_PAGE&amp;utm_content=DOCS,,g' \
              -e 's,href="/docs/,href="${placeholder "out"}/,g' \
        > ''${x%.md}
    done
    find out -name '*.md' -delete
  '';
  installPhase = ''
    mkdir -p $out/
    cp -r out/* $out/
  '';
}

R universe/Documentation/patches/nginx.org-1.patch => flake/universe/Documentation/patches/nginx.org-1.patch +0 -0
R universe/attach-shell/default.nix => flake/universe/attach-shell/default.nix +2 -20
@@ 1,27 1,9 @@
{ uenv, mksh, busybox, writeText, writeScript, writeScriptBin, dvtm, execline
{ uenv, rc, busybox, writeText, writeScript, writeScriptBin, dvtm, execline
, abduco }:
let
  shellrc = writeText "shellrc" ''
    export PS1=">>= "
    unset ENV
    if [ -r ~/.nix-profile/posixrc ] ; then
      . ~/.nix-profile/posixrc
    fi
    if [ -r ~/.posixrc ] ; then
      . ~/.posixrc
    fi
  '';

  # Neither uenv nor mksh are called by absolute path so changes to user
  # profile are caught as soon as new shell is started by dvtm, without
  # need to kill whole dvtm session.
  shell = writeScript "mksh-wrapped" ''
    #!${execline}/bin/execlineb -S0
    ifelse { ${busybox}/bin/test -t 0 } {
      export ENV ${shellrc}
      tryexec { uenv ${execline}/bin/exec -a mksh ${mksh}/bin/mksh -o vi $@ }
      ${uenv}/bin/uenv ${execline}/bin/exec -a mksh ${mksh}/bin/mksh -o vi $@
    } ${execline}/bin/exec -a sh ${busybox}/bin/sh $@
    ${uenv}/bin/uenv ${rc}/bin/rc -l
  '';
  attach-shell = writeScriptBin "attach-shell" ''
    #!${execline}/bin/execlineb -W

R universe/blurdate/blurdate.c => flake/universe/blurdate/blurdate.c +0 -0
R universe/blurdate/default.nix => flake/universe/blurdate/default.nix +0 -0
R universe/default.nix => flake/universe/default.nix +104 -76
@@ 2,80 2,108 @@
let
  inherit (pkgs.lib) isDerivation filterAttrs attrValues optionals;
  outputs = drv: [ drv ] ++ attrValues (filterAttrs (_: isDerivation) drv);
in with pkgs; buildEnv {
    name = "universe-13";
    paths = [
      Documentation
      acpi # Check battery status
      asciinema
      vidir
      attach-shell
      # For personal things I prefer redo(1), Makefiles of other people
      # usually assume GNU Make.
      gnumake
      coreutils
      posixrc
      curl
      haskellPackages.diohsc
      dvtm
      dhall
      dhall-bash
      dhall-json
      dhall-lsp-server
      dbxcli
      fasm
      fasm-arch
      file # This is part of base system.
      gdb
      git
      git-bug
      git-recall
      git-crypt
      passphrase2pgp
      gnupg
      github-cli
      groff
      kpcli
      htop
      jq # json dominated web, and it is probably good
      less
      man-pages # syscall and libc library reference.
      msmtp
      mpop
      mutt
      newsboat
      nix # unstable Nix with flakes support
      ## nixfmt
      nnn # file manager for poorly named files
      openssh
      pkgsStatic.par # Like fmt(1), but better.
      pass
      posix_man_pages # busybox does not provide manpages
      postgresql_10.doc # My ${dayjob} uses Postgres-10
      postgresql_10.man
      psql # client-only
      pstree # overview of processes running on the system.
      python3.pkgs.md2gemini
      rename # mass rename of files
      reuse # automatic management of copyright headers.
      rsync
      srht-ui
      selectors
      strace # When things break, and they break all the time.
      surfraw
      tig
      tree # Useful to inspect result of Nix derivation build
      trezord
      uenv
      urlview # open links in email
      neovim
      w3m # Web-browser that supports tables
      texlab
      python3.pkgs.python-language-server
      ccls
      rnix-lsp
      gopls
      scripts.release
      git-merge-pr
    ];
in with pkgs;
buildEnv {
  name = "universe-13";
  paths = [
    Documentation
    snooze
    gnum4
    acpi # Check battery status
    cached-nix-shell
    age
    rs-git-fsmonitor
    testssl
    go
    indent
    asciinema
    vidir
    attach-shell
    redo-c
    # For personal things I prefer redo(1), Makefiles of other people
    # usually assume GNU Make.
    gnumake
    coreutils
    curl
    haskellPackages.diohsc
    dvtm
    dhall
    dhall-bash
    dhall-json
    dhall-lsp-server
    fasm
    fasm-arch
    rc
    file # This is part of base system.
    gdb
    git
    git-bug
    git-recall
    git-crypt
    passphrase2pgp
    gnupg
    github-cli
    groff
    kpcli
    htop
    jq # json dominated web, and it is probably good
    less
    man-pages # syscall and libc library reference.
    msmtp
    mpop
    mutt
    newsboat
    nix # unstable Nix with flakes support
    nixfmt
    nnn # file manager for poorly named files
    openssh
    pkgsStatic.par # Like fmt(1), but better.
    pass
    posix_man_pages # busybox does not provide manpages
    postgresql_10.doc # My ${dayjob} uses Postgres-10
    postgresql_10.man
    psql # client-only
    pstree # overview of processes running on the system.
    python3.pkgs.md2gemini
    rename # mass rename of files
    reuse # automatic management of copyright headers.
    rsync
    srht-ui
    selectors
    strace # When things break, and they break all the time.
    surfraw
    tig
    tea
    terraform
    tree # Useful to inspect result of Nix derivation build
    trezord
    uenv
    urlview # open links in email
    neovim-custom
    w3m # Web-browser that supports tables
    texlab
    # Not supported by python=3.9 yet
    # python3.pkgs.python-language-server
    ccls
    rnix-lsp
    gopls
    scripts.release
    git-merge-pr
    man-db
    yq-go
    luaformatter
    niv
    (python3.withPackages (p:
      with p; [
        click
        requests
        xmltodict
        attrs
        pycryptodome
        pynvim
        beautifulsoup4
        psycopg2
        pyyaml
      ]))
  ];
}

R universe/doas/default.nix => flake/universe/doas/default.nix +0 -0
R universe/dvtm/default.nix => flake/universe/dvtm/default.nix +0 -0
R universe/dvtm/patches/fix-spelling-errors.patch => flake/universe/dvtm/patches/fix-spelling-errors.patch +0 -0
R universe/dvtm/patches/highlight-selected-tag.patch => flake/universe/dvtm/patches/highlight-selected-tag.patch +0 -0
R universe/dvtm/patches/increase-number-of-tags-to-9.patch => flake/universe/dvtm/patches/increase-number-of-tags-to-9.patch +0 -0
R universe/dvtm/patches/patch-do-not-install-terminal-descriptio.patch => flake/universe/dvtm/patches/patch-do-not-install-terminal-descriptio.patch +0 -0
R universe/dvtm/patches/restore-signal-handlers.patch => flake/universe/dvtm/patches/restore-signal-handlers.patch +0 -0
R universe/dvtm/patches/support-nowrap.patch => flake/universe/dvtm/patches/support-nowrap.patch +0 -0
R universe/fasm-arch/Makefile => flake/universe/fasm-arch/Makefile +0 -0
R universe/fasm-arch/constants.txt => flake/universe/fasm-arch/constants.txt +68 -0
@@ 373,3 373,71 @@ SYS_fsopen
SYS_fsconfig
SYS_fsmount
SYS_fspick
MINSIGSTKSZ
SIGSTKSZ
REG_R8
REG_R9
REG_R10
REG_R11
REG_R12
REG_R13
REG_R14
REG_R15
REG_RDI
REG_RSI
REG_RBP
REG_RBX
REG_RDX
REG_RAX
REG_RCX
REG_RSP
REG_RIP
REG_EFL
REG_CSGSFS
REG_ERR
REG_TRAPNO
REG_OLDMASK
REG_CR2

SA_NOCLDSTOP
SA_NOCLDWAIT
SA_SIGINFO
SA_ONSTACK
SA_RESTART
SA_NODEFER
SA_RESETHAND

SIGHUP
SIGINT
SIGQUIT
SIGILL
SIGTRAP
SIGABRT
SIGIOT
SIGBUS
SIGFPE
SIGKILL
SIGUSR1
SIGSEGV
SIGUSR2
SIGPIPE
SIGALRM
SIGTERM
SIGSTKFLT
SIGCHLD
SIGCONT
SIGSTOP
SIGTSTP
SIGTTIN
SIGTTOU
SIGURG
SIGXCPU
SIGXFSZ
SIGVTALRM
SIGPROF
SIGWINCH
SIGIO
SIGPOLL
SIGPWR
SIGSYS
_NSIG

R universe/fasm-arch/default.nix => flake/universe/fasm-arch/default.nix +0 -0
R universe/fasm-arch/install.sh => flake/universe/fasm-arch/install.sh +0 -0
R universe/fasm-arch/stage1.c => flake/universe/fasm-arch/stage1.c +0 -0
R universe/fasm-arch/stage2.c => flake/universe/fasm-arch/stage2.c +1 -0
@@ 3,6 3,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/syscall.h>
#include <signal.h>

#include <unistd.h>
#include <stdio.h>

R universe/firewall/.gitignore => flake/universe/firewall/.gitignore +0 -0
R universe/firewall/Tupfile => flake/universe/firewall/Tupfile +0 -0
R universe/firewall/Tupfile.ini => flake/universe/firewall/Tupfile.ini +0 -0
R universe/firewall/default.nix => flake/universe/firewall/default.nix +0 -0
R universe/firewall/ifdown.ferm => flake/universe/firewall/ifdown.ferm +0 -0
R universe/firewall/ifup.ferm => flake/universe/firewall/ifup.ferm +0 -0
R universe/git-merge-pr/default.nix => flake/universe/git-merge-pr/default.nix +0 -0
R universe/git-recall/default.nix => flake/universe/git-recall/default.nix +4 -4
@@ 1,7 1,7 @@
{ writeScriptBin, git, execline, fzy }:
writeScriptBin "git-recall" ''
#!${execline}/bin/execlineb -P
backtick -in url { redirfd -r 0 ${./foreign.txt} ${fzy}/bin/fzy }
importas -in url url
git clone $url
  #!${execline}/bin/execlineb -P
  backtick -in url { redirfd -r 0 ${./foreign.txt} ${fzy}/bin/fzy }
  importas -in url url
  git clone $url
''

R universe/git-recall/foreign.txt => flake/universe/git-recall/foreign.txt +0 -0
R universe/htop/default.nix => flake/universe/htop/default.nix +0 -0
R universe/htop/htop.exec => flake/universe/htop/htop.exec +0 -0
R universe/htop/htoprc => flake/universe/htop/htoprc +0 -0
R universe/mk-runscript/default.nix => flake/universe/mk-runscript/default.nix +0 -0
R universe/mk-runscript/mk-runscript.hs => flake/universe/mk-runscript/mk-runscript.hs +0 -0
R universe/mk-runscript/templates/logscript.mustache => flake/universe/mk-runscript/templates/logscript.mustache +0 -0
R universe/msmtp/default.nix => flake/universe/msmtp/default.nix +2 -1
@@ 1,4 1,5 @@
{ msmtp, lib, tempfile, python3, substituteAll, busybox, execline, rewrite-paths }:
{ msmtp, lib, tempfile, python3, substituteAll, busybox, execline, rewrite-paths
}:
let
  wrapper = substituteAll {
    inherit execline;

R universe/msmtp/generator.py => flake/universe/msmtp/generator.py +7 -3
@@ 1,6 1,7 @@
#!/usr/bin/env python3
from email.parser import BytesParser
from email.utils import parseaddr
import codecs
import sys

(_, config, newmail) = sys.argv


@@ 15,13 16,16 @@ with open(config, "w") as config, open(newmail, "w") as newmail:
    else:
        addr = addr.replace("@", "#") + "#v1"
        addr = addr.replace("-request", "")  # solves problem with Mailman
    # People freak out seeing own email address in my "From". This way I still
    # have way to know who leaked my email to spammers, but keep people calm.
    addr = codecs.encode(addr, "rot13")
    user = "demigod"

    config.write(f"""
        account default
        host smtp.migadu.com
        user {user}@kaction.cc
        passwordeval cat /proc/self/fd/91/volatile/kaction.cc
        passwordeval ask smtp://demigod@kaction.cc
        port 587
        protocol smtp
        auth on


@@ 31,6 35,6 @@ with open(config, "w") as config, open(newmail, "w") as newmail:
        tls_certcheck on
        tls_trust_file /etc/ssl/certs/ca-certificates.crt
    """)

    msg["From"] = f"Dmitry Bogatov <{addr}@kaction.cc>"
    if "From" not in msg:
        msg["From"] = f"Dmitry Bogatov <{addr}@kaction.cc>"
    newmail.write(msg.as_string())

R universe/msmtp/wrapper.in => flake/universe/msmtp/wrapper.in +2 -1
@@ 1,5 1,6 @@
#!@execline@/bin/execlineb -WS0
export PATH @path@
importas -in PATH PATH
export PATH @path@:${PATH}
exec
tempfile msmtp.conf
tempfile message.eml

R universe/mutt/default.nix => flake/universe/mutt/default.nix +3 -14
@@ 6,7 6,6 @@ let
    cyrus_sasl = null;
    gnupg = null;
    gpgme = null;
    kerberos = null;
    headerCache = false;
    sslSupport = false;
    saslSupport = false;


@@ 20,18 19,8 @@ let
    configureFlags = old.configureFlags
      ++ [ "--disable-smtp" "--disable-pop" "--disable-nls" ];
    nativeBuildInputs = [ perl ];
  });
  stage3 = rewrite-paths {
    drv = stage2;
    postBuild = ''
    postInstall = ''
      rm -f $out/bin/smime_keys

      mv $out/bin/mutt $out/bin/.mutt
      cat << EOF > $out/bin/mutt
      #!${execline}/bin/execlineb -WS0
      $out/bin/.mutt -F ${./muttrc} \$@
      EOF
      chmod +x $out/bin/mutt
    '';
  };
in stage3
  });
in stage2

R universe/neovim/default.nix => flake/universe/neovim/default.nix +23 -23
@@ 1,4 1,4 @@
{ fetchgit, tree-sitter, neovim-unwrapped, wrapNeovim, vimUtils, vimPlugins }:
{ fetchgit, tree-sitter, neovim, vimUtils, vimPlugins }:
let
  file-json = path: builtins.fromJSON (builtins.readFile path);
  source = path:


@@ 11,46 11,46 @@ let
      version = src.rev;
      src = source path;
    };
  boot-plugin = vimUtils.buildVimPluginFrom2Nix rec {
    pname = "boot";
    version = "1.0";
    src = ./boot;
  };

  nightly = neovim-unwrapped.overrideAttrs (old: {
    name = "neovim-0.4.4+nightly";
    src = source ./src/neovim.json;
    buildInputs = old.buildInputs ++ [ tree-sitter ];
  });
in wrapNeovim nightly {
in neovim.override {
  configure = {
    packages.boot = with vimPlugins; {
      start = [
        nvim-lspconfig
        vim-nix
        nvim-cmp
        plenary-nvim
        cmp_luasnip
        cmp-nvim-lsp
        dhall-vim
        last256
        vim-snipmate
        vim-snippets
        purescript-vim
        vim-addon-mw-utils # hidden dependency of vim-snipmate
        tlib
        vim-colorschemes
        boot-plugin
        vimwiki
        (plugin ./src/nvim-cmp-git.json)
        (plugin ./src/nvim-luasnip.json)
        (plugin ./src/vim-bookmarks.json)
        (plugin ./src/vim-nnn.json)
        (plugin ./src/vim-nginx.json)
        (plugin ./src/vim-pgsql.json)
        (plugin ./src/vim-gemini.json)
        (plugin ./src/vim-vidir.json)
        (plugin ./src/vim-lspconfig.json)
        (plugin ./src/vim-timestamp.json)
        (plugin ./src/vim-terraform.json)
        (plugin ./src/vim-autoformat.json)
        (plugin ./src/vim-asymptote.json)
        (plugin ./src/vim-mustache.json)
        (plugin ./src/vim-rcshell.json)
        (plugin ./src/nvim-luapad.json)
        (let src = source ./src/vim-ghcid.json;
          in vimUtils.buildVimPluginFrom2Nix {
          pname = "ghcid";
          version = src.rev;
          src = "${src}/plugins/nvim";
        })
      ];
    };
    customRC = ''
      set rtp+=${./boot}
      set rtp+=${./boot}/after
      lua require('boot').main()
      ${builtins.readFile ./init.vim}
      source ~/.config/nvim/init.vim
    '';
  };
}

A flake/universe/neovim/src/nvim-cmp-git.json => flake/universe/neovim/src/nvim-cmp-git.json +11 -0
@@ 0,0 1,11 @@
{
  "url": "https://github.com/petertriho/cmp-git",
  "rev": "2d78e6e66130af1a19f8fd15e9d123ed000d633c",
  "date": "2021-11-29T16:07:29+11:00",
  "path": "/nix/store/31vdxjcsd1diwf6ja9dnr43k2xkpmmav-cmp-git",
  "sha256": "0v1h16r2ll6bv20j94padbmxgr8jjr86ll07z1lzy5lk8dndpakx",
  "fetchLFS": false,
  "fetchSubmodules": false,
  "deepClone": false,
  "leaveDotGit": false
}

A flake/universe/neovim/src/nvim-luapad.json => flake/universe/neovim/src/nvim-luapad.json +11 -0
@@ 0,0 1,11 @@
{
  "url": "https://github.com/rafcamlet/nvim-luapad",
  "rev": "33a7237d4ca42b6692042adc15cf77f5231940cf",
  "date": "2021-08-15T20:20:13+02:00",
  "path": "/nix/store/67b5acyx0vf4xrg64gzqisqchvf3icad-nvim-luapad",
  "sha256": "0ylxfzi045wxlsak52jla6m0mrwr2b3bb0mam9w1ay9s9l24dppv",
  "fetchLFS": false,
  "fetchSubmodules": false,
  "deepClone": false,
  "leaveDotGit": false
}

A flake/universe/neovim/src/nvim-luasnip.json => flake/universe/neovim/src/nvim-luasnip.json +11 -0
@@ 0,0 1,11 @@
{
  "url": "https://github.com/L3MON4D3/LuaSnip",
  "rev": "3e4da0cfea0a2f0b4749369bc7ed247c1412a854",
  "date": "2021-12-20T17:22:13+00:00",
  "path": "/nix/store/97lm59sjn61q4zi55mkcgh8rnhkmrxlh-LuaSnip",
  "sha256": "0x8br3dyslbm63krcbflrb8csvppxnwfdgi1407z9b5y38x5zypx",
  "fetchLFS": false,
  "fetchSubmodules": false,
  "deepClone": false,
  "leaveDotGit": false
}

R universe/neovim/src/neovim.json => flake/universe/neovim/src/vim-asymptote.json +5 -5
@@ 1,9 1,9 @@
{
  "url": "https://github.com/neovim/neovim",
  "rev": "b79596eb5e942a299aa021a0f9a3f2db909294da",
  "date": "2021-03-27T19:02:48-07:00",
  "path": "/nix/store/lxmbhs4bcwzh3nck24i43v3h5r5szlg9-neovim",
  "sha256": "1frf4wphhm8ilbgizaj61zhs6srqj6akmc90xahvdqii5rkvhcwp",
  "url": "https://github.com/hura/vim-asymptote",
  "rev": "2c59b7d173bf3837c1378e60b0c51d911cdbe15c",
  "date": "2014-06-26T10:13:56-04:00",
  "path": "/nix/store/fiq9lbi7jl7r4px4hn10h6n9cz5b9hx4-vim-asymptote",
  "sha256": "0j4hrirssgnh37crl3yvy2vxf7wigdir860z1qvn1m72hld8n32y",
  "fetchSubmodules": false,
  "deepClone": false,
  "leaveDotGit": false

A flake/universe/neovim/src/vim-autoformat.json => flake/universe/neovim/src/vim-autoformat.json +10 -0
@@ 0,0 1,10 @@
{
  "url": "https://github.com/Chiel92/vim-autoformat",
  "rev": "d616fcf8a747f86bd3b26004b83ea5b7c7526df1",
  "date": "2021-06-21T09:20:22+02:00",
  "path": "/nix/store/n1radqgbjr9hslh0i6d02iwlndzp55zy-vim-autoformat",
  "sha256": "1292613i7yi38jsl1sly5i9bdi7bzaw2pg67gkymq2ln7zcpvims",
  "fetchSubmodules": false,
  "deepClone": false,
  "leaveDotGit": false
}

R universe/neovim/src/vim-bookmarks.json => flake/universe/neovim/src/vim-bookmarks.json +0 -0
R universe/neovim/src/vim-gemini.json => flake/universe/neovim/src/vim-gemini.json +0 -0
R universe/neovim/src/vim-lspconfig.json => flake/universe/neovim/src/vim-ghcid.json +5 -5
@@ 1,9 1,9 @@
{
  "url": "https://github.com/neovim/nvim-lspconfig",
  "rev": "afc26485cf50c82321d2ccb98517a73d9434af44",
  "date": "2021-03-28T17:07:59+00:00",
  "path": "/nix/store/2vw22agiirpf1h8zvwxqd0h87y6hi5b8-nvim-lspconfig",
  "sha256": "0da410cxswwh7781h28qvjd6xmx89k3k6z11339hjx8bjsqr8dhv",
  "url": "https://github.com/ndmitchell/ghcid",
  "rev": "b18ad1643f753f39e924909ecd957cb6b5a5fa89",
  "date": "2021-10-10T21:57:43+01:00",
  "path": "/nix/store/dhclypk8hjv14g5qmrk963jq04rfnljj-ghcid",
  "sha256": "1swwz4kzc1d41nbvvar3a2c71xy524fsyf5kjyrbbivrghcifpl8",
  "fetchSubmodules": false,
  "deepClone": false,
  "leaveDotGit": false

A flake/universe/neovim/src/vim-mustache.json => flake/universe/neovim/src/vim-mustache.json +10 -0
@@ 0,0 1,10 @@
{
  "url": "https://github.com/mustache/vim-mustache-handlebars",
  "rev": "fcc1401c2f783c14314ef22517a525a884c549ac",
  "date": "2020-08-24T09:08:00-04:00",
  "path": "/nix/store/w2bhh4mbv76c653ilrpm0q15y2n73l4l-vim-mustache-handlebars",
  "sha256": "01nkd89dzjw8cqs2zv7hwwgljxs53dxqfv774kswmz5g198vxf7d",
  "fetchSubmodules": false,
  "deepClone": false,
  "leaveDotGit": false
}

R universe/neovim/src/vim-nginx.json => flake/universe/neovim/src/vim-nginx.json +0 -0
R universe/neovim/src/vim-nnn.json => flake/universe/neovim/src/vim-nnn.json +0 -0
R universe/neovim/src/vim-pgsql.json => flake/universe/neovim/src/vim-pgsql.json +0 -0
A flake/universe/neovim/src/vim-rcshell.json => flake/universe/neovim/src/vim-rcshell.json +10 -0
@@ 0,0 1,10 @@
{
  "url": "https://github.com/vim-scripts/rcshell.vim",
  "rev": "6b307c6e6e6948fbb27146b0f41b5fb2ddf8e1a8",
  "date": "2014-12-28T21:30:05-05:00",
  "path": "/nix/store/rm2y66lfg7j74s5ixym1rqi5q3cqjm34-rcshell.vim",
  "sha256": "0dj6gjq213ljshnncal3ywzv8ply2lzqmvpzaf7vdsd6r6vss3ch",
  "fetchSubmodules": false,
  "deepClone": false,
  "leaveDotGit": false
}

A flake/universe/neovim/src/vim-terraform.json => flake/universe/neovim/src/vim-terraform.json +10 -0
@@ 0,0 1,10 @@
{
  "url": "https://github.com/hashivim/vim-terraform",
  "rev": "814a21db89f742c3ea492c69c5a2bfecded1aeb3",
  "date": "2021-06-09T10:21:04+01:00",
  "path": "/nix/store/7s6nd1qbn8inxzqb7ac23vz03raxqz15-vim-terraform",
  "sha256": "0acdq2m16mhm3g6n4saqf9fljz5qfdalw88h126z2f6mm731y6pi",
  "fetchSubmodules": false,
  "deepClone": false,
  "leaveDotGit": false
}

R universe/neovim/src/vim-timestamp.json => flake/universe/neovim/src/vim-timestamp.json +0 -0
R universe/neovim/src/vim-vidir.json => flake/universe/neovim/src/vim-vidir.json +0 -0
R universe/nix/default.nix => flake/universe/nix/default.nix +0 -0
R universe/nixfmt/default.nix => flake/universe/nixfmt/default.nix +0 -0
R universe/psql/default.nix => flake/universe/psql/default.nix +0 -0
R universe/python3/default.nix => flake/universe/python3/default.nix +0 -0
R universe/python3/overrides.nix => flake/universe/python3/overrides.nix +13 -2
@@ 107,11 107,22 @@ self: super: {

  sphinx-furo = super.buildPythonPackage rec {
    pname = "furo";
    version = "2021.4.11b34";
    version = "2021.10.9";
    propagatedBuildInputs = with self; [ beautifulsoup4 sphinx ];
    preConfigure = "";
    src = super.fetchPypi {
      inherit pname version;
      hash = "sha256-PYjihVlJzs9fVi6KKMqxptM1XYLzz1eW7d+ewjTpdRk";
      sha256 = "032lng2axnczn1zwmyf7kfvibv62p9jb6ahqqsanwgny5si45aib";
    };
  };

  sphinx-better = super.buildPythonPackage rec {
    pname = "sphinx-better-theme";
    version = "0.1.5";
    propagatedBuildInputs = with self; [ sphinx ];
    src = super.fetchPypi {
      inherit pname version;
      hash = "sha256-QgVw2A2MqyWzXO8reWGRBGdXd9/1oj3uvpuiGR1Iwc4=";
    };
  };


A flake/universe/rc/default.nix => flake/universe/rc/default.nix +11 -0
@@ 0,0 1,11 @@
{ rc, yacc, fetchFromGitHub, fetchpatch }:

rc.overrideAttrs (old: {
  nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ yacc ];
  src = fetchFromGitHub {
    owner = "rakitzis";
    repo = "rc";
    rev = "8ca9ab1305c3e30cd064290081d6e5a1fa841d26";
    sha256 = "sha256-n2gCHVTxK25EOeg98XQ9cRmPQ9L1q56y1P8nb3RWhBw=";
  };
})

R universe/rewrite-paths/default.nix => flake/universe/rewrite-paths/default.nix +0 -0
R universe/scripts/default.nix => flake/universe/scripts/default.nix +0 -0
R universe/scripts/release.py => flake/universe/scripts/release.py +0 -0
R universe/selectors/default.nix => flake/universe/selectors/default.nix +6 -0
@@ 22,9 22,15 @@ let
    pipeline { ${git}/bin/git ls-files $@ }
    ${fzy}/bin/fzy
  '';
  branch = writeScript "branch-selector" ''
    #!${execline}/bin/execlineb -WS0
    pipeline { git for-each-ref refs/heads/ --format=%(refname:short) }
    ${fzy}/bin/fzy
  '';
in runCommandLocal "selectors" { } ''
  mkdir -p $out/bin
  ln -sf ${bug} $out/bin/fzy-bug
  ln -sf ${commit} $out/bin/fzy-commit
  ln -sf ${file} $out/bin/fzy-file
  ln -sf ${branch} $out/bin/fzy-branch
''

R universe/srht-ui/default.nix => flake/universe/srht-ui/default.nix +0 -0
R universe/surfraw/default.nix => flake/universe/surfraw/default.nix +0 -0
R universe/tempfile/Makefile => flake/universe/tempfile/Makefile +0 -0
R universe/tempfile/default.nix => flake/universe/tempfile/default.nix +0 -0
R universe/tempfile/tempfile.1.scd => flake/universe/tempfile/tempfile.1.scd +0 -0
R universe/tempfile/tempfile.c => flake/universe/tempfile/tempfile.c +0 -0
R universe/uenv/default.nix => flake/universe/uenv/default.nix +0 -17
@@ 2,26 2,9 @@
let
  home = "/proc/self/fd/42";
  shm = "/proc/self/fd/91";
  ls-colors = stdenv.mkDerivation {
    name = "ls-colors";
    src = fetchFromGitHub {
      owner = "trapd00r";
      repo = "LS_COLORS";
      rev = "e91cc9cc69f6c4780f03b121bc633569742de7cd";
      hash = "sha256-6DnZgWXlQ1+focJGvhlVvgo97owDCj5w2zydF2ZiV8Q";
    };
    installPhase = ''
      sed -i '/^LINK/ d' LS_COLORS
      eval "$(dircolors LS_COLORS)"
      echo "$LS_COLORS" > $out
    '';
  };

  envfile = substituteAll {
    src = ./env.conf;
    inputrc = ./inputrc;
    inherit home shm glibcLocales;
    lscolors = builtins.readFile ls-colors;
  };

  uenv = substituteAll {

A flake/universe/uenv/env.conf => flake/universe/uenv/env.conf +5 -0
@@ 0,0 1,5 @@
MANPATH = @home@/.nix-profile/share/man:/usr/share/man
TERMINFO_DIRS = @home@/.nix-profile/share/terminfo:/usr/share/terminfo
LOCALE_ARCHIVE = @glibcLocales@/lib/locale/locale-archive
ABDUCO_SOCKET_DIR = @shm@
VIDIR_EDITOR_ARGS = -c :set nolist | :set ft=vidir-ls

R universe/uenv/uenv.exec => flake/universe/uenv/uenv.exec +0 -1
@@ 5,5 5,4 @@ if { umask 077 @busybox@/bin/mkdir -p /dev/shm/${USER}/.abduco }
redirfd -r 42 ${HOME}
redirfd -r 91 /dev/shm/${USER}
envfile @envfile@
@execline@/bin/export PATH ${HOME}/.nix-profile/bin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin
@execline@/bin/exec $@

R universe/vidir/default.nix => flake/universe/vidir/default.nix +0 -0
R universe/w3m/default.nix => flake/universe/w3m/default.nix +2 -25
@@ 1,4 1,4 @@
{ w3m, rewrite-paths, perl, pristine-perl, execline, substituteAll, vim
{ w3m, rewrite-paths, perl, pristine-perl, execline, substituteAll, neovim
, writeScript, busybox }:
let
  stage1 = w3m.override {


@@ 23,27 23,4 @@ let
      "--enable-image=no"
    ];
  });
  stage2' = stage1;

  config = substituteAll {
    name = "w3m.conf";
    src = ./w3m.conf;
    editor = "${vim}/bin/vim";
  };
  stage3 = rewrite-paths {
    drv = stage2';
    rules = [{
      old = pristine-perl;
      new = perl;
    }];
    postBuild = ''
      mv $out/bin/w3m $out/bin/.w3m

      cat << EOF > $out/bin/w3m
      #!${execline}/bin/execlineb -WS0
      $out/bin/.w3m -config ${config} \$@
      EOF
      chmod +x $out/bin/w3m
    '';
  };
in stage3
in stage2

D manifest/.gitattributes => manifest/.gitattributes +0 -1
@@ 1,1 0,0 @@
secret/** filter=git-crypt diff=git-crypt

D manifest/.gitignore => manifest/.gitignore +0 -2
@@ 1,2 0,0 @@
shadow
gshadow

D manifest/activate/default.nix => manifest/activate/default.nix +0 -12
@@ 1,12 0,0 @@
{ busybox, execline, runit, runCommand, writeScript, manifest, mk-runscript }:
let
  path = str: manifest.${str}.path;
  runscript = writeScript "activate.run" ''
    #!${execline}/bin/execlineb -P
    if { ${busybox}/bin/sysctl -p ${path "/etc/sysctl.conf"} }
    ${runit}/bin/sv down .
  '';
in runCommand "activate" { inherit runscript; } ''
  ${mk-runscript}/bin/mk-runscript \
    --name $name --target $out --runscript $runscript
''

D manifest/default.nix => manifest/default.nix +0 -78
@@ 1,78 0,0 @@
{ writeText, runCommandLocal, dhall-json, stdenv, callPackage, mk-passwd, doas
}:
let
  symlink = path: {
    action = "symlink";
    inherit path;
  };
  symlink' = expr: symlink (callPackage expr { });
  touch = {
    path = writeText "empty.txt" "";
    action = "copy";
    mode = "0000";
  };
  suid = path: {
    action = "copy";
    mode = "04555";
    inherit path;
  };
  auth = stdenv.mkDerivation {
    name = "auth";
    src = runCommandLocal "passwd.json" { } ''
      set -x
      ${dhall-json}/bin/dhall-to-json < ${./passwd.dhall} > $out
    '';
    nativeBuildInputs = [ mk-passwd ];
    phases = [ "installPhase" ];
    installPhase = ''
      mkdir -p $out
      mk-passwd --passwd $out/passwd --group $out/group < $src
    '';
    allowSubstitutes = false;
  };
  manifest = {
    base = let
      user-mkdir = {
        action = "mkdir";
        owner = 1000; # fixme: extract from {auth}
        mode = "0700";
      };

      f = self: {
        # Must specify explicitly, or it will be root:root
        "/home/kaction" = user-mkdir;
        "/home/kaction/Mail" = user-mkdir;
        "/home/kaction/Mail/cur" = user-mkdir;
        "/home/kaction/Mail/new" = user-mkdir;
        "/home/kaction/Mail/tmp" = user-mkdir;
        "/home/kaction/.config" = user-mkdir;
        "/home/kaction/.config/dbxcli" = user-mkdir;
        "/home/kaction/.config/dbxcli/auth.json" = symlink ./secret/dbx.json;

        "/etc/group" = symlink "${auth}/group";
        "/etc/gshadow" = { action = "unlink"; };
        "/etc/hosts" = symlink' ./hosts;
        "/etc/profile.d/auth.sh" = symlink ./secret/auth.sh;
        "/etc/doas.conf" = symlink ./doas.conf;
        "/etc/nix/nix.conf" = symlink ./nix.conf;
        "/etc/nsswitch.conf" = symlink ./nsswitch.conf;
        "/etc/passwd" = symlink "${auth}/passwd";
        "/etc/runit/runsvdir/default/nix-daemon" =
          symlink' ./nix-daemon/runit.nix;
        "/etc/resolv.conf" = {
          path = ./openvpn/resolv.conf;
          action = "copy";
          mode = "0444";
        };
        "/etc/sysctl.conf" = symlink ./sysctl.conf;

        "/etc/runit/runsvdir/default/activate" =
          symlink (callPackage ./activate { manifest = self; });

        "/var/log/runit/activate/.keep" = touch;
        "/usr/local/bin/doas" = suid "${doas}/bin/doas";
        "/etc/xbps.d/xbps.conf" = symlink ./xbps.conf;
      };
    in writeText "manifest.json" (builtins.toJSON (stdenv.lib.fix f));
  };
in manifest.base

D manifest/doas.conf => manifest/doas.conf +0 -1
@@ 1,1 0,0 @@
permit nopass keepenv kaction

D manifest/hosts/default.nix => manifest/hosts/default.nix +0 -15
@@ 1,15 0,0 @@
{ runCommand }:
let
  # Mirror for list generated by hectorm/hblock. Upstream provides
  # nightly snapshots, but I need something stable. Dropbox links
  # are ugly, I know, but I found no other better gratis and
  # permanent storage.
  dropbox = part: "https://www.dropbox.com/s/${part}?dl=1";
  src = builtins.fetchurl {
    url = dropbox "5ijevtagpidy2et/hosts-2020-12-13.gz";
    sha256 = "0k7k09gai1w107mq5x20yld5cd0l1xk2bw1cg2wxmn8mi4ga4rxa";
  };
in runCommand "hosts" { inherit src; } ''
  cat ${./internal.txt} > $out
  gzip -d < $src >> $out
''

D manifest/hosts/internal.txt => manifest/hosts/internal.txt +0 -2
@@ 1,2 0,0 @@
10.0.2.4 sourcehut.local
10.0.2.5 void.local

D manifest/nix-daemon/openrc.nix => manifest/nix-daemon/openrc.nix +0 -11
@@ 1,11 0,0 @@
{ writeScript, nix, cacert }:
writeScript "nix-daemon" ''
  #!/sbin/openrc-run
  export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
  export NIX_SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
  command=${nix}/bin/nix-daemon
  command_background=true
  pidfile=/run/nix-daemon.pid

  mkdir -p /run
''

D manifest/nix-daemon/runit.nix => manifest/nix-daemon/runit.nix +0 -17
@@ 1,17 0,0 @@
{ runCommand, writeScript, runit, execline, cacert, nix }:
let
  # Increase limit of open files. Default soft/hard limit of 1024/4096
  # is not enough for really huge derivations, like one built in
  # tutor-papers.
  runscript = writeScript "nix-daemon.run" ''
    #!${execline}/bin/execlineb -P
    export SSL_CERT_FILE     ${cacert}/etc/ssl/certs/ca-bundle.crt
    export NIX_SSL_CERT_FILE ${cacert}/etc/ssl/certs/ca-bundle.crt
    ${runit}/bin/chpst -o 16000
    ${nix}/bin/nix-daemon
  '';
in runCommand "nix-daemon.sv" { inherit runscript; } ''
  mkdir -p $out
  cp $runscript $out/run
  ln -s /run/runit/supervise.nix-daemon $out/supervise
''

D manifest/nix.conf => manifest/nix.conf +0 -4
@@ 1,4 0,0 @@
experimental-features = nix-command flakes ca-references
warn-dirty = false
auto-optimise-store = true
secret-key-files = /etc/nix/nix-cache-key.sec

D manifest/nsswitch.conf => manifest/nsswitch.conf +0 -1
@@ 1,1 0,0 @@
hosts: files dns

D manifest/openvpn/.gitignore => manifest/openvpn/.gitignore +0 -1
@@ 1,1 0,0 @@
auth.txt

D manifest/openvpn/resolv.conf => manifest/openvpn/resolv.conf +0 -1
@@ 1,1 0,0 @@
nameserver 1.1.1.1

D manifest/passwd.dhall => manifest/passwd.dhall +0 -82
@@ 1,82 0,0 @@
let User =
      { Type =
          { name : Text
          , passwd : Optional Text
          , uid : Optional Natural
          , gid : Optional Natural
          , home : Optional Text
          , shell : Optional Text
          }
      , default =
        { passwd = None Text
        , uid = None Natural
        , gid = None Natural
        , home = None Text
        , shell = None Text
        }
      }

let Group =
      { Type = { name : Text, gid : Optional Natural, users : List Text }
      , default = { users = [] : List Text, gid = None Natural }
      }

let Config = { users : List User.Type, groups : List Group.Type }

let generate
    : Natural → ∀(a : Type) → (Natural → a) → List a
    = λ(n : Natural) →
      λ(a : Type) →
      λ(f : Natural → a) →
        List/build
          a
          ( λ(list : Type) →
            λ(cons : a → list → list) →
              List/fold
                { index : Natural, value : {} }
                ( List/indexed
                    {}
                    ( List/build
                        {}
                        ( λ(list : Type) →
                          λ(cons : {} → list → list) →
                            Natural/fold n list (cons {=})
                        )
                    )
                )
                list
                (λ(x : { index : Natural, value : {} }) → cons (f x.index))
          )

let nixbuildGid = 81

let username = λ(n : Natural) → "nixbld${Natural/show n}"

let mkNixbuildUser =
      λ(n : Natural) → User::{ name = username n, gid = Some nixbuildGid }

let nixbuildUsers = generate 50 User.Type mkNixbuildUser

in    { users =
            [ User::{
              , name = "kaction"
              , home = Some "/home/kaction"
              , shell = Some "/bin/bash"
              , uid = Some 1000
              }
            , User::{ name = "nobody" }
            ]
          # nixbuildUsers
      , groups =
        [ Group::{
          , name = "nixbld"
          , gid = Some nixbuildGid
          , users = generate 50 Text username
          },
        Group::{
          , name = "vboxsf"
          , users = ["kaction"]
          }
        ]
      }
    : Config

D manifest/secret/auth.sh => manifest/secret/auth.sh +0 -0
D manifest/secret/dbx.json => manifest/secret/dbx.json +0 -0
D manifest/secret/foo.txt => manifest/secret/foo.txt +0 -0
D manifest/sysctl.conf => manifest/sysctl.conf +0 -7
@@ 1,7 0,0 @@
# Allow starting services as unprivileged users on standard ports. Of
# course, any decently written server knows how to drop privileges, but
# it is even better when it never has them in first place.
#
# This is not enough for services that chroot themself, though.
net.ipv4.ip_unprivileged_port_start = 0
kernel.printk = 0 0 0 0

D manifest/xbps.conf => manifest/xbps.conf +0 -1
@@ 1,1 0,0 @@
ignorepkg=sudo

D universe/Documentation/default.nix => universe/Documentation/default.nix +0 -61
@@ 1,61 0,0 @@
{ nix, nixpkgs, postgresql_10, ghc, execline, bash, fasm, runCommand
, haskellPackages, callPackage }:
let
  doc-nginx = callPackage ./doc-nginx.nix { };
  doc-nixpkgs = callPackage ./doc-nixpkgs.nix { inherit nixpkgs; };
  doc-posix = callPackage ./doc-posix.nix { };
  doc-py-dropbox = callPackage ./doc-dropbox.nix { };
  doc-py-attr = callPackage ./doc-py-attrs.nix { };
  doc-py-click = callPackage ./doc-py-click.nix { };
  doc-python = callPackage ./doc-python.nix { };
  doc-uwsgi = callPackage ./doc-uwsgi.nix { };
  doc-jsonschema = callPackage ./doc-jsonschema.nix { };
  doc-laminar = callPackage ./doc-laminar.nix { };
  doc-autoconf = callPackage ./doc-autoconf.nix { };
  doc-m4 = callPackage ./doc-m4.nix { };
  script = callPackage ./script.nix { };
in runCommand "Documentation" { } ''
  base=$out/Documentation
  mkdir -p $base; cd $base
  ln -sf ${doc-nginx}/index.html nginx.html

  mkdir -p posix python haskell
  ln -sf ${doc-posix}/mindex.html posix.html
  ln -sf ${doc-posix}/basedefs/toc.html  posix/posix-definitions.html
  ln -sf ${doc-posix}/functions/toc.html posix/posix-functions.html
  ln -sf ${doc-posix}/utilities/toc.html posix/posix-commands.html
  ln -sf ${doc-posix}/idx/headers.html   posix/posix-headers.html
  ln -sf ${bash.doc}/share/doc/bash/bashref.html Bash.html
  ln -sf ${execline.doc}/share/doc/execline/html/index.html execline.html
  ln -sf ${nix.doc}/share/doc/nix/manual/index.html nix.html
  ln -sf ${ghc.doc}/share/doc/ghc/html/users_guide/index.html GHC.html
  ln -sf ${ghc.doc}/share/doc/ghc/html/libraries/index.html haskell-platform.html
  ln -sf ${postgresql_10.doc}/share/doc/postgresql/html/bookindex.html postgresql-10.html
  ln -sf ${doc-nixpkgs}/share/doc/nixpkgs/manual.html NixPkgs.html
  ln -sf ${doc-py-dropbox}/html/index.html python/dropbox.html
  ln -sf ${doc-py-attr}/html/index.html python/attr.html
  ln -sf ${doc-py-click}/html/index.html python/click.html
  ln -sf ${doc-uwsgi}/html/index.html python/uwsgi.html
  ln -sf ${doc-py-dropbox}/singlehtml/index.html python/_singlepage-dropbox.html
  ln -sf ${doc-py-attr}/singlehtml/index.html python/_signlepage-attr.html
  ln -sf ${doc-py-click}/singlehtml/index.html python/_singlepage-click.html
  ln -sf ${haskellPackages.dhall.doc}/share/doc/*/html/index.html haskell/dhall.html
  ln -sf ${haskellPackages.megaparsec.doc}/share/doc/*/html/index.html haskell/megaparsec.html
  ln -sf ${haskellPackages.lens.doc}/share/doc/*/html/index.html haskell/lens.html
  ln -sf ${doc-python}/html/library/index.html Python.html
  ln -sf ${doc-jsonschema}/index.html JSON-Schema.html
  cp ${doc-laminar} laminar.html
  cp ${doc-m4} m4.html
  cp ${doc-autoconf} Autoconf.html

  cp ${fasm.doc}/share/doc/fasm/fasm.txt fasm.txt

  broken=$(find $out -xtype l)
  if [ -n "$broken" ] ; then
    echo "Broken links: $broken"
    exit 1
  fi

  mkdir -p $out/bin
  cp ${script} $out/bin/Documentation
''

D universe/Documentation/doc-dropbox.nix => universe/Documentation/doc-dropbox.nix +0 -16
@@ 1,16 0,0 @@
{ stdenv, python3 }:
stdenv.mkDerivation {
  name = "Documentation-dropbox.py";
  src = builtins.fetchGit {
    url = "https://github.com/dropbox/dropbox-sdk-python";
    rev = "fdd342befa002c79d7eefc6e75fc8a93f2ec4c15";
  };
  nativeBuildInputs = [ python3.pkgs.sphinx ];
  installPhase = ''
    cd docs
    sphinx-build -b singlehtml -d _build/doctrees . $out/singlehtml
    sphinx-build -b html -d _build/doctrees . $out/html
    cd ..
  '';
  phases = ["unpackPhase" "installPhase"];
}

D universe/Documentation/doc-jsonschema.nix => universe/Documentation/doc-jsonschema.nix +0 -17
@@ 1,17 0,0 @@
{ stdenv, python3 }:
stdenv.mkDerivation {
  name = "Documentation-jsonschema";
  src = builtins.fetchGit {
    url = "https://github.com/json-schema-org/understanding-json-schema";
    rev = "861bd676c5fa921f3454ba4c31da25b82f0db1d1";
  };
  nativeBuildInputs = with python3.pkgs; [
    jsonschema
    sphinx
    sphinx_bootstrap_theme
  ];
  installPhase = ''
    make html
    mv build/html $out
  '';
}

D universe/Documentation/doc-py-attrs.nix => universe/Documentation/doc-py-attrs.nix +0 -17
@@ 1,17 0,0 @@
{ stdenv, python3 }:
stdenv.mkDerivation {
  name = "Documentation-attrs.py";
  inherit (python3.pkgs.attrs) src;
  nativeBuildInputs = [
    python3.pkgs.attrs
    python3.pkgs.sphinx
    python3.pkgs.sphinx-furo
  ];
  installPhase = ''
    cd docs
    sphinx-build -b singlehtml -d _build/doctrees . $out/singlehtml
    sphinx-build -b html -d _build/doctrees . $out/html
    cd ..
  '';
  phases = [ "unpackPhase" "installPhase" ];
}

D universe/Documentation/doc-py-click.nix => universe/Documentation/doc-py-click.nix +0 -22
@@ 1,22 0,0 @@
{ stdenv, python3 }:
stdenv.mkDerivation {
  name = "Documentation-click.py";
  src = builtins.fetchGit {
    url = "https://github.com/pallets/click";
    rev = "1784558ed7c75c65764d2a434bd9cbb206ca939d"; # rev 7.1.2
  };
  nativeBuildInputs = [
    python3.pkgs.click
    python3.pkgs.sphinx
    python3.pkgs.sphinx-issues
    python3.pkgs.sphinx_pallets_theme
    python3.pkgs.sphinxcontrib-logcabinet
  ];
  installPhase = ''
    cd docs
    sphinx-build -b singlehtml -d _build/doctrees . $out/singlehtml
    sphinx-build -b html -d _build/doctrees . $out/html
    cd ..
  '';
  phases = [ "unpackPhase" "installPhase" ];
}

D universe/Documentation/doc-python.nix => universe/Documentation/doc-python.nix +0 -11
@@ 1,11 0,0 @@
{ stdenv, python3 }:
stdenv.mkDerivation {
  name = "Documentation-python3";
  inherit (python3) src;
  phases = ["unpackPhase" "installPhase"];
  nativeBuildInputs = with python3.pkgs; [ sphinx python_docs_theme ];
  installPhase = ''
    cd Doc && sphinx-build -b html -d build/doctrees . $out/html
  '';
}


D universe/Documentation/doc-uwsgi.nix => universe/Documentation/doc-uwsgi.nix +0 -12
@@ 1,12 0,0 @@
{ stdenv, python3 }:
stdenv.mkDerivation {
  name = "Documentation-uwsgi";
  src = builtins.fetchGit {
    url = "https://github.com/unbit/uwsgi-docs";
    rev = "aedf58d86094f36576bffe21eb9016db079697df";
  };
  nativeBuildInputs = [ python3.pkgs.sphinx ];
  installPhase = ''
    sphinx-build -b html -d _build/doctrees . $out/html
  '';
}

D universe/Documentation/script.nix => universe/Documentation/script.nix +0 -17
@@ 1,17 0,0 @@
{ execline, busybox, nnn, writeScript }:
let
  # "readlink -f" trick makes sure that while trying to open symlink,
  # w3m is pointed to destination. Page itself works fine in any case,
  # but this trick makes sure relative links works too.
  opener = writeScript "Documentation-opener" ''
    #!${busybox}/bin/sh
    case $1 in
      (*.html) exec $BROWSER "$(readlink -f "$1")" ;;
      (*) exec $EDITOR "$(readlink -f "$1")" ;;
    esac
  '';
in writeScript "Documentation" ''
  #!${execline}/bin/execlineb -P
  export NNN_OPENER ${opener}
  nnn -c /proc/self/fd/42/.nix-profile/Documentation
''

D universe/dbxcli/default.nix => universe/dbxcli/default.nix +0 -12
@@ 1,12 0,0 @@
{ lib, buildGoModule, fetchFromGitHub }:
buildGoModule rec {
  pname = "dbxcli";
  version = "v3.0.0+";
  src = fetchFromGitHub {
    owner = "dropbox";
    repo = pname;
    rev = "9f870834e8128a78f2ff5ef9f539ae3156cb1d40";
    hash = "sha256-MccjWQHKV3N0x8QbtEa8viXJ77y/SvymSxmvCfYY3zQ";
  };
  vendorSha256 = "sha256-YXaDiRkqUZBDXXKZ9JWOSXqlibJbGn6jS6oJUjSovKg";
}

D universe/git-bug/default.nix => universe/git-bug/default.nix +0 -8
@@ 1,8 0,0 @@
{ git-bug }:
let
  stage1 = git-bug.overrideAttrs (_: {
    patchPhase = ''
      sed -i s,--global,--local,g repository/config_git.go
    '';
  });
in stage1

D universe/git/builder.bash => universe/git/builder.bash +0 -16
@@ 1,16 0,0 @@
#!/bin/bash -- source only
mkdir $out/config/git -p
cp -t $out -rs $git/*

chmod u+w $out/bin && unlink $out/bin/git

cat << EOF > $out/bin/git
#!${execline}/bin/execlineb -S0
export XDG_CONFIG_HOME $out/config
export FILTER_BRANCH_SQUELCH_WARNING 1
${blurdate}/bin/blurdate =hMs ${git}/bin/git \$@
EOF
chmod +x $out/bin/git

substituteAll $gitconfig $out/config/git/config
cp $gitignore $out/config/git/ignore

D universe/git/default.nix => universe/git/default.nix +0 -50
@@ 1,50 0,0 @@
{ git, writeScript, blurdate, perl, busybox, execline, runCommand, substituteAll, githooks }:
let
  stage1 = git.override {
    sendEmailSupport = true;
    coreutils = busybox;
    perlPackages = perl.pkgs;

    # Pure violence. git maintainer did not though about overrides hard
    # enough.
    #
    # Copied from pkgs/applications/version-management/git-and-tools.nix
    perlLibs = with perl.pkgs; [ LWP URI TermReadKey ];
    smtpPerlLibs = with perl.pkgs; [
      libnet
      NetSMTPSSL
      IOSocketSSL
      NetSSLeay
      AuthenSASL
      DigestHMAC
    ];
  };
  stage2 = stage1.overrideAttrs (old: {
    makeFlags = old.makeFlags ++ [ "SHELL_PATH=${busybox}/bin/sh" ];
    doInstallCheck = false;
  });
  stage3 = let
    env = {
      gitconfig = substituteAll {
        # This is tricky. Hooks scripts need git, and git includes
        # config which refers to hooks directory. Recursion.
        #
        # Here I break the loop by providing scripts with git that do
        # not have configuration embedded. This construction will
        # collapse when hook will need git for write operation and will
        # start complaining that user.name is not available.
        githooks = githooks.override { git = stage2; };
        logp = writeScript "logp" ''
          #!${execline}/bin/execlineb -WS0
          pipeline
            { git log -p --color=always --decorate=short $@ }
              less -R -p"^commit [0-9a-f]{40}"
        '';
        src = ./gitconfig.in;
      };
      gitignore = ./gitignore;
      git = stage2;
      inherit execline perl blurdate;
    };
  in runCommand git.name env "source ${./builder.bash}";
in stage3

D universe/githooks/build.py => universe/githooks/build.py +0 -20
@@ 1,20 0,0 @@
import os
import json

for key, value in os.environ.items():
    globals()[key] = value

hooks = json.loads(hooks)

for hook, scripts in hooks.items():
    os.makedirs(f"{out}/{hook}.d")
    for name, path in scripts.items():
        os.symlink(path, f"{out}/{hook}.d/{name}")
    with open(f"{out}/{hook}", "w") as fp:
        fp.write(f"""
#!{execline}/bin/execlineb -WS0
{rundir} {out}/{hook}.d $@
"""[1:])
    os.chmod(f"{out}/{hook}", 0o777)



D universe/githooks/default.nix => universe/githooks/default.nix +0 -52
@@ 1,52 0,0 @@
{ stdenv, python3, writeScript, substituteAll, busybox, debianutils, lib, git
, git-bug, execline }:
let
  run-parts = stdenv.mkDerivation {
    name = "run-parts";
    src = debianutils;
    phases = [ "installPhase" ];
    installPhase = ''
      cp $src/bin/run-parts $out
    '';
  };

  # run-parts has brain-damaged interface for passing arguments to
  # script.
  rundir = stdenv.mkDerivation {
    name = "run-directory";
    src = ./run-directory.c;
    phases = [ "installPhase" ];
    installPhase = ''
      cc -D'RUN_PARTS="${run-parts}"' $src -o $out
    '';
  };

  make-shell = { path ? [ ] }:
    let
      path' = if builtins.isString path then
        path
      else
        lib.makeBinPath (path ++ [ busybox ]);
    in writeScript "busybox-shell" ''
      #!${execline}/bin/execlineb -WS0
      export PATH ${path'}
      ${busybox}/bin/sh $@
    '';

  hooks = {
    post-commit.git-bug = substituteAll {
      shell = make-shell { path = [ git git-bug ]; };
      src = ./post-commit/git-bug.sh;
      isExecutable = true;
    };
  };

in stdenv.mkDerivation {
  inherit execline rundir;

  name = "githooks";
  buildInputs = [ python3 ];
  phases = [ "installPhase" ];
  hooks = builtins.toJSON hooks;
  installPhase = "python3 ${./build.py}";
}

D universe/githooks/run-directory.c => universe/githooks/run-directory.c +0 -34
@@ 1,34 0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char **argv)
{
	const char **args;
	const char *directory;
	int i;
	if (argc < 2) {
		fputs("usage: run-directory <directory> [ARGS ...]\n", stderr);
		return 1;
	}
	directory = argv[1];
	argv++;

	args = malloc(sizeof(char *) * (2 + argc * 2));
	if (!args) {
		fputs("fatal: malloc() failed", stderr);
		return 1;
	}

	i = 0;
	args[i++] = RUN_PARTS;
	while (*++argv) {
		args[i++] = "--arg";
		args[i++] = *argv;
	}
	args[i++] = "--";
	args[i++] = directory;
	args[i++] = NULL;

	return execvp(RUN_PARTS, (char *const *)args);
}

D universe/githooks/run-parts.sh => universe/githooks/run-parts.sh +0 -16
@@ 1,16 0,0 @@
#!@busybox@/bin/sh
set -eu
export PATH=@busybox@/bin
export LC_COLLATION=POSIX

directory=$1; shift
tempfile=$(mktemp)
cat > "${tempfile}"
cleanup() { rm -f "${tempfile}"; }
trap cleanup 0

for script in "${directory}"/* ; do
	if [ -x "${script}" ] && [ -f "${script}" ] ; then
	



D universe/hub/default.nix => universe/hub/default.nix +0 -4
@@ 1,4 0,0 @@
{ hub, git }:
let
  stage1 = hub.override { inherit git; };
in stage1

D universe/mpop/default.nix => universe/mpop/default.nix +0 -30
@@ 1,30 0,0 @@
{ mpop, execline, substituteAll, rewrite-paths }:
let
  config =
    # Mild obfuscation to make sure my email address is not greppable in
    # the source by something as primitive as \w+@\w+.\w+. I would be
    # shoked if spammer would actually build derivation to grep it for
    # email addresses.

    # For now I setup maildir instead of mh, since these days I do not
    # receive much mail, and configuring mmh is slightly more involved
    # than configuring mutt.
    let
      user = "demigod";
      domain = "kaction.cc";
    in substituteAll {
      src = ./mpop.conf;
      account = "user ${user}@${domain}";
    };
  stage1 = rewrite-paths {
    drv = mpop;
    postBuild = ''
      mv $out/bin/mpop $out/bin/.mpop
      cat << EOF > $out/bin/mpop
      #!${execline}/bin/execlineb -WS0
      $out/bin/.mpop --file=${config} \$@
      EOF
      chmod +x $out/bin/mpop
    '';
  };
in stage1

D universe/newsboat/default.nix => universe/newsboat/default.nix +0 -13
@@ 1,13 0,0 @@
{ newsboat, execline, rewrite-paths }:
let
  stage1 = rewrite-paths {
    drv = newsboat;
    postBuild = ''
      export execline=${execline}
      export urlfile=${./urls.txt}
      mv $out/bin/newsboat $out/bin/.newsboat
      substituteAll ${./wrapper.exec} $out/bin/newsboat
      chmod +x $out/bin/*
    '';
  };
in stage1

D universe/newsboat/wrapper.exec => universe/newsboat/wrapper.exec +0 -9
@@ 1,9 0,0 @@
#!@execline@/bin/execlineb -WS0
importas -in HOME HOME
importas -in USER USER
export HOME /dev/shm/${USER}
@out@/bin/.newsboat
	--refresh-on-start
	--url-file @urlfile@
	--cache-file ${HOME}/data/newsboat.cache
	$@

D universe/passphrase2pgp/default.nix => universe/passphrase2pgp/default.nix +0 -12
@@ 1,12 0,0 @@
{ lib, buildGoModule, fetchFromGitHub }:
buildGoModule rec {
  pname = "passphrase2pgp";
  version = "1.1.0";
  src = fetchFromGitHub {
    owner = "skeeto";
    repo = pname;
    rev = "v${version}";
    hash = "sha256-Nje77tn55CKRU6igEA/6IquDhXVVQAdiez6nmN49di4";
  };
  vendorSha256 = "sha256-7q5nwkj4TP7VgHmV9YBbCB11yTPL7tK4gD+uN4Vw3Cs";
}

D universe/posixrc/default.nix => universe/posixrc/default.nix +0 -5
@@ 1,5 0,0 @@
{ runCommandLocal }:
runCommandLocal "posixrc" { } ''
  mkdir -p $out
  cat ${./init.sh} >> $out/posixrc
''

D universe/posixrc/init.sh => universe/posixrc/init.sh +0 -17
@@ 1,17 0,0 @@
alias ls='ls --color=auto'
alias cd-root='cd "$(git root)"'
alias gh='GITHUB_TOKEN=${GITHUB_TOKEN} command gh'

vidir() {
	if [ $# = 0 ] ; then
		find -maxdepth 1 -not -name .git -and -not -name . | command vidir -
	else
		command vidir "$@"
	fi
}

if [ -r /etc/profile.d/auth.sh ] ; then
	. /etc/profile.d/auth.sh
fi
mkdir -p "/dev/shm/${USER}/volatile"
echo "${MSMTP_PASSWORD:-}" > "/dev/shm/${USER}/volatile/kaction.cc"

D universe/tig/default.nix => universe/tig/default.nix +0 -10
@@ 1,10 0,0 @@
{ tig, git, stdenv, nix, pristine-git, rewrite-paths }:
let
  stage1 = rewrite-paths {
    drv = tig;
    rules = [{
      old = pristine-git;
      new = git;
    }];
  };
in stage1

D universe/uenv/env.conf => universe/uenv/env.conf +0 -16
@@ 1,16 0,0 @@
EDITOR = nvim
TZ = America/New_York
BROWSER = w3m
LANG = C.UTF-8
MANPATH = @home@/.nix-profile/share/man:/usr/share/man
TERMINFO_DIRS = @home@/.nix-profile/share/terminfo:/usr/share/terminfo
INPUTRC = @inputrc@
LOCALE_ARCHIVE = @glibcLocales@/lib/locale/locale-archive
ABDUCO_SOCKET_DIR = @shm@
SURFRAW_browser = w3m
GITHUB_USER = kaction
GITHUB_PROTOCOL = https
VIDIR_EDITOR_ARGS = -c :set nolist | :set ft=vidir-ls
REALNAME = Dmitry Bogatov
EMAIL = pgp#v1@kaction.cc
LS_COLORS = @lscolors@

D universe/vim/default.nix => universe/vim/default.nix +0 -83
@@ 1,83 0,0 @@
{ buildEnv, makeWrapper, vidir, vim, vimPlugins, vimUtils, fetchFromGitHub }:
let
  plugin = path:
    let info = builtins.fromJSON (builtins.readFile path);
    in vimUtils.buildVimPluginFrom2Nix {
      pname = info.repo;
      version = info.rev;
      src = fetchFromGitHub info;
    };
  vim-bookmarks = plugin ./src/vim-bookmarks.json;
  nnn-vim = plugin ./src/nnn.vim.json;
  vim-nginx = vimUtils.buildVimPluginFrom2Nix {
    pname = "vim-nginx";
    version = "2020.01.04";
    src = fetchFromGitHub {
      owner = "chr4";
      repo = "nginx.vim";
      rev = "0b67dd4db92207fb3295a49832d60413b5658065";
      sha256 = "11vz5l99qh08fz6gxsk7swam38g5iw3k889gs25b8009lf5cx96r";
    };
  };
  vim-pgsql = vimUtils.buildVimPluginFrom2Nix {
    pname = "vim-pgsql";
    version = "2020.02.29";
    src = fetchFromGitHub {
      owner = "lifepillar";
      repo = "pgsql.vim";
      rev = "38b14b2ec7129cceb87519c17e283419d84adc3e";
      sha256 = "0krmwmzkvld3sbzkvxds578i80b8f8j0sy803zwgnpdx3ak5p9cl";
    };
  };
  vim-gemini = vimUtils.buildVimPluginFrom2Nix {
    pname = "vim-gemini";
    version = "2020.06.08";
    src = builtins.fetchGit {
      url = "https://tildegit.org/sloum/gemini-vim-syntax";
      rev = "5c206be6d5635500dd2276681050a40ddb0ba5e3";
    };
  };
  vim-syntax-vidir-ls = vimUtils.buildVimPluginFrom2Nix {
    pname = "vim-syntax-vidir-ls";
    version = "2019-04-02";
    src = builtins.fetchGit {
      url = "https://github.com/trapd00r/vim-syntax-vidir-ls";
      rev = "2b64ff03eb1a523fe0528e69804c5d19d8a809d7";
    };
  };
in buildEnv {
  inherit (vim) name;
  ignoreCollisions = true;
  paths = let
    plugins = with vimPlugins; [
      vim-nix
      vidir.vim
      vim-pgsql
      dhall-vim
      agda-vim
      nnn-vim
      vim-nginx
      LanguageClient-neovim
      vim-gemini
      purescript-vim
      vim-snipmate
      vim-snippets
      vim-addon-mw-utils # hidden dependency of vim-snipmate
      tlib
      last256
      vim-syntax-vidir-ls
      vim-bookmarks
    ];
  in [ ./vim vim ] ++ plugins;
  meta = { priority = 3; };
  buildInputs = [ makeWrapper ];
  postBuild = ''
    for path in $out/share/vim-plugins/* ; do
        echo "set rtp+=$path" >> $out/share/vim/vim82/vimrc.prefix
    done
    cat $out/share/vim/vim82/vimrc{.prefix,} > $out/share/vim/vim82/vimrc.new
    mv $out/share/vim/vim82/vimrc{.new,}
    wrapProgram $out/bin/vim --set VIM $out/share/vim/vim82
    rm $out/bin/.keepit
  '';
}

D universe/vim/src/nnn.vim.json => universe/vim/src/nnn.vim.json +0 -7
@@ 1,7 0,0 @@
{
    "owner": "mcchrish",
    "repo": "nnn.vim",
    "rev": "edfc91e1189a36a5f0d5438d7f9c575571f759fa",
    "sha256": "LmVB03rJ0wDd5oPH51+ulRBjigTeso9ePKPcKRrEv4U=",
    "fetchSubmodules": true
}
\ No newline at end of file

D universe/vim/src/vim-bookmarks.json => universe/vim/src/vim-bookmarks.json +0 -7
@@ 1,7 0,0 @@
{
    "owner": "MattesGroeger",
    "repo": "vim-bookmarks",
    "rev": "3adeae10639edcba29ea80dafa1c58cf545cb80e",
    "sha256": "dRGSKZE1A9At9KEsQMMYMvRLwoPIKuxQhitpbFnRb8Y=",
    "fetchSubmodules": false
}
\ No newline at end of file

D universe/vim/vim/bin/.keepit => universe/vim/vim/bin/.keepit +0 -2
@@ 1,2 0,0 @@
This file ensures that "buildEnv" creates $out/bin as directory,
populated with symlinks, not as symlink to ${vim}/bin.

D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/c.vim => universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/c.vim +0 -2
@@ 1,2 0,0 @@
vnoremap  <buffer> -- :!boxes -m -d c<CR>
setlocal equalprg=indent\ -linux\ -psl

D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/debchangelog.vim => universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/debchangelog.vim +0 -1
@@ 1,1 0,0 @@
setlocal sw=2

D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/dhall.vim => universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/dhall.vim +0 -2
@@ 1,2 0,0 @@
set expandtab
set shiftwidth=2

D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/execline.vim => universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/execline.vim +0 -4
@@ 1,4 0,0 @@
setlocal shiftwidth=2
setlocal tabstop=2
setlocal expandtab
let b:undo_ftplugin = ""

D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/gitcommit.vim => universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/gitcommit.vim +0 -1
@@ 1,1 0,0 @@
set textwidth=0 " conflicts with language server

D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/gmi.vim => universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/gmi.vim +0 -5
@@ 1,5 0,0 @@
set colorcolumn=0
set textwidth=0
set wrap
set wrapmargin=0
set linebreak

D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/haskell.vim => universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/haskell.vim +0 -15
@@ 1,15 0,0 @@

setlocal expandtab
setlocal shiftwidth=2
setlocal softtabstop=2
setlocal textwidth=79
setlocal equalprg=brittany

nnoremap <buffer> <leader>= m'ggVG=''

command! -bang -nargs=1 -complete=tag HSymbol call hsymbol#main(<f-args>, "<bang>")
command! -bang HSymbolWord call hsymbol#main(expand("<cword>"), "<bang>")
nnoremap <buffer> <leader>i :HSymbolWord<CR>
nnoremap <buffer> <leader>I :HSymbolWord!<CR>

au BufWrite *.hs :silent !vtags --silent 2>/dev/null &

D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/html.vim => universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/html.vim +0 -3
@@ 1,3 0,0 @@
setlocal shiftwidth=2
setlocal expandtab
setlocal softtabstop=2

D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/lua.vim => universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/lua.vim +0 -3
@@ 1,3 0,0 @@
setlocal shiftwidth=2
setlocal expandtab
setlocal softtabstop=2

D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/python.vim => universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/python.vim +0 -1
@@ 1,1 0,0 @@
set equalprg=pyfmt

D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/sh.vim => universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/sh.vim +0 -7
@@ 1,7 0,0 @@
setlocal tabstop=4
setlocal shiftwidth=4

if expand("%:t") ==# '.posixrc'
  let &path = printf("%s/prefix/config/posix", expand("%:h"))
  setlocal suffixesadd+=.sh
endif

D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/vim.vim => universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/vim.vim +0 -1
@@ 1,1 0,0 @@
setlocal shiftwidth=2

D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/yaml.vim => universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/ftplugin/yaml.vim +0 -2
@@ 1,2 0,0 @@
set expandtab
set shiftwidth=2

D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/syntax/execline.vim => universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/syntax/execline.vim +0 -49
@@ 1,49 0,0 @@
if exists("b:current_syntax") | finish | endif
syntax keyword Special background
syntax keyword Special backtick
syntax keyword Special cd
syntax keyword Special define
syntax keyword Special dollarat
syntax keyword Special elgetopt
syntax keyword Special elgetpositionals
syntax keyword Special elglob
syntax keyword Special emptyenv
syntax keyword Special exec
syntax keyword Special exitcodes
syntax keyword Special exit
syntax keyword Special export
syntax keyword Special fdblock
syntax keyword Special fdclose
syntax keyword Special fdmove
syntax keyword Special fdreserve
syntax keyword Special fdswap
syntax keyword Special forbacktickx
syntax keyword Special foreground
syntax keyword Special forstdin
syntax keyword Special forx
syntax keyword Special getcwd
syntax keyword Special getpid
syntax keyword Special heredoc
syntax keyword Special homeof
syntax keyword Special ifelse
syntax keyword Special if
syntax keyword Special ifte
syntax keyword Special ifthenelse
syntax keyword Special importas
syntax keyword Special loopwhilex
syntax keyword Special multidefine
syntax keyword Special multisubstitute
syntax keyword Special pipeline
syntax keyword Special piperw
syntax keyword Special redirfd
syntax keyword Special runblock
syntax keyword Special shift
syntax keyword Special trap
syntax keyword Special tryexec
syntax keyword Special umask
syntax keyword Special unexport
syntax keyword Special upgrade
syntax keyword Special wait
syntax keyword Special withstdinas
syntax match Function /\(^\| \):[a-z-]\+\($\| \)/
syntax match Comment /^#.*/

D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/syntax/gitcommit.vim => universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/syntax/gitcommit.vim +0 -29
@@ 1,29 0,0 @@
" Minor amendments to gitcommit.vim syntax file to encourage formatting
" commit messages more verbosely and informative. Following is added:
"
" * Highlight `m4-style' quotation. Personally, I often mix this style
"   with `markdown` one. With highlighting it is easier to be
"   consistent.
"
" * Highlight GNU-style changelog entries, like following:
"
"     * src/foo.c: reworked i/o subsistem.
"     * src/bar.c(output_object): rewrite function to avoid use of
"       stdio.
"
" * Make mode suitable for editing src(1) commit messages too.

syn region gitcommitEntry start="^ \* " end=":" transparent
  \ contains=gitcommitFilePath,gitcommitAffected
syn match gitcommitBullet "^ \*" contained
syn match gitcommitFilePath "\v^ \* [a-zA-Z0-9./_-]+" contained contains=gitcommitBullet
syn match gitcommitAffected "\v\(\zs[a-zA-Z0-9_-]+\ze\)" contained
syn match gitcommitQuote "\v`\zs[a-zA-Z/.-]+\ze'"
syn region gitcommitComment start="^\.\.\." end="^Changes to be committed:"
syn region gitcommitDiff start=/^--- / end=/______/ contains=@gitcommitDiff

hi! def link gitcommitBullet gitcommitComment
hi! def link gitcommitFilePath Type
hi! def link gitcommitBullet Title
hi! def link gitcommitAffected Identifier
hi! def link gitcommitQuote Constant

D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/syntax/sh.vim => universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/syntax/sh.vim +0 -4
@@ 1,4 0,0 @@
syntax match shSpecial "^\s*include "
syntax match shSpecial "^\s*once "
syntax match shSpecial "^\s*have "
syntax match shSpecial "^\s*optional "

D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/syntax/sql.vim => universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/after/syntax/sql.vim +0 -3
@@ 1,3 0,0 @@
set shiftwidth=2
set tabstop=2
set expandtab

D universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/autoload/hsymbol.vim => universe/vim/vim/share/vim/vim82/pack/dist/opt/personal/autoload/hsymbol.vim +0 -28
@@ 1,28 0,0 @@
let s:enum = {ix, val -> string(ix + 1) . '. ' . val}
let s:cmd  = {sym -> 'hsymbol ' . sym . '< /tmp/hsymbol.dat'}
let s:not_found = {sym -> 'symbol `' . sym . "' not found" }

function! hsymbol#main(symbol, bang) abort
  let opts = systemlist(s:cmd(a:symbol))

  if len(opts) ==# 0
    echo s:not_found(a:symbol)
    return
  endif

  let choice = opts[0]
  if len(opts) ># 1
    let header = 'What module you want?'
    let choices = map(copy(opts), s:enum)
    let ix = inputlist(extend([header], choices)[0:&lines - 2])
    let choice = opts[ix - 1]
  endif

  let ex_cmd  = 'silent %!hsimport /dev/stdin -o /dev/stdout '
  let ex_cmd .= '-s "' . a:symbol . '" '
  let ex_cmd .= choice
  if a:bang ==# '!'
    let ex_cmd .= ' -a'
  endif
  execute(ex_cmd)
endfunction

D universe/vim/vim/share/vim/vim82/vimrc => universe/vim/vim/share/vim/vim82/vimrc +0 -121
@@ 1,121 0,0 @@
set nocompatible
syntax enable
highlight Folded ctermfg=Green ctermbg=Black

filetype plugin indent on
packadd matchit
packadd personal
runtime! plugin/gzip.vim

set keymap=russian-jcukenwin
set iminsert=0
set imsearch=0

set autoindent
set cmdwinheight=4
" This teaches vim to find files references by Python's pkgutil.get_data
set path+=.;.git
set cindent
set directory=/proc/self/fd/42/.cache/vim-backup
set complete+=t "tag completion
set copyindent
set exrc
set foldclose=all
set foldlevel=0
set foldmethod=marker
set incsearch
set list
set listchars=trail:-,tab:>.
" panic action to prevent cve-2019-12735
set nomodeline
set magic
set nohlsearch
set ruler
set secure
set showmatch
set showcmd
set smartcase
set wildmenu
set wildmode=list:longest,list:longest
set infercase
set colorcolumn=80
set laststatus=0
" I love column of line numbers on the left so much, but they consume
" horizontal space and define difference between font-18 and font-14.
set nonumber

" There is no reason for .viminfo file to survive reboot. This way it
" does not clutter ~/.
let &viminfofile = "/dev/shm/" . getenv("USER") . "/.viminfo"
let g:netrw_home = "/dev/shm/" . getenv("USER")
let g:sql_type_default = 'pgsql'
let g:pgsql_pl = ['python']

" Vim thinks, that /bin/sh scripts must use backticks for command
" substitution. Make it believe that shell is actually bash.
let g:is_bash=1
let g:sh_fold_enabled=7

map Q gq
noremap j gj
noremap k gk
set tags+=codex.tags
set tags+=../tags,../../tags,../../../tags,../../../../tags

au BufWrite *.hs :silent !git codex >/dev/null 2>&1 &
au BufNewFile,BufRead *.asy setf asy
au BufNewFile,BufRead manifest setf sh

" These are huge files (~150k lines) in nixpkgs, and they hang syntax
" highlight.
au BufNewFile,BufRead all-packages.nix set syntax=off
au BufNewFile,BufRead hackage-packages.nix set syntax=off

au BufNewFile,BufRead */.mail/*/[0123456789]* setf mail
au BufNewFile,BufRead /tmp/src* setf gitcommit
au BufNewFile,BufRead *.asy setfiletype asy
au BufNewFile,BufRead manifest setfiletype sh
au BufNewFile,BufRead *.ex set filetype=execline
" Used by redo(1) build system.
au BufNewFile,BufRead *.do set filetype=sh
au BufNewFile,BufRead *.fasm setfiletype fasm
au BufNewFile,BufRead,BufWritePost *.gmi set columns=80
au BufNewFile,BufRead */mail/*/[0123456789]* setfiletype mail
au BufNewFile,BufRead syntax sync minlines=200 "slower but more correct highlighting
au BufWritePre * :silent !mkdir -p %:p:h

imap <Tab> <Plug>snipMateNextOrTrigger
smap <Tab> <Plug>snipMateNextOrTrigger
vmap <Tab> <Plug>snipMateVisual

imap <S-Tab> <Plug>snipMateBack
smap <S-Tab> <Plug>snipMateBack

imap <C-s> <Plug>snipMateShow
let g:snipMate = { 'snippet_version': 1 }
let g:LanguageClient_serverCommands = {
  \ 'c': ['ccls'],
  \ 'python': ['pyls'],
  \ 'dhall': ['dhall-lsp-server'],
  \ 'tex': ['texlab'],
  \ 'go': ['gopls'],
  \ 'nix': ['rnix-lsp'],
  \ 'haskell': ['haskell-language-server-wrapper', '--lsp']
  \ }
nmap <silent> K  <Plug>(lcn-hover)
nmap <silent> gd <Plug>(lcn-definition)
nmap <silent> gr <Plug>(lcn-rename)
nmap <silent> g? <Plug>(lcn-references)
nmap <silent> gl <Plug>(lcn-symbols)
nmap <silent> g= <Plug>(lcn-format)
nmap <silent> g. <Plug>(lcn-explain-error)
nmap <silent> g' <Plug>(lcn-code-action)
nmap <silent> g; <Plug>(lcn-code-lens-action)
set completefunc=LanguageClient#complete
set formatexpr=LanguageClient#textDocument_rangeFormatting_sync()
let g:nnn#action = {
      \ '<c-t>': 'tab split',
      \ '<c-x>': 'split',
      \ '<c-v>': 'vsplit' }
let g:nnn#replace_netrw = 1
colorscheme last256