commit 1c853edcab3261a431315a4b675f9409a3dde82e Author: Leon Vatthauer Date: Fri Feb 16 13:59:46 2024 +0100 initial commit after purge diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..3570931 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "nix-secrets"] + path = nix-secrets + url = gitea@git.vatthauer.xyz:leonv/nix-secrets.git diff --git a/common/default.nix b/common/default.nix new file mode 100755 index 0000000..475408f --- /dev/null +++ b/common/default.nix @@ -0,0 +1,11 @@ +{ pkgs, ... }: +{ + imports = [ + ./vscode.nix + ./git.nix + ./direnv.nix + ./starship.nix + ./neovim + #./vim.nix + ]; +} diff --git a/common/direnv.nix b/common/direnv.nix new file mode 100755 index 0000000..d222ccb --- /dev/null +++ b/common/direnv.nix @@ -0,0 +1,8 @@ +{ + programs.direnv = { + enable = true; + nix-direnv = { + enable = true; + }; + }; +} \ No newline at end of file diff --git a/common/doom.d/config.el b/common/doom.d/config.el new file mode 100644 index 0000000..e69de29 diff --git a/common/doom.d/init.el b/common/doom.d/init.el new file mode 100644 index 0000000..e69de29 diff --git a/common/doom.d/packages.el b/common/doom.d/packages.el new file mode 100644 index 0000000..e69de29 diff --git a/common/eww/config/eww.scss b/common/eww/config/eww.scss new file mode 100644 index 0000000..c053b74 --- /dev/null +++ b/common/eww/config/eww.scss @@ -0,0 +1,109 @@ +// catppuccin colors +$rosewater: #f4dbd6; +$flamingo: #f0c6c6; +$pink: #f5bde6; +$mauve: #c6a0f6; +$red: #ed8796; +$maroon: #ee99a0; +$peach: #f5a97f; +$yellow: #eed49f; +$green: #a6da95; +$teal: #8bd5ca; +$sky: #91d7e3; +$sapphire: #7dc4e4; +$blue: #8aadf4; +$lavender: #b7bdf8; +$accent: $flamingo; +$text: #cad3f5; +$subtext1: #b8c0e0; +$subtext0: #a5adcb; +$overlay2: #939ab7; +$overlay1: #8087a2; +$overlay0: #6e738d; +$surface2: #5b6078; +$surface1: #494d64; +$surface0: #363a4f; +$base: #24273a; +$mantle: #1e2030; +$crust: #181926; + +*{ + all: unset; + font-family: "monospace"; +} + +// .bar { +// background-color: $base; +// border-radius: 16px; +// } + +.container { + background-color: $base; + border-radius: 16px; +} + +tooltip.background { + background-color: #0f0f17; + font-size: 18px; + border-radius: 10px; + color: #bfc9db; +} + +tooltip label { + margin: 6px; +} + +.time { + font-size: 18px; + margin: 0px 20px 0px 10px; + color: $teal; + font-weight: bold; +} + +.volume_text { + font-size: 18px; + color: $maroon; + margin: 0px 10px 0px 10px; +} + +.network_icon { + font-size: 18px; + color: $green; + margin: 0px 10px 0px 10px; +} +.bluetooth_icon { + font-size: 18px; + color: $blue; + margin: 0px 10px 0px 10px; +} +.cpu_text { + font-size: 18px; + color: $maroon; + margin: 0px 10px 0px 10px; +} +.mem_text { + font-size: 18px; + color: $yellow; + margin: 0px 10px 0px 10px; +} + +.workspaces-widget { + color: $sky; + font-size: 22px; +} + +.workspaces-widget .empty { + color: rgba($sky, 0.3); +} + +.title { + color: $mauve; + font-size: 16px; + padding: 0px 5px 0px 5px; +} + +.nixos-icon { + font-size: 22px; + color: #7CB5DE; + margin: 0px 10px 0px 10px; +} \ No newline at end of file diff --git a/common/eww/config/eww.yuck b/common/eww/config/eww.yuck new file mode 100644 index 0000000..be74b1d --- /dev/null +++ b/common/eww/config/eww.yuck @@ -0,0 +1,51 @@ +; inspired by https://github.com/saimoomedits/eww-widgets/tree/main + +(include "./widgets/workspaces/eww.yuck") +(include "./widgets/window-title/eww.yuck") +(include "./widgets/resources/eww.yuck") + +(defwindow top-bar + :monitor 0 + :geometry (geometry :x "0%" + :y "10px" + :width "98.8%" + :height "30px" + :anchor "top center") + :stacking "fg" + :exclusive true + (centerbox + :class "bar" + (left) + (center) + (right))) + +(defwidget left [] + (box + :space-evenly false + :halign "start" + :class "container" + (label :text "" :class "nixos-icon") + (workspaces) + )) + +(defwidget center [] + (box + :space-evenly false + :halign "center" + :class "container" + :visible {strlength(window) != 0} + (windowtitle) + )) + +(defwidget right [] + (box + :space-evenly false + :halign "end" + :class "container" + (volume) + (cpu) + (mem) + (network) + (bluetooth) + (datetime) + )) diff --git a/common/eww/config/widgets/resources/eww.yuck b/common/eww/config/widgets/resources/eww.yuck new file mode 100644 index 0000000..b647f2a --- /dev/null +++ b/common/eww/config/widgets/resources/eww.yuck @@ -0,0 +1,92 @@ +; for unicode symbols: https://jrgraphix.net/r/Unicode/E000-F8FF + +; VARIABLES + +(defvar GB 1024000000) +(defvar MB 1024000) + +; DATE + TIME + +(defpoll time :interval "5s" + :initial "" + `date +%H:%M`) +(defpoll date :interval "60s" + :initial "" + `date "+%A | %m-%d-%+4Y"`) + +(defwidget datetime [] + (eventbox + :tooltip date + (label + :class "text time" + :text time) + )) + +; CPU + +(defwidget cpu [] + (box + :active true + :tooltip "${round(EWW_CPU.cores[0].freq/1000,2)} GHz" + (label + :class "cpu_text" + :text " ${round(EWW_CPU.avg,0)}%") + ) +) + +; MEMORY +(defwidget mem [] + (box + :active true + :tooltip {EWW_RAM.used_mem / GB < 1 ? "${round(EWW_RAM.used_mem / MB, 1)} M used" : "${round(EWW_RAM.used_mem / GB, 1)} G used"} + (label + :class "mem_text" + :text " ${round(EWW_RAM.used_mem_perc,0)}%") + ) +) + +; TEMP +; TODO temperature widget (hover to show all times sorted nicely) +;  + +; NETWORK + +(defpoll hostname :interval "1m" :initial "" "hostname") +(defpoll status-icon :interval "5s" :initial "" "./widgets/resources/network.sh") + +(defwidget network [] + (eventbox + :active true + :onclick "/usr/bin/env nm-connection-editor &" + :tooltip hostname + (label + :text status-icon + :class "network_icon"))) + +; BLUETOOTH +(defwidget bluetooth [] + (eventbox + :active true + :onclick "blueman-manager &" + (label + :text "" + :class "bluetooth_icon"))) + +; VOLUME + +(defpoll volume_percent :interval "0.1s" :initial "40" "amixer sget Master | grep 'Left:' | awk -F'[][]' '{ print $2 }' | tr -d '%'") + +(defwidget volume [] + (eventbox + :active true + :onclick "/usr/bin/env pavucontrol &" + :onscroll "if [ {} = 'up' ]; then wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+; else wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%-; fi" ; wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%- + (box + :space-evenly false + :orientation "h" + :spacing "3" + (label + :class "volume_text" + :text "${volume_percent <= 33 ? "" : volume_percent <= 66 ? "" : ""} ${volume_percent}%") + ))) +; TODO add mic widget \ No newline at end of file diff --git a/common/eww/config/widgets/resources/network.sh b/common/eww/config/widgets/resources/network.sh new file mode 100755 index 0000000..a42907f --- /dev/null +++ b/common/eww/config/widgets/resources/network.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +status=$(nmcli g | grep -oE "disconnected") + +if [ $status ] ; then + echo "✘" +else + echo "" +fi diff --git a/common/eww/config/widgets/window-title/eww.yuck b/common/eww/config/widgets/window-title/eww.yuck new file mode 100644 index 0000000..66ff506 --- /dev/null +++ b/common/eww/config/widgets/window-title/eww.yuck @@ -0,0 +1,7 @@ +(deflisten window :initial "" "sh ./widgets/window-title/get-window-title.sh") +(defwidget windowtitle [] + (box :class "title" + (label :text {window == "null" ? "" : window} :class "title" + ) + ) +) \ No newline at end of file diff --git a/common/eww/config/widgets/window-title/get-window-title.sh b/common/eww/config/widgets/window-title/get-window-title.sh new file mode 100644 index 0000000..f5a494a --- /dev/null +++ b/common/eww/config/widgets/window-title/get-window-title.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +hyprctl activewindow -j | jq --raw-output .title +socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | stdbuf -o0 awk -F '>>|,' '/^activewindow>>/{print $3}' \ No newline at end of file diff --git a/common/eww/config/widgets/workspaces/change-active-workspace.sh b/common/eww/config/widgets/workspaces/change-active-workspace.sh new file mode 100644 index 0000000..19b559a --- /dev/null +++ b/common/eww/config/widgets/workspaces/change-active-workspace.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +function clamp { + min=$1 + max=$2 + val=$3 + python -c "print(max($min, min($val, $max)))" +} + +direction=$1 +current=$2 +if test "$direction" = "down" +then + target=$(clamp 1 10 $(($current+1))) + echo "jumping to $target" + hyprctl dispatch workspace $target +elif test "$direction" = "up" +then + target=$(clamp 1 10 $(($current-1))) + echo "jumping to $target" + hyprctl dispatch workspace $target +fi \ No newline at end of file diff --git a/common/eww/config/widgets/workspaces/eww.yuck b/common/eww/config/widgets/workspaces/eww.yuck new file mode 100644 index 0000000..b361931 --- /dev/null +++ b/common/eww/config/widgets/workspaces/eww.yuck @@ -0,0 +1,18 @@ +(deflisten workspaces :initial "[]" "bash ./widgets/workspaces/get-workspaces.sh") +(deflisten current_workspace :initial "1" "bash ./widgets/workspaces/get-active-workspace.sh") + +(defwidget workspaces [] + (eventbox :onscroll "bash ./widgets/workspaces/change-active-workspace.sh {} ${current_workspace}" :class "workspaces-widget" + (box :space-evenly true + (label :text "${workspaces}${current_workspace}" :visible false) + (for workspace in workspaces + (eventbox :onclick "hyprctl dispatch workspace ${workspace.id}" + (box :width "30" :height "30" :class "workspace-entry ${workspace.id == current_workspace ? "current" : ""} ${workspace.windows > 0 ? "occupied" : "empty"}" + (label :text {workspace.id == current_workspace ? "" : workspace.windows > 0 ? "" : ""} + ) + ) + ) + ) + ) + ) +) \ No newline at end of file diff --git a/common/eww/config/widgets/workspaces/get-active-workspace.sh b/common/eww/config/widgets/workspaces/get-active-workspace.sh new file mode 100755 index 0000000..0ebac7b --- /dev/null +++ b/common/eww/config/widgets/workspaces/get-active-workspace.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +hyprctl monitors -j | jq '.[] | select(.focused) | .activeWorkspace.id' + +socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | + stdbuf -o0 awk -F '>>|,' -e '/^workspace>>/ {print $2}' -e '/^focusedmon>>/ {print $3}' \ No newline at end of file diff --git a/common/eww/config/widgets/workspaces/get-workspaces.sh b/common/eww/config/widgets/workspaces/get-workspaces.sh new file mode 100755 index 0000000..fa7d904 --- /dev/null +++ b/common/eww/config/widgets/workspaces/get-workspaces.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +spaces (){ + WORKSPACE_WINDOWS=$(hyprctl workspaces -j | jq 'map({key: .id | tostring, value: .windows}) | from_entries') + seq 1 10 | jq --argjson windows "${WORKSPACE_WINDOWS}" --slurp -Mc 'map(tostring) | map({id: ., windows: ($windows[.]//0)})' +} + +spaces +socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do + spaces +done \ No newline at end of file diff --git a/common/eww/default.nix b/common/eww/default.nix new file mode 100644 index 0000000..65ec07e --- /dev/null +++ b/common/eww/default.nix @@ -0,0 +1,8 @@ +{ pkgs, ... }: +{ + programs.eww = { + enable = true; + package = pkgs.eww-wayland; + configDir = ./config; + }; +} \ No newline at end of file diff --git a/common/git.nix b/common/git.nix new file mode 100755 index 0000000..8b2e56b --- /dev/null +++ b/common/git.nix @@ -0,0 +1,24 @@ +{ + programs.git = { + enable = true; + lfs.enable = true; + extraConfig = { + init = { + defaultBranch = "main"; + }; + }; + includes = [ + { + contents = { + gpg.format = "ssh"; + user = { + name = "Leon Vatthauer"; + email = "leon.vatthauer@fau.de"; + signingkey = "~/.ssh/git"; + }; + commit.gpgsign = true; + }; + } + ]; + }; +} diff --git a/common/neovim/coc.nix b/common/neovim/coc.nix new file mode 100644 index 0000000..2c2f526 --- /dev/null +++ b/common/neovim/coc.nix @@ -0,0 +1,185 @@ +{ pkgs, ...}: +{ + programs.neovim = { + coc = { + enable = true; + settings = { + languageserver = { + haskell = { + command = "haskell-language-server-wrapper"; + args = [ "--lsp" ]; + rootPatterns = [ + "*.cabal" + "cabal.project" + "hie.yaml" + ]; + filetypes = [ "haskell" "lhaskell" ]; + }; + }; + }; + }; + plugins = with pkgs.vimPlugins; [ + { + plugin = coc-nvim; + config = '' + " Having longer updatetime (default is 4000 ms = 4s) leads to noticeable + " delays and poor user experience + set updatetime=300 + + " Always show the signcolumn, otherwise it would shift the text each time + " diagnostics appear/become resolved + set signcolumn=yes + + " Use tab for trigger completion with characters ahead and navigate + " NOTE: There's always complete item selected by default, you may want to enable + " no select by `"suggest.noselect": true` in your configuration file + " NOTE: Use command ':verbose imap ' to make sure tab is not mapped by + " other plugin before putting this into your config + inoremap + \ coc#pum#visible() ? coc#pum#next(1) : + \ CheckBackspace() ? "\" : + \ coc#refresh() + inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" + + " Make to accept selected completion item or notify coc.nvim to format + " u breaks current undo, please make your own choice + inoremap coc#pum#visible() ? coc#pum#confirm() + \: "\u\\=coc#on_enter()\" + + function! CheckBackspace() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' + endfunction + + " Use to trigger completion + if has('nvim') + inoremap coc#refresh() + else + inoremap coc#refresh() + endif + + " Use `[g` and `]g` to navigate diagnostics + " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list + nmap [g (coc-diagnostic-prev) + nmap ]g (coc-diagnostic-next) + + " GoTo code navigation + nmap gd (coc-definition) + nmap gy (coc-type-definition) + nmap gi (coc-implementation) + nmap gr (coc-references) + + " Use K to show documentation in preview window + nnoremap K :call ShowDocumentation() + + function! ShowDocumentation() + if CocAction('hasProvider', 'hover') + call CocActionAsync('doHover') + else + call feedkeys('K', 'in') + endif + endfunction + + " Highlight the symbol and its references when holding the cursor + autocmd CursorHold * silent call CocActionAsync('highlight') + + " Symbol renaming + nmap rn (coc-rename) + + " Formatting selected code + xmap f (coc-format-selected) + nmap f (coc-format-selected) + + augroup mygroup + autocmd! + " Setup formatexpr specified filetype(s) + autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') + " Update signature help on jump placeholder + autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') + augroup end + + " Applying code actions to the selected code block + " Example: `aap` for current paragraph + xmap a (coc-codeaction-selected) + nmap a (coc-codeaction-selected) + + " Remap keys for applying code actions at the cursor position + nmap ac (coc-codeaction-cursor) + " Remap keys for apply code actions affect whole buffer + nmap as (coc-codeaction-source) + " Apply the most preferred quickfix action to fix diagnostic on the current line + nmap qf (coc-fix-current) + + " Remap keys for applying refactor code actions + nmap re (coc-codeaction-refactor) + xmap r (coc-codeaction-refactor-selected) + nmap r (coc-codeaction-refactor-selected) + + " Run the Code Lens action on the current line + nmap cl (coc-codelens-action) + + " Map function and class text objects + " NOTE: Requires 'textDocument.documentSymbol' support from the language server + xmap if (coc-funcobj-i) + omap if (coc-funcobj-i) + xmap af (coc-funcobj-a) + omap af (coc-funcobj-a) + xmap ic (coc-classobj-i) + omap ic (coc-classobj-i) + xmap ac (coc-classobj-a) + omap ac (coc-classobj-a) + + " Remap and to scroll float windows/popups + if has('nvim-0.4.0') || has('patch-8.2.0750') + nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" + nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" + inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" + inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" + vnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" + vnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" + endif + + " Use CTRL-S for selections ranges + " Requires 'textDocument/selectionRange' support of language server + nmap (coc-range-select) + xmap (coc-range-select) + + " Add `:Format` command to format current buffer + command! -nargs=0 Format :call CocActionAsync('format') + " Add `:Fold` command to fold current buffer + command! -nargs=? Fold :call CocAction('fold', ) + + " Add `:OR` command for organize imports of the current buffer + command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport') + + " Add (Neo)Vim's native statusline support + " NOTE: Please see `:h coc-status` for integrations with external plugins that + " provide custom statusline: lightline.vim, vim-airline + + " Mappings for CoCList + " Show all diagnostics + nnoremap a :CocList diagnostics + " Manage extensions + nnoremap e :CocList extensions + " Show commands + nnoremap c :CocList commands + " Find symbol of current document + nnoremap o :CocList outline + " Search workspace symbols + nnoremap s :CocList -I symbols + " Do default action for next item + nnoremap j :CocNext + " Do default action for previous item + nnoremap k :CocPrev + " Resume latest coc list + nnoremap p :CocListResume + ''; + } + coc-git + coc-snippets + vim-snippets + coc-vimtex + vim-lightline-coc + ]; + }; +} diff --git a/common/neovim/coq.nix b/common/neovim/coq.nix new file mode 100644 index 0000000..bcad816 --- /dev/null +++ b/common/neovim/coq.nix @@ -0,0 +1,15 @@ +{ pkgs, ... }: +{ + programs.neovim = { + plugins = with pkgs.vimPlugins; [ + { + plugin = Coqtail; + config = '' + nnoremap CoqNextCoqJumpToEnd + nnoremap CoqUndoCoqJumpToEnd + nnoremap CoqToLine + ''; + } + ]; + }; +} diff --git a/common/neovim/default.nix b/common/neovim/default.nix new file mode 100644 index 0000000..6b86429 --- /dev/null +++ b/common/neovim/default.nix @@ -0,0 +1,32 @@ +{ pkgs, ... }: +{ + imports = [ + ./haskell.nix + ./coq.nix + ./telescope.nix + ./coc.nix + ./lightline.nix + ./nerdtree.nix + ./treesitter.nix + ]; + programs.neovim = { + enable = true; + extraConfig = import ./nvimrc.nix; + plugins = with pkgs.vimPlugins; [ + # languages + nvim-dap + nvim-lspconfig + vim-nix + vimtex + + # look and feel + awesome-vim-colorschemes + fugitive + ]; + withPython3 = true; + withNodeJs = true; + defaultEditor = true; + viAlias = true; + vimAlias = true; + }; +} diff --git a/common/neovim/haskell.nix b/common/neovim/haskell.nix new file mode 100644 index 0000000..ab79d12 --- /dev/null +++ b/common/neovim/haskell.nix @@ -0,0 +1,18 @@ +# haskell integration, adapted from @srid +# https://github.com/srid/nixos-config/blob/master/home/neovim/haskell.nix + +{ pkgs, ... }: +{ + programs.neovim = { + plugins = with pkgs.vimPlugins; [ + haskell-vim + vim-hoogle + ]; + extraLuaConfig = '' + -- Setup language servers. + local lspconfig = require('lspconfig') + lspconfig.hls.setup {} + ''; + + }; +} \ No newline at end of file diff --git a/common/neovim/lightline.nix b/common/neovim/lightline.nix new file mode 100644 index 0000000..51c8ad8 --- /dev/null +++ b/common/neovim/lightline.nix @@ -0,0 +1,30 @@ +{ pkgs, ...}: +{ + programs.neovim = { + plugins = with pkgs.vimPlugins; [ + { + plugin = lightline-vim; + config = '' + function! CocCurrentFunction() + return get(b:, 'coc_current_function', ''\'') + endfunction + + let g:lightline = { + \ 'colorscheme': 'solarized', + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], + \ [ 'cocstatus', 'currentfunction', 'readonly', 'filename', 'modified' ], + \ [ 'gitbranch' ] ] + \ }, + \ 'component_function': { + \ 'cocstatus': 'coc#status', + \ 'currentfunction': 'CocCurrentFunction', + \ 'gitbranch': 'FugitiveHead' + \ }, + \ } + + ''; + } + ]; + }; +} diff --git a/common/neovim/nerdtree.nix b/common/neovim/nerdtree.nix new file mode 100644 index 0000000..c8ac46a --- /dev/null +++ b/common/neovim/nerdtree.nix @@ -0,0 +1,27 @@ +{ pkgs, ... }: +{ + programs.neovim = { + plugins = with pkgs.vimPlugins; [ + { + plugin = nerdtree; + config = '' + nnoremap + nnoremap + nnoremap + nnoremap + nnoremap :NERDTreeToggle + nnoremap :NERDTreeFocus + " Exit Vim if NERDTree is the only window remaining in the only tab. + autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif + + " Close the tab if NERDTree is the only window remaining in it. + autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif + " If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree. + autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | + \ let buf=bufnr() | buffer# | execute "normal! \w" | execute 'buffer'.buf | endif + ''; + } + nerdtree-git-plugin + ]; + }; +} diff --git a/common/neovim/nvimrc.nix b/common/neovim/nvimrc.nix new file mode 100644 index 0000000..528358e --- /dev/null +++ b/common/neovim/nvimrc.nix @@ -0,0 +1,296 @@ +'' +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => General +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +set mouse=a +" Sets how many lines of history VIM has to remember +set history=500 + +" Enable filetype plugins +filetype plugin on +filetype indent on + +" Set to auto read when a file is changed from the outside +set autoread +au FocusGained,BufEnter * checktime + +" Fast saving +nmap s :w! + +" :W sudo saves the file +" (useful for handling the permission-denied error) +command! W execute 'w !sudo tee % > /dev/null' edit! + +" clipboard +set clipboard^=unnamed,unnamedplus + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => VIM user interface +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Set 7 lines to the cursor - when moving vertically using j/k +set so=7 + +" Avoid garbled characters in Chinese language windows OS +let $LANG='en' +set langmenu=en +source $VIMRUNTIME/delmenu.vim +source $VIMRUNTIME/menu.vim + +" Turn on the Wild menu +set wildmenu + +set relativenumber + +" Ignore compiled files +set wildignore=*.o,*~,*.pyc +if has("win16") || has("win32") + set wildignore+=.git\*,.hg\*,.svn\* +else + set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store +endif + +"Always show current position +set ruler + +" Height of the command bar +set cmdheight=1 + +" A buffer becomes hidden when it is abandoned +set hid + +" Configure backspace so it acts as it should act +set backspace=eol,start,indent +set whichwrap+=<,>,h,l + +" Ignore case when searching +set ignorecase + +" When searching try to be smart about cases +set smartcase + +" Highlight search results +set hlsearch + +" Makes search act like search in modern browsers +set incsearch + +" Don't redraw while executing macros (good performance config) +set lazyredraw + +" For regular expressions turn magic on +set magic + +" Show matching brackets when text indicator is over them +set showmatch +" How many tenths of a second to blink when matching brackets +set mat=2 + +" No annoying sound on errors +set noerrorbells +set novisualbell +set t_vb= +set tm=500 + +" Properly disable sound on errors on MacVim +if has("gui_macvim") + autocmd GUIEnter * set vb t_vb= +endif + + +" Add a bit extra margin to the left +set foldcolumn=1 + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Colors and Fonts +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Enable syntax highlighting +syntax enable + +" Enable 256 colors palette in Gnome Terminal +if $COLORTERM == 'gnome-terminal' + set t_Co=256 +endif + +try + colorscheme solarized8_high +catch +endtry + +set background=dark + +" Set extra options when running in GUI mode +if has("gui_running") + set guioptions-=T + set guioptions-=e + set t_Co=256 + set guitablabel=%M\ %t +endif + +" Set utf8 as standard encoding and en_US as the standard language +set encoding=utf8 + +" Use Unix as the standard file type +set ffs=unix,dos,mac + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Files, backups and undo +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Turn backup off, since most stuff is in SVN, git etc. anyway... +set nobackup +set nowb +set noswapfile + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Text, tab and indent related +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Use spaces instead of tabs +set expandtab + +" Be smart when using tabs ;) +set smarttab + +" 1 tab == 4 spaces +set shiftwidth=4 +set tabstop=4 + +" Linebreak on 500 characters +set lbr +set tw=500 + +set ai "Auto indent +set si "Smart indent +set wrap "Wrap lines + + +"""""""""""""""""""""""""""""" +" => Visual mode related +"""""""""""""""""""""""""""""" +" Visual mode pressing * or # searches for the current selection +" Super useful! From an idea by Michael Naumann +vnoremap * :call VisualSelection(''\'', ''\'')/=@/ +vnoremap # :call VisualSelection(''\'', ''\'')?=@/ + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Moving around, tabs, windows and buffers +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Map to / (search) and Ctrl- to ? (backwards search) +"map / +"map ? + +" Disable highlight when is pressed +"map :noh + +" Smart way to move between windows +"map j +"map k +"map h +"map l + +" Close the current buffer +"map bd :Bclose:tabclosegT + +" Close all the buffers +"map ba :bufdo bd + +"map bl :bnext +"map bh :bprevious + +" Useful mappings for managing tabs +"map tn :tabnew +"map to :tabonly +"map tc :tabclose +"map tm :tabmove +"map t :tabnext + +" Let 'tl' toggle between this and the last accessed tab +"let g:lasttab = 1 +"nmap tl :exe "tabn ".g:lasttab +"au TabLeave * let g:lasttab = tabpagenr() + + +" Opens a new tab with the current buffer's path +" Super useful when editing files in the same directory +"map te :tabedit =expand("%:p:h")/ + +" Switch CWD to the directory of the open buffer +"map cd :cd %:p:h:pwd + +" Specify the behavior when switching between buffers +"try +" set switchbuf=useopen,usetab,newtab +" set stal=2 +"catch +"endtry + +" Return to last edit position when opening files (You want this!) +"au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif + + +"""""""""""""""""""""""""""""" +" => Status line +"""""""""""""""""""""""""""""" +" Always show the status line +"set laststatus=2 + +" Format the status line +"set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Editing mappings +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Remap VIM 0 to first non-blank character +"map 0 ^ + +" Move a line of text using ALT+[jk] or Command+[jk] on mac +"nmap mz:m+`z +"nmap mz:m-2`z +"vmap :m'>+`mzgv`yo`z +"vmap :m'<-2`>my` +" nmap +" vmap +" vmap +"endif + +"" Delete trailing white space on save, useful for some filetypes ;) +"fun! CleanExtraSpaces() +" let save_cursor = getpos(".") +" let old_query = getreg('/') +" silent! %s/\s\+$//e +" call setpos('.', save_cursor) +" call setreg('/', old_query) +"endfun + +"if has("autocmd") +" autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces() +"endif + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => EXTRAS BY LEON +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" Better splitting +set splitbelow +set splitright +" Enable mouse + +set noshowmode + +augroup neovim_terminal + autocmd! + " Enter Terminal-mode (insert) automatically + autocmd TermOpen * startinsert + " Disables number lines on terminal buffers + autocmd TermOpen * :set nonumber norelativenumber + " allows you to use Ctrl-c on terminal window + autocmd TermOpen * nnoremap i +augroup END +'' diff --git a/common/neovim/telescope.nix b/common/neovim/telescope.nix new file mode 100644 index 0000000..71449c5 --- /dev/null +++ b/common/neovim/telescope.nix @@ -0,0 +1,38 @@ +{ pkgs, ... }: +{ + programs.neovim = { + plugins = with pkgs.vimPlugins; [ + { + plugin = telescope-nvim; + type = "lua"; + config = '' + local telescope = require('telescope') + telescope.setup { + extensions = { + coc = { + theme = 'ivy', + prefer_locations = true, -- always use Telescope locations to preview definitions/declarations/implementations etc + } + }, + } + telescope.load_extension('hoogle') + telescope.load_extension('coc') + function map (mode, shortcut, command) + vim.api.nvim_set_keymap(mode, shortcut, command, { noremap = true, silent = true }) + end + map('n', "ff", ":Telescope find_files") + map('n', "fg", ":Telescope live_grep") + map('n', "fb", ":Telescope buffers") + map('n', "fH", ":Telescope help_tags") + map('n', "fd", ":Telescope lsp_definitions") + map('n', "fs", ":Telescope lsp_document_symbols") + map('n', "fS", ":Telescope lsp_workspace_symbols") + map('n', "fh", ":Telescope hoogle") + ''; + } + telescope-coc-nvim + telescope_hoogle + plenary-nvim + ]; + }; +} \ No newline at end of file diff --git a/common/neovim/treesitter.nix b/common/neovim/treesitter.nix new file mode 100644 index 0000000..8a8cb22 --- /dev/null +++ b/common/neovim/treesitter.nix @@ -0,0 +1,13 @@ +{ pkgs, ... }: +{ + programs.neovim = { + plugins = with pkgs.vimPlugins; [ + nvim-treesitter + nvim-treesitter-parsers.haskell + nvim-treesitter-parsers.latex + nvim-treesitter-parsers.bibtex + nvim-treesitter-parsers.rust + nvim-treesitter-parsers.agda + ]; + }; +} diff --git a/common/starship.nix b/common/starship.nix new file mode 100755 index 0000000..ede36bc --- /dev/null +++ b/common/starship.nix @@ -0,0 +1,17 @@ +{ pkgs, ... }: +{ + programs.starship = { + enable = true; + settings = { + format = "$all"; + palette = "catppuccin_macchiato"; + gradle.symbol = "🐘"; + } // builtins.fromTOML (builtins.readFile + (pkgs.fetchFromGitHub { + owner = "catppuccin"; + repo = "starship"; + rev = "5629d2356f62a9f2f8efad3ff37476c19969bd4f"; + sha256 = "sha256-nsRuxQFKbQkyEI4TXgvAjcroVdG+heKX5Pauq/4Ota0="; + } + /palettes/macchiato.toml)); + }; +} \ No newline at end of file diff --git a/common/vim.nix b/common/vim.nix new file mode 100644 index 0000000..d9e7990 --- /dev/null +++ b/common/vim.nix @@ -0,0 +1,28 @@ +{ pkgs, ...}: +{ + programs.vim = { + enable = true; + extraConfig = import ./vimrc.nix; + plugins = with pkgs.vimPlugins; [ + # specific language support + vim-nix + Coqtail + vimtex + + # general plugins + nerdtree + fugitive + nerdtree-git-plugin + vim-lsp + vim-snippets + lightline-vim + vim-colorschemes + + # CoC + coc-nvim + coc-git + coc-snippets + ]; + defaultEditor = true; + }; +} \ No newline at end of file diff --git a/common/vimrc.nix b/common/vimrc.nix new file mode 100644 index 0000000..fa3ae70 --- /dev/null +++ b/common/vimrc.nix @@ -0,0 +1,604 @@ +'' +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Maintainer: +" Amir Salihefendic - @amix3k +" Forked by: +" Leon Vatthauer - @reijix +" +" Sections: +" -> General +" -> VIM user interface +" -> Colors and Fonts +" -> Files and backups +" -> Text, tab and indent related +" -> Visual mode related +" -> Moving around, tabs and buffers +" -> Status line +" -> Editing mappings +" -> vimgrep searching and cope displaying +" -> Spell checking +" -> Misc +" -> Helper functions +" +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => General +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Sets how many lines of history VIM has to remember +set history=500 + +" Enable filetype plugins +filetype plugin on +filetype indent on + +" Set to auto read when a file is changed from the outside +set autoread +au FocusGained,BufEnter * checktime + +" With a map leader it's possible to do extra key combinations +" like w saves the current file +let mapleader = "," + +" Fast saving +nmap w :w! + +" :W sudo saves the file +" (useful for handling the permission-denied error) +command! W execute 'w !sudo tee % > /dev/null' edit! + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => VIM user interface +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Set 7 lines to the cursor - when moving vertically using j/k +set so=7 + +" Avoid garbled characters in Chinese language windows OS +let $LANG='en' +set langmenu=en +source $VIMRUNTIME/delmenu.vim +source $VIMRUNTIME/menu.vim + +" Turn on the Wild menu +set wildmenu + +" Ignore compiled files +set wildignore=*.o,*~,*.pyc +if has("win16") || has("win32") + set wildignore+=.git\*,.hg\*,.svn\* +else + set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store +endif + +" Always show current position +set ruler +set relativenumber + +" Height of the command bar +set cmdheight=1 + +" A buffer becomes hidden when it is abandoned +set hid + +" Configure backspace so it acts as it should act +set backspace=eol,start,indent +set whichwrap+=<,>,h,l + +" Ignore case when searching +set ignorecase + +" When searching try to be smart about cases +set smartcase + +" Highlight search results +set hlsearch + +" Makes search act like search in modern browsers +set incsearch + +" Don't redraw while executing macros (good performance config) +set lazyredraw + +" For regular expressions turn magic on +set magic + +" Show matching brackets when text indicator is over them +set showmatch + +" How many tenths of a second to blink when matching brackets +set mat=2 + +" No annoying sound on errors +set noerrorbells +set novisualbell +set t_vb= +set tm=500 + +" Properly disable sound on errors on MacVim +if has("gui_macvim") + autocmd GUIEnter * set vb t_vb= +endif + +" Add a bit extra margin to the left +set foldcolumn=1 + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Colors and Fonts +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Enable syntax highlighting +syntax enable + +" Set regular expression engine automatically +set regexpengine=0 + +" Enable 256 colors palette in Gnome Terminal +"if $COLORTERM == 'gnome-terminal' +" set t_Co=256 +"endif + +" termcolors for theme +set termguicolors + +try + colorscheme molokai +catch +endtry + +set background=dark + +" Set extra options when running in GUI mode +if has("gui_running") + set guioptions-=T + set guioptions-=e + set t_Co=256 + set guitablabel=%M\ %t +endif + +" Set utf8 as standard encoding and en_US as the standard language +set encoding=utf8 + +" Use Unix as the standard file type +set ffs=unix,dos,mac + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Files, backups and undo +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Turn backup off, since most stuff is in SVN, git etc. anyway... +set nobackup +set nowb +set noswapfile + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Text, tab and indent related +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Use spaces instead of tabs +set expandtab + +" Be smart when using tabs ;) +set smarttab + +" 1 tab == 4 spaces +set shiftwidth=4 +set tabstop=4 + +" Linebreak on 500 characters +set lbr +set tw=500 + +set ai "Auto indent +set si "Smart indent +set wrap "Wrap lines + + +"""""""""""""""""""""""""""""" +" => Visual mode related +"""""""""""""""""""""""""""""" +" Visual mode pressing * or # searches for the current selection +" Super useful! From an idea by Michael Naumann +vnoremap * :call VisualSelection(''\'', ''\'')/=@/ +vnoremap # :call VisualSelection(''\'', ''\'')?=@/ + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Moving around, tabs, windows and buffers +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Map to / (search) and Ctrl- to ? (backwards search) +map / +map ? + +" Disable highlight when is pressed +map :noh + +" Smart way to move between windows +map j +map k +map h +map l + +" Close the current buffer +map bd :Bclose:tabclosegT + +" Close all the buffers +map ba :bufdo bd + +map l :bnext +map h :bprevious + +" Useful mappings for managing tabs +map tn :tabnew +map to :tabonly +map tc :tabclose +map tm :tabmove +map t :tabnext + +" Let 'tl' toggle between this and the last accessed tab +let g:lasttab = 1 +nmap tl :exe "tabn ".g:lasttab +au TabLeave * let g:lasttab = tabpagenr() + + +" Opens a new tab with the current buffer's path +" Super useful when editing files in the same directory +map te :tabedit =escape(expand("%:p:h"), " ")/ + +" Switch CWD to the directory of the open buffer +map cd :cd %:p:h:pwd + +" Specify the behavior when switching between buffers +try + set switchbuf=useopen,usetab,newtab + set stal=2 +catch +endtry + +" Return to last edit position when opening files (You want this!) +au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif + + +"""""""""""""""""""""""""""""" +" => Status line +"""""""""""""""""""""""""""""" +" Always show the status line +set laststatus=2 + +" Format the status line +set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Editing mappings +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Remap VIM 0 to first non-blank character +map 0 ^ + +" Move a line of text using ALT+[jk] or Command+[jk] on mac +nmap mz:m+`z +nmap mz:m-2`z +vmap :m'>+`mzgv`yo`z +vmap :m'<-2`>my` + nmap + vmap + vmap +endif + +" Delete trailing white space on save, useful for some filetypes ;) +fun! CleanExtraSpaces() + let save_cursor = getpos(".") + let old_query = getreg('/') + silent! %s/\s\+$//e + call setpos('.', save_cursor) + call setreg('/', old_query) +endfun + +if has("autocmd") + autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces() +endif + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Spell checking +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Pressing ,ss will toggle and untoggle spell checking +map ss :setlocal spell! + +" Shortcuts using +map sn ]s +map sp [s +map sa zg +map s? z= + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Misc +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Remove the Windows ^M - when the encodings gets messed up +noremap m mmHmt:%s///ge'tzt'm + +" Quickly open a buffer for scribble +map q :e ~/buffer + +" Quickly open a markdown buffer for scribble +map x :e ~/buffer.md + +" Toggle paste mode on and off +map pp :setlocal paste! + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Helper functions +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Returns true if paste mode is enabled +function! HasPaste() + if &paste + return 'PASTE MODE ' + endif + return ''\'' +endfunction + +" Don't close window, when deleting a buffer +command! Bclose call BufcloseCloseIt() +function! BufcloseCloseIt() + let l:currentBufNum = bufnr("%") + let l:alternateBufNum = bufnr("#") + + if buflisted(l:alternateBufNum) + buffer # + else + bnext + endif + + if bufnr("%") == l:currentBufNum + new + endif + + if buflisted(l:currentBufNum) + execute("bdelete! ".l:currentBufNum) + endif +endfunction + +function! CmdLine(str) + call feedkeys(":" . a:str) +endfunction + +function! VisualSelection(direction, extra_filter) range + let l:saved_reg = @" + execute "normal! vgvy" + + let l:pattern = escape(@", "\\/.*'$^~[]") + let l:pattern = substitute(l:pattern, "\n$", "", "") + + if a:direction == 'gv' + call CmdLine("Ack '" . l:pattern . "' " ) + elseif a:direction == 'replace' + call CmdLine("%s" . '/'. l:pattern . '/') + endif + + let @/ = l:pattern + let @" = l:saved_reg +endfunction + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => EXTRAS BY LEON +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" Better splitting +set splitbelow +set splitright +" Enable mouse +set mouse=a + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => COQ +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +nnoremap CoqNextCoqJumpToEnd +nnoremap CoqUndoCoqJumpToEnd +nnoremap CoqToLine + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => NERDTree +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +nnoremap +nnoremap +nnoremap :NERDTreeToggle +" Exit Vim if NERDTree is the only window remaining in the only tab. +autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif + +" Close the tab if NERDTree is the only window remaining in it. +autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif +" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree. +autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | + \ let buf=bufnr() | buffer# | execute "normal! \w" | execute 'buffer'.buf | endif + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => CoC +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" Having longer updatetime (default is 4000 ms = 4s) leads to noticeable +" delays and poor user experience +set updatetime=300 + +" Always show the signcolumn, otherwise it would shift the text each time +" diagnostics appear/become resolved +set signcolumn=yes + +" Use tab for trigger completion with characters ahead and navigate +" NOTE: There's always complete item selected by default, you may want to enable +" no select by `"suggest.noselect": true` in your configuration file +" NOTE: Use command ':verbose imap ' to make sure tab is not mapped by +" other plugin before putting this into your config +inoremap + \ coc#pum#visible() ? coc#pum#next(1) : + \ CheckBackspace() ? "\" : + \ coc#refresh() +inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" + +" Make to accept selected completion item or notify coc.nvim to format +" u breaks current undo, please make your own choice +inoremap coc#pum#visible() ? coc#pum#confirm() + \: "\u\\=coc#on_enter()\" + +function! CheckBackspace() abort +let col = col('.') - 1 +return !col || getline('.')[col - 1] =~# '\s' +endfunction + +" Use to trigger completion +if has('nvim') +inoremap coc#refresh() +else +inoremap coc#refresh() +endif + +" Use `[g` and `]g` to navigate diagnostics +" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list +nmap [g (coc-diagnostic-prev) +nmap ]g (coc-diagnostic-next) + +" GoTo code navigation +nmap gd (coc-definition) +nmap gy (coc-type-definition) +nmap gi (coc-implementation) +nmap gr (coc-references) + +" Use K to show documentation in preview window +nnoremap K :call ShowDocumentation() + +function! ShowDocumentation() +if CocAction('hasProvider', 'hover') + call CocActionAsync('doHover') +else + call feedkeys('K', 'in') +endif +endfunction + +" Highlight the symbol and its references when holding the cursor +autocmd CursorHold * silent call CocActionAsync('highlight') + +" Symbol renaming +nmap rn (coc-rename) + +" Formatting selected code +xmap f (coc-format-selected) +nmap f (coc-format-selected) + +augroup mygroup +autocmd! +" Setup formatexpr specified filetype(s) +autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') +" Update signature help on jump placeholder +autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') +augroup end + +" Applying code actions to the selected code block +" Example: `aap` for current paragraph +xmap a (coc-codeaction-selected) +nmap a (coc-codeaction-selected) + +" Remap keys for applying code actions at the cursor position +nmap ac (coc-codeaction-cursor) +" Remap keys for apply code actions affect whole buffer +nmap as (coc-codeaction-source) +" Apply the most preferred quickfix action to fix diagnostic on the current line +nmap qf (coc-fix-current) + +" Remap keys for applying refactor code actions +nmap re (coc-codeaction-refactor) +xmap r (coc-codeaction-refactor-selected) +nmap r (coc-codeaction-refactor-selected) + +" Run the Code Lens action on the current line +nmap cl (coc-codelens-action) + +" Map function and class text objects +" NOTE: Requires 'textDocument.documentSymbol' support from the language server +xmap if (coc-funcobj-i) +omap if (coc-funcobj-i) +xmap af (coc-funcobj-a) +omap af (coc-funcobj-a) +xmap ic (coc-classobj-i) +omap ic (coc-classobj-i) +xmap ac (coc-classobj-a) +omap ac (coc-classobj-a) + +" Remap and to scroll float windows/popups +if has('nvim-0.4.0') || has('patch-8.2.0750') +nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" +nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" +inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" +inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" +vnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" +vnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" +endif + +" Use CTRL-S for selections ranges +" Requires 'textDocument/selectionRange' support of language server +nmap (coc-range-select) +xmap (coc-range-select) + +" Add `:Format` command to format current buffer +command! -nargs=0 Format :call CocActionAsync('format') + +" Add `:Fold` command to fold current buffer +command! -nargs=? Fold :call CocAction('fold', ) + +" Add `:OR` command for organize imports of the current buffer +command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport') + +" Add (Neo)Vim's native statusline support +" NOTE: Please see `:h coc-status` for integrations with external plugins that +" provide custom statusline: lightline.vim, vim-airline + +" Mappings for CoCList +" Show all diagnostics +nnoremap a :CocList diagnostics +" Manage extensions +nnoremap e :CocList extensions +" Show commands +nnoremap c :CocList commands +" Find symbol of current document +nnoremap o :CocList outline +" Search workspace symbols +nnoremap s :CocList -I symbols +" Do default action for next item +nnoremap j :CocNext +" Do default action for previous item +nnoremap k :CocPrev +" Resume latest coc list +nnoremap p :CocListResume + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Lightline +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +function! CocCurrentFunction() + return get(b:, 'coc_current_function', ''\'') +endfunction + +let g:lightline = { + \ 'colorscheme': 'molokai', + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], + \ [ 'cocstatus', 'currentfunction', 'readonly', 'filename', 'modified' ], + \ [ 'gitbranch' ] ] + \ }, + \ 'component_function': { + \ 'cocstatus': 'coc#status', + \ 'currentfunction': 'CocCurrentFunction', + \ 'gitbranch': 'FugitiveHead' + \ }, + \ } + +set noshowmode + +'' diff --git a/common/vscode.nix b/common/vscode.nix new file mode 100755 index 0000000..8c0ef6b --- /dev/null +++ b/common/vscode.nix @@ -0,0 +1,103 @@ +{ pkgs, ... }: +{ + programs.vscode = { + enable = true; + extensions = with pkgs.vscode-extensions; [ + jdinhlife.gruvbox + vscodevim.vim + yzhang.markdown-all-in-one + haskell.haskell + justusadam.language-haskell + maximedenes.vscoq + james-yu.latex-workshop + bbenoist.nix + mkhl.direnv + catppuccin.catppuccin-vsc + ] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [ + { + name = "theme-panda"; + publisher = "tinkertrain"; + version = "1.3.0"; + sha256 = "sha256-ijOXoby3FHgDhF2sibXnGpkldKNPCoEXCY0Iw0ndUtw="; + } + { + name = "agda-mode"; + publisher = "banacorn"; + version = "0.4.1"; + sha256 = "sha256-Zt2OifhS5BI0HcMZkKOa1gqV9Vpj0lIUR6VcHvX5M9o="; + } + { + name = "yuck"; + publisher = "eww-yuck"; + version = "0.0.3"; + sha256 = "sha256-DITgLedaO0Ifrttu+ZXkiaVA7Ua5RXc4jXQHPYLqrcM="; + } + ]; + userSettings = { + "agdaMode.connection.agdaLanguageServer" = false; + "agdaMode.highlighting.getHighlightWithThemeColors" = false; + "editor.unicodeHighlight.ambiguousCharacters" = false; + "editor.semanticHighlighting.enabled" = true; + "workbench.colorTheme" = "Catppuccin Mocha"; + # "workbench.iconTheme" = "catppuccin-mocha"; + "haskell.manageHLS" = "PATH"; + "editor.fontFamily" = "Berkeley Mono, DejaVu Sans Mono, monospace, Unifont"; + "terminal.integrated.minimumContrastRatio" = 1; + "terminal.integrated.shellIntegration.enabled" = false; + "terminal.integrated.profiles.linux" = { + bash = null; + zsh = { + path = "/run/current-system/sw/bin/zsh"; + icon = "terminal-linux"; + }; + }; + "terminal.integrated.defaultProfile.linux" = "zsh"; + "vim.handleKeys" = { + "" = false; + "" = false; + "" = false; + "" = false; + "" = false; + "" = false; + }; + "vim.overrideCopy" = false; + "window.titleBarStyle" = "custom"; + "window.customMenuBarAltFocus" = false; + "window.enableMenuBarMnemonics" = false; + #"ltex.additionalRules.motherTongue" = "de-DE"; + #"ltex.language" = "de-DE"; + #"ltex.ltex-ls.path" = "/etc/profiles/per-user/leonv/"; + "ltex.java.path" = "/etc/profiles/per-user/leonv/"; + #"ltex.sentenceCacheSize" = 50000; + #"ltex.java.maximumHeapSize" = 8192; + "editor.tabSize" = 2; + "explorer.excludeGitIgnore" = true; + "files.exclude" = { + "**/*.agdai" = true; + }; + # try to fix agda suggestions: + "editor.acceptSuggestionOnCommitCharacter" = false; + "editor.minimap.enabled" = false; + "editor.autoClosingOvertype" = "never"; + "editor.autoClosingBrackets" = "never"; + "editor.accessibilitySupport" = "off"; + }; + keybindings = [ + { + key = "ctrl+shift+v"; + command = "extension.vim_ctrl+v"; + when = "editorTextFocus && vim.active && !inDebugRepl"; + } + { + key = "ctrl+shift+="; + command = "editor.action.fontZoomIn"; + when = ""; + } + { + key = "ctrl+shift+-"; + command = "editor.action.fontZoomOut"; + when = ""; + } + ]; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..800065f --- /dev/null +++ b/flake.lock @@ -0,0 +1,361 @@ +{ + "nodes": { + "brew-src": { + "flake": false, + "locked": { + "lastModified": 1705326576, + "narHash": "sha256-9PvMgHgdbpb5vBO8fHCRufodR731ynzGMF9+68vKWck=", + "owner": "Homebrew", + "repo": "brew", + "rev": "1c612baa096c69f2fcb221c74e6f5b9979efdcee", + "type": "github" + }, + "original": { + "owner": "Homebrew", + "ref": "4.2.4", + "repo": "brew", + "type": "github" + } + }, + "cask-fonts": { + "flake": false, + "locked": { + "lastModified": 1707957157, + "narHash": "sha256-RjcJgrLJ9Zed6XsRTYuq/yXOBm+K5AMGycOWWW8QIUI=", + "owner": "homebrew", + "repo": "homebrew-cask-fonts", + "rev": "3c9d137956343e190e0feb319613de9ab50cd8c0", + "type": "github" + }, + "original": { + "owner": "homebrew", + "repo": "homebrew-cask-fonts", + "type": "github" + } + }, + "cl-nix-lite": { + "locked": { + "lastModified": 1698901928, + "narHash": "sha256-gMHZybEVA3uMOBu1483gXfvUqpv4Qn7GJs3ZfCQYxpc=", + "owner": "hraban", + "repo": "cl-nix-lite", + "rev": "9ad861b45bda7f59eba5ad1b43565a03c7c58553", + "type": "github" + }, + "original": { + "owner": "hraban", + "repo": "cl-nix-lite", + "type": "github" + } + }, + "darwin": { + "inputs": { + "nixpkgs": [ + "unstable" + ] + }, + "locked": { + "lastModified": 1707707289, + "narHash": "sha256-YuDt/eSTXMEHv8jS8BEZJgqCcG8Tr3cyqaZjJFXZHsw=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "44f50a5ecaab72a61d5fd8e5c5717bc4bf9c25dd", + "type": "github" + }, + "original": { + "owner": "lnl7", + "ref": "master", + "repo": "nix-darwin", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1697816753, + "narHash": "sha256-40to80AEIyKCQI0xMKCeF5ePoIKTYgjVVCZeu4CnTxM=", + "owner": "hraban", + "repo": "flake-compat", + "rev": "6025bade1336a36014639bc3f67eacc853dab78f", + "type": "github" + }, + "original": { + "owner": "hraban", + "ref": "fixed-output", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "id": "flake-utils", + "type": "indirect" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1687709756, + "narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "unstable" + ] + }, + "locked": { + "lastModified": 1708031129, + "narHash": "sha256-EH20hJfNnc1/ODdDVat9B7aKm0B95L3YtkIRwKLvQG8=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "3d6791b3897b526c82920a2ab5f61d71985b3cf8", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "homebrew-cask": { + "flake": false, + "locked": { + "lastModified": 1708086358, + "narHash": "sha256-h+afCxxV/FdfipQ/HpHhgkvbXgu9UfEgyrmfxr32ogA=", + "owner": "homebrew", + "repo": "homebrew-cask", + "rev": "75f6b30c1d7b23c7984a93b53fc86b97df233157", + "type": "github" + }, + "original": { + "owner": "homebrew", + "repo": "homebrew-cask", + "type": "github" + } + }, + "homebrew-core": { + "flake": false, + "locked": { + "lastModified": 1708085757, + "narHash": "sha256-u/rE6MjReC+34dT83BmRRSbtqWubg0hf/gRQoZ2Uh2E=", + "owner": "homebrew", + "repo": "homebrew-core", + "rev": "a008a7f04d026bb35b9aded0a427c6ee38aa8eb7", + "type": "github" + }, + "original": { + "owner": "homebrew", + "repo": "homebrew-core", + "type": "github" + } + }, + "hyprland-contrib": { + "inputs": { + "nixpkgs": [ + "unstable" + ] + }, + "locked": { + "lastModified": 1706198673, + "narHash": "sha256-bHlxFd+3QHy6eXtTzzhwVNcyxBSOxTvBuJGNUzI4C4M=", + "owner": "hyprwm", + "repo": "contrib", + "rev": "16884001b26e6955ff4b88b4dfe4c8986e20f153", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "contrib", + "type": "github" + } + }, + "mac-app-util": { + "inputs": { + "cl-nix-lite": "cl-nix-lite", + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1707183497, + "narHash": "sha256-K6LVwmM32uUEYXpDFCnwNqOyi863FRXR6KFq87X3iHg=", + "owner": "hraban", + "repo": "mac-app-util", + "rev": "95d9c38d6dec0296d73929f63a7de130f435437b", + "type": "github" + }, + "original": { + "owner": "hraban", + "repo": "mac-app-util", + "type": "github" + } + }, + "nix-darwin": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1688307440, + "narHash": "sha256-7PTjbN+/+b799YN7Tk2SS5Vh8A0L3gBo8hmB7Y0VXug=", + "owner": "LnL7", + "repo": "nix-darwin", + "rev": "b06bab83bdf285ea0ae3c8e145a081eb95959047", + "type": "github" + }, + "original": { + "owner": "LnL7", + "repo": "nix-darwin", + "type": "github" + } + }, + "nix-homebrew": { + "inputs": { + "brew-src": "brew-src", + "flake-utils": "flake-utils_2", + "nix-darwin": "nix-darwin", + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1705952034, + "narHash": "sha256-H0nk8Gk8kPw4yi2WwOTsSHgPrzSwyNgWEYHk10IJwfc=", + "owner": "zhaofengli-wip", + "repo": "nix-homebrew", + "rev": "40f5ee46b58e7c5f1927e2c5a583dc3d7e571ed9", + "type": "github" + }, + "original": { + "owner": "zhaofengli-wip", + "repo": "nix-homebrew", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1698553279, + "narHash": "sha256-T/9P8yBSLcqo/v+FTOBK+0rjzjPMctVymZydbvR/Fak=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "90e85bc7c1a6fc0760a94ace129d3a1c61c3d035", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1687274257, + "narHash": "sha256-TutzPriQcZ8FghDhEolnHcYU2oHIG5XWF+/SUBNnAOE=", + "path": "/nix/store/22qgs3skscd9bmrxv9xv4q5d4wwm5ppx-source", + "rev": "2c9ecd1f0400076a4d6b2193ad468ff0a7e7fdc5", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1688049487, + "narHash": "sha256-100g4iaKC9MalDjUW9iN6Jl/OocTDtXdeAj7pEGIRh4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4bc72cae107788bf3f24f30db2e2f685c9298dc9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "cask-fonts": "cask-fonts", + "darwin": "darwin", + "home-manager": "home-manager", + "homebrew-cask": "homebrew-cask", + "homebrew-core": "homebrew-core", + "hyprland-contrib": "hyprland-contrib", + "mac-app-util": "mac-app-util", + "nix-homebrew": "nix-homebrew", + "unstable": "unstable" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "unstable": { + "locked": { + "lastModified": 1707956935, + "narHash": "sha256-ZL2TrjVsiFNKOYwYQozpbvQSwvtV/3Me7Zwhmdsfyu4=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "a4d4fe8c5002202493e87ec8dbc91335ff55552c", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..09bc8c6 --- /dev/null +++ b/flake.nix @@ -0,0 +1,84 @@ +{ + description = "Master flake for all my setups"; + + inputs = { + unstable.url = "github:nixos/nixpkgs/nixos-unstable"; + + darwin.url = "github:lnl7/nix-darwin/master"; + darwin.inputs.nixpkgs.follows = "unstable"; + + nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew"; + + homebrew-core.url = "github:homebrew/homebrew-core"; + homebrew-core.flake = false; + + homebrew-cask.url = "github:homebrew/homebrew-cask"; + homebrew-cask.flake = false; + + cask-fonts.url = "github:homebrew/homebrew-cask-fonts"; + cask-fonts.flake = false; + + home-manager.url = "github:nix-community/home-manager"; + home-manager.inputs.nixpkgs.follows = "unstable"; + + hyprland-contrib.url = "github:hyprwm/contrib"; + hyprland-contrib.inputs.nixpkgs.follows = "unstable"; + + # fix for app links on macos + mac-app-util.url = "github:hraban/mac-app-util"; + }; + + outputs = { unstable, home-manager, darwin, hyprland-contrib, nix-homebrew, homebrew-core, homebrew-cask, cask-fonts, ...}@inputs: { + nixosConfigurations = { + gunther = unstable.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { inherit inputs; }; + modules = [ + ./gunther/configuration.nix + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.leonv = import ./gunther/leonv.nix; + home-manager.extraSpecialArgs = { inherit inputs; }; + } + ]; + }; + iso = unstable.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { inherit inputs; }; + modules = [ + "${unstable}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix" + ./iso/configuration.nix + ]; + }; + willem = unstable.lib.nixosSystem { + system = "aarch64-linux"; + modules = [ ./willem/configuration.nix ]; + }; + }; + darwinConfigurations = { + shinx = darwin.lib.darwinSystem { + system = "aarch64-darwin"; + specialArgs = { inherit inputs; }; + modules = [ + ./shinx/default.nix + home-manager.darwinModules.home-manager + nix-homebrew.darwinModules.nix-homebrew + { + nix-homebrew = { + enable = true; + enableRosetta = true; + user = "leonvatthauer"; + taps = { + "homebrew/homebrew-core" = homebrew-core; + "homebrew/homebrew-cask" = homebrew-cask; + "homebrew/homebrew-cask-fonts" = cask-fonts; + }; + }; + } + ]; + }; + }; + }; +} diff --git a/gunther/configuration.nix b/gunther/configuration.nix new file mode 100755 index 0000000..10a5d4f --- /dev/null +++ b/gunther/configuration.nix @@ -0,0 +1,248 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). + +{ config, pkgs, lib, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + # VM + virtualisation.vmVariant = { + # following configuration is added only when building VM with build-vm + virtualisation = { + memorySize = 2048; # Use 2048MiB memory. + cores = 3; + }; + }; + + # optimize storage + nix.optimise.automatic = true; + + # Bootloader. + boot.loader.efi.canTouchEfiVariables = true; + boot.loader.efi.efiSysMountPoint = "/boot"; + boot.loader.systemd-boot.enable = true; + + networking.hostName = "gunther"; + networking.networkmanager.enable = true; + + # Set your time zone. + time.timeZone = "Europe/Berlin"; + + i18n.supportedLocales = [ + "en_US.UTF-8/UTF-8" + "de_DE.UTF-8/UTF-8" + ]; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + i18n.extraLocaleSettings = { + LANG = "en_US.UTF-8"; + LC_ALL = "en_US.UTF-8"; + LANGUAGE = "en_US.UTF-8"; + LC_ADDRESS = "de_DE.UTF-8"; + LC_IDENTIFICATION = "de_DE.UTF-8"; + LC_MEASUREMENT = "de_DE.UTF-8"; + LC_MONETARY = "de_DE.UTF-8"; + LC_NAME = "de_DE.UTF-8"; + LC_NUMERIC = "de_DE.UTF-8"; + LC_PAPER = "de_DE.UTF-8"; + LC_TELEPHONE = "de_DE.UTF-8"; + LC_TIME = "de_DE.UTF-8"; + }; + + services.greetd = { + enable = true; + package = pkgs.greetd.gtkgreet; + settings = { + default_session = { + command = "Hyprland --config /etc/greetd/hyprland.conf"; + user = "greeter"; + }; + }; + }; + environment.etc."greetd/environments".text = '' + Hyprland + ''; + environment.etc."greetd/hyprland.conf".text = '' + monitor = DP-3,2560x1440@144,1920x0,1 + monitor = HDMI-A-5,1920x1080@75,0x0,1 + misc { + disable_hyprland_logo = true + } + + exec-once = gtkgreet -l -b /etc/greetd/wallpaper.jpg -s /etc/greetd/style.css; hyprctl dispatch exit + ''; + environment.etc."greetd/wallpaper.jpg".source = ./hypr/wallpaper.jpg; + environment.etc."greetd/style.css".text = '' + window { + background-position: center; + background-repeat: no-repeat; + background-size: cover; + background-color: black; + } + ''; + + # Configure console keymap + console.keyMap = "us"; + + # Enable CUPS to print documents. + services.avahi = { + enable = true; + nssmdns = true; + openFirewall = true; + }; + services.printing = { + enable = true; + drivers = [ pkgs.splix ]; + }; + + # bluetooth + hardware.bluetooth.enable = true; + hardware.bluetooth.powerOnBoot = true; + services.blueman.enable = true; + + # Enable sound with pipewire. + sound.enable = true; + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; + + # Define a user account. + users.users.leonv = { + isNormalUser = true; + description = "Leon Vatthauer"; + extraGroups = [ "networkmanager" "wheel" ]; + initialPassword = "leonv"; # just for setup + }; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # List packages installed in system profile. + environment.systemPackages = + with pkgs; + let + catp-gtk = pkgs.catppuccin-gtk.override { + accents = [ "flamingo" ]; # You can specify multiple accents here to output multiple themes + size = "compact"; + tweaks = [ "rimless" "black" ]; # You can also specify multiple tweaks here + variant = "macchiato"; + }; + in [ + # for connecting to nas + nfs-utils + + # some standards for convenience + vim + parted + os-prober + qpdfview + swww + + # greeter + greetd.gtkgreet + catp-gtk + + # deps for hyprland / eww + socat + ]; + + system.stateVersion = "23.11"; + + # NFS setup + services.rpcbind.enable = true; # needed for NFS + systemd.mounts = [{ + type = "nfs"; + mountConfig = { + Options = "noatime"; + }; + what = "192.168.178.20:/volume1/MiniDrive"; + where = "/MiniDrive"; + }]; + + systemd.automounts = [{ + wantedBy = [ "multi-user.target" ]; + automountConfig = { + TimeoutIdleSec = "10"; + }; + where = "/MiniDrive"; + }]; + + # source zsh + programs.zsh.enable = true; + users.defaultUserShell = pkgs.zsh; + + # Binary Cache for Haskell.nix + nix.settings.trusted-public-keys = [ + "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" + ]; + nix.settings.substituters = [ + "https://aseipp-nix-cache.global.ssl.fastly.net" + "https://cache.iog.io" + ]; + + # environment variables + environment.sessionVariables = { + ## disable logging when direnv changes + DIRENV_LOG_FORMAT = []; + # GTK theme (set here for greetd) + GTK_THEME = "Catppuccin-Macchiato-Compact-Flamingo-Dark"; + }; + + # fonts + fonts = { + packages = with pkgs; [ + ((nerdfonts.override { fonts = [ "Hack" "DejaVuSansMono" "DroidSansMono" "Noto" ]; })) + mononoki + # noto-fonts + noto-fonts-cjk + noto-fonts-emoji + ]; + enableDefaultPackages = true; + fontconfig = { + defaultFonts = { + monospace = [ "Berkeley Mono Nerd Font" ]; + sansSerif = [ "NotoSans Nerd Font" ]; + serif = [ "NotoSans Nerd Font" ]; + emoji = [ "Noto Color Emoji" ]; + }; + }; + }; + + # enable flakes + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + # hyprland + programs.hyprland.enable = true; + + # ssh + programs.ssh.startAgent = true; + programs.ssh.extraConfig = '' + AddKeysToAgent yes + IdentityFile ~/.ssh/git + ''; + + programs.steam.enable = true; + + # thunar + programs.thunar = { + enable = true; + plugins = with pkgs.xfce; [ + thunar-archive-plugin + thunar-volman + ]; + }; + services.gvfs.enable = true; # Mount, trash, and others + services.tumbler.enable = true; # thumbnail support for images +} diff --git a/gunther/hardware-configuration.nix b/gunther/hardware-configuration.nix new file mode 100644 index 0000000..02a15e5 --- /dev/null +++ b/gunther/hardware-configuration.nix @@ -0,0 +1,34 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/2191540a-8cf9-400e-b4bc-9dbf71527b07"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/3DD6-C061"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/7c6d727e-1d40-472a-a409-205db0776d20"; } + ]; + + networking.useDHCP = lib.mkDefault true; + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/gunther/hypr/catppuccin-macchiato.rasi b/gunther/hypr/catppuccin-macchiato.rasi new file mode 100644 index 0000000..696d769 --- /dev/null +++ b/gunther/hypr/catppuccin-macchiato.rasi @@ -0,0 +1,111 @@ +* { + bg-col: #24273a; + bg-col-light: #24273a; + border-col: #24273a; + selected-col: #24273a; + blue: #8aadf4; + fg-col: #cad3f5; + fg-col2: #ed8796; + grey: #6e738d; + + width: 600; + font: "JetBrainsMono Nerd Font 14"; +} + +element-text, element-icon , mode-switcher { + background-color: inherit; + text-color: inherit; +} + +window { + height: 360px; + border: 3px; + border-color: @border-col; + background-color: @bg-col; +} + +mainbox { + background-color: @bg-col; +} + +inputbar { + children: [prompt,entry]; + background-color: @bg-col; + border-radius: 5px; + padding: 2px; +} + +prompt { + background-color: @blue; + padding: 6px; + text-color: @bg-col; + border-radius: 3px; + margin: 20px 0px 0px 20px; +} + +textbox-prompt-colon { + expand: false; + str: ":"; +} + +entry { + padding: 6px; + margin: 20px 0px 0px 10px; + text-color: @fg-col; + background-color: @bg-col; +} + +listview { + border: 0px 0px 0px; + padding: 6px 0px 0px; + margin: 10px 0px 0px 20px; + columns: 2; + lines: 5; + background-color: @bg-col; +} + +element { + padding: 5px; + background-color: @bg-col; + text-color: @fg-col ; +} + +element-icon { + size: 25px; +} + +element selected { + background-color: @selected-col ; + text-color: @fg-col2 ; +} + +mode-switcher { + spacing: 0; + } + +button { + padding: 10px; + background-color: @bg-col-light; + text-color: @grey; + vertical-align: 0.5; + horizontal-align: 0.5; +} + +button selected { + background-color: @bg-col; + text-color: @blue; +} + +message { + background-color: @bg-col-light; + margin: 2px; + padding: 2px; + border-radius: 5px; +} + +textbox { + padding: 6px; + margin: 20px 0px 0px 20px; + text-color: @blue; + background-color: @bg-col-light; +} diff --git a/gunther/hypr/hyprland.nix b/gunther/hypr/hyprland.nix new file mode 100644 index 0000000..8a162f2 --- /dev/null +++ b/gunther/hypr/hyprland.nix @@ -0,0 +1,181 @@ +{ pkgs, ... }: +{ + # hyprland setup + wayland.windowManager.hyprland = { + enable = true; + xwayland.enable = true; + settings = { + monitor = [ + "DP-3 , 2560x1440@144, 1920x0, 1" + "HDMI-A-5, 1920x1080@75 , 0x0 , 1" + ]; + input = { + kb_layout = "de"; + kb_variant = "us"; + follow_mouse = 1; + }; + "$mod" = "SUPER"; + "$modd" = "SUPER_SHIFT"; + general = { + gaps_in = 8; + gaps_out = 15; + border_size = 3; + + resize_on_border = true; + layout = "dwindle"; + + "col.active_border" = "rgba(cba6f7ff) rgba(89b4faff) rgba(94e2d5ff) 10deg"; + "col.inactive_border" = "0xff45475a"; + "col.nogroup_border" = "0xff89dceb"; + "col.nogroup_border_active" = "0xfff9e2af"; + }; + decoration = { + blur = { + new_optimizations = true; + size = 1; + passes = 1; + }; + drop_shadow = true; + shadow_range = 100; + shadow_render_power = 5; + "col.shadow" = "0x33000000"; + "col.shadow_inactive" = "0x22000000"; + rounding = 15; + }; + animations = { + enabled = 1; + bezier = "overshot,0.13,0.99,0.29,1.1"; + animation = [ + "windows,1,4,overshot,slide" + "border,1,10,default" + "fade,1,10,default" + "workspaces,1,6,overshot,slidevert" + ]; + }; + misc = { + disable_hyprland_logo = true; + }; + bind = [ + # opening programs + "$mod, Return, exec, foot" + "$mod, D, exec, rofi -show drun -show-icons" + "$mod, M, exit, " + "$mod, Q, killactive, " + + # moving around + "$mod, left , movefocus, l" + "$mod, right, movefocus, r" + "$mod, down , movefocus, d" + "$mod, up , movefocus, u" + + # moving windows + "$modd, left , movewindow, l" + "$modd, right, movewindow, r" + "$modd, down , movewindow, d" + "$modd, up , movewindow, u" + + # workspaces + "$mod, 1, workspace, 1" + "$mod, 2, workspace, 2" + "$mod, 3, workspace, 3" + "$mod, 4, workspace, 4" + "$modd, 1, movetoworkspacesilent, 1" + "$modd, 2, movetoworkspacesilent, 2" + "$modd, 3, movetoworkspacesilent, 3" + "$modd, 4, movetoworkspacesilent, 4" + + # fullscreen + "$mod, F11, fullscreen, 0" + "$mod, m, fullscreen, 1" # maximize + + # floating + "$mod, F, togglefloating, active" + + # screenshot + ", Print, exec, grimblast copysave area $HOME\"/screenshots/\"$(date +'%F-%T.png');" + + + ]; + bindm = [ + "$mod, mouse:272, movewindow" + ]; + bindle = [ + ", XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+" + ", XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%-" + ", XF86AudioMute, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 0%" + ]; + exec-once = [ + "bash ~/Git/nixos/gunther/hypr/start.sh" + ]; + }; + }; + + # tell electron to use wayland + home.sessionVariables.NIXOS_OZONE_WL = "1"; + + # terminal + programs.foot = { + enable = true; + settings = { + main = { + font = "monospace:size=12"; + dpi-aware = "yes"; + }; + colors = { + foreground = "cad3f5"; + background = "24273a"; + regular0 = "494d64"; + regular1 = "ed8796"; + regular3 = "eed49f"; + regular4 = "8aadf4"; + regular5 = "f5bde6"; + regular6 = "8bd5ca"; + regular7 = "b8c0e0"; + bright0 = "5b6078"; + bright1 = "ed8796"; + bright3 = "eed49f"; + bright4 = "8aadf4"; + bright5 = "f5bde6"; + bright6 = "8bd5ca"; + bright7 = "a5adcb"; + }; + }; + }; + + programs.rofi = { + enable = true; + package = pkgs.rofi-wayland; + theme = ./catppuccin-macchiato.rasi; + font = "monospace 14"; + terminal = "foot"; + extraConfig = { + modi = "drun,run,top"; + }; + plugins = [ + pkgs.rofi-top + ]; + }; + + services.mako = { + enable = true; + extraConfig = '' + background-color=#24273a + text-color=#cad3f5 + border-color=#8aadf4 + progress-color=over #363a4f + sort=-time + layer=overlay + width=300 + height=110 + border-size=2 + border-radius=15 + max-icon-size=64 + default-timeout=5000 + ignore-timeout=1 + + [urgency=high] + border-color=#f5a97f + ''; + }; + +} diff --git a/gunther/hypr/hyprpaper.conf b/gunther/hypr/hyprpaper.conf new file mode 100644 index 0000000..df79657 --- /dev/null +++ b/gunther/hypr/hyprpaper.conf @@ -0,0 +1,5 @@ +preload = ~/Git/nixos/gunther/hypr/wallpaper.jpg +# +#set the default wallpaper(s) seen on inital workspace(s) --depending on the number of monitors used +wallpaper = monitor1,~/Git/nixos/gunther/hypr/wallpaper.jpg +wallpaper = monitor2,~/Git/nixos/gunther/hypr/wallpaper.jpg diff --git a/gunther/hypr/start.sh b/gunther/hypr/start.sh new file mode 100755 index 0000000..c25dc87 --- /dev/null +++ b/gunther/hypr/start.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# init nmapplet +# TODO add back once eww supports tray +# nm-applet --indicator & +swww init +swww img /home/leonv/Git/nixos/gunther/hypr/wallpaper.jpg + +eww daemon +eww open top-bar + +# notification +mako diff --git a/gunther/hypr/wallpaper.jpg b/gunther/hypr/wallpaper.jpg new file mode 100644 index 0000000..c36b7fd Binary files /dev/null and b/gunther/hypr/wallpaper.jpg differ diff --git a/gunther/leonv.nix b/gunther/leonv.nix new file mode 100755 index 0000000..b9f9f2f --- /dev/null +++ b/gunther/leonv.nix @@ -0,0 +1,137 @@ +{ config, pkgs, inputs, ... }: +{ + imports = [ + ./../common + ./hypr/hyprland.nix + ./../common/eww + ]; + /* The home.stateVersion option does not have a default and must be set */ + home.stateVersion = "23.11"; + home.username = "leonv"; + home.homeDirectory = "/home/leonv"; + + home.packages = with pkgs; [ + # theme for gtk applications + orchis-theme + + # stuff + jq + vlc + openvpn + signal-desktop + webcord + firefox-wayland + ungoogled-chromium + thunderbird + gimp + qpdfview + wget + fontforge + gparted + eza + ripgrep + fd + zoom-us + + # development + jetbrains.idea-ultimate + gnumake + texlive.combined.scheme-full + ltex-ls + ghostscript + jdk11 + coq + gcc + ghc + cabal-install + haskell-language-server + python3 + python3Packages.pygments + nodejs_20 + unifont + anki + pandoc + + # games + prismlauncher + + # hyprland + kitty + networkmanagerapplet + mako + libnotify + pavucontrol + hyprpaper + qimgv + playerctl + hyprpicker + wev + inputs.hyprland-contrib.packages.${pkgs.system}.grimblast + bluez + htop + archiver + gnome.file-roller + discord + zip + emacs + shellcheck + + # yubikey + yubico-pam + yubikey-manager + + # agda + + (agda.withPackages [ + agdaPackages.standard-library + agdaPackages.agda-categories + ]) + ]; + + programs.home-manager.enable = true; + + programs.zsh = { + enable = true; + shellAliases = { + clean = "sudo nix-env --delete-generations old --profile /nix/var/nix/profiles/system && sudo /nix/var/nix/profiles/system/bin/switch-to-configuration switch && sudo nix-store --gc"; + ls = "eza"; + ll = "eza -l"; + l = "eza -lah"; + }; + initExtra = '' + function rebuild () { + sudo nixos-rebuild switch --flake /home/leonv/Git/nixos + sudo cp -r /home/leonv/Git/nixos /etc/ + } + ''; + oh-my-zsh.enable = true; + }; + + gtk = { + enable = true; + theme = { + name = "Catppuccin-Macchiato-Compact-Flamingo-Dark"; + package = pkgs.catppuccin-gtk.override { + accents = [ "flamingo" ]; + size = "compact"; + tweaks = [ "rimless" "black" ]; + variant = "macchiato"; + }; + }; + iconTheme = { + name = "Dracula"; + package = pkgs.dracula-icon-theme; + }; + font = { + name = "NotoSans Nerd Font"; + }; + }; + home.sessionVariables.GTK_THEME = "Catppuccin-Macchiato-Compact-Flamingo-Dark"; + home.sessionPath = [ "$HOME/.config/emacs/bin" ]; + + services.syncthing = { + enable = true; + }; + + services.mpris-proxy.enable = true; +} diff --git a/iso/configuration.nix b/iso/configuration.nix new file mode 100644 index 0000000..a22999f --- /dev/null +++ b/iso/configuration.nix @@ -0,0 +1,105 @@ + +{ config, pkgs, lib, ... }: +{ + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.leonv = { + isNormalUser = true; + description = "Leon Vatthauer"; + extraGroups = [ "networkmanager" "wheel" ]; + initialPassword = "leonv"; + }; + + networking.hostName = "gunther"; # Define your hostname. + # Enable networking + networking.networkmanager = { + enable = true; + }; + + # Set your time zone. + time.timeZone = "Europe/Berlin"; + + i18n.supportedLocales = [ + "en_US.UTF-8/UTF-8" + "de_DE.UTF-8/UTF-8" + ]; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + i18n.extraLocaleSettings = { + LANG = "en_US.UTF-8"; + LC_ALL = "en_US.UTF-8"; + LANGUAGE = "en_US.UTF-8"; + LC_ADDRESS = "de_DE.UTF-8"; + LC_IDENTIFICATION = "de_DE.UTF-8"; + LC_MEASUREMENT = "de_DE.UTF-8"; + LC_MONETARY = "de_DE.UTF-8"; + LC_NAME = "de_DE.UTF-8"; + LC_NUMERIC = "de_DE.UTF-8"; + LC_PAPER = "de_DE.UTF-8"; + LC_TELEPHONE = "de_DE.UTF-8"; + LC_TIME = "de_DE.UTF-8"; + }; + + # Enable sound with pipewire. + sound.enable = true; + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # List packages installed in system profile. + environment.systemPackages = with pkgs; [ + # for connecting to nas + nfs-utils + + # some standards for convenience + vim + parted + git + ]; + + system.stateVersion = "23.11"; # Did you read the comment? + + # NFS setup + services.rpcbind.enable = true; # needed for NFS + systemd.mounts = [{ + type = "nfs"; + mountConfig = { + Options = "noatime"; + }; + what = "192.168.178.20:/volume1/MiniDrive"; + where = "/MiniDrive"; + }]; + + systemd.automounts = [{ + wantedBy = [ "multi-user.target" ]; + automountConfig = { + TimeoutIdleSec = "10"; + }; + where = "/MiniDrive"; + }]; + + # source zsh + programs.zsh.enable = true; + users.defaultUserShell = pkgs.zsh; + + # Binary Cache for Haskell.nix + nix.settings.trusted-public-keys = [ + "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" + ]; + nix.settings.substituters = [ + "https://aseipp-nix-cache.global.ssl.fastly.net" + "https://cache.iog.io" + ]; + + # flakes + nix.settings.experimental-features = [ "nix-command" "flakes" ]; +} \ No newline at end of file diff --git a/shinx/default.nix b/shinx/default.nix new file mode 100755 index 0000000..28ab0d2 --- /dev/null +++ b/shinx/default.nix @@ -0,0 +1,27 @@ +# hosts/YourHostName/default.nix +{ pkgs, home-manager, inputs, ... }@mod-inputs: +{ + + # Make sure the nix daemon always runs + services.nix-daemon.enable = true; + # Installs a version of nix, that dosen't need "experimental-features = nix-command flakes" in /etc/nix/nix.conf + #services.nix-daemon.package = pkgs.nixFlakes; + + # if you use zsh (the default on new macOS installations), + # you'll need to enable this so nix-darwin creates a zshrc sourcing needed environment changes + programs.zsh.enable = true; + # bash is enabled by default + home-manager = { + extraSpecialArgs = { inherit (mod-inputs) inputs; }; + useGlobalPkgs = true; + useUserPackages = true; + users.leonvatthauer = import ./leonvatthauer.nix; + }; + nixpkgs.config.allowUnfree = true; + users.users.leonvatthauer = { + home="/Users/leonvatthauer"; + }; + fonts.fonts = [ + pkgs.mononoki + ]; +} diff --git a/shinx/leonvatthauer.nix b/shinx/leonvatthauer.nix new file mode 100755 index 0000000..8c38fde --- /dev/null +++ b/shinx/leonvatthauer.nix @@ -0,0 +1,70 @@ +{ pkgs, lib, config, inputs, ... }: +{ + home.stateVersion = "23.11"; + imports = [ + ./../common/default.nix + ]; + + home.activation = { + trampolineApps = let + mac-app-util = inputs.mac-app-util.packages.${pkgs.stdenv.system}.default; + in lib.hm.dag.entryAfter [ "writeBoundary" ] '' + fromDir="$HOME/Applications/Home Manager Apps" + toDir="$HOME/Applications/Home Manager Trampolines" + ${mac-app-util}/bin/mac-app-util sync-trampolines "$fromDir" "$toDir" + ''; + }; + + home.packages = with pkgs; [ + zsh + oh-my-zsh + coq + openvpn + ghc + haskell-language-server + cabal-install + haskellPackages.alex + haskellPackages.happy + python3 + python3Packages.pygments + nodejs_20 + iterm2 + (agda.withPackages [ + agdaPackages.standard-library + agdaPackages.agda-categories + ]) + texlive.combined.scheme-full + pandoc + gh + #yubico-pam + #yubikey-manager + # programs for emacs + emacs + fd + ripgrep + gnugrep + nixfmt + shellcheck + fontconfig + coreutils + coreutils-prefixed + ]; + + programs.home-manager.enable = true; + programs.kitty = { + enable = true; + font.name = "Berkeley Mono"; + + }; + programs.zsh = { + enable = true; + oh-my-zsh = { + enable = true; + plugins = [ "git" ]; + theme = "robbyrussell"; + }; + initExtra = '' + export PATH="/opt/homebrew/bin:$PATH" + ''; + }; +} diff --git a/willem/README.md b/willem/README.md new file mode 100644 index 0000000..7a1a1cf --- /dev/null +++ b/willem/README.md @@ -0,0 +1,20 @@ +# Willem + +Willem is a server running on a Raspberry Pi 400 offering the following services: +- [Gitea](git.vatthauer.xyz) +- [Vaultwarden](bitwarden.vatthauer.xyz) + +There are daily backups of the Gitea instance using Restic via B2. +## Installation on Raspberry Pi 400 +### Resources +- https://nixos.wiki/wiki/NixOS_on_ARM/Raspberry_Pi_4 +- https://nixos.wiki/wiki/NixOS_on_ARM#Installation + +### Step by step +1. Follow the [generic installation steps](https://nixos.wiki/wiki/NixOS_on_ARM#Installation) to get NixOS up and running on the Pi. +2. Generate the default `configuration.nix` via `sudo nixos-generate-config` and do a first rebuild `sudo nixos-rebuild switch` +3. Somehow get this repository onto the machine and `cd` into it +4. We need git: `nix-shell -p git` +5. Build the flake via `sudo nixos-rebuild switch --flake .` +6. At this point you can restart +7. Login, set password, move the repository to `/home/leonv/nixos` \ No newline at end of file diff --git a/willem/configuration.nix b/willem/configuration.nix new file mode 100644 index 0000000..b7ebe0e --- /dev/null +++ b/willem/configuration.nix @@ -0,0 +1,77 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running 'nixos-help'). + +{ config, pkgs, lib, ... }: + +{ + imports = + [ + ./hardware-configuration.nix + ./services + ./programs + ]; + + # enable flakes + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + # Use the extlinux boot loader. (NixOS wants to enable GRUB by default) + boot.loader.grub.enable = false; + # Enables the generation of /boot/extlinux/extlinux.conf + boot.loader.generic-extlinux-compatible.enable = true; + + networking.hostName = "willem"; # Define your hostname. + #networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + networking.firewall.allowedTCPPorts = [ 22 80 443 631 8096 8920 ]; + networking.firewall.allowedUDPPorts = [ 22 80 443 631 1900 7359 ]; + + # Set your time zone. + time.timeZone = "Europe/Berlin"; + + # Define a user account. Don't forget to set a password with 'passwd'. + users.users.leonv = { + isNormalUser = true; + initialPassword = "leonv"; + extraGroups = [ "wheel" ]; # Enable 'sudo' for the user. + packages = with pkgs; [ + ]; + }; + users.defaultUserShell = pkgs.zsh; + + # List packages installed in system profile. + environment.systemPackages = with pkgs; [ + wget + git + zsh + oh-my-zsh + restic + ]; + environment.variables = { + EDITOR = "nvim"; + + # bitwarden key + YUBICO_CLIENT_ID = "${../nix-secrets/willem/vaultwarden/yubico-id}"; + YUBICO_SECRET_KEY = "${../nix-secrets/willem/vaultwarden/yubico-secret}"; + }; + environment.shells = [ pkgs.zsh ]; + + nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ + "plexmediaserver" + ]; + + services.plex = { + enable = true; + openFirewall = true; + }; + + services.jellyfin.enable = true; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It's perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "23.11"; # Did you read the comment? +} + diff --git a/willem/hardware-configuration.nix b/willem/hardware-configuration.nix new file mode 100644 index 0000000..c6a3513 --- /dev/null +++ b/willem/hardware-configuration.nix @@ -0,0 +1,26 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "usbhid" "usb_storage" "uas" "pcie-brcmstb" "reset-raspberrypi" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-partuuid/45e5879b-02"; + fsType = "ext4"; + }; + + swapDevices = [ ]; + + networking.useDHCP = lib.mkDefault true; + nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux"; + powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand"; +} diff --git a/willem/programs/default.nix b/willem/programs/default.nix new file mode 100644 index 0000000..5316865 --- /dev/null +++ b/willem/programs/default.nix @@ -0,0 +1,8 @@ +{ + imports = [ + ./neovim.nix + ./ssh.nix + ./starship.nix + ./zsh.nix + ]; +} diff --git a/willem/programs/neovim.nix b/willem/programs/neovim.nix new file mode 100644 index 0000000..37a1ea9 --- /dev/null +++ b/willem/programs/neovim.nix @@ -0,0 +1,14 @@ +{ pkgs, ... }: +{ + programs.neovim = { + enable = true; + configure = { + customRC = ''''; + packages.myVimPackage = with pkgs.vimPlugins; { + start = [ vim-nix ]; + }; + }; + viAlias = true; + vimAlias = true; + }; +} \ No newline at end of file diff --git a/willem/programs/ssh.nix b/willem/programs/ssh.nix new file mode 100644 index 0000000..e4c886d --- /dev/null +++ b/willem/programs/ssh.nix @@ -0,0 +1,6 @@ +{ + programs.ssh.startAgent = true; + programs.ssh.extraConfig = '' + AddKeysToAgent yes + ''; +} \ No newline at end of file diff --git a/willem/programs/starship.nix b/willem/programs/starship.nix new file mode 100644 index 0000000..a2d4525 --- /dev/null +++ b/willem/programs/starship.nix @@ -0,0 +1,8 @@ +{ + programs.starship = { + enable = true; + settings = { + gradle.symbol = "🐘"; + }; + }; +} \ No newline at end of file diff --git a/willem/programs/zsh.nix b/willem/programs/zsh.nix new file mode 100644 index 0000000..d4e9708 --- /dev/null +++ b/willem/programs/zsh.nix @@ -0,0 +1,19 @@ +{ + programs.zsh = { + enable = true; + shellAliases = { + clean = "sudo nix-env --delete-generations old --profile /nix/var/nix/profiles/system && sudo /nix/var/nix/profiles/system/bin/switch-to-configuration switch && sudo nix-store --gc"; + }; + shellInit = '' + function rebuild () { + sudo nixos-rebuild switch --flake /home/leonv/nixos + sudo cp -r /home/leonv/nixos /etc/ + } + ''; + ohMyZsh = { + enable = true; + plugins = [ "git" ]; + theme = "dpoggi"; + }; + }; +} \ No newline at end of file diff --git a/willem/services/acme.nix b/willem/services/acme.nix new file mode 100644 index 0000000..955c5f4 --- /dev/null +++ b/willem/services/acme.nix @@ -0,0 +1,8 @@ +{ + security.acme.acceptTerms = true; + security.acme.certs = { + "git.vatthauer.xyz".email = "leonvatthauer@outlook.com"; + "bitwarden.vatthauer.xyz".email = "leonvatthauer@outlook.com"; + "video.vatthauer.xyz".email = "leonvatthauer@outlook.com"; + }; +} diff --git a/willem/services/ddns.nix b/willem/services/ddns.nix new file mode 100644 index 0000000..76d79d0 --- /dev/null +++ b/willem/services/ddns.nix @@ -0,0 +1,16 @@ +{ pkgs, ... }: +{ + # dynamic dns + users.users.ddns = { + isSystemUser = true; + group = "ddns"; + }; + users.groups.ddns = {}; + systemd.services.ddns-updater = { + enable = true; + serviceConfig.User = "ddns"; + path = [ pkgs.curl ]; + script = "${../../nix-secrets/willem/ddns/update}"; + startAt = "hourly"; + }; +} diff --git a/willem/services/default.nix b/willem/services/default.nix new file mode 100644 index 0000000..69bc66f --- /dev/null +++ b/willem/services/default.nix @@ -0,0 +1,12 @@ +{ + imports = [ + ./acme.nix + ./ddns.nix + ./nginx.nix + ./gitea.nix + ./printing.nix + ./restic.nix + ./ssh.nix + ./vaultwarden.nix + ]; +} diff --git a/willem/services/gitea.nix b/willem/services/gitea.nix new file mode 100644 index 0000000..1c2bb15 --- /dev/null +++ b/willem/services/gitea.nix @@ -0,0 +1,23 @@ +{ pkgs, ...}: +{ + services.gitea = { + enable = true; + appName = "Lambda-Git"; + package = pkgs.forgejo; + stateDir = "/gitea"; + database = { + type = "sqlite3"; + }; + dump = { + enable = true; + interval = "02:00"; + }; + settings.server = { + ROOT_URL = "https://git.vatthauer.xyz"; + HTTP_PORT = 3001; + DOMAIN = "git.vatthauer.xyz"; + }; + settings.session.COOKIE_SECURE = true; + settings.service.DISABLE_REGISTRATION = true; + }; +} \ No newline at end of file diff --git a/willem/services/nginx.nix b/willem/services/nginx.nix new file mode 100644 index 0000000..96aebac --- /dev/null +++ b/willem/services/nginx.nix @@ -0,0 +1,33 @@ +{ + services.nginx = { + enable = true; + recommendedGzipSettings = true; + recommendedOptimisation = true; + recommendedProxySettings = true; + recommendedTlsSettings = true; + }; + + services.nginx.virtualHosts."git.vatthauer.xyz" = { + enableACME = true; + forceSSL = true; + locations."/" = { + proxyPass = "http://localhost:3001/"; + }; + }; + + services.nginx.virtualHosts."bitwarden.vatthauer.xyz" = { + enableACME = true; + forceSSL = true; + locations."/" = { + proxyPass = "http://localhost:8222/"; + }; + }; + + services.nginx.virtualHosts."video.vatthauer.xyz" = { + enableACME = true; + forceSSL = false; + locations."/" = { + proxyPass = "http://localhost:8096"; + }; + }; +} diff --git a/willem/services/printing.nix b/willem/services/printing.nix new file mode 100644 index 0000000..321e5b2 --- /dev/null +++ b/willem/services/printing.nix @@ -0,0 +1,20 @@ +{ pkgs, ... }: +{ + # Enable CUPS to print documents. + services.avahi = { + enable = true; + publish.enable = true; + publish.userServices = true; + }; + services.printing = { + enable = true; + drivers = [ pkgs.splix ]; + browsing = true; + listenAddresses = [ "*:631" ]; + allowFrom = [ "all" ]; + defaultShared = true; + extraConf = '' + BrowseLocalProtocols all + ''; + }; +} diff --git a/willem/services/restic.nix b/willem/services/restic.nix new file mode 100644 index 0000000..2b4f213 --- /dev/null +++ b/willem/services/restic.nix @@ -0,0 +1,17 @@ +{ + services.restic.backups = { + giteaBackup = { + paths = [ "/gitea/dump" ]; + # environmentFile = "/home/leonv/nixos/willem/private/gitea_backupCreds"; + # passwordFile = "/home/leonv/nixos/willem/private/restic-password"; + environmentFile = "${../../nix-secrets/willem/gitea/backupCreds}"; + passwordFile = "${../../nix-secrets/willem/restic/password}"; + repository = "b2:gitea-willem"; + initialize = true; + timerConfig = { + OnCalendar = "04:00"; + Persistent = true; + }; + }; + }; +} \ No newline at end of file diff --git a/willem/services/ssh.nix b/willem/services/ssh.nix new file mode 100644 index 0000000..dba27db --- /dev/null +++ b/willem/services/ssh.nix @@ -0,0 +1,4 @@ +{ + # Enable the OpenSSH daemon. + services.openssh.enable = true; +} \ No newline at end of file diff --git a/willem/services/vaultwarden.nix b/willem/services/vaultwarden.nix new file mode 100644 index 0000000..1f7d8a2 --- /dev/null +++ b/willem/services/vaultwarden.nix @@ -0,0 +1,19 @@ +{ + services.vaultwarden = { + enable = true; + config = { + DOMAIN = "https://bitwarden.vatthauer.xyz"; + SIGNUPS_ALLOWED = false; + + ROCKET_ADDRESS = "127.0.0.1"; + ROCKET_PORT = 8222; + + ROCKET_LOG = "critical"; + + ADMIN_TOKEN = "${../../nix-secrets/willem/vaultwarden/admin-token}"; + + YUBICO_CLIENT_ID = "${../../nix-secrets/willem/vaultwarden/yubico-id}"; + YUBICO_SECRET_KEY = "${../../nix-secrets/willem/vaultwarden/yubico-secret}"; + }; + }; +}