From 2bef9032fc372087c417a045dd416f2ba0a7e5ca Mon Sep 17 00:00:00 2001 From: Matthew Ess Date: Sun, 10 Jan 2021 22:59:20 -0500 Subject: [PATCH] Reorg for multiple machines --- assets/init.vim | 60 +++--- assets/pijul.fish | 1 + configuration.nix | 222 ------------------- hardware-configuration.nix | 30 --- hm-configs/dunst.nix | 43 ++++ hm-configs/files.nix | 59 +++++ hm-configs/fish.nix | 72 +++++++ i3.nix => hm-configs/i3.nix | 10 +- hm-configs/neovim.nix | 23 ++ hm-configs/vscode.nix | 18 ++ home.nix | 331 ----------------------------- install.sh | 17 +- machines/gagarin/configuration.nix | 37 ++++ machines/nixpad/configuration.nix | 41 ++++ profiles/caches.nix | 10 + profiles/common.nix | 37 ++++ profiles/fonts.nix | 16 ++ profiles/graphical.nix | 49 +++++ profiles/laptop.nix | 42 ++++ profiles/quicksudo.nix | 4 + services/l10n.nix | 13 ++ services/pubkey.nix | 4 + services/ssh.nix | 12 ++ services/vpn.nix | 4 + users/mat-hm-laptop.nix | 103 +++++++++ users/mat-hm.nix | 75 +++++++ users/mat.nix | 15 ++ 27 files changed, 729 insertions(+), 619 deletions(-) create mode 120000 assets/pijul.fish delete mode 100644 configuration.nix delete mode 100644 hardware-configuration.nix create mode 100644 hm-configs/dunst.nix create mode 100644 hm-configs/files.nix create mode 100644 hm-configs/fish.nix rename i3.nix => hm-configs/i3.nix (95%) create mode 100644 hm-configs/neovim.nix create mode 100644 hm-configs/vscode.nix delete mode 100644 home.nix mode change 100644 => 100755 install.sh create mode 100644 machines/gagarin/configuration.nix create mode 100644 machines/nixpad/configuration.nix create mode 100644 profiles/caches.nix create mode 100644 profiles/common.nix create mode 100644 profiles/fonts.nix create mode 100644 profiles/graphical.nix create mode 100644 profiles/laptop.nix create mode 100644 profiles/quicksudo.nix create mode 100644 services/l10n.nix create mode 100644 services/pubkey.nix create mode 100644 services/ssh.nix create mode 100644 services/vpn.nix create mode 100644 users/mat-hm-laptop.nix create mode 100644 users/mat-hm.nix create mode 100644 users/mat.nix diff --git a/assets/init.vim b/assets/init.vim index 72fa05c..f0dcee4 100644 --- a/assets/init.vim +++ b/assets/init.vim @@ -43,33 +43,33 @@ autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isT nnoremap :NERDTreeToggle "LSP support -set hidden -let g:LanguageClient_rootMarkers = ['*.cabal', 'stack.yaml'] -let g:LanguageClient_serverCommands = { - \ 'haskell': ['ghcide', '--lsp'], - \ } -let g:LanguageClient_preferredMarkupKind = ['plaintext'] -let g:LanguageClient_completionPreferTextEdit = 1 -nnoremap K :call LanguageClient#textDocument_hover() -nnoremap f :call LanguageClient#textDocument_rangeFormatting() -nnoremap F :call LanguageClient#textDocument_formatting() -nnoremap gd :call LanguageClient#textDocument_definition() -nnoremap gr :call LanguageClient#textDocument_references() -set cmdheight=2 -set updatetime=300 -set signcolumn=yes - -"NCM2 -autocmd bufenter * call ncm2#enable_for_buffer() -au User Ncm2PopupOpen set completeopt=noinsert,menuone,noselect -au User Ncm2PopupClose set completeopt=menuone -set shortmess+=c -" CTRL-C doesn't trigger the InsertLeave autocmd . map to instead. -inoremap -" When the key is pressed while the popup menu is visible, it only -" hides the menu. Use this mapping to close the menu and also start a new -" line. -inoremap (pumvisible() ? "\\" : "\") -" Use to select the popup menu: -inoremap pumvisible() ? "\" : "\" -inoremap pumvisible() ? "\" : "\" +"set hidden +"let g:LanguageClient_rootMarkers = ['*.cabal', 'stack.yaml'] +"let g:LanguageClient_serverCommands = { +" \ 'haskell': ['ghcide', '--lsp'], +" \ } +"let g:LanguageClient_preferredMarkupKind = ['plaintext'] +"let g:LanguageClient_completionPreferTextEdit = 1 +"nnoremap K :call LanguageClient#textDocument_hover() +"nnoremap f :call LanguageClient#textDocument_rangeFormatting() +"nnoremap F :call LanguageClient#textDocument_formatting() +"nnoremap gd :call LanguageClient#textDocument_definition() +"nnoremap gr :call LanguageClient#textDocument_references() +"set cmdheight=2 +"set updatetime=300 +"set signcolumn=yes +" +""NCM2 +"autocmd bufenter * call ncm2#enable_for_buffer() +"au User Ncm2PopupOpen set completeopt=noinsert,menuone,noselect +"au User Ncm2PopupClose set completeopt=menuone +"set shortmess+=c +"" CTRL-C doesn't trigger the InsertLeave autocmd . map to instead. +"inoremap +"" When the key is pressed while the popup menu is visible, it only +"" hides the menu. Use this mapping to close the menu and also start a new +"" line. +"inoremap (pumvisible() ? "\\" : "\") +"" Use to select the popup menu: +"inoremap pumvisible() ? "\" : "\" +"inoremap pumvisible() ? "\" : "\" diff --git a/assets/pijul.fish b/assets/pijul.fish new file mode 120000 index 0000000..087399c --- /dev/null +++ b/assets/pijul.fish @@ -0,0 +1 @@ +/home/mat/dev/pijul-fish-completions/pijul.fish \ No newline at end of file diff --git a/configuration.nix b/configuration.nix deleted file mode 100644 index 7ea2932..0000000 --- a/configuration.nix +++ /dev/null @@ -1,222 +0,0 @@ -# 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 - # Cachix caches - ./cachix.nix - # Overlays - - ]; - - # Bootloader - boot.loader.systemd-boot.enable = true; - boot.loader.systemd-boot.configurationLimit = 64; - boot.loader.efi.canTouchEfiVariables = true; - - console.earlySetup = true; - console.keyMap = "us"; - - system.autoUpgrade.enable = true; - - networking = { - hostName = "nixpad"; # Define your hostname. - networkmanager = { - enable = true; - wifi.scanRandMacAddress = false; - }; - - # The global useDHCP flag is deprecated, therefore explicitly set to false here. - # Per-interface useDHCP will be mandatory in the future, so this generated config - # replicates the default behaviour. - useDHCP = false; - interfaces = { - enp0s25.useDHCP = true; - wlp3s0.useDHCP = true; - wwp0s20u4c2i12.useDHCP = true; - }; - - wireguard.enable = true; - - firewall = let - ports = [ - 32400 # Plex local - 57955 # Plex VPN - 57430 # Deluge - ]; - in { - allowedTCPPorts = ports; - allowedUDPPorts = ports; - }; - }; - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - fonts = { - enableDefaultFonts = true; - fonts = with pkgs; [ - source-code-pro - fira-code - fira-code-symbols - font-awesome_4 - aileron - gohufont - spleen - tamsyn - siji - unscii - ]; - fontconfig = { - enable = true; - defaultFonts = { monospace = [ "Fira Code" ]; }; - }; - }; - - # Select internationalisation properties. - i18n = { defaultLocale = "en_US.UTF-8"; }; - - # Set your time zone. - time.timeZone = "America/New_York"; - - # List packages installed in system profile. To search, run: - # $ nix search wget - environment.systemPackages = with pkgs; [ - # System utilities - git - tmux - tree - vim - wget - - # Interfacing with HFS+ drives - hfsprogs - ]; - - # Some programs need SUID wrappers, can be configured further or are - # started in user sessions. - # programs.mtr.enable = true; - # programs.gnupg.agent = { enable = true; enableSSHSupport = true; }; - - programs = { - fish.enable = false; - light.enable = true; - nm-applet.enable = true; - seahorse.enable = true; - ssh = { startAgent = true; }; - }; - - # List services that you want to enable: - services = { - fprintd = { - enable = true; - # package = pkgs.fprintd-thinkpad; - }; - openssh.enable = true; - clipmenu.enable = true; - geoclue2.enable = true; - gvfs.enable = true; - printing.enable = true; - gnome3.gnome-keyring.enable = true; - upower.enable = true; - mullvad-vpn.enable = true; - plex = { - enable = true; - # user = "mat"; - }; - xserver = { - enable = true; - layout = "us"; - - videoDrivers = [ "intel" ]; - deviceSection = '' - Option "DRI" "3" - Option "TearFree" "true" - ''; - useGlamor = true; - - # Enable touchpad support. - libinput = { - enable = true; - naturalScrolling = true; - disableWhileTyping = true; - }; - - desktopManager = { - session = [{ - name = "home-manager"; - start = '' - ${pkgs.runtimeShell} $HOME/.hm-xsession & - waitPID=$! - ''; - }]; - }; - displayManager = { - defaultSession = "home-manager"; - autoLogin = { - enable = true; - user = "mat"; - }; - }; - }; - }; - - # Enable sound. - sound.enable = true; - - # Hardware switches - hardware = { - logitech.wireless = { - enable = true; - # enableGraphical = true; - }; - opengl = { - driSupport32Bit = true; - extraPackages32 = [ pkgs.pkgsi686Linux.libva ]; - }; - pulseaudio = { - enable = true; - support32Bit = true; - }; - }; - - nixpkgs.config.allowUnfree = true; - - # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.mat = { - isNormalUser = true; - shell = pkgs.fish; - extraGroups = [ - "wheel" # Enable ‘sudo’ for the user. - "networkmanager" - "audio" - "video" - ]; - }; - home-manager.users.mat = import ./home.nix; - - fileSystems = { - "/mnt/passport".device = "/dev/sdb"; - }; - - # Don't ask for my password *quite* as often. - security.sudo.extraConfig = "Defaults timestamp_timeout=60"; - - nix = { - binaryCaches = [ "https://hydra.iohk.io" ]; - binaryCachePublicKeys = - [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ]; - }; - - # This value determines the NixOS release with which your system is to be - # compatible, in order to avoid breaking some software such as database - # servers. You should change this only after NixOS release notes say you - # should. - system.stateVersion = "19.09"; # Did you read the comment? - -} diff --git a/hardware-configuration.nix b/hardware-configuration.nix deleted file mode 100644 index 10e8b67..0000000 --- a/hardware-configuration.nix +++ /dev/null @@ -1,30 +0,0 @@ -# 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 = - [ "xhci_pci" "ehci_pci" "ahci" "usb_storage" "sd_mod" ]; - boot.initrd.kernelModules = [ ]; - boot.kernelModules = [ "kvm-intel" ]; - boot.extraModulePackages = [ ]; - - fileSystems."/" = { - device = "/dev/disk/by-uuid/3aad55c2-899f-4af7-a0b4-5aa1c11685a7"; - fsType = "ext4"; - }; - - fileSystems."/boot" = { - device = "/dev/disk/by-uuid/4A83-BBDF"; - fsType = "vfat"; - }; - - swapDevices = - [{ device = "/dev/disk/by-uuid/d1bbcef9-0948-4618-ba61-06c5cb98c1d7"; }]; - - nix.maxJobs = lib.mkDefault 4; - powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; -} diff --git a/hm-configs/dunst.nix b/hm-configs/dunst.nix new file mode 100644 index 0000000..76e6e2d --- /dev/null +++ b/hm-configs/dunst.nix @@ -0,0 +1,43 @@ +{ + enable = true; + settings = { + global = { + geometry = "0x5-30+20"; + notification_height = 25; + indicate_hidden = "yes"; + corner_radius = 5; + padding = 10; + horizontal_padding = 10; + idle_threshold = 60; + font = "Fira Code 16"; + markup = "full"; + format = '' + %s %a + %b''; + alignment = "center"; + horizontal_alignment = "center"; + icon_position = "left"; + max_icon_size = 100; + separator_color = "#383838"; + frame_color = "#383838"; + frame_width = 2; + }; + shortcuts = { + close = "ctrl+space"; + history = "ctrl+shift+grave"; + }; + urgency_low = { + background = "#282828"; + foreground = "#5882FA"; + }; + urgency_normal = { + background = "#282828"; + foreground = "#5882FA"; + }; + urgency_critical = { + background = "#282828"; + foreground = "#FF0040"; + timeout = 0; + }; + }; +} diff --git a/hm-configs/files.nix b/hm-configs/files.nix new file mode 100644 index 0000000..62ec028 --- /dev/null +++ b/hm-configs/files.nix @@ -0,0 +1,59 @@ +{ + ".background-image".source = ../assets/background-image; + ".lockscreen-image".source = ../assets/lockscreen-image; + ".config/fish/fishfile".text = '' + laughedelic/pisces + joehillen/to-fish + jethrokuan/z + decors/fish-colored-man + franciscolourenco/done + haslersn/fish-nix-completions + gyakovlev/fish-fzy + joseluisq/gitnow + edc/bass + fishpkg/fish-get + fishpkg/fish-spin + oh-my-fish/plugin-bang-bang + fishpkg/fish-humanize-duration + jorgebucaran/fish-getopts + matthewess/fish-autovenv + ''; + ".config/fish/completions/pijul.fish".source = ../assets/pijul.fish; + ".config/fish/completions/systemctl.fish".source = ../assets/systemctl.fish; + ".config/fish/functions/colortest.fish".source = ../assets/colortest.fish; + ".config/fish/functions/kbl.fish".text = '' + function kbl -a level + set -l initial (cat /sys/class/leds/tpacpi\:\:kbd_backlight/brightness) + test -z "$level"; and set -l level $initial + echo $level > /sys/class/leds/tpacpi\:\:kbd_backlight/brightness + end + ''; + ".config/fish/functions/mkdcd.fish".text = '' + function mkdcd -a target + mkdir $target + cd $target + end + ''; + ".config/fish/functions/unz.fish".text = '' + function unz -a target + # strip extensions + string match \*.zip $target; and set target (string split -r -m1 . $target)[1] + unzip -d $target $target + end + ''; + ".config/i3status.toml".source = ../assets/i3status.toml; + ".config/kitty/kitty.conf".text = '' + font_family Fira Code Regular + bold_font Fira Code Bold + font_size 15.0 + include ./theme.conf + ''; + ".config/kitty/theme.conf".source = ../assets/kitty-theme.conf; + ".config/rofi/theme.rasi".source = ../assets/sidetab.rasi; + ".config/pijul/config.toml".text = '' + [author] + name = "mat" + full_name = "mat" + email = "mat@mat.services" + ''; +} diff --git a/hm-configs/fish.nix b/hm-configs/fish.nix new file mode 100644 index 0000000..ddce51d --- /dev/null +++ b/hm-configs/fish.nix @@ -0,0 +1,72 @@ +{ pkgs, ... }: { + enable = true; + package = pkgs.fish; + interactiveShellInit = '' + echo 'ヽ(´ᗜ`)ノ welcome ヽ(´ᗜ`)ノ' + if not functions -q fisher + set -q XDG_CONFIG_HOME; or set XDG_CONFIG_HOME ~/.config + curl https://git.io/fisher --create-dirs -sLo $XDG_CONFIG_HOME/fish/functions/fisher.fish + fish -c fisher + end + fish_vi_key_bindings + set VIRTUAL_ENV_DISABLE_PROMPT true + + alias cat=bat + alias br=broot + alias tree=br + alias ack=rg + alias ag=rg + alias grep=rg + + alias sys="sudo systemctl" + + alias rebuild="sudo nixos-rebuild switch" + alias rebuildd="sudo nixos-rebuild switch; and systemctl restart display-manager" + alias upgrade="sudo rm -rf /root/.cache/nix/tarballs; and sudo nix-channel --update; and sudo nixos-rebuild switch --upgrade" + + alias clip="xclip -selection c" + + alias cxuse="sudo cachix use -d ~/dotfiles.nix" + alias cxpsh="nix-shell --command exit; nix-store -qR --include-outputs (nix-instantiate shell.nix) | cachix push" + alias cxpush=cxpsh + + function config -a file + if test -z "$file" + set file configuration + end + vim ~/dotfiles.nix/$file.nix +'cd %:p:h' + end + + alias vims="vim -S Session.vim" + + alias bigscreen="xrandr --output eDP1 --off --output HDMI2 --auto" + alias smallscreen="xrandr --output eDP1 --auto --output HDMI2 --off" + + function tmux-ssh -a user -a host + set target "$user@$host" + set session "$user-$host" + env TERM=tmux-256color ssh $target -t "tmux -2 attach -t $session || tmux -2 new -s $session" + end + + alias pi="tmux-ssh pi pi" + alias mir="tmux-ssh mat mir" + alias drop=mir + alias soviet="tmux-ssh mat soviet" + alias gagarin="tmux-ssh mat gagarin" + alias yuri=gagarin + alias gaga=gagarin + + alias wifi="nmcli r w off; nmcli r w on" + + alias nixops=~/dev/nixops/result/bin/nixops + + bind \cr 'fzy_select_history (commandline -b)' + bind -M insert \cr 'fzy_select_history (commandline -b)' + + bind \cf 'fzy_select_directory' + bind -M insert \cf 'fzy_select_directory' + + bind -M insert ! __history_previous_command + bind -M insert '$' __history_previous_command_arguments + ''; +} diff --git a/i3.nix b/hm-configs/i3.nix similarity index 95% rename from i3.nix rename to hm-configs/i3.nix index ebf4b5d..e32b534 100644 --- a/i3.nix +++ b/hm-configs/i3.nix @@ -1,4 +1,4 @@ -{ lib, lockCmd, statusCmd, ... }: { +{ lib, statusCmd, ... }: { enable = true; config = rec { fonts = [ "Aileron" "FontAwesome 14" ]; @@ -92,6 +92,7 @@ # "${modifier}+Shift+Right" = "workspace next"; # "${modifier}+Shift+Left" = "workspace prev"; "${modifier}+d" = "exec --no-startup-id rofi -show run"; + "${modifier}+g" = "exec --no-startup-id /home/mat/.bin/lagrange"; "XF86AudioRaiseVolume" = "exec --no-startup-id amixer sset Master 5%+"; "XF86AudioLowerVolume" = "exec --no-startup-id amixer sset Master 5%-"; "XF86MonBrightnessUp" = "exec --no-startup-id light -A 10"; @@ -99,7 +100,11 @@ }; workspaceLayout = "tabbed"; assigns = { - "1: web" = [{ class = "Firefox"; }]; + "1: web" = [ + { class = "Firefox"; } + { class = "(?i)castor"; } + { class = "(?i)lagrange"; } + ]; "2: devel" = [ { class = "(?i)kitty"; } { class = "(?i)(vsc|c)odium"; } @@ -111,7 +116,6 @@ { class = "discord"; } { class = "(?i)signal(-desktop)?"; } { class = "(?i)fractal"; } - { class = "(?i)castor"; } ]; "4: other" = [{ class = ".*"; }]; }; diff --git a/hm-configs/neovim.nix b/hm-configs/neovim.nix new file mode 100644 index 0000000..7f6f99e --- /dev/null +++ b/hm-configs/neovim.nix @@ -0,0 +1,23 @@ +{ pkgs, ... }: { + enable = true; + viAlias = true; + vimAlias = true; + withNodeJs = true; + extraPython3Packages = ps: with ps; [ pynvim ]; + plugins = with pkgs.vimPlugins; [ + neovim-sensible + vim-fugitive + vim-surround + nerdtree + nerdtree-git-plugin + vim-colorschemes + vim-nix + lightline-vim + haskell-vim + auto-pairs + vim-fish + ctrlp + dhall-vim + ]; + extraConfig = builtins.readFile ../assets/init.vim; +} diff --git a/hm-configs/vscode.nix b/hm-configs/vscode.nix new file mode 100644 index 0000000..2c49f07 --- /dev/null +++ b/hm-configs/vscode.nix @@ -0,0 +1,18 @@ +{ pkgs, ... }: { + enable = true; + package = pkgs.vscodium.overrideAttrs (_: { + preFixupPhases = [ "preFixup" ]; + preFixup = '' + sed -i "s#open-vsx.org/vscode/gallery#marketplace.visualstudio.com/_apis/public/gallery#" $out/lib/vscode/resources/app/product.json + sed -i "s#open-vsx.org/vscode/item#marketplace.visualstudio.com/items#" $out/lib/vscode/resources/app/product.json + sed -i "s#open-vsx.org#marketplace.visualstudio.com#" $out/lib/vscode/resources/app/product.json + ''; + }); + extensions = with pkgs.vscode-extensions; [ + matklad.rust-analyzer + # ms-python.python + skyapps.fish-vscode + # TODO: reenable + # vadimcn.vscode-lldb + ]; +} diff --git a/home.nix b/home.nix deleted file mode 100644 index d24eb68..0000000 --- a/home.nix +++ /dev/null @@ -1,331 +0,0 @@ -{ pkgs, lib, ... }: - -let - name = "Matthew Ess"; - email = "daringseal@gmail.com"; - workEmail = "mess@yelp.com"; - lockCmd = "i3lock -i ~/.lockscreen-image"; - statusCmd = "i3status-rs ~/.config/i3status.toml"; - -in { - nixpkgs = { config = { allowUnfree = true; }; }; - home = { - sessionVariables = { - EDITOR = "vim"; - BROWSER = "firefox"; - TERMINAL = "kitty"; - }; - packages = with pkgs; [ - # nix utilities - cachix - niv - nixfmt - nix-prefetch-git - # command line utilities - ag - bottom - du-dust - exercism - fzy - httpie - imagemagick - jq - pijul - procs - rlwrap - tealdeer - unzip - unrar - wireguard - # graphical applications - castor - deluge - discord - (dunst.override { dunstify = true; }) - enpass - fractal - firefox - kitty - mullvad-vpn - signal-desktop - slack - steam - vlc - xfce.thunar - xfce.thunar-archive-plugin - # graphical utilities - clipmenu - clipnotify - dmenu - gnome3.gnome-disk-utility - i3lock - i3status-rust - libappindicator - libnotify - lxappearance - rofi - xclip - ]; - file = { - ".background-image".source = ./assets/background-image; - ".lockscreen-image".source = ./assets/lockscreen-image; - ".config/fish/fishfile".text = '' - laughedelic/pisces - joehillen/to-fish - jethrokuan/z - decors/fish-colored-man - franciscolourenco/done - haslersn/fish-nix-completions - gyakovlev/fish-fzy - joseluisq/gitnow - edc/bass - fishpkg/fish-get - fishpkg/fish-spin - oh-my-fish/plugin-bang-bang - fishpkg/fish-humanize-duration - jorgebucaran/fish-getopts - matthewess/fish-autovenv - ''; - ".config/fish/completions/systemctl.fish".source = - ./assets/systemctl.fish; - ".config/fish/functions/colortest.fish".source = ./assets/colortest.fish; - ".config/fish/functions/kbl.fish".text = '' - function kbl -a level - set -l initial (cat /sys/class/leds/tpacpi\:\:kbd_backlight/brightness) - test -z "$level"; and set -l level $initial - echo $level > /sys/class/leds/tpacpi\:\:kbd_backlight/brightness - end - ''; - ".config/fish/functions/mkdcd.fish".text = '' - function mkdcd -a target - mkdir $target - cd $target - end - ''; - ".config/fish/functions/unz.fish".text = '' - function unz -a target - # strip extensions - string match \*.zip $target; and set target (string split -r -m1 . $target)[1] - unzip -d $target $target - end - ''; - ".config/i3status.toml".source = ./assets/i3status.toml; - ".config/kitty/kitty.conf".text = '' - font_family Fira Code Regular - bold_font Fira Code Bold - font_size 15.0 - include ./theme.conf - ''; - ".config/kitty/theme.conf".source = ./assets/kitty-theme.conf; - # ".config/nvim/init.vim".source = ./assets/init.vim; - ".config/rofi/theme.rasi".source = ./assets/sidetab.rasi; - }; - }; - programs = { - alacritty = { - enable = false; - settings = { - font = { - normal.family = "Fira Code"; - size = 10.5; - }; - }; - }; - bat.enable = true; - broot.enable = true; - command-not-found.enable = true; - direnv.enable = true; - feh.enable = true; - firefox.enable = true; - fish = { - enable = true; - package = pkgs.fish; - interactiveShellInit = '' - echo 'ヽ(´ᗜ`)ノ welcome ヽ(´ᗜ`)ノ' - if not functions -q fisher - set -q XDG_CONFIG_HOME; or set XDG_CONFIG_HOME ~/.config - curl https://git.io/fisher --create-dirs -sLo $XDG_CONFIG_HOME/fish/functions/fisher.fish - fish -c fisher - end - fish_vi_key_bindings - set VIRTUAL_ENV_DISABLE_PROMPT true - - alias cat=bat - alias br=broot - alias tree=br - alias ack=ag - alias grep=ag - alias sys="sudo systemctl" - alias rebuild="sudo nixos-rebuild switch" - alias rebuildd="sudo nixos-rebuild switch; and systemctl restart display-manager" - alias upgrade="sudo rm -rf /root/.cache/nix/tarballs; and sudo nix-channel --upgrade; and sudo nixos-rebuild switch --upgrade" - alias clip="xclip -selection c" - alias cxuse="sudo cachix use -d ~/dotfiles.nix" - alias cxpsh="nix-shell --command exit; nix-store -qR --include-outputs (nix-instantiate shell.nix) | cachix push" - alias cxpush=cxpsh - alias home="vim ~/dotfiles.nix/home.nix +'cd %:p:h'" - alias i3="vim ~/dotfiles.nix/i3.nix +'cd %:p:h'" - alias config="vim ~/dotfiles.nix/configuration.nix +'cd %:p:h'" - alias vims="vim -S Session.vim" - alias bigscreen="xrandr --output eDP1 --off --output HDMI2 --auto" - alias smallscreen="xrandr --output eDP1 --auto --output HDMI2 --off" - alias pi="env TERM=xterm ssh pi@pi" - alias drop="env TERM=xterm ssh mat@drop" - alias wgup="wg-quick up wg0" - alias wgdn="wg-quick down wg0" - alias wifi="nmcli r w off; nmcli r w on" - - bind \cr 'fzy_select_history (commandline -b)' - bind -M insert \cr 'fzy_select_history (commandline -b)' - - bind \cf 'fzy_select_directory' - bind -M insert \cf 'fzy_select_directory' - - bind -M insert ! __history_previous_command - bind -M insert '$' __history_previous_command_arguments - ''; - }; - git = { - enable = true; - userName = "${name}"; - userEmail = "${email}"; - ignores = [ ".*.sw[a-z]" "tags" ]; - extraConfig = { - color.ui = true; - core.editor = "vim"; - push.default = "simple"; - init.defaultBranch = "main"; - }; - }; - htop = { - enable = true; - highlightBaseName = true; - }; - jq.enable = true; - man.enable = true; - neovim = { - enable = true; - viAlias = true; - vimAlias = true; - withNodeJs = true; - extraPython3Packages = ps: with ps; [ pynvim ]; - plugins = with pkgs.vimPlugins; [ - neovim-sensible - vim-fugitive - vim-surround - nerdtree - nerdtree-git-plugin - vim-colorschemes - vim-nix - lightline-vim - haskell-vim - auto-pairs - vim-fish - LanguageClient-neovim - ncm2 - ncm2-path - nvim-yarp - ctrlp - dhall-vim - ]; - extraConfig = builtins.readFile ./assets/init.vim; - }; - rofi = { - enable = true; - font = "Fira Code 14"; - lines = 10; - location = "center"; - theme = "~/.config/rofi/theme.rasi"; - }; - ssh = { - enable = true; - extraOptionOverrides = { "AddKeysToAgent" = "true"; }; - matchBlocks = { - "drop".hostname = "104.131.174.193"; - "pi".hostname = "192.168.1.165"; - }; - }; - starship.enable = true; - vscode = { - enable = true; - package = pkgs.vscodium.overrideAttrs (_: { - preFixupPhases = [ "preFixup" ]; - preFixup = '' - sed -i "s#open-vsx.org/vscode/gallery#marketplace.visualstudio.com/_apis/public/gallery#" $out/lib/vscode/resources/app/product.json - sed -i "s#open-vsx.org/vscode/item#marketplace.visualstudio.com/items#" $out/lib/vscode/resources/app/product.json - sed -i "s#open-vsx.org#marketplace.visualstudio.com#" $out/lib/vscode/resources/app/product.json - ''; - }); - extensions = with pkgs.vscode-extensions; [ - matklad.rust-analyzer - # ms-python.python - skyapps.fish-vscode - vadimcn.vscode-lldb - ]; - }; - }; - services = { - dunst = { - enable = true; - settings = { - global = { - geometry = "0x5-30+20"; - notification_height = 25; - indicate_hidden = "yes"; - corner_radius = 5; - padding = 10; - horizontal_padding = 10; - idle_threshold = 60; - font = "Fira Code 16"; - markup = "full"; - format = '' - %s %a - %b''; - alignment = "center"; - horizontal_alignment = "center"; - icon_position = "left"; - separator_color = "#383838"; - frame_color = "#383838"; - frame_width = 2; - }; - shortcuts = { - close = "ctrl+space"; - history = "ctrl+shift+grave"; - }; - urgency_low = { - background = "#282828"; - foreground = "#5882FA"; - }; - urgency_normal = { - background = "#282828"; - foreground = "#5882FA"; - }; - urgency_critical = { - background = "#282828"; - foreground = "#FF0040"; - timeout = 0; - }; - }; - }; - gnome-keyring.enable = true; - lorri.enable = true; - redshift = { - enable = true; - provider = "geoclue2"; - }; - screen-locker = { - enable = false; - lockCmd = "${lockCmd}"; - }; - }; - xsession = { - enable = true; - scriptPath = ".hm-xsession"; - windowManager = { - i3 = import ./i3.nix { inherit lib lockCmd statusCmd; }; - awesome = { - enable = false; - }; - }; - }; -} diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index f7fd44e..bbca43e --- a/install.sh +++ b/install.sh @@ -1,5 +1,16 @@ -#!/bin/bash +#!/usr/bin/env bash -sudo ln -s $PWD/configuration.nix /etc/nixos/configuration.nix -sudo ln -s $PWD/hardware-configuration.nix /etc/nixos/hardware-configuration.nix +machine=$1 +if [[ -z "$machine" ]]; then + machine=$(hostname) +fi + +if [[ ! -d "machines/$machine" ]]; then + echo "$machine is not a known machine" + exit +else + echo "Linking ./machines/$machine/configuration.nix to /etc/nixos/configuration.nix" +fi + +sudo ln -sf $PWD/machines/$machine/configuration.nix /etc/nixos/configuration.nix diff --git a/machines/gagarin/configuration.nix b/machines/gagarin/configuration.nix new file mode 100644 index 0000000..99b967a --- /dev/null +++ b/machines/gagarin/configuration.nix @@ -0,0 +1,37 @@ +# 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. + /etc/nixos/hardware-configuration.nix + ]; + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.systemd-boot.configurationLimit = 64; + boot.loader.efi.canTouchEfiVariables = true; + + console.earlySetup = true; + + networking.hostName = "gagarin"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # The global useDHCP flag is deprecated, therefore explicitly set to false here. + # Per-interface useDHCP will be mandatory in the future, so this generated config + # replicates the default behaviour. + networking.useDHCP = false; + networking.interfaces.enp0s31f6.useDHCP = 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 = "20.09"; # Did you read the comment? + +} + diff --git a/machines/nixpad/configuration.nix b/machines/nixpad/configuration.nix new file mode 100644 index 0000000..0568d2a --- /dev/null +++ b/machines/nixpad/configuration.nix @@ -0,0 +1,41 @@ +# 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. + /etc/nixos/hardware-configuration.nix + ../../profiles/laptop.nix + ]; + + # Bootloader + boot.loader.systemd-boot.enable = true; + boot.loader.systemd-boot.configurationLimit = 64; + boot.loader.efi.canTouchEfiVariables = true; + + console.earlySetup = true; + + networking = { + hostName = "nixpad"; # Define your hostname. + + # The global useDHCP flag is deprecated, therefore explicitly set to false here. + # Per-interface useDHCP will be mandatory in the future, so this generated config + # replicates the default behaviour. + useDHCP = false; + interfaces = { + enp0s25.useDHCP = true; + wlp3s0.useDHCP = true; + # wwp0s20u4c2i12.useDHCP = true; + }; + }; + + # This value determines the NixOS release with which your system is to be + # compatible, in order to avoid breaking some software such as database + # servers. You should change this only after NixOS release notes say you + # should. + system.stateVersion = "19.09"; # Did you read the comment? + +} diff --git a/profiles/caches.nix b/profiles/caches.nix new file mode 100644 index 0000000..ca091d3 --- /dev/null +++ b/profiles/caches.nix @@ -0,0 +1,10 @@ +{ config, ... }: { + imports = [ # Cachix caches + ../cachix.nix + ]; + nix = { + binaryCaches = [ "https://hydra.iohk.io" ]; + binaryCachePublicKeys = + [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ]; + }; +} diff --git a/profiles/common.nix b/profiles/common.nix new file mode 100644 index 0000000..01999e7 --- /dev/null +++ b/profiles/common.nix @@ -0,0 +1,37 @@ +{ config, pkgs, lib, ... }: { + imports = [ + # basic services + ../services/ssh.nix + ../services/vpn.nix + ../services/l10n.nix + ./caches.nix + ./quicksudo.nix + ../users/mat.nix + ../users/mat-hm.nix + ]; + + system.autoUpgrade.enable = true; + system.copySystemConfiguration = true; + + environment.systemPackages = with pkgs; [ + fish + git + htop + tmux + tree + unzip + vim + wget + zip + ]; + + environment.variables = { + "EDITOR" = "vim"; + "VISUAL" = "vim"; + }; + + programs = { + fish.enable = false; + ssh = { startAgent = true; }; + }; +} diff --git a/profiles/fonts.nix b/profiles/fonts.nix new file mode 100644 index 0000000..af87e1b --- /dev/null +++ b/profiles/fonts.nix @@ -0,0 +1,16 @@ +{ config, pkgs, ... }: { + fonts = { + enableDefaultFonts = true; + fonts = with pkgs; [ + source-code-pro + fira-code + fira-code-symbols + font-awesome_4 + aileron + ]; + fontconfig = { + enable = true; + defaultFonts = { monospace = [ "Fira Code" ]; }; + }; + }; +} diff --git a/profiles/graphical.nix b/profiles/graphical.nix new file mode 100644 index 0000000..0a3e855 --- /dev/null +++ b/profiles/graphical.nix @@ -0,0 +1,49 @@ +{ config, pkgs, lib, ... }: { + imports = [ ./fonts.nix ]; + + programs = { + light.enable = true; + nm-applet.enable = true; + }; + + networking = { + networkmanager = { + enable = true; + wifi.scanRandMacAddress = false; + }; + }; + + services = { + clipmenu.enable = true; + geoclue2.enable = true; + gvfs.enable = true; + xserver = { + enable = true; + + videoDrivers = [ "intel" ]; + deviceSection = '' + Option "DRI" "3" + Option "TearFree" "true" + ''; + useGlamor = true; + + desktopManager = { + session = [{ + name = "home-manager"; + start = '' + ${pkgs.runtimeShell} $HOME/.hm-xsession & + waitPID=$! + ''; + }]; + }; + displayManager = { + defaultSession = "home-manager"; + autoLogin = { + enable = true; + user = "mat"; + }; + }; + }; + + }; +} diff --git a/profiles/laptop.nix b/profiles/laptop.nix new file mode 100644 index 0000000..32f4595 --- /dev/null +++ b/profiles/laptop.nix @@ -0,0 +1,42 @@ +{ config, pkgs, ... }: + +{ + + imports = [ ./common.nix ./graphical.nix ../users/mat-hm-laptop.nix ]; + + # enable power management + powerManagement.enable = true; + + services = { + upower.enable = true; + xserver = { + # Enable touchpad support. + libinput = { + enable = true; + naturalScrolling = true; + disableWhileTyping = true; + }; + }; + }; + + # Enable sound. + sound.enable = true; + + # Hardware switches + hardware = { + logitech.wireless = { + enable = true; + # enableGraphical = true; + }; + opengl = { + driSupport32Bit = true; + extraPackages32 = [ pkgs.pkgsi686Linux.libva ]; + }; + pulseaudio = { + enable = true; + support32Bit = true; + }; + }; + + nixpkgs.config.allowUnfree = true; +} diff --git a/profiles/quicksudo.nix b/profiles/quicksudo.nix new file mode 100644 index 0000000..30a0540 --- /dev/null +++ b/profiles/quicksudo.nix @@ -0,0 +1,4 @@ +{ config, ... }: { + # Don't ask for my password *quite* as often. + security.sudo.extraConfig = "Defaults timestamp_timeout=60"; +} diff --git a/services/l10n.nix b/services/l10n.nix new file mode 100644 index 0000000..e0b84bd --- /dev/null +++ b/services/l10n.nix @@ -0,0 +1,13 @@ +{ config, ... }: { + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + console = { + font = "Lat2-Terminus16"; + keyMap = "us"; + }; + + services.xserver.layout = "us"; + + # Set your time zone. + time.timeZone = "America/New_York"; +} diff --git a/services/pubkey.nix b/services/pubkey.nix new file mode 100644 index 0000000..a19ee94 --- /dev/null +++ b/services/pubkey.nix @@ -0,0 +1,4 @@ +{ + mat = + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDrPN7A8SFsP9P+jwYGAr3elsVabXaiLhb20YYxhCSS0wPiYXv1Ko2ucPQTOY9Skx3EiYPGBqEeh5o11cPwPowfiRL6fq7YTxMZDJLPtEHxPpWY+/f3my6hscSsH00M02ZQ+iebu1VXA1YHGma9v5MOSDqic4R+ic6lGK+H/Efi8M8z8nT5+nI0+f8sEhG/8D4VVcmNnb/AW1tHYqdInU28A0kboA4N3ED/7Tb2GyVCWmYEryKxTa8Z9f2Bp9TRn9TPX7Wwo2op+EfxBe30XTHqWnb/vk5GBjd9OCJhBSVun4ecfmT2iTsLr9zVuCL6KVcSq849I+EE0Qaase1SNFd6J2zAe6IEQ7ePwwWZVmncQFsvzAwQ40X2AmHbY6zTAxQenQHPpG3yuDCcyov425c7QAnTkJGQl6uFGAb++tgryfCMVj5rri14FaAk2VPz6tX3Xivvi0g4fTeDrPEyYRadko4/RVw8p04Dbefod7sjUOlfyKA5cDDWJVmVE3C3dfp7ykrZRKFYzg5xij4ClRYyUN2ZmmtCnTO5ktH7qeZ8K3Sx1IPZ29+whSEpCl5lfC6Tv9Mx7v5rRV+SIq4D49FVbhR+rNCDApyYnyK3r2ybHz46zmMiRXaHzFmRVfd59nII37qA/d157YHYc/s5ec0IsI6Sc8TNeMtMyUiKdqJrDQ== matthewess"; +} diff --git a/services/ssh.nix b/services/ssh.nix new file mode 100644 index 0000000..a3a35fc --- /dev/null +++ b/services/ssh.nix @@ -0,0 +1,12 @@ +{ config, pkgs, lib, ... }: + +let pubkey = import ./pubkey.nix; +in { + services.openssh = { + enable = true; + permitRootLogin = "yes"; + passwordAuthentication = lib.mkDefault false; + }; + + users.users.root.openssh.authorizedKeys.keys = lib.mkDefault [ pubkey.mat ]; +} diff --git a/services/vpn.nix b/services/vpn.nix new file mode 100644 index 0000000..5f4e802 --- /dev/null +++ b/services/vpn.nix @@ -0,0 +1,4 @@ +{ config, pkgs, lib, ... }: { + networking.wireguard.enable = true; + services.mullvad-vpn.enable = true; +} diff --git a/users/mat-hm-laptop.nix b/users/mat-hm-laptop.nix new file mode 100644 index 0000000..7fbcfab --- /dev/null +++ b/users/mat-hm-laptop.nix @@ -0,0 +1,103 @@ +{ config, ... }: + +let + + statusCmd = "i3status-rs ~/.config/i3status.toml"; + +in { + home-manager.users.mat = { pkgs, lib, ... }: { + home = { + sessionVariables = { + BROWSER = "firefox"; + TERMINAL = "kitty"; + }; + packages = with pkgs; [ + # command line utilities + asuka + bottom + du-dust + fzy + httpie + imagemagick + jq + pijul + procs + # graphical applications + deluge + discord + (dunst.override { dunstify = true; }) + enpass + fractal + firefox + kitty + signal-desktop + slack + # steam + vlc + xfce.thunar + xfce.thunar-archive-plugin + # graphical utilities + clipmenu + clipnotify + dmenu # needed for clipmenu + gnome3.gnome-disk-utility + i3status-rust + libappindicator + libnotify + lxappearance + rofi + xclip + ]; + file = import ../hm-configs/files.nix; + }; + programs = { + alacritty = { + enable = false; + settings = { + font = { + normal.family = "Fira Code"; + size = 10.5; + }; + }; + }; + feh.enable = true; + firefox.enable = true; + fish = import ../hm-configs/fish.nix { inherit pkgs; }; + + jq.enable = true; + neovim = import ../hm-configs/neovim.nix { inherit pkgs; }; + rofi = { + enable = true; + font = "Fira Code 14"; + lines = 10; + location = "center"; + theme = "~/.config/rofi/theme.rasi"; + }; + ssh = { + enable = true; + extraOptionOverrides = { "AddKeysToAgent" = "true"; }; + matchBlocks = { + "pi".hostname = "192.168.1.165"; + "gagarin".hostname = "192.168.1.246"; + "mir".hostname = "138.197.58.58"; + "soviet".hostname = "soviet.circumlunar.space"; + }; + }; + vscode = import ../hm-configs/vscode.nix { inherit pkgs; }; + }; + services = { + redshift = { + enable = true; + provider = "geoclue2"; + }; + }; + xsession = { + enable = true; + scriptPath = ".hm-xsession"; + windowManager = { + i3 = import ../hm-configs/i3.nix { inherit lib statusCmd; }; + awesome = { enable = false; }; + }; + }; + }; +} diff --git a/users/mat-hm.nix b/users/mat-hm.nix new file mode 100644 index 0000000..3a9c112 --- /dev/null +++ b/users/mat-hm.nix @@ -0,0 +1,75 @@ +{ config, ... }: +let + name = "Matthew Ess"; + email = "mat@mat.services"; +in { + imports = [ ]; + + home-manager.useUserPackages = true; + home-manager.useGlobalPkgs = true; + + home-manager.users.mat = { pkgs, ... }: { + home = { + sessionVariables = { EDITOR = "vim"; }; + packages = with pkgs; [ + # nix utilities + cachix + niv + nixfmt + nix-prefetch-git + fish-foreign-env + # command line utils + ripgrep + rlwrap + tealdeer + unrar + mullvad-vpn + ]; + }; + + programs = { + bat.enable = true; + broot.enable = true; + command-not-found.enable = true; + direnv.enable = true; + fish.enable = true; + + git = { + enable = true; + userName = "${name}"; + userEmail = "${email}"; + ignores = [ ".*.sw[a-z]" "tags" ]; + extraConfig = { + color.ui = true; + core.editor = "vim"; + push.default = "simple"; + init.defaultBranch = "main"; + }; + }; + + htop = { + enable = true; + highlightBaseName = true; + }; + + man.enable = true; + + ssh = { + enable = true; + serverAliveInterval = 60; + }; + + starship.enable = true; + + tmux = { + enable = true; + keyMode = "vi"; + newSession = true; + shortcut = "a"; + baseIndex = 1; + }; + }; + services = { lorri.enable = true; }; + + }; +} diff --git a/users/mat.nix b/users/mat.nix new file mode 100644 index 0000000..222c40a --- /dev/null +++ b/users/mat.nix @@ -0,0 +1,15 @@ +{ config, pkgs, lib, ... }: + +{ + + users.users.mat = { + isNormalUser = true; + shell = pkgs.fish; + extraGroups = lib.mkDefault [ + "wheel" # enable sudo + "networkmanager" + "audio" + "video" + ]; + }; +}