commit 8c98e8bd14aa66759ca18f55599a6163e6b37a6c Author: foosinn Date: Thu Jun 11 19:13:58 2020 +0200 initial diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..59d0e90 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/result +/roles/wireless.nix diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..61c4758 --- /dev/null +++ b/configuration.nix @@ -0,0 +1,40 @@ +# 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, ... }: + +{ + imports = + [ + + + + # Include the results of the hardware scan. + ./hardware-configuration.nix + + ./roles/dev.nix + ./roles/base.nix + ./roles/desktop.nix + ./roles/wireless.nix + ]; + + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + networking.hostName = "raven"; + networking.hostId = "e3a397c5"; + + networking.useDHCP = false; + networking.interfaces.enp0s25.useDHCP = true; + networking.interfaces.wlp3s0.useDHCP = true; + + i18n.defaultLocale = "en_US.UTF-8"; + time.timeZone = "Europe/Berlin"; + + services.openssh.enable = true; + networking.firewall.enable = true; + + system.stateVersion = "20.03"; # We can stay here +} + diff --git a/dotfiles/sway/config b/dotfiles/sway/config new file mode 100644 index 0000000..3944eb2 --- /dev/null +++ b/dotfiles/sway/config @@ -0,0 +1,132 @@ +# config +set $mod Mod1 +set $left h +set $down j +set $up k +set $right l +set $term alacritty +set $menu bemenu-run + +output * bg /home/stefan/Sync/wall/nasa-yZygONrUBe8-unsplash.jpg fill +output eDP-1 scale 1.3 +output DP-1 res 5120x1440 + +# user keybinds +bindsym $mod+Return exec $term +bindsym $mod+Shift+q kill +bindsym $mod+d exec $menu +floating_modifier $mod normal +bindsym $mod+Shift+c reload +bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit' +bindsym $mod+Shift+p exec keepassxc +bindsym $mod+z exec swaylock -t +bindsym $mod+Up exec light -A 5 +bindsym $mod+Down exec light -U 5 +bindsym Print exec grim -g "$(slurp)" - | wl-copy -t image/png + +# app rules +for_window [app_id="org.keepassxc.KeePassXC"] floating enable + +# font +font Cascadia Code 10 + +# colors +set $black #2d2a2e +set $base00 #2d2a2e +set $base01 #cc6666 +set $base02 #a9dc76 +set $base03 #ffd866 +set $base04 #78dce8 +set $base05 #55dbbe +set $base06 #ff6181 +set $base07 #eeeeee +set $base08 #323232 +set $base09 #cc6666 +set $base0A #ffd866 +set $base0B #78dce8 +set $base0C #55dbbe +set $base0D #ff6181 +set $base0E #a6dc76 +set $base0F #ffffff + +# border background text indicator +client.focused $base04 $base00 $base07 $base04 $base04 +client.focused_inactive $base00 $base00 $base07 $base00 $base00 +client.unfocused $black $black $base07 $base00 $base00 +client.urgent $base01 $base01 $base00 $base08 $base07 + + +# movement +bindsym $mod+$left focus left +bindsym $mod+$down focus down +bindsym $mod+$up focus up +bindsym $mod+$right focus right +bindsym $mod+Shift+$left move left +bindsym $mod+Shift+$down move down +bindsym $mod+Shift+$up move up +bindsym $mod+Shift+$right move right + +bindsym $mod+1 workspace 1 +bindsym $mod+2 workspace 2 +bindsym $mod+3 workspace 3 +bindsym $mod+4 workspace 4 +bindsym $mod+5 workspace 5 +bindsym $mod+6 workspace 6 +bindsym $mod+7 workspace 7 +bindsym $mod+8 workspace 8 +bindsym $mod+9 workspace 9 +bindsym $mod+0 workspace 10 +bindsym $mod+Shift+1 move container to workspace 1 +bindsym $mod+Shift+2 move container to workspace 2 +bindsym $mod+Shift+3 move container to workspace 3 +bindsym $mod+Shift+4 move container to workspace 4 +bindsym $mod+Shift+5 move container to workspace 5 +bindsym $mod+Shift+6 move container to workspace 6 +bindsym $mod+Shift+7 move container to workspace 7 +bindsym $mod+Shift+8 move container to workspace 8 +bindsym $mod+Shift+9 move container to workspace 9 +bindsym $mod+Shift+0 move container to workspace 10 + +bindsym $mod+b splith +bindsym $mod+v splitv +bindsym $mod+s layout stacking +bindsym $mod+w layout tabbed +bindsym $mod+e layout toggle split +bindsym $mod+f fullscreen +bindsym $mod+Shift+space floating toggle +bindsym $mod+space focus mode_toggle +bindsym $mod+a focus parent + +bindsym $mod+Shift+minus move scratchpad +bindsym $mod+minus scratchpad show + +mode "resize" { + bindsym $left resize shrink width 10px + bindsym $down resize grow height 10px + bindsym $up resize shrink height 10px + bindsym $right resize grow width 10px + bindsym Return mode "default" + bindsym Escape mode "default" +} +bindsym $mod+r mode "resize" + +bar { + position bottom + colors { + background $black + statusline $base07 + separator $base04 + + # border back text + focused_workspace $base04 $base04 $base00 + active_workspace $base04 $base04 $base00 + urgent_workspace $base01 $base01 $base07 + inactive_workspace $base00 $base00 $base07 + + } + status_command i3status-rs /etc/sway/status.toml +} + +include /etc/sway/config.d/* + +exec mako diff --git a/dotfiles/sway/status.toml b/dotfiles/sway/status.toml new file mode 100644 index 0000000..0f42571 --- /dev/null +++ b/dotfiles/sway/status.toml @@ -0,0 +1,109 @@ +[theme] +name = "plain" +[theme.overrides] +idle_bg = "#2d2a2e" +idle_fg = "#eeeeee" +info_bg = "#2d2a2e" +info_fg = "#eeeeee" +good_bg = "#2d2a2e" +good_fg = "#a9dc76" +warning_bg = "#2d2a2e" +warning_fg = "#ffd866" +critical_bg = "#2a2e38" +critical_fg = "#ff665c" +separator_bg = "#2d2a2e" +separator_fg = "#555555" +separator = "|" + +[icons] +name = "none" +[icons.overrides] +bat = "  " +bat_full = "  " +bat_charging = "   " +bat_discharging = "  " +backlight_empty = "  " +backlight_partial1 = "  " +backlight_partial2 = "  " +backlight_partial3 = "  " +backlight_full = "  " +volume_full = "  " +volume_half = "  " +volume_empty = "  " +volume_muted= "MUTE" +cogs = "  " +memory_mem = "  " +headphones = "  " +net_wireless = " " +net_vpn = " " +net_wired = "" +net_up = "UP" +net_down = "DOWN" +thermometer = "  " + + +[[block]] +block = "net" +device = "wg" +ip = true +ssid = false +speed_up = false +speed_down = false +hide_inactive = true +hide_missing = true + +[[block]] +block = "net" +device = "wlp0s20f3" +ip = true +ssid = true +speed_up = false +speed_down = false +hide_inactive = true +hide_missing = true + +[[block]] +block = "temperature" +collapsed = false +interval = 10 +chip = "coretemp-isa-0000" +format = "{min}..{max}°" + +[[block]] +block = "disk_space" +path = "/" +alias = " /" +info_type = "available" +unit = "GB" +interval = 20 +warning = 20.0 +alert = 10.0 + +[[block]] +block = "memory" +display_type = "memory" +format_mem = "{Mup}%" +clickable = false + +[[block]] +block = "load" +interval = 1 +format = "{1m}" + +[[block]] +block = "sound" +driver = "pulseaudio" + +[[block]] +block = "backlight" + +[[block]] +block = "battery" +device = "BAT0" +interval = 10 +format = "{percentage}%" + +[[block]] +block = "time" +interval = 60 +format = "%Y-%m-%d %H:%M" diff --git a/hardware-configuration.nix b/hardware-configuration.nix new file mode 100644 index 0000000..e9bda5f --- /dev/null +++ b/hardware-configuration.nix @@ -0,0 +1,44 @@ +# 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, ... }: + +{ + imports = + [ + ]; + + boot.initrd.availableKernelModules = [ "ehci_pci" "ahci" "usb_storage" "sd_mod" "sdhci_pci" ]; + boot.initrd.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + + boot.initrd.luks.devices = { + swap = { + device = "/dev/disk/by-uuid/fe87a31c-7d0b-4073-98fc-fa825de77181"; + allowDiscards = true; + }; + }; + + fileSystems."/" = + { device = "tank/root/nixos"; + fsType = "zfs"; + }; + + fileSystems."/home" = + { device = "tank/home"; + fsType = "zfs"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/0C2D-2799"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/2ac33f61-0db5-4f94-8148-93f2166b2f29"; } + ]; + + nix.maxJobs = lib.mkDefault 4; + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; +} diff --git a/packages/neovim.nix b/packages/neovim.nix new file mode 100644 index 0000000..969f584 --- /dev/null +++ b/packages/neovim.nix @@ -0,0 +1,113 @@ +with import {}; + +neovim.override { + configure = { + customRC = '' + set hidden + + " langserver + let g:LanguageClient_serverCommands = { + \ 'go': ['gopls'], + \ 'python': ['pyls'], + \ 'rust': ['rust-analyzer'], + \ } + + " basic builtin + set background=dark + set shiftwidth=4 + set softtabstop=4 + set tabstop=4 + set expandtab + set ttyfast + set lazyredraw + set regexpengine=1 + set synmaxcol=500 + set relativenumber + set number + set relativenumber + set mouse=a + set shortmess+=c + + " better search + set incsearch + set ignorecase + set smartcase + set gdefault + + " autocomplete + autocmd BufEnter * call ncm2#enable_for_buffer() + inoremap + inoremap (pumvisible() ? "\\" : "\") + set completeopt=noinsert,menuone,noselect + let g:LanguageClient_completionPreferTextEdit = 1 + let g:LanguageClient_diagnosticsSignsMax = 0 + + " securemodelines + let g:secure_modelines_allowed_items = [ + \ "textwidth", "tw", + \ "softtabstop", "sts", + \ "tabstop", "ts", + \ "shiftwidth", "sw", + \ "expandtab", "et", "noexpandtab", "noet", + \ "filetype", "ft", + \ "foldmethod", "fdm", + \ "readonly", "ro", "noreadonly", "noro", + \ "rightleft", "rl", "norightleft", "norl", + \ "colorcolumn" + \ ] + + " leader + let mapleader = " " + nnoremap :WhichKey '' + noremap :Commands + noremap :b# + let g:which_key_map = {} + + let g:which_key_map.f = { 'name': '+files' } + noremap ff :FZF + noremap fc :saveas + + let g:which_key_map.y = { 'name': '+yank' } + noremap yp :read !wl-paste + noremap yy :read !wl-paste + noremap ya :w !wl-copy + + let g:which_key_map.b = { 'name': '+buffers' } + noremap bb :Buffers + noremap bh :History + noremap bd :bd + noremap bn :bn + noremap bp :bp + + let g:which_key_map.b = { 'name': '+lang' } + noremap mc :call LanguageClient#textDocument_references() + noremap mf :call LanguageClient#textDocument_formatting() + noremap mgg :call LanguageClient#textDocument_definition() + noremap mh :call LanguageClient#textDocument_documentHighlight() + noremap mm :call LanguageClient#textDocument_hover() + noremap mr :call LanguageClient#textDocument_rename() + noremap ms :call LanguageClient#workspace_symbol() + + " lang specifics + let g:rustfmt_autosave = 1 + let g:rustfmt_emit_files = 1 + let g:rustfmt_fail_silently = 0 + ''; + packages.myNvim = with pkgs.vimPlugins; { + start = [ + airline + easymotion + editorconfig-vim + fugitive + fzf + LanguageClient-neovim + ncm2 + surround + syntastic + vim-addon-nix + vim-highlightedyank + vim-which-key + ]; + }; + }; +} diff --git a/packages/vim.nix b/packages/vim.nix new file mode 100644 index 0000000..b700556 --- /dev/null +++ b/packages/vim.nix @@ -0,0 +1,30 @@ +with import {}; + +vim_configurable.customize { + name = "vim"; + vimrcConfig.customRC = '' + set hidden + + " langserver + let g:LanguageClient_serverCommands = { + \ 'rust': ['rust-analyzer'], + \ 'python': ['pyls'], + \ } + + let g:deoplete#enable_at_startup = 1 + + ''; + + vimrcConfig.packages.myVim = with pkgs.vimPlugins; { + start = [ + airline + easymotion + fugitive + fzf + LanguageClient-neovim + surround + syntastic + vim-mucomplete + ]; + }; +} diff --git a/roles/base.nix b/roles/base.nix new file mode 100644 index 0000000..d177262 --- /dev/null +++ b/roles/base.nix @@ -0,0 +1,67 @@ +# 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, ... }: + +{ + environment.systemPackages = with pkgs; [ + bash + bat + emacs-nox + fd + fzf + git + htop + jq + ripgrep + z-lua + # (import ../packages/vim.nix) + (import ../packages/neovim.nix) + ]; + + + programs.bash = { + interactiveShellInit = '' + pw () { + len=''${1:-$(( $RANDOM % 24 + 8 ))} + tr -dc a-zA-Z0-9 < /dev/urandom | head -c $len + echo + } + + cdg() { + gitroot=$(until [ -d .git ]; do [ "$PWD" == "/" ] && exit 1; cd ..; done; echo $PWD) + if [ $? == 0 ]; then + cd $gitroot + else + echo "gitroot not found." + return 1 + fi + } + + git_branch(){ + branch=$(git branch 2> /dev/null) || exit 0 + branch=$(sed -n '/^*/ s/* \(.*\)/\1/p' <<< $branch) + status=$(git status 2> /dev/null \ + | grep -q "nothing to commit, working tree clean" || e cho -n '*') + echo "$branch$status " + } + + . "$(fzf-share)/key-bindings.bash" + . "$(fzf-share)/completion.bash" + eval $(z --init bash) + ''; + shellAliases = { + cat = "bat -pp"; + less = "bat -p"; + ls = "ls --color=auto"; + vim = "nvim"; + }; + }; + + users.users.stefan = { + extraGroups = [ "wheel" ]; + home = "/home/stefan"; + isNormalUser = true; + uid = 1000; + }; +} diff --git a/roles/desktop.nix b/roles/desktop.nix new file mode 100644 index 0000000..74e35dd --- /dev/null +++ b/roles/desktop.nix @@ -0,0 +1,75 @@ +# 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, ... }: + +{ + programs.sway = { + enable = true; + extraPackages = with pkgs; [ + bemenu + grim + i3status-rust + kanshi + mako + slurp + swayidle + swaylock + ]; + }; + + environment = { + etc = { + "sway/config".source = ../dotfiles/sway/config; + "sway/status.toml".source = ../dotfiles/sway/status.toml; + }; + }; + + sound.enable = true; + hardware.pulseaudio.enable = true; + + fonts.enableDefaultFonts = true; + fonts.fontconfig.antialias = true; + fonts.fonts = with pkgs; [ + cascadia-code + font-awesome + noto-fonts + noto-fonts-emoji + ]; + + environment.systemPackages = with pkgs; [ + alacritty + firefox + keepassxc + neofetch + pulseaudio + pulsemixer + ( + pkgs.writeTextFile { + name = "startsway"; + destination = "/bin/startsway"; + executable = true; + text = '' + #! ${pkgs.bash}/bin/bash + + export MOZ_ENABLE_WAYLAND=1 + export QT_QPA_PLATFORM=wayland-egl + export QT_WAYLAND_FORCE_DPI=physical + export SDL_VIDEODRIVER=wayland + export _JAVA_AWT_WM_NOREPARENTING=1 + exec ${pkgs.dbus}/bin/dbus-run-session ${pkgs.sway}/bin/sway + ''; + } + ) + ]; + + services.syncthing = { + enable = true; + openDefaultPorts = true; + user = "stefan"; + group = "users"; + dataDir = "/home/stefan"; + }; + + services.printing.enable = true; +} diff --git a/roles/dev.nix b/roles/dev.nix new file mode 100644 index 0000000..b975189 --- /dev/null +++ b/roles/dev.nix @@ -0,0 +1,21 @@ +# 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, ... }: + +let + unstable = import {}; + mozilla_overlay = import {}; + +in { + environment.systemPackages = with pkgs; [ + go + python37 + python37Packages.pyls-black + python37Packages.pyls-isort + python37Packages.pyls-mypy + rustup + unstable.gopls + unstable.rust-analyzer + ]; +}