diff --git a/.gitignore b/.gitignore index 1afbbd8..fcaeac4 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ **/.direnv/** result .luarc.json +private/** +!private/**.age +!private/**.sha512 diff --git a/modules/neovim/.stylua.toml b/.stylua.toml similarity index 100% rename from modules/neovim/.stylua.toml rename to .stylua.toml diff --git a/README.md b/README.md index 9387107..3b1b270 100644 --- a/README.md +++ b/README.md @@ -1,99 +1,69 @@ +# System Configurations + This repository contains configuration files for my NixOS, macOS, and WSL hosts. They are organized and managed by [Nix](https://nixos.org), so some of the configuration may be difficult to translate to a non-Nix system. -However, some of the configurations are easier to lift directly: +## System Features -- [Neovim](https://github.com/nmasur/dotfiles/tree/master/modules/neovim/lua) -- [Fish functions](https://github.com/nmasur/dotfiles/tree/master/modules/shell/fish/functions) -- [More fish aliases](https://github.com/nmasur/dotfiles/blob/master/modules/shell/fish/default.nix) -- [Git aliases](https://github.com/nmasur/dotfiles/blob/master/modules/shell/git.nix) -- [Hammerspoon](https://github.com/nmasur/dotfiles/tree/master/modules/darwin/hammerspoon) +| Feature | Program | Configuration | +| --- | --- | --- | +| OS | [NixOS](https://nixos.org) | [Link](./modules/nixos) | +| Display Server | [X11](https://www.x.org/wiki/) | [Link](./modules/nixos/graphical/xorg.nix) | +| Compositor | [Picom](https://github.com/yshui/picom) | [Link](./modules/nixos/graphical/picom.nix) | +| Window Manager | [i3](https://i3wm.org/) | [Link](./modules/nixos/graphical/i3.nix) | +| Panel | [Polybar](https://polybar.github.io/) | [Link](./modules/nixos/graphical/polybar.nix) | +| Font | [Victor Mono](https://rubjo.github.io/victor-mono/) | [Link](./modules/nixos/graphical/fonts.nix) | +| Launcher | [Rofi](https://github.com/davatorium/rofi) | [Link](./modules/nixos/graphical/rofi.nix) | + +## User Features + +| Feature | Program | Configuration | +| --- | --- | --- | +| Dotfiles | [Home-Manager](https://github.com/nix-community/home-manager) | [Link](./modules/common) | +| Terminal | [Kitty](https://sw.kovidgoyal.net/kitty/) | [Link](./modules/common/applications/kitty.nix) | +| Shell | [Fish](https://fishshell.com/) | [Link](./modules/common/shell/fish) | +| Shell Prompt | [Starship](https://starship.rs/) | [Link](./modules/common/shell/starhip.nix) | +| Colorscheme | [Gruvbox](https://github.com/morhetz/gruvbox) | [Link](./colorscheme/gruvbox/default.nix) | +| Wallpaper | [Road](https://gitlab.com/exorcist365/wallpapers/-/blob/master/gruvbox/road.jpg) | [Link](./hosts/tempest/default.nix) | +| Text Editor | [Neovim](https://neovim.io/) | [Link](./modules/common/neovim/config) | +| Browser | [Firefox](https://www.mozilla.org/en-US/firefox/new/) | [Link](./modules/common/applications/firefox.nix) | +| E-Mail | [Aerc](https://aerc-mail.org/) | [Link](./modules/common/mail/aerc.nix) | +| File Manager | [Nautilus](https://wiki.gnome.org/action/show/Apps/Files) | [Link](./modules/common/applications/nautilus.nix) | +| PDF Reader | [Zathura](https://pwmt.org/projects/zathura/) | [Link](./modules/common/applications/media.nix) | +| Video Player | [mpv](https://mpv.io/) | [Link](./modules/common/applications/media.nix) | + +## macOS Features + +| Feature | Program | Configuration | +| --- | --- | --- | +| Keybinds | [Hammerspoon](https://www.hammerspoon.org/) | [Link](./modules/darwin/hammerspoon) | --- # Installation -## NixOS - From Live Disk +Click [here](./docs/installation.md) for detailed installation instructions. -Format drives and build system from any NixOS host, including the live -installer disk: +# Neovim -**This will erase your drives; use at your own risk!** +Try out my Neovim config with nix: ```bash -lsblk # Choose the disk you want to wipe -nix-shell -p nixFlakes -nix run github:nmasur/dotfiles#installer -- nvme0n1 desktop +nix run github:nmasur/dotfiles#neovim ``` -## NixOS - From Existing System - -If you're already running NixOS, you can switch to this configuration with the -following command: +Or build it as a package: ```bash -nix-shell -p nixFlakes -sudo nixos-rebuild switch --flake github:nmasur/dotfiles#desktop +nix build github:nmasur/dotfiles#neovim ``` -## Windows - From NixOS WSL - -After [installing NixOS on -WSL](https://xeiaso.net/blog/nix-flakes-4-wsl-2022-05-01), you can switch to -the WSL configuration: - -``` -nix-shell -p nixFlakes -sudo nixos-rebuild switch --flake github:nmasur/dotfiles#wsl -``` - -You should also download the -[FiraCode](https://github.com/ryanoasis/nerd-fonts/releases/download/v2.2.2/FiraCode.zip) -font and install it on Windows. Install [Alacritty](https://alacritty.org/) and -move the `windows/alacritty.yml` file to -`C:\Users\\AppData\Roaming\alacritty`. - -## macOS - -To get started on a bare macOS installation, first install Nix: - -```bash -sh -c "$(curl -L https://nixos.org/nix/install)" -``` - -Then use Nix to build nix-darwin: - -```bash -nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer -./result/bin/darwin-installer -``` - -Then switch to the macOS configuration: - -```bash -darwin-rebuild switch --flake github:nmasur/dotfiles#macbook -``` - -### Dealing with corporate MITM SSL certificates: - -```bash -# Get the certificates -openssl s_client -showcerts -verify 5 -connect cache.nixos.org:443 < /dev/null - -# Paste them in here -sudo nvim $NIX_SSL_CERT_FILE -``` - -### Dealing with Neovim issues: - -Update Neovim Packer plugins: `:PackerSync` - -Update TreeSitter languages: `:TSUpdateSync` - ---- +If you already have a Neovim configuration, you may need to move it out of +`~/.config/nvim` or set `XDG_CONFIG_HOME` to another value; otherwise both +configs might conflict with each other. # Flake Templates diff --git a/apps/default.nix b/apps/default.nix new file mode 100644 index 0000000..659628c --- /dev/null +++ b/apps/default.nix @@ -0,0 +1,34 @@ +{ pkgs, ... }: rec { + + # Show quick helper + default = import ./help.nix { inherit pkgs; }; + + # Format primary disk + format-root = import ./format-root.nix { inherit pkgs; }; + + # Format and install from nothing (deprecated) + installer = import ./installer.nix { inherit pkgs; }; + + # Display the readme for this repository + readme = import ./readme.nix { inherit pkgs; }; + + # Rebuild + rebuild = import ./rebuild.nix { inherit pkgs; }; + + # Load the SSH key for this machine + loadkey = import ./loadkey.nix { inherit pkgs; }; + + # Encrypt secret for all machines + encrypt-secret = import ./encrypt-secret.nix { inherit pkgs; }; + + # Re-encrypt secrets for all machines + reencrypt-secrets = import ./reencrypt-secrets.nix { inherit pkgs; }; + + # Connect machine metrics to Netdata Cloud + netdata = import ./netdata-cloud.nix { inherit pkgs; }; + + # Run neovim as an app + neovim = import ./neovim.nix { inherit pkgs; }; + nvim = neovim; + +} diff --git a/apps/encrypt-secret.nix b/apps/encrypt-secret.nix new file mode 100644 index 0000000..7e83cba --- /dev/null +++ b/apps/encrypt-secret.nix @@ -0,0 +1,19 @@ +{ pkgs, ... }: { + + # nix run github:nmasur/dotfiles#encrypt-secret > private/mysecret.age + + type = "app"; + + program = builtins.toString (pkgs.writeShellScript "encrypt-secret" '' + printf "\nEnter the secret data to encrypt for all hosts...\n\n" 1>&2 + read -p "Secret: " secret + printf "\nEncrypting...\n\n" 1>&2 + tmpfile=$(mktemp) + echo "''${secret}" > ''${tmpfile} + ${pkgs.age}/bin/age --encrypt --armor --recipients-file ${ + builtins.toString ../public-keys + } $tmpfile + rm $tmpfile + ''); + +} diff --git a/apps/format-root.nix b/apps/format-root.nix new file mode 100644 index 0000000..c7449b4 --- /dev/null +++ b/apps/format-root.nix @@ -0,0 +1,39 @@ +{ pkgs, ... }: { + + # This script will partition and format drives; use at your own risk! + + type = "app"; + + program = builtins.toString (pkgs.writeShellScript "format-root" '' + set -e + + DISK=$1 + + if [ -z "''${DISK}" ]; then + ${pkgs.gum}/bin/gum style --width 50 --margin "1 2" --padding "2 4" \ + --foreground "#fb4934" \ + "Missing required parameter." \ + "Usage: format-root -- " \ + "Flake example: nix run github:nmasur/dotfiles#format-root -- nvme0n1" + echo "(exiting)" + exit 1 + fi + + ${pkgs.disko-packaged}/bin/disko \ + --mode create \ + --dry-run \ + --flake "path:$(pwd)#root" \ + --arg disk \""/dev/''${DISK}"\" + + ${pkgs.gum}/bin/gum confirm \ + "This will ERASE ALL DATA on the disk /dev/''${DISK}. Are you sure you want to continue?" \ + --default=false + + ${pkgs.disko-packaged}/bin/disko \ + --mode create \ + --flake "path:$(pwd)#root" \ + --arg disk "/dev/''${DISK}" + + ''); + +} diff --git a/apps/help.nix b/apps/help.nix new file mode 100644 index 0000000..cb31b37 --- /dev/null +++ b/apps/help.nix @@ -0,0 +1,23 @@ +{ pkgs, ... }: { + + type = "app"; + + program = builtins.toString (pkgs.writeShellScript "default" '' + ${pkgs.gum}/bin/gum style --margin "1 2" --padding "0 2" --foreground "15" --background "55" "Options" + ${pkgs.gum}/bin/gum format --type=template -- ' {{ Italic "Run with" }} {{ Color "15" "69" " nix run github:nmasur/dotfiles#" }}{{ Color "15" "62" "someoption" }}{{ Color "15" "69" " " }}.' + echo "" + echo "" + ${pkgs.gum}/bin/gum format --type=template -- \ + ' • {{ Color "15" "57" " readme " }} {{ Italic "Documentation for this repository." }}' \ + ' • {{ Color "15" "57" " rebuild " }} {{ Italic "Switch to this configuration." }}' \ + ' • {{ Color "15" "57" " installer " }} {{ Italic "Format and install from nothing." }}' \ + ' • {{ Color "15" "57" " neovim " }} {{ Italic "Test out the Neovim package." }}' \ + ' • {{ Color "15" "57" " loadkey " }} {{ Italic "Load an ssh key for this machine using melt." }}' \ + ' • {{ Color "15" "57" " encrypt-secret " }} {{ Italic "Encrypt a secret for all machines." }}' \ + ' • {{ Color "15" "57" " reencrypt-secrets " }} {{ Italic "Reencrypt all secrets when new machine is added." }}' \ + ' • {{ Color "15" "57" " netdata " }} {{ Italic "Connect a machine to Netdata cloud." }}' + echo "" + echo "" + ''); + +} diff --git a/apps/loadkey.nix b/apps/loadkey.nix new file mode 100644 index 0000000..a1e03ba --- /dev/null +++ b/apps/loadkey.nix @@ -0,0 +1,12 @@ +{ pkgs, ... }: { + + type = "app"; + + program = builtins.toString (pkgs.writeShellScript "loadkey" '' + printf "\nEnter the seed phrase for your SSH key...\n" + printf "\nThen press ^D when complete.\n\n" + ${pkgs.melt}/bin/melt restore ~/.ssh/id_ed25519 + printf "\n\nContinuing activation.\n\n" + ''); + +} diff --git a/apps/neovim.nix b/apps/neovim.nix new file mode 100644 index 0000000..c944af9 --- /dev/null +++ b/apps/neovim.nix @@ -0,0 +1,12 @@ +{ pkgs, ... }: { + + type = "app"; + + program = "${ + (import ../modules/common/neovim/package { + inherit pkgs; + colors = (import ../colorscheme/gruvbox).dark; + }) + }/bin/nvim"; + +} diff --git a/apps/netdata-cloud.nix b/apps/netdata-cloud.nix new file mode 100644 index 0000000..f98dbd7 --- /dev/null +++ b/apps/netdata-cloud.nix @@ -0,0 +1,19 @@ +{ pkgs, ... }: { + + type = "app"; + + program = builtins.toString (pkgs.writeShellScript "netdata-cloud" '' + if [ "$EUID" -ne 0 ]; then + echo "Please run as root" + exit 1 + fi + mkdir --parents --mode 0750 /var/lib/netdata/cloud.d + printf "\nEnter the claim token for netdata cloud...\n\n" + read -p "Token: " token + echo "''${token}" > /var/lib/netdata/cloud.d/token + chown -R netdata:netdata /var/lib/netdata + ${pkgs.netdata}/bin/netdata-claim.sh -id=$(uuidgen) + printf "\n\nNow restart netdata service.\n\n" + ''); + +} diff --git a/apps/readme.nix b/apps/readme.nix index 034c639..9507513 100644 --- a/apps/readme.nix +++ b/apps/readme.nix @@ -3,7 +3,7 @@ type = "app"; program = builtins.toString (pkgs.writeShellScript "readme" '' - ${pkgs.glow}/bin/glow ${builtins.toString ../README.md} + ${pkgs.glow}/bin/glow --pager ${builtins.toString ../README.md} ''); } diff --git a/apps/rebuild.nix b/apps/rebuild.nix new file mode 100644 index 0000000..973be25 --- /dev/null +++ b/apps/rebuild.nix @@ -0,0 +1,15 @@ +{ pkgs, ... }: { + + type = "app"; + + program = builtins.toString (pkgs.writeShellScript "rebuild" '' + echo ${pkgs.system} + SYSTEM=${if pkgs.stdenv.isDarwin then "darwin" else "linux"} + if [ "$SYSTEM" == "darwin" ]; then + sudo darwin-rebuild switch --flake ${builtins.toString ../.} + else + doas nixos-rebuild switch --flake ${builtins.toString ../.} + fi + ''); + +} diff --git a/apps/reencrypt-secrets.nix b/apps/reencrypt-secrets.nix new file mode 100644 index 0000000..24c21c9 --- /dev/null +++ b/apps/reencrypt-secrets.nix @@ -0,0 +1,27 @@ +{ pkgs, ... }: { + + # nix run github:nmasur/dotfiles#reencrypt-secrets ./private + + type = "app"; + + program = builtins.toString (pkgs.writeShellScript "reencrypt-secrets" '' + if [ $# -eq 0 ]; then + echo "Must provide directory to reencrypt." + exit 1 + fi + encrypted=$1 + for encryptedfile in ''${1}/*; do + tmpfile=$(mktemp) + echo "Decrypting ''${encryptedfile}..." + ${pkgs.age}/bin/age --decrypt \ + --identity ~/.ssh/id_ed25519 $encryptedfile > $tmpfile + echo "Encrypting ''${encryptedfile}..." + ${pkgs.age}/bin/age --encrypt --armor --recipients-file ${ + builtins.toString ../public-keys + } $tmpfile > $encryptedfile + rm $tmpfile + done + echo "Finished." + ''); + +} diff --git a/modules/colorscheme/everforest/default.nix b/colorscheme/everforest/default.nix similarity index 100% rename from modules/colorscheme/everforest/default.nix rename to colorscheme/everforest/default.nix diff --git a/colorscheme/gruvbox-dark/default.nix b/colorscheme/gruvbox-dark/default.nix new file mode 100644 index 0000000..d8d84ef --- /dev/null +++ b/colorscheme/gruvbox-dark/default.nix @@ -0,0 +1,45 @@ +# Gruvbox with a darker background for greater contrast + +{ + name = "gruvbox-dark"; # Dark, Medium + author = + "Dawid Kurek (dawikur@gmail.com), morhetz (https://github.com/morhetz/gruvbox), ElRastaOk (https://www.reddit.com/user/ElRastaOk)"; + dark = { + base00 = "#1D2122"; # ---- This is the change from normal gruvbox + base01 = "#3c3836"; # --- + base02 = "#504945"; # -- + base03 = "#665c54"; # - + base04 = "#bdae93"; # + + base05 = "#d5c4a1"; # ++ + base06 = "#ebdbb2"; # +++ + base07 = "#fbf1c7"; # ++++ + base08 = "#fb4934"; # red + base09 = "#fe8019"; # orange + base0A = "#fabd2f"; # yellow + base0B = "#b8bb26"; # green + base0C = "#8ec07c"; # aqua/cyan + base0D = "#83a598"; # blue + base0E = "#d3869b"; # purple + base0F = "#d65d0e"; # brown + batTheme = "gruvbox-dark"; + }; + light = { + base00 = "#fbf1c7"; # ---- + base01 = "#ebdbb2"; # --- + base02 = "#d5c4a1"; # -- + base03 = "#bdae93"; # - + base04 = "#665c54"; # + + base05 = "#504945"; # ++ + base06 = "#3c3836"; # +++ + base07 = "#1D2122"; # ++++ Adjusted darker here + base08 = "#9d0006"; # red + base09 = "#af3a03"; # orange + base0A = "#b57614"; # yellow + base0B = "#79740e"; # green + base0C = "#427b58"; # aqua/cyan + base0D = "#076678"; # blue + base0E = "#8f3f71"; # purple + base0F = "#d65d0e"; # brown + batTheme = "gruvbox-light"; + }; +} diff --git a/colorscheme/gruvbox/default.nix b/colorscheme/gruvbox/default.nix new file mode 100644 index 0000000..945ba49 --- /dev/null +++ b/colorscheme/gruvbox/default.nix @@ -0,0 +1,43 @@ +{ + name = "gruvbox"; # Dark, Medium + author = + "Dawid Kurek (dawikur@gmail.com), morhetz (https://github.com/morhetz/gruvbox)"; + dark = { + base00 = "#282828"; # ---- + base01 = "#3c3836"; # --- + base02 = "#504945"; # -- + base03 = "#665c54"; # - + base04 = "#bdae93"; # + + base05 = "#d5c4a1"; # ++ + base06 = "#ebdbb2"; # +++ + base07 = "#fbf1c7"; # ++++ + base08 = "#fb4934"; # red + base09 = "#fe8019"; # orange + base0A = "#fabd2f"; # yellow + base0B = "#b8bb26"; # green + base0C = "#8ec07c"; # aqua/cyan + base0D = "#83a598"; # blue + base0E = "#d3869b"; # purple + base0F = "#d65d0e"; # brown + batTheme = "gruvbox-dark"; + }; + light = { + base00 = "#fbf1c7"; # ---- + base01 = "#ebdbb2"; # --- + base02 = "#d5c4a1"; # -- + base03 = "#bdae93"; # - + base04 = "#665c54"; # + + base05 = "#504945"; # ++ + base06 = "#3c3836"; # +++ + base07 = "#282828"; # ++++ + base08 = "#9d0006"; # red + base09 = "#af3a03"; # orange + base0A = "#b57614"; # yellow + base0B = "#79740e"; # green + base0C = "#427b58"; # aqua/cyan + base0D = "#076678"; # blue + base0E = "#8f3f71"; # purple + base0F = "#d65d0e"; # brown + batTheme = "gruvbox-light"; + }; +} diff --git a/colorscheme/nord/default.nix b/colorscheme/nord/default.nix new file mode 100644 index 0000000..99f711d --- /dev/null +++ b/colorscheme/nord/default.nix @@ -0,0 +1,23 @@ +{ + dark = { + name = "nord"; + author = "arcticicestudio"; + base00 = "#2E3440"; + base01 = "#3B4252"; + base02 = "#434C5E"; + base03 = "#4C566A"; + base04 = "#D8DEE9"; + base05 = "#E5E9F0"; + base06 = "#ECEFF4"; + base07 = "#8FBCBB"; + base08 = "#88C0D0"; + base09 = "#81A1C1"; + base0A = "#5E81AC"; + base0B = "#BF616A"; + base0C = "#D08770"; + base0D = "#EBCB8B"; + base0E = "#A3BE8C"; + base0F = "#B48EAD"; + batTheme = "nord"; + }; +} diff --git a/modules/colorscheme/nord/neovim.lua b/colorscheme/nord/neovim.lua similarity index 100% rename from modules/colorscheme/nord/neovim.lua rename to colorscheme/nord/neovim.lua diff --git a/disks/root.nix b/disks/root.nix new file mode 100644 index 0000000..2f0f3c1 --- /dev/null +++ b/disks/root.nix @@ -0,0 +1,42 @@ +{ disk, ... }: { + disk = { + boot = { + type = "disk"; + device = disk; + content = { + type = "table"; + format = "gpt"; + partitions = [ + # Boot partition + { + name = "ESP"; + start = "0"; + end = "512MiB"; + fs-type = "fat32"; + bootable = true; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + extraArgs = [ "-n boot" ]; + }; + } + # Root partition ext4 + { + name = "root"; + start = "512MiB"; + end = "100%"; + part-type = "primary"; + bootable = true; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + extraArgs = [ "-L nixos" ]; + }; + } + ]; + }; + }; + }; +} diff --git a/disks/zfs.nix b/disks/zfs.nix new file mode 100644 index 0000000..7181f4d --- /dev/null +++ b/disks/zfs.nix @@ -0,0 +1,95 @@ +{ pool, disks, ... }: { + disk = lib.genAttrs disks (disk: { + "${disk}" = { + type = "disk"; + device = "/dev/${disk}"; + content = { + type = "table"; + format = "gpt"; + partitions = [{ + type = "partition"; + name = "zfs"; + start = "128MiB"; + end = "100%"; + content = { + type = "zfs"; + pool = pool; + }; + }]; + }; + }; + }); + zpool = { + "${pool}" = { + type = "zpool"; + mode = "raidz1"; + rootFsOptions = { + compression = "on"; # lz4 by default + "com.sun:auto-snapshot" = "false"; + ashift = "12"; + }; + # mountpoint = "/"; + + datasets = { + root = { + zfs_type = "filesystem"; + mountpoint = null; + options."com.sun:auto-snapshot" = "false"; + }; + # "media/movies" = { + # zfs_type = "filesystem"; + # mountpoint = "/media/movies"; + # options.recordsize = "1M"; + # }; + # "media/tv" = { + # zfs_type = "filesystem"; + # mountpoint = "/media/tv"; + # options.recordsize = "1M"; + # }; + # "media/books" = { + # zfs_type = "filesystem"; + # mountpoint = "/media/books"; + # }; + # archive = { + # zfs_type = "filesystem"; + # mountpoint = "/archive"; + # options.compression = "zstd"; + # options."com.sun:auto-snapshot" = "true"; + # }; + # zfs_unmounted_fs = { + # zfs_type = "filesystem"; + # options.mountpoint = "none"; + # }; + # zfs_legacy_fs = { + # zfs_type = "filesystem"; + # options.mountpoint = "legacy"; + # mountpoint = "/zfs_legacy_fs"; + # }; + # zfs_testvolume = { + # zfs_type = "volume"; + # size = "10M"; + # content = { + # type = "filesystem"; + # format = "ext4"; + # mountpoint = "/ext4onzfs"; + # }; + # }; + # encrypted = { + # zfs_type = "filesystem"; + # size = "20M"; + # options = { + # mountpoint = "none"; + # encryption = "aes-256-gcm"; + # keyformat = "passphrase"; + # keylocation = "file:///tmp/secret.key"; + # }; + # }; + # "encrypted/test" = { + # zfs_type = "filesystem"; + # size = "2M"; + # mountpoint = "/zfs_crypted"; + # }; + }; + }; + }; +} diff --git a/docs/installation.md b/docs/installation.md new file mode 100644 index 0000000..739e7d6 --- /dev/null +++ b/docs/installation.md @@ -0,0 +1,67 @@ +[Back to README](../README.md) + +--- + +# Installation + +## NixOS - From Live Disk + +Format drives and build system from any NixOS host, including the live +installer disk: + +**This will erase your drives; use at your own risk!** + +```bash +lsblk # Choose the disk you want to wipe +nix-shell -p nixVersions.stable +nix run github:nmasur/dotfiles#installer -- nvme0n1 tempest +``` + +## NixOS - From Existing System + +If you're already running NixOS, you can switch to this configuration with the +following command: + +```bash +nix-shell -p nixVersions.stable +sudo nixos-rebuild switch --flake github:nmasur/dotfiles#tempest +``` + +## Windows - From NixOS WSL + +After [installing NixOS on +WSL](https://xeiaso.net/blog/nix-flakes-4-wsl-2022-05-01), you can switch to +the WSL configuration: + +``` +nix-shell -p nixVersions.stable +sudo nixos-rebuild switch --flake github:nmasur/dotfiles#hydra +``` + +You should also download the +[FiraCode](https://github.com/ryanoasis/nerd-fonts/releases/download/v2.2.2/FiraCode.zip) +font and install it on Windows. Install [Alacritty](https://alacritty.org/) and +move the `windows/alacritty.yml` file to +`C:\Users\\AppData\Roaming\alacritty`. + +## macOS + +To get started on a bare macOS installation, first install Nix: + +```bash +sh -c "$(curl -L https://nixos.org/nix/install)" +``` + +Then use Nix to build nix-darwin: + +```bash +nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer +./result/bin/darwin-installer +``` + +Then switch to the macOS configuration: + +```bash +darwin-rebuild switch --flake github:nmasur/dotfiles#lookingglass +``` + diff --git a/docs/restore-calibre.md b/docs/restore-calibre.md new file mode 100644 index 0000000..01aa71a --- /dev/null +++ b/docs/restore-calibre.md @@ -0,0 +1,23 @@ +# Restoring Calibre From Backup + +The `metadata.db` holds the library and `app.db` and `gdrive.db` contain the +web/account information. + +Place books directories in `/data/books/`. + +Place `metadata.db` in `/var/lib/calibre-web-db/`. + +Symlink `metadata.db` to the library: + +``` +sudo ln -s /var/lib/calibre-web-db/metadata.db /data/books/metadata.db +``` + +Place `app.db` and `gdrive.db` in `/var/lib/calibre-web/`. + +Restart Calibre: + +``` +sudo systemctl restart calibre-web.service +``` + diff --git a/docs/restore-nextcloud.md b/docs/restore-nextcloud.md new file mode 100644 index 0000000..ff01b41 --- /dev/null +++ b/docs/restore-nextcloud.md @@ -0,0 +1,43 @@ +# Restoring Nextcloud From Backup + +Install the `litestream` package. + +``` +nix-shell --run fish -p litestream +``` + +Set the S3 credentials: + +``` +set -x AWS_ACCESS_KEY_ID (read) +set -x AWS_SECRET_ACCESS_KEY (read) +``` + +Restore from S3: + +``` +litestream restore -o nextcloud.db s3://noahmasur-backup.s3.us-west-002.backblazeb2.com/nextcloud +``` + +Install Nextcloud. Then copy DB: + +``` +sudo rm /data/nextcloud/data/nextcloud.db* +sudo mv nextcloud.db /data/nextcloud/data/ +sudo chown nextcloud:nextcloud /data/nextcloud/data/nextcloud.db +sudo chmod 770 /data/nextcloud/data/nextcloud.db +``` + +Restart Nextcloud: + +``` +sudo systemctl restart phpfpm-nextcloud.service +``` + +Adjust Permissions and Directories: + +``` +sudo mkdir /data/nextcloud/data/noah/files +sudo chown nextcloud:nextcloud /data/nextcloud/data/noah/files +``` + diff --git a/flake.lock b/flake.lock index 1d1d66c..987a4a5 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,55 @@ { "nodes": { + "Comment-nvim-src": { + "flake": false, + "locked": { + "lastModified": 1681214440, + "narHash": "sha256-48hy+hiaDJLlgWqC7IeZI3dT+VwWkRo4atQbyPxu/ys=", + "owner": "numToStr", + "repo": "Comment.nvim", + "rev": "e51f2b142d88bb666dcaa77d93a07f4b419aca70", + "type": "github" + }, + "original": { + "owner": "numToStr", + "ref": "v0.8.0", + "repo": "Comment.nvim", + "type": "github" + } + }, + "bufferline-nvim-src": { + "flake": false, + "locked": { + "lastModified": 1687763763, + "narHash": "sha256-wbOeylzjjScQXkrDbBU2HtrOZrp2YUK+wQ2aOkgxmRQ=", + "owner": "akinsho", + "repo": "bufferline.nvim", + "rev": "bf2f6b7edd0abf6b0732f5e5c0a8f30e51611c75", + "type": "github" + }, + "original": { + "owner": "akinsho", + "ref": "v4.2.0", + "repo": "bufferline.nvim", + "type": "github" + } + }, + "cmp-nvim-lsp-src": { + "flake": false, + "locked": { + "lastModified": 1687494203, + "narHash": "sha256-mU0soCz79erJXMMqD/FyrJZ0mu2n6fE0deymPzQlxts=", + "owner": "hrsh7th", + "repo": "cmp-nvim-lsp", + "rev": "44b16d11215dce86f253ce0c30949813c0a90765", + "type": "github" + }, + "original": { + "owner": "hrsh7th", + "repo": "cmp-nvim-lsp", + "type": "github" + } + }, "darwin": { "inputs": { "nixpkgs": [ @@ -7,11 +57,11 @@ ] }, "locked": { - "lastModified": 1664210064, - "narHash": "sha256-df6nKVZe/yAhmJ9csirTPahc0dldwm3HBhCVNA6qWr0=", + "lastModified": 1687517837, + "narHash": "sha256-Ea+JTy6NSf+wWIFrgC8gnOnyt01xwmtDEn2KecvaBkg=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "02d2551c927b7d65ded1b3c7cd13da5cc7ae3fcf", + "rev": "6460468e7a3e1290f132fee4170ebeaa127f6f32", "type": "github" }, "original": { @@ -21,14 +71,52 @@ "type": "github" } }, + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1687598357, + "narHash": "sha256-70ciIe8415oQnQypawaqocEaLJcI1XtkqRNmle8vsrg=", + "owner": "nix-community", + "repo": "disko", + "rev": "1e7098ee0448dc5d33df394d040f454cd42a809c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, + "firefox-darwin": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1687568341, + "narHash": "sha256-5mnjEy1tPfWjlFq/3UB/AyoqkDOJeVu/y/C6Yw2MW9k=", + "owner": "bandithedoge", + "repo": "nixpkgs-firefox-darwin", + "rev": "0bb6fa671d1f1964b2cab7a3774cba1e071aa26e", + "type": "github" + }, + "original": { + "owner": "bandithedoge", + "repo": "nixpkgs-firefox-darwin", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { - "lastModified": 1650374568, - "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", "owner": "edolstra", "repo": "flake-compat", - "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", "type": "github" }, "original": { @@ -39,11 +127,47 @@ }, "flake-utils": { "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "lastModified": 1678901627, + "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", "owner": "numtide", "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", "type": "github" }, "original": { @@ -56,15 +180,14 @@ "inputs": { "nixpkgs": [ "nixpkgs" - ], - "utils": "utils" + ] }, "locked": { - "lastModified": 1664273942, - "narHash": "sha256-PFQR1UJQs7a7eaH5YoCZky5dmxR5cjaKRK+MpPbR7YE=", + "lastModified": 1687627695, + "narHash": "sha256-6Pu7nWb52PRtUmihwuDNShDmsZiXgtXR0OARtH4DSik=", "owner": "nix-community", "repo": "home-manager", - "rev": "1f5ef2bb419a327fae28a83b50fab50959132c24", + "rev": "172d46d4b2677b32277d903bdf4cff77c2cc6477", "type": "github" }, "original": { @@ -74,13 +197,123 @@ "type": "github" } }, + "nil": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs_2", + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1680544266, + "narHash": "sha256-d/TusDXmIo8IT5DNRA21lN+nOVSER8atIx9TJteR6LQ=", + "owner": "oxalica", + "repo": "nil", + "rev": "56a1fa87b98a9508920f4b0ab8fe36d5b54b2362", + "type": "github" + }, + "original": { + "owner": "oxalica", + "ref": "2023-04-03", + "repo": "nil", + "type": "github" + } + }, + "nix2vim": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1685980282, + "narHash": "sha256-uQyVaoqkiocA8bXKMfrgizuKmz0hUzHye5owFoUd2AQ=", + "owner": "gytis-ivaskevicius", + "repo": "nix2vim", + "rev": "3836a348503ae27340c7f83f0bc7bcb907f3781d", + "type": "github" + }, + "original": { + "owner": "gytis-ivaskevicius", + "repo": "nix2vim", + "type": "github" + } + }, + "nixlib": { + "locked": { + "lastModified": 1687049841, + "narHash": "sha256-FBNZQfWtA7bb/rwk92mfiWc85x4hXta2OAouDqO5W8w=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "908af6d1fa3643c5818ea45aa92b21d6385fbbe5", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixos-generators": { + "inputs": { + "nixlib": "nixlib", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1687398392, + "narHash": "sha256-T6kc3NMTpGJk1/dve8PGupeVcxboEb78xtTKhe3LL/A=", + "owner": "nix-community", + "repo": "nixos-generators", + "rev": "649171f56a45af13ba693c156207eafbbbf7edfe", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixos-generators", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1664195620, - "narHash": "sha256-/0V1a1gAR+QbiQe4aCxBoivhkxss0xyt2mBD6yDrgjw=", + "lastModified": 1639237670, + "narHash": "sha256-RTdL4rEQcgaZGpvtDgkp3oK/V+1LM3I53n0ACPSroAQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "edfb969386ebe6c3cf8f878775a7975cd88f926d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "master", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1680487167, + "narHash": "sha256-9FNIqrxDZgSliGGN2XJJSvcDYmQbgOANaZA4UWnTdg4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "62228ccc672ed000f35b1e5c82e4183e46767e52", + "rev": "53dad94e874c9586e71decf82d972dfb640ef044", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1687502512, + "narHash": "sha256-dBL/01TayOSZYxtY4cMXuNCBk8UMLoqRZA+94xiFpJA=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "3ae20aa58a6c0d1ca95c9b11f59a2d12eebc511f", "type": "github" }, "original": { @@ -90,28 +323,45 @@ "type": "github" } }, - "nixpkgs_2": { + "nixpkgs_4": { "locked": { - "lastModified": 1660318005, - "narHash": "sha256-g9WCa9lVUmOV6dYRbEPjv/TLOR5hamjeCcKExVGS3OQ=", + "lastModified": 1686929285, + "narHash": "sha256-WGtVzn+vGMPTXDO0DMNKVFtf+zUSqeW+KKk4Y/Ae99I=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5c211b47aeadcc178c5320afd4e74c7eed5c389f", + "rev": "93fddcf640ceca0be331210ba3101cee9d91c13d", "type": "github" }, "original": { - "id": "nixpkgs", - "ref": "nixos-22.05", - "type": "indirect" + "owner": "NixOS", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "null-ls-nvim-src": { + "flake": false, + "locked": { + "lastModified": 1686871437, + "narHash": "sha256-MxIZqyRW8jStiDNXt7Bsw8peDLKpqxKEaUuIJsXkGMI=", + "owner": "jose-elias-alvarez", + "repo": "null-ls.nvim", + "rev": "bbaf5a96913aa92281f154b08732be2f57021c45", + "type": "github" + }, + "original": { + "owner": "jose-elias-alvarez", + "repo": "null-ls.nvim", + "type": "github" } }, "nur": { "locked": { - "lastModified": 1664282944, - "narHash": "sha256-PrID+Tc90HWhkbO4b2kk3MFgjK+iBDWtDd534Y2D2Zs=", + "lastModified": 1687625402, + "narHash": "sha256-V+vSWypmm/tGbwNXGhqzmiV7vTjV2gNCEh9N7OhNnyA=", "owner": "nix-community", "repo": "nur", - "rev": "dcc2af3d2504af6726c5cf40eb5e1165d5700721", + "rev": "aeaf37c7538965e45700d39e6b5dc9c9a0e0749c", "type": "github" }, "original": { @@ -120,28 +370,183 @@ "type": "github" } }, + "nvim-lspconfig-src": { + "flake": false, + "locked": { + "lastModified": 1675639052, + "narHash": "sha256-B8IgpypxzCACZ5VcqM6KiWyClaN+KrmemtkwMznmj5Y=", + "owner": "neovim", + "repo": "nvim-lspconfig", + "rev": "255e07ce2a05627d482d2de77308bba51b90470c", + "type": "github" + }, + "original": { + "owner": "neovim", + "ref": "v0.1.6", + "repo": "nvim-lspconfig", + "type": "github" + } + }, + "nvim-tree-lua-src": { + "flake": false, + "locked": { + "lastModified": 1687132855, + "narHash": "sha256-ZRUoCDBv8rO8ZUBUMLgo33EBbqD9+ZOSET9rkFsA++E=", + "owner": "kyazdani42", + "repo": "nvim-tree.lua", + "rev": "c3c6544ee00333b0f1d6a13735d0dd302dba4f70", + "type": "github" + }, + "original": { + "owner": "kyazdani42", + "repo": "nvim-tree.lua", + "type": "github" + } + }, + "nvim-treesitter-src": { + "flake": false, + "locked": { + "lastModified": 1681121236, + "narHash": "sha256-iPsPDLhVKJ14iP1/2cCgcY9SCKK/DQz9Y0mQB1DqNiM=", + "owner": "nvim-treesitter", + "repo": "nvim-treesitter", + "rev": "cc360a9beb1b30d172438f640e2c3450358c4086", + "type": "github" + }, + "original": { + "owner": "nvim-treesitter", + "ref": "v0.9.0", + "repo": "nvim-treesitter", + "type": "github" + } + }, "root": { "inputs": { + "Comment-nvim-src": "Comment-nvim-src", + "bufferline-nvim-src": "bufferline-nvim-src", + "cmp-nvim-lsp-src": "cmp-nvim-lsp-src", "darwin": "darwin", + "disko": "disko", + "firefox-darwin": "firefox-darwin", "home-manager": "home-manager", - "nixpkgs": "nixpkgs", + "nil": "nil", + "nix2vim": "nix2vim", + "nixos-generators": "nixos-generators", + "nixpkgs": "nixpkgs_3", + "null-ls-nvim-src": "null-ls-nvim-src", "nur": "nur", + "nvim-lspconfig-src": "nvim-lspconfig-src", + "nvim-tree-lua-src": "nvim-tree-lua-src", + "nvim-treesitter-src": "nvim-treesitter-src", + "telescope-nvim-src": "telescope-nvim-src", + "telescope-project-nvim-src": "telescope-project-nvim-src", + "toggleterm-nvim-src": "toggleterm-nvim-src", "wallpapers": "wallpapers", "wsl": "wsl" } }, - "utils": { + "rust-overlay": { + "inputs": { + "flake-utils": [ + "nil", + "flake-utils" + ], + "nixpkgs": [ + "nil", + "nixpkgs" + ] + }, "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "lastModified": 1680488274, + "narHash": "sha256-0vYMrZDdokVmPQQXtFpnqA2wEgCCUXf5a3dDuDVshn0=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "7ec2ff598a172c6e8584457167575b3a1a5d80d8", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "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" + } + }, + "telescope-nvim-src": { + "flake": false, + "locked": { + "lastModified": 1686302912, + "narHash": "sha256-fV3LLRwAPykVGc4ImOnUSP+WTrPp9Ad9OTfBJ6wqTMk=", + "owner": "nvim-telescope", + "repo": "telescope.nvim", + "rev": "776b509f80dd49d8205b9b0d94485568236d1192", + "type": "github" + }, + "original": { + "owner": "nvim-telescope", + "ref": "0.1.2", + "repo": "telescope.nvim", + "type": "github" + } + }, + "telescope-project-nvim-src": { + "flake": false, + "locked": { + "lastModified": 1682606566, + "narHash": "sha256-H6lrPjpOUVleKHB0ziI+6dthg9ymitHhEWtcgYJTrKo=", + "owner": "nvim-telescope", + "repo": "telescope-project.nvim", + "rev": "7c64b181dd4e72deddcf6f319e3bf1e95b2a2f30", + "type": "github" + }, + "original": { + "owner": "nvim-telescope", + "repo": "telescope-project.nvim", + "type": "github" + } + }, + "toggleterm-nvim-src": { + "flake": false, + "locked": { + "lastModified": 1685434104, + "narHash": "sha256-oiCnBrvft6XxiQtQH8E4F842xhh348SaTpHzaeb+iDY=", + "owner": "akinsho", + "repo": "toggleterm.nvim", + "rev": "95204ece0f2a54c89c4395295432f9aeedca7b5f", + "type": "github" + }, + "original": { + "owner": "akinsho", + "ref": "v2.7.0", + "repo": "toggleterm.nvim", "type": "github" } }, @@ -164,15 +569,15 @@ "wsl": { "inputs": { "flake-compat": "flake-compat", - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs_2" + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1661772734, - "narHash": "sha256-DkvAaLDg9D6O0i2MzUknaf/U078K4KWAZaJQmNC/tL8=", + "lastModified": 1687279045, + "narHash": "sha256-LR0dsXd/A07M61jclyBUW0wRojEQteWReKM35zoJXp0=", "owner": "nix-community", "repo": "NixOS-WSL", - "rev": "c1b0259313f661cf74051c916cf3bb4f061ce11f", + "rev": "a8486b5d191f11d571f15d80b6e265d1712d01cf", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 5ccbac8..f59094b 100644 --- a/flake.nix +++ b/flake.nix @@ -16,7 +16,7 @@ # Used for Windows Subsystem for Linux compatibility wsl.url = "github:nix-community/NixOS-WSL"; - # Used for user packages + # Used for user packages and dotfiles home-manager = { url = "github:nix-community/home-manager/master"; inputs.nixpkgs.follows = @@ -26,15 +26,81 @@ # Community packages; used for Firefox extensions nur.url = "github:nix-community/nur"; + # Use official Firefox binary for macOS + firefox-darwin.url = "github:bandithedoge/nixpkgs-firefox-darwin"; + + # Manage disk format and partitioning + disko = { + url = "github:nix-community/disko"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + # Wallpapers wallpapers = { url = "gitlab:exorcist365/wallpapers"; flake = false; }; + # Used to generate NixOS images for other platforms + nixos-generators = { + url = "github:nix-community/nixos-generators"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + # Convert Nix to Neovim config + nix2vim = { + url = "github:gytis-ivaskevicius/nix2vim"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + # Nix language server + nil.url = "github:oxalica/nil/2023-04-03"; + + # Neovim plugins + nvim-lspconfig-src = { + url = "github:neovim/nvim-lspconfig/v0.1.6"; + flake = false; + }; + cmp-nvim-lsp-src = { + url = "github:hrsh7th/cmp-nvim-lsp"; + flake = false; + }; + null-ls-nvim-src = { + url = "github:jose-elias-alvarez/null-ls.nvim"; + flake = false; + }; + Comment-nvim-src = { + url = "github:numToStr/Comment.nvim/v0.8.0"; + flake = false; + }; + nvim-treesitter-src = { + url = "github:nvim-treesitter/nvim-treesitter/v0.9.0"; + flake = false; + }; + telescope-nvim-src = { + url = "github:nvim-telescope/telescope.nvim/0.1.2"; + flake = false; + }; + telescope-project-nvim-src = { + url = "github:nvim-telescope/telescope-project.nvim"; + flake = false; + }; + toggleterm-nvim-src = { + url = "github:akinsho/toggleterm.nvim/v2.7.0"; + flake = false; + }; + bufferline-nvim-src = { + url = "github:akinsho/bufferline.nvim/v4.2.0"; + flake = false; + }; + nvim-tree-lua-src = { + url = "github:kyazdani42/nvim-tree.lua"; + flake = false; + }; + }; - outputs = { self, nixpkgs, darwin, wsl, home-manager, nur, wallpapers }: + outputs = { nixpkgs, ... }@inputs: let @@ -44,10 +110,21 @@ fullName = "Noah Masur"; gitName = fullName; gitEmail = "7386960+nmasur@users.noreply.github.com"; - mailServer = "noahmasur.com"; - dotfilesRepo = "https://github.com/nmasur/dotfiles"; + mail.server = "noahmasur.com"; + mail.imapHost = "imap.purelymail.com"; + mail.smtpHost = "smtp.purelymail.com"; + dotfilesRepo = "git@github.com:nmasur/dotfiles"; }; + # Common overlays to always use + overlays = [ + inputs.nur.overlay + inputs.nix2vim.overlay + (import ./overlays/neovim-plugins.nix inputs) + (import ./overlays/calibre-web.nix) + (import ./overlays/disko.nix inputs) + ]; + # System types to support. supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; @@ -55,36 +132,66 @@ # Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. forAllSystems = nixpkgs.lib.genAttrs supportedSystems; - in { + in rec { + # Contains my full system builds, including home-manager + # nixos-rebuild switch --flake .#tempest nixosConfigurations = { - desktop = import ./hosts/desktop { - inherit nixpkgs home-manager nur globals wallpapers; - }; - wsl = import ./hosts/wsl { inherit nixpkgs wsl home-manager globals; }; + tempest = import ./hosts/tempest { inherit inputs globals overlays; }; + hydra = import ./hosts/hydra { inherit inputs globals overlays; }; + flame = import ./hosts/flame { inherit inputs globals overlays; }; + swan = import ./hosts/swan { inherit inputs globals overlays; }; }; + # Contains my full Mac system builds, including home-manager + # darwin-rebuild switch --flake .#lookingglass darwinConfigurations = { - macbook = import ./hosts/macbook { - inherit nixpkgs darwin home-manager nur globals; - }; + lookingglass = + import ./hosts/lookingglass { inherit inputs globals overlays; }; }; + # For quickly applying local settings with: + # home-manager switch --flake .#tempest + homeConfigurations = { + tempest = + nixosConfigurations.tempest.config.home-manager.users.${globals.user}.home; + lookingglass = + darwinConfigurations.lookingglass.config.home-manager.users."Noah.Masur".home; + }; + + # Disk formatting, only used once + diskoConfigurations = { root = import ./disks/root.nix; }; + + packages = let + aws = system: + import ./hosts/aws { inherit inputs globals overlays system; }; + staff = system: + import ./hosts/staff { inherit inputs globals overlays system; }; + neovim = system: + let pkgs = import nixpkgs { inherit system overlays; }; + in import ./modules/common/neovim/package { + inherit pkgs; + colors = (import ./colorscheme/gruvbox-dark).dark; + }; + in { + x86_64-linux.aws = aws "x86_64-linux"; + x86_64-linux.staff = staff "x86_64-linux"; + + # Package Neovim config into standalone package + x86_64-linux.neovim = neovim "x86_64-linux"; + x86_64-darwin.neovim = neovim "x86_64-darwin"; + aarch64-linux.neovim = neovim "aarch64-linux"; + aarch64-darwin.neovim = neovim "aarch64-darwin"; + }; + + # Programs that can be run by calling this flake apps = forAllSystems (system: - let pkgs = import nixpkgs { inherit system; }; - in rec { - default = readme; - - # Format and install from nothing - installer = import ./apps/installer.nix { inherit pkgs; }; - - # Display the readme for this repository - readme = import ./apps/readme.nix { inherit pkgs; }; - - }); + let pkgs = import nixpkgs { inherit system overlays; }; + in import ./apps { inherit pkgs; }); + # Development environments devShells = forAllSystems (system: - let pkgs = import nixpkgs { inherit system; }; + let pkgs = import nixpkgs { inherit system overlays; }; in { # Used to run commands and edit files in this repo @@ -92,23 +199,6 @@ buildInputs = with pkgs; [ git stylua nixfmt shfmt shellcheck ]; }; - # Used for cloud and systems development and administration - devops = pkgs.mkShell { - buildInputs = with pkgs; [ - git - terraform - consul - vault - awscli2 - google-cloud-sdk - ansible - kubectl - kubernetes-helm - kustomize - fluxcd - ]; - }; - }); # Templates for starting other projects quickly diff --git a/hosts/README.md b/hosts/README.md new file mode 100644 index 0000000..052c3b4 --- /dev/null +++ b/hosts/README.md @@ -0,0 +1,12 @@ +# Hosts + +| Host | Purpose | +| --- | --- | +| [aws](./aws/default.nix) | AWS AMI | +| [staff](./staff/default.nix) | Live USB stick | +| [flame](./flame/default.nix) | Oracle cloud server | +| [hydra](./hydra/default.nix) | WSL config | +| [lookingglass](./lookingglass/default.nix) | Work MacBook | +| [swan](./swan/default.nix) | Home server | +| [tempest](./tempest/default.nix) | Linux desktop | + diff --git a/hosts/aws/default.nix b/hosts/aws/default.nix new file mode 100644 index 0000000..45b9285 --- /dev/null +++ b/hosts/aws/default.nix @@ -0,0 +1,31 @@ +{ inputs, system, globals, overlays, ... }: + +inputs.nixos-generators.nixosGenerate { + inherit system; + format = "amazon"; + modules = [ + inputs.home-manager.nixosModules.home-manager + { + nixpkgs.overlays = overlays; + user = globals.user; + fullName = globals.fullName; + dotfilesRepo = globals.dotfilesRepo; + gitName = globals.gitName; + gitEmail = globals.gitEmail; + networking.hostName = "sheep"; + gui.enable = false; + theme.colors = (import ../../colorscheme/gruvbox).dark; + passwordHash = null; + publicKey = + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; + # AWS settings require this + permitRootLogin = "prohibit-password"; + } + ../../modules/common + ../../modules/nixos + ../../modules/nixos/services/sshd.nix + ] ++ [ + # Required to fix diskSize errors during build + ({ ... }: { amazonImage.sizeMB = 16 * 1024; }) + ]; +} diff --git a/hosts/aws/main.tf b/hosts/aws/main.tf new file mode 100644 index 0000000..4fbb2ca --- /dev/null +++ b/hosts/aws/main.tf @@ -0,0 +1,80 @@ +locals { + image_file = one(fileset(path.root, "result/nixos-amazon-image-*.vhd")) +} + +# Upload to S3 +resource "aws_s3_object" "image" { + bucket = "your_bucket_name" + key = basename(local.image_file) + source = local.image_file + etag = filemd5(local.image_file) +} + +# Setup IAM access for the VM Importer +data "aws_iam_policy_document" "vmimport_trust_policy" { + statement { + actions = ["sts:AssumeRole"] + principals { + type = "Service" + identifiers = ["vmie.amazonaws.com"] + } + } +} + +data "aws_iam_policy_document" "vmimport" { + statement { + actions = [ + "s3:GetBucketLocation", + "s3:GetObject", + "s3:ListBucket", + ] + resources = [ + "arn:aws:s3:::${aws_s3_object.image.bucket}", + "arn:aws:s3:::${aws_s3_object.image.bucket}/*", + ] + } + statement { + actions = [ + "ec2:ModifySnapshotAttribute", + "ec2:CopySnapshot", + "ec2:RegisterImage", + "ec2:Describe*", + ] + resources = ["*"] + } +} + +resource "aws_iam_role" "vmimport" { + name = "vmimport" + assume_role_policy = data.aws_iam_policy_document.vmimport_trust_policy.json + inline_policy { + name = "vmimport" + policy = data.aws_iam_policy_document.vmimport.json + } +} + +# Import to EBS +resource "aws_ebs_snapshot_import" "image" { + disk_container { + format = "VHD" + user_bucket { + s3_bucket = aws_s3_object.image.bucket + s3_key = aws_s3_object.image.key + } + } + + role_name = aws_iam_role.vmimport.name +} + +# Convert to AMI +resource "aws_ami" "image" { + description = "Created with NixOS." + name = replace(basename(local.image_file), "/\\.vhd$/", "") + virtualization_type = "hvm" + + ebs_block_device { + device_name = "/dev/xvda" + snapshot_id = aws_ebs_snapshot_import.image.id + volume_size = 8 + } +} diff --git a/hosts/aws/workflow.yml b/hosts/aws/workflow.yml new file mode 100644 index 0000000..b8e38d1 --- /dev/null +++ b/hosts/aws/workflow.yml @@ -0,0 +1,280 @@ +name: 'Terraform' +env: + + AWS_ACCOUNT_NUMBER: '' + AWS_PLAN_ROLE_NAME: github_actions_plan + AWS_APPLY_ROLE_NAME: github_actions_admin + + # Always required. Used for authenticating to AWS, but can also act as your + # default region if you don't want to specify in the provider configuration. + AWS_REGION: us-east-1 + + # You must change these to fit your project. + TF_VAR_project: change-me + TF_VAR_label: change-me + TF_VAR_owner: Your Name Here + + # If storing Terraform in a subdirectory, specify it here. + TERRAFORM_DIRECTORY: . + + # Pinned versions of tools to use. + # Check for new releases: + # - https://github.com/hashicorp/terraform/releases + # - https://github.com/fugue/regula/releases + # - https://github.com/terraform-linters/tflint/releases + TERRAFORM_VERSION: 1.2.6 + REGULA_VERSION: 2.9.0 + TFLINT_VERSION: 0.39.1 + + # Terraform configuration options + TERRAFORM_PARALLELISM: 10 + + # These variables are passed to Terraform based on GitHub information. + TF_VAR_repo: ${{ github.repository }} + +# This workflow is triggered in the following ways. +on: + + # Any push or merge to these branches. + push: + branches: + - dev + - prod + + # Any pull request targeting these branches (plan only). + pull_request: + branches: + - dev + - prod + + + # Any manual trigger on these branches. + workflow_dispatch: + branches: + - dev + - prod + +# ------------------------------------------------------------------- +# The rest of this workflow can operate without adjustments. Edit the +# below content at your own risk! +# ------------------------------------------------------------------- + +# Used to connect to AWS IAM +permissions: + id-token: write + contents: read + pull-requests: write + +# Only run one workflow at a time for each Terraform state. This prevents +# lockfile conflicts, especially during PR vs push. +concurrency: terraform-${{ github.base_ref || github.ref }} + +jobs: + terraform: + + name: 'Terraform' + + # Change this if you need to run your deployment on-prem. + runs-on: ubuntu-latest + + steps: + + # Downloads the current repo code to the runner. + - name: Checkout Repo Code + uses: actions/checkout@v3 + + # Enable access to KVM, required to build an image + - name: Enable KVM group perms + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + + # Login to AWS + - name: AWS Assume Role + uses: aws-actions/configure-aws-credentials@v1.6.1 + with: + role-to-assume: ${{ env.AWS_ROLE_ARN }} + aws-region: ${{ env.AWS_REGION }} + + # Install Nix + - name: Install Nix + uses: cachix/install-nix-action@v17 + with: + extra_nix_config: | + substituters = s3://insert-cache-bucket https://cache.nixos.org/ + trusted-public-keys = insert-cache-bucket:M6PsZjHXcLvbQyPUBLICKEYGVoNwI84g1FBQzouRU= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= + + # Build the image + - name: Build Image + run: nix build .#aws + + # Copy the image to S3 + - name: Upload Image to Cache + env: + NIX_CACHE_PRIVATE_KEY: ${{ secrets.NIX_CACHE_PRIVATE_KEY }} + run: | + echo "$NIX_CACHE_PRIVATE_KEY" > cache.key + nix store sign --key-file cache.key $(readlink result) + nix copy --to s3://t2-aws-nixos-test $(readlink result) + rm cache.key + + # Exports all GitHub Secrets as environment variables prefixed by + # "TF_VAR_", which exposes them to Terraform. The name of each GitHub + # Secret must match its Terraform variable name exactly. + - name: Export Secrets to Terraform Variables + env: + ALL_SECRETS: ${{ toJson(secrets) }} + run: | + echo "$ALL_SECRETS" \ + | jq "to_entries | .[] | \"TF_VAR_\" + ( .key | ascii_downcase ) + \"=\" + .value" \ + | tr -d \" >> $GITHUB_ENV + + # Installs the Terraform binary and some other accessory functions. + - name: Setup Terraform + uses: hashicorp/setup-terraform@v2 + with: + terraform_version: ${{ env.TERRAFORM_VERSION }} + + # Checks whether Terraform is formatted properly. If this fails, you + # should install the pre-commit hook. + - name: Check Formatting + run: | + terraform fmt -no-color -check -diff -recursive + + # Downloads a Terraform code lint test. + - uses: terraform-linters/setup-tflint@v1 + name: Setup TFLint + with: + tflint_version: v${{ env.TFLINT_VERSION }} + + # Sets up linting with this codebase. + - name: Init TFLint + working-directory: ${{ env.TERRAFORM_DIRECTORY }} + run: tflint --init + + # Lints the current code. + - name: Run TFLint + working-directory: ${{ env.TERRAFORM_DIRECTORY }} + run: | + tflint -f compact + find ./modules/* -type d -maxdepth 0 | xargs -I __ tflint -f compact --disable-rule=terraform_required_providers --disable-rule=terraform_required_version __ + + # Connects to remote state backend and download providers. + - name: Terraform Init + working-directory: ${{ env.TERRAFORM_DIRECTORY }} + run: | + terraform init \ + -backend-config="role_arn=${{ env.AWS_STATE_ROLE_ARN }}" \ + -backend-config="region=us-east-1" \ + -backend-config="workspace_key_prefix=accounts/${{ env.AWS_ACCOUNT_NUMBER }}/${{ github.repository }}" \ + -backend-config="key=state.tfstate" \ + -backend-config="dynamodb_table=global-tf-state-lock" + + # Set the Terraform Workspace to the current branch name. + - name: Set Terraform Workspace + working-directory: ${{ env.TERRAFORM_DIRECTORY }} + shell: bash + run: | + export WORKSPACE=${{ github.base_ref || github.ref_name }} + terraform workspace select ${WORKSPACE} || terraform workspace new $WORKSPACE + echo "TF_WORKSPACE=$(echo ${WORKSPACE} | sed 's/\//_/g')" >> $GITHUB_ENV + + # Checks differences between current code and infrastructure state. + - name: Terraform Plan + id: plan + working-directory: ${{ env.TERRAFORM_DIRECTORY }} + run: | + terraform plan \ + -input=false \ + -no-color \ + -out=tfplan \ + -parallelism=${TERRAFORM_PARALLELISM} \ + -var-file=variables-${TF_WORKSPACE}.tfvars + + # Gets the results of the plan for pull requests. + - name: Terraform Show Plan + id: show + working-directory: ${{ env.TERRAFORM_DIRECTORY }} + run: terraform show -no-color tfplan + + # Adds the results of the plan to the pull request. + - name: Comment Plan + uses: actions/github-script@v6 + if: github.event_name == 'pull_request' + env: + STDOUT: "```terraform\n${{ steps.show.outputs.stdout }}```" + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + // 1. Retrieve existing bot comments for the PR + const { data: comments } = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }) + const botComment = comments.find(comment => { + return comment.user.type === 'Bot' && comment.body.includes('Terraform Format and Style') + }) + + // 2. Prepare format of the comment + const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\` + #### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\` + #### Terraform Validation 🤖\`${{ steps.validate.outcome }}\` +
Validation Output + + \`\`\`\n + ${{ steps.validate.outputs.stdout }} + \`\`\` + +
+ + #### Terraform Plan 📖\`${{ steps.plan.outcome }}\` + +
Show Plan + + \`\`\`\n + ${process.env.PLAN} + \`\`\` + +
+ + *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`*`; + + // 3. If we have a comment, update it, otherwise create a new one + if (botComment) { + github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: botComment.id, + body: output + }) + } else { + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: output + }) + } + + # Downloads Regula and checks whether the plan meets compliance requirements. + - name: Regula Compliance Check + shell: bash + working-directory: ${{ env.TERRAFORM_DIRECTORY }} + run: | + REGULA_URL="https://github.com/fugue/regula/releases/download/v${REGULA_VERSION}/regula_${REGULA_VERSION}_Linux_x86_64.tar.gz" + curl -sL "$REGULA_URL" -o regula.tar.gz + tar xzf regula.tar.gz + terraform show -json tfplan | ./regula run + + # Deploys infrastructure or changes to infrastructure. + - name: Terraform Apply + if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' + working-directory: ${{ env.TERRAFORM_DIRECTORY }} + run: | + terraform apply \ + -auto-approve \ + -input=false \ + -parallelism=${TERRAFORM_PARALLELISM} \ + tfplan diff --git a/hosts/common.nix b/hosts/common.nix deleted file mode 100644 index e50cd98..0000000 --- a/hosts/common.nix +++ /dev/null @@ -1,85 +0,0 @@ -{ config, lib, pkgs, ... }: { - - imports = - [ ../modules/shell ../modules/neovim ../modules/repositories/dotfiles.nix ]; - - options = with lib; { - user = mkOption { - type = types.str; - description = "Primary user of the system"; - }; - fullName = lib.mkOption { - type = lib.types.str; - description = "Human readable name of the user"; - }; - userDirs = { - # Required to prevent infinite recursion when referenced by himalaya - download = lib.mkOption { - type = lib.types.str; - description = "XDG directory for downloads"; - default = - if pkgs.stdenv.isDarwin then "$HOME/Downloads" else "$HOME/downloads"; - }; - }; - gui = { - enable = mkEnableOption { - description = "Enable graphics"; - default = false; - }; - }; - colorscheme = mkOption { - type = types.attrs; - description = "Base16 color scheme"; - }; - homePath = mkOption { - type = types.path; - description = "Path of user's home directory."; - default = builtins.toPath (if pkgs.stdenv.isDarwin then - "/Users/${config.user}" - else - "/home/${config.user}"); - }; - dotfilesPath = mkOption { - type = types.path; - description = "Path of dotfiles repository."; - default = config.homePath + "/dev/personal/dotfiles"; - }; - dotfilesRepo = mkOption { - type = types.str; - description = "Link to dotfiles repository."; - }; - unfreePackages = mkOption { - type = types.listOf types.str; - description = "List of unfree packages to allow."; - default = [ ]; - }; - }; - - config = let stateVersion = "22.11"; - in { - - # Enable features in Nix commands - nix.extraOptions = "experimental-features = nix-command flakes"; - - # Basic common system packages for all devices - environment.systemPackages = with pkgs; [ git vim wget curl ]; - - # Use the system-level nixpkgs instead of Home Manager's - home-manager.useGlobalPkgs = true; - - # Install packages to /etc/profiles instead of ~/.nix-profile, useful when - # using multiple profiles for one user - home-manager.useUserPackages = true; - - # Allow specified unfree packages (identified elsewhere) - # Retrieves package object based on string name - nixpkgs.config.allowUnfreePredicate = pkg: - builtins.elem (lib.getName pkg) config.unfreePackages; - - # Pin a state version to prevent warnings - home-manager.users.${config.user}.home.stateVersion = stateVersion; - home-manager.users.root.home.stateVersion = stateVersion; - - }; - -} diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix deleted file mode 100644 index 35d821a..0000000 --- a/hosts/desktop/default.nix +++ /dev/null @@ -1,44 +0,0 @@ -{ nixpkgs, home-manager, nur, globals, wallpapers, ... }: - -# System configuration for my desktop -nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = { }; - modules = [ - globals - home-manager.nixosModules.home-manager - { - networking.hostName = "desktop"; - nixpkgs.overlays = [ nur.overlay ]; - # Set registry to flake packages, used for nix X commands - nix.registry.nixpkgs.flake = nixpkgs; - gaming.steam = true; - gaming.leagueoflegends = true; - gaming.legendary = true; - gui = { - enable = true; - compositor.enable = true; - wallpaper = "${wallpapers}/gruvbox/road.jpg"; - gtk.theme = { name = "Adwaita-dark"; }; - }; - colorscheme = (import ../../modules/colorscheme/gruvbox); - passwordHash = - "$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF."; - } - - ./hardware-configuration.nix - ../common.nix - ../../modules/hardware - ../../modules/nixos - ../../modules/graphical - ../../modules/gaming - ../../modules/applications - ../../modules/mail/himalaya.nix - ../../modules/repositories/notes.nix - ../../modules/services/keybase.nix - ../../modules/services/gnupg.nix - ../../modules/services/mullvad.nix - ../../modules/programming/nix.nix - ../../modules/programming/haskell.nix - ]; -} diff --git a/hosts/desktop/hardware-configuration.nix b/hosts/desktop/hardware-configuration.nix deleted file mode 100644 index af59134..0000000 --- a/hosts/desktop/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, modulesPath, ... }: - -{ - imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; - - boot.initrd.availableKernelModules = - [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" ]; - boot.initrd.kernelModules = [ ]; - boot.kernelModules = [ "kvm-intel" ]; - boot.extraModulePackages = [ ]; - - fileSystems."/" = { - device = "/dev/disk/by-label/nixos"; - fsType = "ext4"; - }; - - fileSystems."/boot" = { - device = "/dev/disk/by-label/boot"; - fsType = "vfat"; - }; - - swapDevices = [ ]; - - powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; - hardware.cpu.intel.updateMicrocode = - lib.mkDefault config.hardware.enableRedistributableFirmware; -} diff --git a/hosts/flame/default.nix b/hosts/flame/default.nix new file mode 100644 index 0000000..3d249eb --- /dev/null +++ b/hosts/flame/default.nix @@ -0,0 +1,99 @@ +# The Flame +# System configuration for an Oracle free server + +# How to install: +# https://blog.korfuri.fr/posts/2022/08/nixos-on-an-oracle-free-tier-ampere-machine/ + +{ inputs, globals, overlays, ... }: + +inputs.nixpkgs.lib.nixosSystem { + system = "aarch64-linux"; + specialArgs = { }; + modules = [ + (removeAttrs globals [ "mail.server" ]) + inputs.home-manager.nixosModules.home-manager + ../../modules/common + ../../modules/nixos + { + nixpkgs.overlays = overlays; + + # Hardware + server = true; + networking.hostName = "flame"; + + imports = [ (inputs.nixpkgs + "/nixos/modules/profiles/qemu-guest.nix") ]; + boot.initrd.availableKernelModules = [ "xhci_pci" "virtio_pci" "usbhid" ]; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/e1b6bd50-306d-429a-9f45-78f57bc597c3"; + fsType = "ext4"; + }; + + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/D5CA-237A"; + fsType = "vfat"; + }; + + # Theming + gui.enable = false; + theme = { colors = (import ../../colorscheme/gruvbox).dark; }; + + # Disable passwords, only use SSH key + publicKey = + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; + + # Programs and services + caddy.enable = true; + cloudflare.enable = true; # Proxy traffic with Cloudflare + dotfiles.enable = true; # Clone dotfiles + gaming.minecraft-server.enable = true; # Setup Minecraft server + giteaServer = "git.masu.rs"; + metricsServer = "metrics.masu.rs"; + neovim.enable = true; + vaultwardenServer = "vault.masu.rs"; + + # Nextcloud backup config + backup.s3 = { + endpoint = "s3.us-west-002.backblazeb2.com"; + bucket = "noahmasur-backup"; + accessKeyId = "0026b0e73b2e2c80000000005"; + }; + + # # Grant access to Jellyfin directories from Nextcloud + # users.users.nextcloud.extraGroups = [ "jellyfin" ]; + + # # Wireguard config for Transmission + # wireguard.enable = true; + # networking.wireguard.interfaces.wg0 = { + # + # # The local IPs for this machine within the Wireguard network + # # Any inbound traffic bound for these IPs should be kept on localhost + # ips = [ "10.66.13.200/32" "fc00:bbbb:bbbb:bb01::3:dc7/128" ]; + # + # peers = [{ + # + # # Identity of Wireguard target peer (VPN) + # publicKey = "bOOP5lIjqCdDx5t+mP/kEcSbHS4cZqE0rMlBI178lyY="; + # + # # The public internet address of the target peer + # endpoint = "86.106.143.132:51820"; + # + # # Which outgoing IP ranges should be sent through Wireguard + # allowedIPs = [ "0.0.0.0/0" "::0/0" ]; + # + # # Send heartbeat signal within the network + # persistentKeepalive = 25; + # + # }]; + # + # }; + + # # VPN port forwarding + # services.transmission.settings.peer-port = 57599; + + # # Grant access to Transmission directories from Jellyfin + # users.users.jellyfin.extraGroups = [ "transmission" ]; + + } + ]; +} diff --git a/hosts/hydra/default.nix b/hosts/hydra/default.nix new file mode 100644 index 0000000..aff2ba8 --- /dev/null +++ b/hosts/hydra/default.nix @@ -0,0 +1,46 @@ +# The Hydra +# System configuration for WSL + +{ inputs, globals, overlays, ... }: + +inputs.nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { }; + modules = [ + ../../modules/common + ../../modules/nixos + ../../modules/wsl + globals + inputs.wsl.nixosModules.wsl + inputs.home-manager.nixosModules.home-manager + { + networking.hostName = "hydra"; + nixpkgs.overlays = overlays; + identityFile = "/home/${globals.user}/.ssh/id_ed25519"; + gui.enable = false; + theme = { + colors = (import ../../colorscheme/gruvbox).dark; + dark = true; + }; + passwordHash = inputs.nixpkgs.lib.fileContents ../../password.sha512; + wsl = { + enable = true; + wslConf.automount.root = "/mnt"; + defaultUser = globals.user; + startMenuLaunchers = true; + nativeSystemd = true; + wslConf.network.generateResolvConf = true; # Turn off if it breaks VPN + interop.includePath = + false; # Including Windows PATH will slow down Neovim command mode + }; + + neovim.enable = true; + mail.enable = true; + mail.aerc.enable = true; + mail.himalaya.enable = true; + dotfiles.enable = true; + nixlang.enable = true; + lua.enable = true; + } + ]; +} diff --git a/hosts/lookingglass/default.nix b/hosts/lookingglass/default.nix new file mode 100644 index 0000000..ea7df5c --- /dev/null +++ b/hosts/lookingglass/default.nix @@ -0,0 +1,46 @@ +# The Looking Glass +# System configuration for my work Macbook + +{ inputs, globals, overlays, ... }: + +inputs.darwin.lib.darwinSystem { + system = "x86_64-darwin"; + specialArgs = { }; + modules = [ + ../../modules/common + ../../modules/darwin + (globals // rec { + user = "Noah.Masur"; + gitName = "Noah-Masur_1701"; + gitEmail = "${user}@take2games.com"; + }) + inputs.home-manager.darwinModules.home-manager + { + nixpkgs.overlays = [ inputs.firefox-darwin.overlay ] ++ overlays; + networking.hostName = "lookingglass"; + identityFile = "/Users/Noah.Masur/.ssh/id_ed25519"; + gui.enable = true; + theme = { + colors = (import ../../colorscheme/gruvbox).dark; + dark = true; + }; + mail.user = globals.user; + charm.enable = true; + neovim.enable = true; + mail.enable = true; + mail.aerc.enable = true; + mail.himalaya.enable = false; + kitty.enable = true; + discord.enable = true; + firefox.enable = true; + dotfiles.enable = true; + nixlang.enable = true; + terraform.enable = true; + python.enable = true; + lua.enable = true; + kubernetes.enable = true; + _1password.enable = true; + slack.enable = true; + } + ]; +} diff --git a/hosts/macbook/default.nix b/hosts/macbook/default.nix deleted file mode 100644 index 8d58f1e..0000000 --- a/hosts/macbook/default.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ nixpkgs, darwin, home-manager, nur, globals, ... }: - -# System configuration for my work MacBook -darwin.lib.darwinSystem { - system = "x86_64-darwin"; - specialArgs = { }; - modules = [ - (globals // { - user = "Noah.Masur"; - gitName = "Noah-Masur_1701"; - gitEmail = "Noah.Masur@take2games.com"; - }) - home-manager.darwinModules.home-manager - { - gui.enable = true; - colorscheme = (import ../../modules/colorscheme/gruvbox); - mailUser = globals.user; - networking.hostName = "noah-masur-mac"; - nixpkgs.overlays = [ nur.overlay ]; - # Set registry to flake packages, used for nix X commands - nix.registry.nixpkgs.flake = nixpkgs; - } - ../common.nix - ../../modules/darwin - ../../modules/applications/alacritty.nix - ../../modules/applications/discord.nix - ../../modules/mail/himalaya.nix - ../../modules/repositories/notes.nix - ../../modules/programming/nix.nix - ../../modules/programming/terraform.nix - ../../modules/programming/python.nix - ../../modules/programming/lua.nix - ../../modules/programming/kubernetes.nix - ]; -} diff --git a/hosts/server/default.nix b/hosts/server/default.nix deleted file mode 100644 index fad1431..0000000 --- a/hosts/server/default.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ nixpkgs, home-manager, globals, ... }: - -# System configuration for a generic server -nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = { }; - modules = [ - globals - home-manager.nixosModules.home-manager - { - networking.hostName = "sheep"; - gui.enable = false; - colorscheme = (import ../../modules/colorscheme/gruvbox); - passwordHash = - "$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF."; - } - ../common.nix - ../../modules/nixos - ]; -} diff --git a/hosts/staff/default.nix b/hosts/staff/default.nix new file mode 100644 index 0000000..3888b28 --- /dev/null +++ b/hosts/staff/default.nix @@ -0,0 +1,43 @@ +# The Staff +# ISO configuration for my USB drive + +{ inputs, system, overlays, ... }: + +inputs.nixos-generators.nixosGenerate { + inherit system; + format = "install-iso"; + modules = [{ + nixpkgs.overlays = overlays; + networking.hostName = "staff"; + users.extraUsers.root.openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s" + ]; + services.openssh = { + enable = true; + ports = [ 22 ]; + allowSFTP = true; + settings = { + GatewayPorts = "no"; + X11Forwarding = false; + PasswordAuthentication = false; + PermitRootLogin = "yes"; + }; + }; + environment.systemPackages = + let pkgs = import inputs.nixpkgs { inherit system overlays; }; + in with pkgs; [ + git + vim + wget + curl + (import ../../modules/common/neovim/package { + inherit pkgs; + colors = (import ../../colorscheme/gruvbox).dark; + }) + ]; + nix.extraOptions = '' + experimental-features = nix-command flakes + warn-dirty = false + ''; + }]; +} diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix new file mode 100644 index 0000000..87ff2fd --- /dev/null +++ b/hosts/swan/default.nix @@ -0,0 +1,79 @@ +# The Swan +# System configuration for my home NAS server + +{ inputs, globals, overlays, ... }: + +inputs.nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { }; + modules = [ + globals + inputs.home-manager.nixosModules.home-manager + inputs.disko.nixosModules.disko + ../../modules/common + ../../modules/nixos + { + # Hardware + server = true; + networking.hostName = "swan"; + + boot.initrd.availableKernelModules = + [ "xhci_pci" "ahci" "nvme" "usb_storage" "sd_mod" ]; + + # Required for transcoding + boot.initrd.kernelModules = [ "amdgpu" ]; + boot.kernelParams = [ + "radeon.si_support=0" + "amdgpu.si_support=1" + "radeon.cik_support=0" + "amdgpu.cik_support=1" + "amdgpu.dc=1" + ]; + hardware.enableRedistributableFirmware = true; + + powerManagement.cpuFreqGovernor = "powersave"; + hardware.cpu.intel.updateMicrocode = true; + + # ZFS + zfs.enable = true; + # Generated with: head -c 8 /etc/machine-id + networking.hostId = "600279f4"; # Random ID required for ZFS + disko = { + enableConfig = true; + devices = (import ../../disks/root.nix { disk = "/dev/nvme0n1"; }); + }; + boot.zfs.extraPools = [ "tank" ]; + + gui.enable = false; + theme = { colors = (import ../../colorscheme/gruvbox).dark; }; + nixpkgs.overlays = overlays; + neovim.enable = true; + caddy.enable = true; + cloudflare.enable = true; + dotfiles.enable = true; + streamServer = "stream.masu.rs"; + nextcloudServer = "cloud.masu.rs"; + bookServer = "books.masu.rs"; + arrServer = "download.masu.rs"; + samba.enable = true; + + cloudflareTunnel = { + enable = true; + id = "646754ac-2149-4a58-b51a-e1d0a1f3ade2"; + credentialsFile = ../../private/cloudflared-swan.age; + ca = + "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCHF/UMtJqPFrf6f6GRY0ZFnkCW7b6sYgUTjTtNfRj1RdmNic1NoJZql7y6BrqQinZvy7nsr1UFDNWoHn6ah3tg= open-ssh-ca@cloudflareaccess.org"; + }; + + backup.s3 = { + endpoint = "s3.us-west-002.backblazeb2.com"; + bucket = "noahmasur-backup"; + accessKeyId = "0026b0e73b2e2c80000000005"; + }; + + # Disable passwords, only use SSH key + publicKey = + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; + } + ]; +} diff --git a/hosts/tempest/default.nix b/hosts/tempest/default.nix new file mode 100644 index 0000000..fd00134 --- /dev/null +++ b/hosts/tempest/default.nix @@ -0,0 +1,97 @@ +# The Tempest +# System configuration for my desktop + +{ inputs, globals, overlays, ... }: + +inputs.nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + globals + inputs.home-manager.nixosModules.home-manager + ../../modules/common + ../../modules/nixos + { + nixpkgs.overlays = overlays; + + # Hardware + physical = true; + networking.hostName = "tempest"; + + boot.initrd.availableKernelModules = + [ "nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; + boot.initrd.kernelModules = [ "amdgpu" ]; + boot.kernelModules = [ "kvm-amd" ]; + services.xserver.videoDrivers = [ "amdgpu" ]; + hardware.enableRedistributableFirmware = true; + powerManagement.cpuFreqGovernor = "performance"; + hardware.cpu.amd.updateMicrocode = true; + hardware.fancontrol.enable = true; + hardware.fancontrol.config = '' + # Configuration file generated by pwmconfig, changes will be lost + INTERVAL=10 + DEVPATH=hwmon0=devices/pci0000:00/0000:00:03.1/0000:06:00.0/0000:07:00.0/0000:08:00.0 + DEVNAME=hwmon0=amdgpu + FCTEMPS=hwmon0/pwm1=hwmon0/temp1_input + FCFANS= hwmon0/pwm1=hwmon0/fan1_input + MINTEMP=hwmon0/pwm1=50 + MAXTEMP=hwmon0/pwm1=70 + MINSTART=hwmon0/pwm1=100 + MINSTOP=hwmon0/pwm1=10 + MINPWM=hwmon0/pwm1=10 + MAXPWM=hwmon0/pwm1=240 + ''; + + fileSystems."/" = { + device = "/dev/disk/by-label/nixos"; + fsType = "ext4"; + }; + + fileSystems."/boot" = { + device = "/dev/disk/by-label/boot"; + fsType = "vfat"; + }; + + # Must be prepared ahead + identityFile = "/home/${globals.user}/.ssh/id_ed25519"; + passwordHash = inputs.nixpkgs.lib.fileContents ../../password.sha512; + + # Theming + gui.enable = true; + theme = { + colors = (import ../../colorscheme/gruvbox-dark).dark; + dark = true; + }; + wallpaper = "${inputs.wallpapers}/gruvbox/road.jpg"; + gtk.theme.name = inputs.nixpkgs.lib.mkDefault "Adwaita-dark"; + + # Programs and services + charm.enable = true; + neovim.enable = true; + media.enable = true; + dotfiles.enable = true; + firefox.enable = true; + kitty.enable = true; + _1password.enable = true; + discord.enable = true; + nautilus.enable = true; + obsidian.enable = true; + mail.enable = true; + mail.aerc.enable = true; + mail.himalaya.enable = true; + keybase.enable = true; + mullvad.enable = false; + nixlang.enable = true; + yt-dlp.enable = true; + gaming = { + dwarf-fortress.enable = true; + enable = true; + steam.enable = true; + legendary.enable = true; + lutris.enable = true; + leagueoflegends.enable = true; + ryujinx.enable = true; + }; + + } + ]; +} diff --git a/hosts/wsl/default.nix b/hosts/wsl/default.nix deleted file mode 100644 index a2e37a5..0000000 --- a/hosts/wsl/default.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ nixpkgs, wsl, home-manager, globals, ... }: - -# System configuration for WSL -nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = { }; - modules = [ - globals - wsl.nixosModules.wsl - home-manager.nixosModules.home-manager - { - networking.hostName = "wsl"; - # Set registry to flake packages, used for nix X commands - nix.registry.nixpkgs.flake = nixpkgs; - gui.enable = false; - colorscheme = (import ../../modules/colorscheme/gruvbox); - passwordHash = - "$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF."; - wsl = { - enable = true; - automountPath = "/mnt"; - defaultUser = globals.user; - startMenuLaunchers = true; - wslConf.network.generateResolvConf = true; # Turn off if it breaks VPN - interop.includePath = - false; # Including Windows PATH will slow down Neovim command mode - }; - } - ../common.nix - ../../modules/wsl - ../../modules/nixos - ../../modules/mail/himalaya.nix - ../../modules/repositories/notes.nix - ../../modules/programming/nix.nix - ../../modules/programming/lua.nix - ]; -} diff --git a/legacy/bin/biggest b/legacy/bin/biggest deleted file mode 100755 index 1655ef3..0000000 --- a/legacy/bin/biggest +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/local/bin/nu - -ls | sort-by size | reverse | keep 10 - diff --git a/legacy/bin/biggest-files b/legacy/bin/biggest-files deleted file mode 100755 index 16d10aa..0000000 --- a/legacy/bin/biggest-files +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/local/bin/nu - -ls **/* | where type == File | sort-by size | reverse | keep 10 diff --git a/legacy/bin/docker_cleanup b/legacy/bin/docker_cleanup deleted file mode 100755 index 59cf41d..0000000 --- a/legacy/bin/docker_cleanup +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -# Stop all containers -if [ "$(docker ps -a -q)" ]; then - echo "Stopping docker containers..." - docker stop "$(docker ps -a -q)" -else - echo "No running docker containers." -fi - -# Remove all stopped containers -if [ "$(docker ps -a -q)" ]; then - echo "Removing docker containers..." - docker rm "$(docker ps -a -q)" -else - echo "No stopped docker containers." -fi - -# Remove all untagged images -if [[ $(docker images | grep "^") ]]; then - docker rmi "$(docker images | grep "^" | awk '{print $3}')" -else - echo "No untagged docker images." -fi - -echo "Cleaned up docker." diff --git a/legacy/bin/jira-checkout b/legacy/bin/jira-checkout deleted file mode 100755 index 69e297c..0000000 --- a/legacy/bin/jira-checkout +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -# Adapted from: https://seb.jambor.dev/posts/improving-shell-workflows-with-fzf/ -# Requires the following variables to be set: -# - ATLASSIAN_EMAIL -# - ATLASSIAN_API_TOKEN -# - JIRA_HOSTNAME -# - JIRA_PROJECT - -choose_issue() { - jq_template='"\(.key): \(.fields.summary)"' - query="project=$JIRA_PROJECT AND status not in (\"Done\") AND assignee=currentUser()" - - branch_name=$( - curl \ - --data-urlencode "jql=$query" \ - --get \ - --user "$ATLASSIAN_EMAIL:$ATLASSIAN_API_TOKEN" \ - --silent \ - --compressed \ - "https://$JIRA_HOSTNAME/rest/api/2/search" | - jq ".issues[] | $jq_template" | - sed -e 's/"\(.*\)"/\1/' | - fzf \ - --preview='jira-details {1}' \ - --preview-window=top:wrap | - sed -e 's/: /:/' -e 's/[^a-zA-Z0-9:]/-/g' | - awk -F ":" '{printf "%s/%s", $1, tolower($2)}' - ) - - echo "$branch_name" -} - -issue_branch=$(choose_issue) -if [ -n "$issue_branch" ]; then - echo "git checkout -b \"$issue_branch\"" -fi diff --git a/legacy/bin/jira-details b/legacy/bin/jira-details deleted file mode 100755 index 7d73fc5..0000000 --- a/legacy/bin/jira-details +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -# Adapted from: https://seb.jambor.dev/posts/improving-shell-workflows-with-fzf/ -# Requires the following variables to be set: -# - ATLASSIAN_EMAIL -# - ATLASSIAN_API_TOKEN -# - JIRA_HOSTNAME -# - JIRA_PROJECT (for other script) - -issue_details() { - jira_key=$(echo "$1" | cut -d":" -f1) - jq_template='"'\ -'# \(.key): \(.fields.summary)\n'\ -'\n'\ -'*Created*: \(.fields.created)\n'\ -'*Status*: \(.fields.status.statusCategory.name)\n'\ -'*Reporter*: \(.fields.reporter.displayName)\n'\ -'*Priority*: \(.fields.priority.name)\n'\ -"*Epic*: https://$JIRA_HOSTNAME/browse/\(.fields.customfield_10014)\n"\ -'\n'\ -'## Link\n\n'\ -"https://$JIRA_HOSTNAME/browse/\(.key)\n"\ -'\n'\ -'## Description\n\n'\ -'\(.fields.description)'\ -'"' - curl \ - --get \ - --user "$ATLASSIAN_EMAIL:$ATLASSIAN_API_TOKEN" \ - --silent \ - --compressed \ - "https://$JIRA_HOSTNAME/rest/api/2/issue/$jira_key" | - jq "$jq_template" | - xargs printf | - bat -l md --color always --style plain -} - -issue_details "$1" diff --git a/legacy/bin/kube-dashboard b/legacy/bin/kube-dashboard deleted file mode 100755 index 73542fd..0000000 --- a/legacy/bin/kube-dashboard +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -kubectl -n kube-system get secret "$( - kubectl -n kube-system get secret | - grep dashboard-admin | - awk '{print $1}' -)" -o json | - jq -j --raw-output '.data.token' | - base64 --decode | - pbcopy - -open http://localhost:8001/api/v1/namespaces/default/services/https:kubernetes-dashboard:https/proxy/#!/login - -kubectl proxy diff --git a/legacy/bin/newest b/legacy/bin/newest deleted file mode 100755 index 5d33ea8..0000000 --- a/legacy/bin/newest +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/local/bin/nu - -ls | sort-by modified | reverse | keep 5 diff --git a/legacy/bin/oldest b/legacy/bin/oldest deleted file mode 100755 index a9cc938..0000000 --- a/legacy/bin/oldest +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/local/bin/nu - -ls | sort-by modified | keep 5 diff --git a/legacy/bin/pod b/legacy/bin/pod deleted file mode 100755 index c1d491a..0000000 --- a/legacy/bin/pod +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -# Credit: https://github.com/junegunn/fzf/blob/master/ADVANCED.md - -read -ra tokens < <( - kubectl get pods --all-namespaces | - fzf --info=inline --layout=reverse --header-lines=1 --border \ - --prompt "$(kubectl config current-context | sed 's/-context$//')> " \ - --header $'Press CTRL-O to open log in editor\n\n' \ - --bind ctrl-/:toggle-preview \ - --bind "ctrl-o:execute:${EDITOR:-vim} <(kubectl logs --namespace {1} {2}) > /dev/tty" \ - --preview-window up,follow \ - --preview 'kubectl logs --follow --tail=100000 --namespace {1} {2}' "$@" -) -[ ${#tokens} -gt 1 ] && - kubectl exec -it --namespace "${tokens[0]}" "${tokens[1]}" -- /bin/sh diff --git a/legacy/bin/symlinks b/legacy/bin/symlinks deleted file mode 100755 index 71cd0c2..0000000 --- a/legacy/bin/symlinks +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/local/bin/nu - -ls -al | where type == Symlink | select name target diff --git a/legacy/bin/url-decode b/legacy/bin/url-decode deleted file mode 100755 index 10a20ae..0000000 --- a/legacy/bin/url-decode +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; } - -urldecode "$@" diff --git a/legacy/newsboat/com.noah.newsboat.plist b/legacy/newsboat/com.noah.newsboat.plist deleted file mode 100644 index 1c19f9c..0000000 --- a/legacy/newsboat/com.noah.newsboat.plist +++ /dev/null @@ -1,28 +0,0 @@ - - - - - Label - com.noah.newsboat - - ProgramArguments - - /usr/local/bin/newsboat -x reload - - - Nice - 1 - - StartInterval - 1800 - - RunAtLoad - - - StandardErrorPath - /tmp/newsboat.err - - StandardOutPath - /tmp/newsboat.out - - diff --git a/legacy/newsboat/config b/legacy/newsboat/config deleted file mode 100644 index ecd3aba..0000000 --- a/legacy/newsboat/config +++ /dev/null @@ -1,40 +0,0 @@ -browser "$BROWSER %u" -prepopulate-query-feeds yes -feed-sort-order lastupdated -reload-only-visible-feeds yes -text-width 72 - -bind-key j down -bind-key k up -bind-key j next articlelist -bind-key k prev articlelist -bind-key G end -bind-key g home -bind-key d pagedown -bind-key u pageup -bind-key n next-unread -bind-key p prev-unread -bind-key ; macro-prefix -bind-key B bookmark -bind-key f edit-flags - -macro v set browser "mpv %u"; open-in-browser; set browser "$BROWSER %u" -macro p set browser "echo %u"; one; set browser "$BROWSER %u" -macro H set browser "clx view $(echo %u | cut -d '=' -f2)"; one; set browser "$BROWSER %u" -macro h set browser "clx view $(echo %u | cut -d '=' -f2)"; two; set browser "$BROWSER %u" -macro w set browser "w3m -o confirm_qq=false %u"; open-in-browser; set browser "$BROWSER %u" -macro r set browser "url-markdown %u | glow -p -w 72 -"; open-in-browser; set browser "$BROWSER %u" -macro d set browser "youtube-dl -o ~/Downloads/%(title)s.%(ext)s %u &"; open-in-browser-noninteractively; set browser "$BROWSER %u" -macro n set-tag News; reload-all -macro a set-tag All -macro e set-tag Reddit; reload-all -macro y set-tag YouTube; reload-all - -bookmark-cmd "bookmark" - -highlight article "^(Feed|Title|Author|Link|Date):.*" color243 default -highlight article "^(Links):.*" color243 default -highlight article "^(\\[[0-9]+\\]):.*" color243 default -highlight article "^(\\[[0-9]+\\])" color243 default -highlight article "^\\[.*\\]$" color243 default -highlight article "^(Title:).*" color249 default diff --git a/legacy/nix-env.fish b/legacy/nix-env.fish deleted file mode 100644 index b84fba0..0000000 --- a/legacy/nix-env.fish +++ /dev/null @@ -1,137 +0,0 @@ -# Setup Nix - -# We need to distinguish between single-user and multi-user installs. -# This is difficult because there's no official way to do this. -# We could look for the presence of /nix/var/nix/daemon-socket/socket but this will fail if the -# daemon hasn't started yet. /nix/var/nix/daemon-socket will exist if the daemon has ever run, but -# I don't think there's any protection against accidentally running `nix-daemon` as a user. -# We also can't just look for /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh because -# older single-user installs used the default profile instead of a per-user profile. -# We can still check for it first, because all multi-user installs should have it, and so if it's -# not present that's a pretty big indicator that this is a single-user install. If it does exist, -# we still need to verify the install type. To that end we'll look for a root owner and sticky bit -# on /nix/store. Multi-user installs set both, single-user installs don't. It's certainly possible -# someone could do a single-user install as root and then manually set the sticky bit but that -# would be extremely unusual. - -set -l nix_profile_path /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh -set -l single_user_profile_path ~/.nix-profile/etc/profile.d/nix.sh -if test -e $nix_profile_path - # The path exists. Double-check that this is a multi-user install. - # We can't just check for ~/.nix-profile/… because this may be a single-user install running as - # the wrong user. - - # stat is not portable. Splitting the output of ls -nd is reliable on most platforms. - set -l owner (string split -n ' ' (command ls -nd /nix/store 2>/dev/null))[3] - if not test -k /nix/store -a $owner -eq 0 - # /nix/store is either not owned by root or not sticky. Assume single-user. - set nix_profile_path $single_user_profile_path - end -else - # The path doesn't exist. Assume single-user - set nix_profile_path $single_user_profile_path -end - -if test -e $nix_profile_path - # Source the nix setup script - # We're going to run the regular Nix profile under bash and then print out a few variables - for line in (command env -u BASH_ENV bash -c '. "$0"; for name in PATH "${!NIX_@}"; do printf "%s=%s\0" "$name" "${!name}"; done' $nix_profile_path | string split0) - set -xg (string split -m 1 = $line) - end - - # Insert Nix's fish share directories into fish's special variables. - # nixpkgs-installed fish tries to set these up already if NIX_PROFILES is defined, which won't - # be the case when sourcing $__fish_data_dir/share/config.fish normally, but might be for a - # recursive invocation. To guard against that, we'll only insert paths that don't already exit. - # Furthermore, for the vendor_conf.d sourcing, we'll use the pre-existing presence of a path in - # $fish_function_path to determine whether we want to source the relevant vendor_conf.d folder. - - # To start, let's locally define NIX_PROFILES if it doesn't already exist. - set -al NIX_PROFILES - if test (count $NIX_PROFILES) -eq 0 - set -a NIX_PROFILES $HOME/.nix-profile - end - # Replicate the logic from nixpkgs version of $__fish_data_dir/__fish_build_paths.fish. - set -l __nix_profile_paths (string split ' ' -- $NIX_PROFILES)[-1..1] - set -l __extra_completionsdir \ - $__nix_profile_paths/etc/fish/completions \ - $__nix_profile_paths/share/fish/vendor_completions.d - set -l __extra_functionsdir \ - $__nix_profile_paths/etc/fish/functions \ - $__nix_profile_paths/share/fish/vendor_functions.d - set -l __extra_confdir \ - $__nix_profile_paths/etc/fish/conf.d \ - $__nix_profile_paths/share/fish/vendor_conf.d - ### Configure fish_function_path ### - # Remove any of our extra paths that may already exist. - # Record the equivalent __extra_confdir path for any function path that exists. - set -l existing_conf_paths - for path in $__extra_functionsdir - if set -l idx (contains --index -- $path $fish_function_path) - set -e fish_function_path[$idx] - set -a existing_conf_paths $__extra_confdir[(contains --index -- $path $__extra_functionsdir)] - end - end - # Insert the paths before $__fish_data_dir. - if set -l idx (contains --index -- $__fish_data_dir/functions $fish_function_path) - # Fish has no way to simply insert into the middle of an array. - set -l new_path $fish_function_path[1..$idx] - set -e new_path[$idx] - set -a new_path $__extra_functionsdir - set fish_function_path $new_path $fish_function_path[$idx..-1] - else - set -a fish_function_path $__extra_functionsdir - end - - ### Configure fish_complete_path ### - # Remove any of our extra paths that may already exist. - for path in $__extra_completionsdir - if set -l idx (contains --index -- $path $fish_complete_path) - set -e fish_complete_path[$idx] - end - end - # Insert the paths before $__fish_data_dir. - if set -l idx (contains --index -- $__fish_data_dir/completions $fish_complete_path) - set -l new_path $fish_complete_path[1..$idx] - set -e new_path[$idx] - set -a new_path $__extra_completionsdir - set fish_complete_path $new_path $fish_complete_path[$idx..-1] - else - set -a fish_complete_path $__extra_completionsdir - end - - ### Source conf directories ### - # The built-in directories were already sourced during shell initialization. - # Any __extra_confdir that came from $__fish_data_dir/__fish_build_paths.fish was also sourced. - # As explained above, we're using the presence of pre-existing paths in $fish_function_path as a - # signal that the corresponding conf dir has also already been sourced. - # In order to simulate this, we'll run through the same algorithm as found in - # $__fish_data_dir/config.fish except we'll avoid sourcing the file if it comes from an - # already-sourced location. - # Caveats: - # * Files will be sourced in a different order than we'd ideally do (because we're coming in - # after the fact to source them). - # * If there are existing extra conf paths, files in them may have been sourced that should have - # been suppressed by paths we're inserting in front. - # * Similarly any files in $__fish_data_dir/vendor_conf.d that should have been suppressed won't - # have been. - set -l sourcelist - for file in $__fish_config_dir/conf.d/*.fish $__fish_sysconf_dir/conf.d/*.fish - # We know these paths were sourced already. Just record them. - set -l basename (string replace -r '^.*/' '' -- $file) - contains -- $basename $sourcelist - or set -a sourcelist $basename - end - for root in $__extra_confdir - for file in $root/*.fish - set -l basename (string replace -r '^.*/' '' -- $file) - contains -- $basename $sourcelist - and continue - set -a sourcelist $basename - contains -- $root $existing_conf_paths - and continue # this is a pre-existing path, it will have been sourced already - [ -f $file -a -r $file ] - and source $file - end - end -end diff --git a/legacy/scripts/configure_macos b/legacy/scripts/configure_macos deleted file mode 100755 index 1bd8e00..0000000 --- a/legacy/scripts/configure_macos +++ /dev/null @@ -1,168 +0,0 @@ -#!/bin/sh - -echo "Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs)" -defaults write NSGlobalDomain AppleKeyboardUIMode -int 3 - -echo "Automatically show and hide the dock" -defaults write com.apple.dock autohide -bool true - -echo "Automatically show and hide the menu bar" -defaults write NSGlobalDomain _HIHideMenuBar -bool true - -echo "Make Dock icons of hidden applications translucent" -defaults write com.apple.dock showhidden -bool true - -echo "Use current directory as default search scope in Finder" -defaults write com.apple.finder FXDefaultSearchScope -string "SCcf" - -echo "Expand save panel by default" -defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true - -echo "Expand print panel by default" -defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true - -echo "Disable the \"Are you sure you want to open this application?\" dialog" -defaults write com.apple.LaunchServices LSQuarantine -bool false - -echo "Enable highlight hover effect for the grid view of a stack (Dock)" -defaults write com.apple.dock mouse-over-hilte-stack -bool true - -echo "Enable spring loading for all Dock items" -defaults write enable-spring-load-actions-on-all-items -bool true - -echo "Disable press-and-hold for keys in favor of key repeat" -defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false -defaults write -g ApplePressAndHoldEnabled -bool false - -echo "Set a blazingly fast keyboard repeat rate" -defaults write NSGlobalDomain KeyRepeat -int 2 - -echo "Set a shorter Delay until key repeat" -defaults write NSGlobalDomain InitialKeyRepeat -int 12 - -echo "Disable disk image verification" -defaults write com.apple.frameworks.diskimages skip-verify -bool true -defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true -defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true - -echo "Avoid creating .DS_Store files on network volumes" -defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true - -echo "Disable the warning when changing a file extension" -defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false - -# echo "Enable snap-to-grid for desktop icons" -# /usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist - -echo "Disable the warning before emptying the Trash" -defaults write com.apple.finder WarnOnEmptyTrash -bool false - -echo "Disable tap to click (Trackpad)" -defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool false - -echo "Enable Safari’s debug menu" -defaults write com.apple.Safari IncludeInternalDebugMenu -bool true - -echo "Make Safari’s search banners default to Contains instead of Starts With" -defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false - -echo "Add a context menu item for showing the Web Inspector in web views" -defaults write NSGlobalDomain WebKitDeveloperExtras -bool true - -echo "Save to disk (not to iCloud) by default" -defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false - -echo "Disable automatic capitalization as it’s annoying when typing code" -defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool false - -echo "Disable smart dashes as they’re annoying when typing code" -defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false - -echo "Disable automatic period substitution as it’s annoying when typing code" -defaults write NSGlobalDomain NSAutomaticPeriodSubstitutionEnabled -bool false - -echo "Disable smart quotes as they’re annoying when typing code" -defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false - -echo "Disable auto-correct" -defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false - -echo "Use scroll gesture with the Ctrl (^) modifier key to zoom" -defaults write com.apple.universalaccess closeViewScrollWheelToggle -bool true -defaults write com.apple.universalaccess HIDScrollZoomModifierMask -int 262144 -echo "Follow the keyboard focus while zoomed in" -defaults write com.apple.universalaccess closeViewZoomFollowsFocus -bool true - -echo "Require password immediately after sleep or screen saver begins" -defaults write com.apple.screensaver askForPassword -int 1 -defaults write com.apple.screensaver askForPasswordDelay -int 0 - -echo "Save screenshots to downloads" -defaults write com.apple.screencapture location -string "${HOME}/Downloads" - -echo "Finder: allow quitting via ⌘ + Q; doing so will also hide desktop icons" -defaults write com.apple.finder QuitMenuItem -bool true - -echo "Show the ~/Library folder" -chflags nohidden ~/Library && xattr -d com.apple.FinderInfo ~/Library - -# Noah Prefs -echo "Enable dock magnification" -defaults write com.apple.dock magnification -bool true - -echo "Set dock size" -defaults write com.apple.dock largesize -int 48 -defaults write com.apple.dock tilesize -int 44 - -echo "Choose and order dock icons" -__dock_item() { - printf '%s%s%s%s%s' \ - 'tile-datafile-data' \ - '_CFURLString' \ - "$1" \ - '_CFURLStringType0' \ - '' -} - -defaults write com.apple.dock persistent-apps -array \ - "$(__dock_item /Applications/1Password\ 7.app)" \ - "$(__dock_item /Applications/Slack.app)" \ - "$(__dock_item /System/Applications/Calendar.app)" \ - "$(__dock_item /Applications/Firefox.app)" \ - "$(__dock_item /System/Applications/Messages.app)" \ - "$(__dock_item /System/Applications/Mail.app)" \ - "$(__dock_item /Applications/Mimestream.app)" \ - "$(__dock_item /Applications/zoom.us.app)" \ - "$(__dock_item /Applications/Obsidian.app)" \ - "$(__dock_item /Applications/Alacritty.app)" \ - "$(__dock_item /System/Applications/System\ Preferences.app)" - -echo "No recent items in dock" -defaults write com.apple.dock show-recents -bool FALSE - -echo "Switch to dark mode" -defaults write "Apple Global Domain" "AppleInterfaceStyle" "Dark" - -echo "Turn on Scroll Reverser" -open /Applications/Scroll\ Reverser.app -osascript -e 'tell application "System Events" to make login item at end with properties {path:"/Applications/Scroll Reverser.app", hidden:false}' - -echo "Allow apps from anywhere" -SPCTL=$(spctl --status) -if ! [ "$SPCTL" = "assessments disabled" ] -then - sudo spctl --master-disable -fi - -# --- - -echo "Reset Launchpad" -# [ -e ~/Library/Application\ Support/Dock/*.db ] && rm ~/Library/Application\ Support/Dock/*.db -rm ~/Library/Application\ Support/Dock/*.db - -echo "Show the ~/Library folder" -chflags nohidden ~/Library - -# Clean up -echo "Kill affected applications" -for app in Safari Finder Dock Mail SystemUIServer; do killall "$app" >/dev/null 2>&1; done diff --git a/legacy/scripts/npm b/legacy/scripts/npm deleted file mode 100755 index 2ad7268..0000000 --- a/legacy/scripts/npm +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -npm update -g -npm install -g pyright -npm install -g diagnostic-languageserver diff --git a/legacy/scripts/rust b/legacy/scripts/rust deleted file mode 100755 index 2456f0b..0000000 --- a/legacy/scripts/rust +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh - -install_rust() { - if ! (which ~/.cargo/bin/rustup > /dev/null) - then - echo "installing rustup" - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - fi - - echo "rustup ✓" -} - -update_rust() { - ~/.cargo/bin/rustup update > /dev/null 2>&1 - rust_version=$(~/.cargo/bin/rustc --version | awk '{print $2}') - - echo "latest rust: $rust_version ✓" -} - -download_rust_analyzer() { - if ! (which rust-analyzer > /dev/null) - then - echo "downloading rust analyzer" - rust_analyzer_bin=/usr/local/bin/rust-analyzer - curl -s -L https://github.com/rust-analyzer/rust-analyzer/releases/latest/download/rust-analyzer-mac -o $rust_analyzer_bin - chmod +x $rust_analyzer_bin - fi - - echo "rust-analyzer ✓" -} - -# cargo-edit: quickly add and remove packages -# whatfeatures: see optional features for a package -install_cargos() { - set -- \ - 'cargo-edit' \ - 'cargo-whatfeatures' - for program do - cargo install "$program" - done - - echo "cargos ✓" -} - -install_rust -update_rust -download_rust_analyzer -install_cargos diff --git a/legacy/scripts/setup_cheatsheet b/legacy/scripts/setup_cheatsheet deleted file mode 100755 index e10058c..0000000 --- a/legacy/scripts/setup_cheatsheet +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -echo "downloading cheatsheet" -curl https://cht.sh/:cht.sh > ~/.local/bin/cheat -chmod 755 ~/.local/bin/cheat -echo "cheatsheet ✓" diff --git a/legacy/scripts/setup_fish b/legacy/scripts/setup_fish deleted file mode 100755 index 269833d..0000000 --- a/legacy/scripts/setup_fish +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env fish - -set -U FISH_DIR (readlink ~/.config/fish) # Used for getting to this repo -set -Ux DOTS (dirname $FISH_DIR) # Directory of this config repo -set -U CDPATH . $HOME # Directories available for immediate cd -set -Ux EDITOR nvim # Preferred text editor -set -U PROJ $HOME/dev/work # Projects directory -set -Ux NOTES_PATH "$HOME/dev/personal/notes" # Notes directory -set -Ux MANPAGER "nvim +Man!" # Used for reading man pages -set -Ux DIRENV_LOG_FORMAT "" # Disable direnv output -set -Ux BROWSER "/Applications/Firefox.app/Contents/MacOS/firefox" - -# Load abbreviations -abbrs - -# Turn off greeting -set -U fish_greeting "" - -# Set colors (Base16 Eighties) -set -U fish_color_normal normal -set -U fish_color_command 99cc99 -set -U fish_color_quote ffcc66 -set -U fish_color_redirection d3d0c8 -set -U fish_color_end cc99cc -set -U fish_color_error f2777a -set -U fish_color_selection white --bold --background=brblack -set -U fish_color_search_match bryellow --background=brblack -set -U fish_color_history_current --bold -set -U fish_color_operator 6699cc -set -U fish_color_escape 66cccc -set -U fish_color_cwd green -set -U fish_color_cwd_root red -set -U fish_color_valid_path --underline -set -U fish_color_autosuggestion 747369 -set -U fish_color_user brgreen -set -U fish_color_host normal -set -U fish_color_cancel -r -set -U fish_pager_color_completion normal -set -U fish_pager_color_description B3A06D yellow -set -U fish_pager_color_prefix white --bold --underline -set -U fish_pager_color_progress brwhite --background=cyan -set -U fish_color_comment ffcc66 -set -U fish_color_param d3d0c8 -set -U fish_color_match 6699cc - -echo "fish setup ✓" diff --git a/legacy/scripts/setup_ytfzf b/legacy/scripts/setup_ytfzf deleted file mode 100755 index 0408a3a..0000000 --- a/legacy/scripts/setup_ytfzf +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -echo "downloading ytfzf" -mkdir -p ~/.local/bin -curl -sL "https://raw.githubusercontent.com/pystardust/ytfzf/master/ytfzf" >~/.local/bin/ytfzf -chmod 755 ~/.local/bin/ytfzf -echo "ytfzf ✓" diff --git a/legacy/templates/kubernetes/clusterrole.yaml b/legacy/templates/kubernetes/clusterrole.yaml deleted file mode 100644 index 10fc326..0000000 --- a/legacy/templates/kubernetes/clusterrole.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: -rules: - - apiGroups: [""] - resources: - verbs: [] diff --git a/legacy/templates/kubernetes/clusterrolebinding.yaml b/legacy/templates/kubernetes/clusterrolebinding.yaml deleted file mode 100644 index 3d5095e..0000000 --- a/legacy/templates/kubernetes/clusterrolebinding.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: -subjects: -- kind: ServiceAccount - name: - namespace: default diff --git a/legacy/templates/kubernetes/configmap.yaml b/legacy/templates/kubernetes/configmap.yaml deleted file mode 100644 index 0dfc20a..0000000 --- a/legacy/templates/kubernetes/configmap.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: - namespace: default - annotations: - replicator.v1.mittwald.de/replicate-to: ".*" -data: diff --git a/legacy/templates/kubernetes/deployment.yaml b/legacy/templates/kubernetes/deployment.yaml deleted file mode 100644 index 204bcfc..0000000 --- a/legacy/templates/kubernetes/deployment.yaml +++ /dev/null @@ -1,33 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: - namespace: default -spec: - replicas: 1 - selector: - matchLabels: - app: - template: - metadata: - labels: - app: - spec: - serviceAccountName: - containers: - - name: - image: - imagePullPolicy: Always - envFrom: - - configMapRef: - name: - - secretRef: - name: - ports: - - containerPort: - protocol: TCP - resources: - limits: - cpu: - requests: - cpu: diff --git a/legacy/templates/kubernetes/ingress.yaml b/legacy/templates/kubernetes/ingress.yaml deleted file mode 100644 index df7b928..0000000 --- a/legacy/templates/kubernetes/ingress.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: networking.k8s.io/v1beta1 # must be beta until k8s 1.19 -kind: Ingress -metadata: - annotations: - kubernetes.io/ingress.class: alb - alb.ingress.kubernetes.io/group.name: - alb.ingress.kubernetes.io/listen-ports: '[{"HTTPS":443}]' - alb.ingress.kubernetes.io/scheme: internet-facing - alb.ingress.kubernetes.io/security-groups: - alb.ingress.kubernetes.io/tags: Project= - alb.ingress.kubernetes.io/target-type: instance - name: - namespace: -spec: - rules: - - host: - http: - paths: - - backend: - serviceName: - servicePort: diff --git a/legacy/templates/kubernetes/role.yaml b/legacy/templates/kubernetes/role.yaml deleted file mode 100644 index 395080d..0000000 --- a/legacy/templates/kubernetes/role.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: - namespace: default -rules: -- apiGroups: [""] - resourceNames: - resources: - verbs: diff --git a/legacy/templates/kubernetes/rolebinding.yaml b/legacy/templates/kubernetes/rolebinding.yaml deleted file mode 100644 index 6fcb96c..0000000 --- a/legacy/templates/kubernetes/rolebinding.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: - namespace: default -roleRef: - kind: - name: - apiGroup: rbac.authorization.k8s.io -subjects: -- kind: - name: - apiGroup: rbac.authorization.k8s.io diff --git a/legacy/templates/kubernetes/secret.yaml b/legacy/templates/kubernetes/secret.yaml deleted file mode 100644 index a8025a0..0000000 --- a/legacy/templates/kubernetes/secret.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -kind: Secret -metadata: - name: - namespace: default - annotations: - replicator.v1.mittwald.de/replicate-to: ".*" -data: diff --git a/legacy/templates/kubernetes/service.yaml b/legacy/templates/kubernetes/service.yaml deleted file mode 100644 index e375f08..0000000 --- a/legacy/templates/kubernetes/service.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - alb.ingress.kubernetes.io/healthcheck-path: - name: - namespace: default -spec: - ports: - - port: 443 - protocol: TCP - targetPort: 80 - selector: - app: - type: NodePort diff --git a/legacy/templates/kubernetes/serviceaccount.yaml b/legacy/templates/kubernetes/serviceaccount.yaml deleted file mode 100644 index 1c89f57..0000000 --- a/legacy/templates/kubernetes/serviceaccount.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: v1 -kind: ServiceAccount -metadata: - name: - namespace: default diff --git a/legacy/templates/programs/skeleton.py b/legacy/templates/programs/skeleton.py deleted file mode 100644 index 395f57d..0000000 --- a/legacy/templates/programs/skeleton.py +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python - -""" -Program -""" - -def main(): - """Run the program""" - pass - -if __name__ == "__main__": - main() diff --git a/legacy/templates/programs/skeleton.sh b/legacy/templates/programs/skeleton.sh deleted file mode 100644 index 1e5bc66..0000000 --- a/legacy/templates/programs/skeleton.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then - cat < = + # To use '=' in a key sequence, substitute it with "Eq": "" + # If you wish to bind #, you can wrap the key sequence in quotes: "#" = quit + global = { + "" = ":prev-tab"; + "" = ":next-tab "; + "" = ":term"; + "?" = ":help keys"; + }; + + messages = { + q = ":quit"; + + j = ":next "; + "" = ":next"; + "" = ":next 50%"; + "" = ":next 100%"; + "" = ":next 100%"; + + k = ":prev "; + "" = ":prev"; + "" = ":prev 50%"; + "" = ":prev 100%"; + "" = ":prev 100%"; + g = ":select 0 "; + G = ":select -1"; + + J = ":next-folder "; + K = ":prev-folder"; + H = ":collapse-folder"; + L = ":expand-folder"; + + v = ":mark -t"; + V = ":mark -v"; + + T = ":toggle-threads"; + + "" = ":view"; + d = ":prompt 'Really delete this message?' 'delete-message'"; + D = ":move Trash"; + A = ":archive flat"; + + C = ":compose"; + + rr = ":reply -a"; + rq = ":reply -aq"; + Rr = ":reply"; + Rq = ":reply -q"; + + c = ":cf"; + "$" = ":term"; + "!" = ":term"; + "|" = ":pipe"; + + "/" = ":search"; + "\\" = ":filter "; + n = ":next-result"; + N = ":prev-result"; + "" = ":clear"; + }; + + "messages:folder=Drafts" = { "" = ":recall"; }; + + view = { + "/" = ":toggle-key-passthrough /"; + q = ":close"; + O = ":open"; + S = ":save"; + "|" = ":pipe"; + D = ":move Trash"; + A = ":archive flat"; + + "" = ":open-link "; + + f = ":forward "; + rr = ":reply -a"; + rq = ":reply -aq"; + Rr = ":reply"; + Rq = ":reply -q"; + + H = ":toggle-headers"; + "" = ":prev-part"; + "" = ":next-part"; + J = ":next "; + K = ":prev"; + }; + + "view::passthrough" = { + "$noinherit" = "true"; + "$ex" = ""; + "" = ":toggle-key-passthrough"; + }; + + compose = { + # Keybindings used when the embedded terminal is not selected in the compose + # view + "$noinherit" = "true"; + "$ex" = ""; + "" = ":prev-field"; + "" = ":next-field"; + "" = ":switch-account -p"; + "" = ":switch-account -n"; + "" = ":next-field"; + "" = ":prev-tab"; + "" = ":next-tab"; + }; + + "compose::editor" = { + # Keybindings used when the embedded terminal is selected in the compose view + "$noinherit" = "true"; + "$ex" = ""; + "" = ":prev-field"; + "" = ":next-field"; + "" = ":prev-tab"; + "" = ":next-tab"; + }; + + "compose::review" = { + # Keybindings used when reviewing a message to be sent + y = ":send "; + n = ":abort"; + p = ":postpone"; + q = ":choose -o d discard abort -o p postpone postpone"; + e = ":edit"; + a = ":attach"; + d = ":detach"; + }; + + terminal = { + "$noinherit" = "true"; + "$ex" = ""; + "" = ":prev-tab"; + "" = ":next-tab"; + }; + + }; + extraConfig = { + general.unsafe-accounts-conf = true; + viewer = { pager = "${pkgs.less}/bin/less -R"; }; + filters = { + "text/plain" = "${pkgs.aerc}/libexec/aerc/filters/colorize"; + "text/calendar" = + "${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/libexec/aerc/filters/calendar"; + "text/html" = + "${pkgs.aerc}/libexec/aerc/filters/html | ${pkgs.aerc}/libexec/aerc/filters/colorize"; # Requires w3m, dante + # "text/*" = + # ''${pkgs.bat}/bin/bat -fP --file-name="$AERC_FILENAME "''; + "message/delivery-status" = + "${pkgs.aerc}/libexec/aerc/filters/colorize"; + "message/rfc822" = "${pkgs.aerc}/libexec/aerc/filters/colorize"; + "application/x-sh" = "${pkgs.bat}/bin/bat -fP -l sh"; + "application/pdf" = "${pkgs.zathura}/bin/zathura -"; + "audio/*" = "${pkgs.mpv}/bin/mpv -"; + "image/*" = "${pkgs.feh}/bin/feh -"; + }; + }; + }; + accounts.email.accounts.home.aerc = { + enable = true; + extraAccounts = { + check-mail = "5m"; + check-mail-cmd = "${pkgs.isync}/bin/mbsync -a"; + }; + }; + + xdg.desktopEntries.aerc = lib.mkIf pkgs.stdenv.isLinux { + name = "aerc"; + exec = "kitty aerc %u"; + }; + xsession.windowManager.i3.config.keybindings = + lib.mkIf pkgs.stdenv.isLinux { + "${ + config.home-manager.users.${config.user}.xsession.windowManager.i3.config.modifier + }+Shift+e" = "exec ${ + # Don't name the script `aerc` or it will affect grep + builtins.toString (pkgs.writeShellScript "focus-mail.sh" '' + count=$(ps aux | grep -c aerc) + if [ "$count" -eq 1 ]; then + i3-msg "exec --no-startup-id kitty --class aerc aerc" + sleep 0.25 + fi + i3-msg "[class=aerc] focus" + '') + }"; + }; + + programs.fish.shellAbbrs = { ae = "aerc"; }; + + }; + + }; +} diff --git a/modules/mail/himalaya.nix b/modules/common/mail/default.nix similarity index 50% rename from modules/mail/himalaya.nix rename to modules/common/mail/default.nix index 4e8963a..9482739 100644 --- a/modules/mail/himalaya.nix +++ b/modules/common/mail/default.nix @@ -1,83 +1,87 @@ { config, pkgs, lib, ... }: { + imports = [ ./himalaya.nix ./aerc.nix ]; + options = { - mailUser = lib.mkOption { + mail.enable = lib.mkEnableOption "Mail service."; + mail.user = lib.mkOption { type = lib.types.str; description = "User name for the email address."; default = config.user; }; - mailServer = lib.mkOption { - type = lib.types.str; + mail.server = lib.mkOption { + type = lib.types.nullOr lib.types.str; description = "Server name for the email address."; }; + mail.imapHost = lib.mkOption { + type = lib.types.nullOr lib.types.str; + description = "Server host for IMAP (reading mail)."; + }; + mail.smtpHost = lib.mkOption { + type = lib.types.nullOr lib.types.str; + description = "Server host for SMTP (sending mail)."; + }; }; - config = { + config = lib.mkIf config.mail.enable { home-manager.users.${config.user} = { - - programs.himalaya = { enable = true; }; programs.mbsync = { enable = true; }; services.mbsync = lib.mkIf pkgs.stdenv.isLinux { enable = true; frequency = "*:0/5"; + postExec = "${pkgs.notmuch}/bin/notmuch new"; }; - + services.imapnotify.enable = pkgs.stdenv.isLinux; + programs.notmuch.enable = true; accounts.email = { maildirBasePath = "${config.homePath}/mail"; accounts = { - home = let address = "${config.mailUser}@${config.mailServer}"; + home = let address = "${config.mail.user}@${config.mail.server}"; in { userName = address; realName = config.fullName; primary = true; inherit address; - aliases = map (mailUser: "${mailUser}@${config.mailServer}") [ + aliases = map (user: "${user}@${config.mail.server}") [ "me" "hey" "admin" ]; alot = { }; flavor = "plain"; - folders = { }; - getmail = { }; - himalaya = { - enable = true; - settings = { - downloads-dir = config.userDirs.download; - smtp-insecure = true; - }; - }; imap = { - host = "imap.purelymail.com"; + host = config.mail.imapHost; port = 993; tls.enable = true; }; imapnotify = { - enable = false; - boxes = [ ]; - onNotify = ""; - onNotifyPost = ""; + enable = true; + boxes = [ "Inbox" ]; + onNotify = "${pkgs.isync}/bin/mbsync -a"; + onNotifyPost = lib.mkIf + config.home-manager.users.${config.user}.services.dunst.enable + "${pkgs.libnotify}/bin/notify-send 'New mail arrived'"; }; maildir = { path = "main"; }; mbsync = { enable = true; - create = "maildir"; - expunge = "none"; - remove = "none"; + create = "both"; + expunge = "both"; + remove = "both"; patterns = [ "*" ]; extraConfig.channel = { CopyArrivalDate = "yes"; # Sync time of original message }; }; - mu.enable = false; - notmuch.enable = false; + notmuch.enable = true; passwordCommand = - "${pkgs.age}/bin/age --decrypt --identity ${config.homePath}/.ssh/id_ed25519 ${ - builtins.toString ./mailpass.age + "${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${ + pkgs.writeText "mailpass.age" + (builtins.readFile ../../../private/mailpass.age) }"; smtp = { - host = "smtp.purelymail.com"; + host = config.mail.smtpHost; port = 465; tls.enable = true; }; @@ -85,8 +89,6 @@ }; }; - programs.fish.shellAbbrs = { hi = "himalaya"; }; - }; }; diff --git a/modules/common/mail/himalaya.nix b/modules/common/mail/himalaya.nix new file mode 100644 index 0000000..bf627b1 --- /dev/null +++ b/modules/common/mail/himalaya.nix @@ -0,0 +1,25 @@ +{ config, lib, ... }: { + + options.mail.himalaya.enable = lib.mkEnableOption "Himalaya email."; + + config = lib.mkIf config.mail.himalaya.enable { + + home-manager.users.${config.user} = { + + programs.himalaya = { enable = true; }; + accounts.email.accounts.home.himalaya = { + enable = true; + backend = "imap"; + sender = "smtp"; + settings = { + downloads-dir = config.userDirs.download; + smtp-insecure = true; + }; + }; + + programs.fish.shellAbbrs = { hi = "himalaya"; }; + + }; + + }; +} diff --git a/modules/common/neovim/config/align.nix b/modules/common/neovim/config/align.nix new file mode 100644 index 0000000..37abafe --- /dev/null +++ b/modules/common/neovim/config/align.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: { + plugins = [ pkgs.vimPlugins.tabular ]; + lua = '' + -- Align + vim.keymap.set("", "ta", ":Tabularize /") + vim.keymap.set("", "t#", ":Tabularize /#") + vim.keymap.set("", "tl", ":Tabularize /---") + ''; +} diff --git a/modules/common/neovim/config/bufferline.nix b/modules/common/neovim/config/bufferline.nix new file mode 100644 index 0000000..73a6514 --- /dev/null +++ b/modules/common/neovim/config/bufferline.nix @@ -0,0 +1,22 @@ +{ pkgs, ... }: { + plugins = [ + pkgs.vimPlugins.bufferline-nvim + pkgs.vimPlugins.vim-bbye # Better closing of buffers + ]; + setup.bufferline = { + options = { + diagnostics = "nvim_lsp"; + always_show_bufferline = false; + separator_style = "slant"; + offsets = [{ filetype = "NvimTree"; }]; + }; + }; + lua = '' + -- Move buffers + vim.keymap.set("n", "L", ":BufferLineCycleNext", { silent = true }) + vim.keymap.set("n", "H", ":BufferLineCyclePrev", { silent = true }) + + -- Kill buffer + vim.keymap.set("n", "x", " :Bdelete", { silent = true }) + ''; +} diff --git a/modules/common/neovim/config/colors.nix b/modules/common/neovim/config/colors.nix new file mode 100644 index 0000000..7b72e20 --- /dev/null +++ b/modules/common/neovim/config/colors.nix @@ -0,0 +1,20 @@ +{ pkgs, lib, config, ... }: { + + options.colors = lib.mkOption { + type = lib.types.attrsOf lib.types.str; + description = "Attrset of base16 colorscheme key value pairs."; + }; + + config = { + plugins = [ pkgs.vimPlugins.nvim-base16 ]; + setup.base16-colorscheme = config.colors; + + # Telescope isn't working, shut off for now + lua = '' + require('base16-colorscheme').with_config { + telescope = false, + } + ''; + }; + +} diff --git a/modules/common/neovim/config/completion.nix b/modules/common/neovim/config/completion.nix new file mode 100644 index 0000000..d38aac5 --- /dev/null +++ b/modules/common/neovim/config/completion.nix @@ -0,0 +1,155 @@ +{ pkgs, dsl, ... }: { + + plugins = [ + pkgs.vimPlugins.cmp-nvim-lsp + pkgs.vimPlugins.cmp-buffer + pkgs.vimPlugins.cmp-path + pkgs.vimPlugins.cmp-cmdline + pkgs.vimPlugins.cmp-nvim-lua + pkgs.vimPlugins.luasnip + pkgs.vimPlugins.cmp_luasnip + pkgs.vimPlugins.cmp-rg + pkgs.vimPlugins.friendly-snippets + ]; + + use.cmp.setup = dsl.callWith { + + # Disable in telescope buffers + enabled = dsl.rawLua '' + function() + if vim.bo.buftype == "prompt" then + return false + end + return true + end + ''; + + snippet.expand = dsl.rawLua '' + function(args) + require("luasnip").lsp_expand(args.body) + end + ''; + + mapping = { + "['']" = dsl.rawLua + "require('cmp').mapping.select_next_item({ behavior = require('cmp').SelectBehavior.Insert })"; + "['']" = dsl.rawLua + "require('cmp').mapping.select_prev_item({ behavior = require('cmp').SelectBehavior.Insert })"; + "['']" = dsl.rawLua + "require('cmp').mapping.select_next_item({ behavior = require('cmp').SelectBehavior.Select })"; + "['']" = dsl.rawLua + "require('cmp').mapping.select_prev_item({ behavior = require('cmp').SelectBehavior.Select })"; + "['']" = dsl.rawLua "require('cmp').mapping.scroll_docs(-4)"; + "['']" = dsl.rawLua "require('cmp').mapping.scroll_docs(4)"; + "['']" = dsl.rawLua "require('cmp').mapping.abort()"; + "['']" = dsl.rawLua + "require('cmp').mapping.confirm({ behavior = require('cmp').ConfirmBehavior.Replace, select = true, })"; + "['']" = dsl.rawLua + "require('cmp').mapping.confirm({ behavior = require('cmp').ConfirmBehavior.Replace, select = true, })"; + "['']" = dsl.rawLua '' + function(_) + cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }) + vim.cmd("stopinsert") --- Abort and leave insert mode + end + ''; + "['']" = dsl.rawLua '' + cmp.mapping(function(_) + if require("luasnip").expand_or_jumpable() then + require("luasnip").expand_or_jump() + end + end, { "i", "s" }) + ''; + }; + + sources = [ + { name = "nvim_lua"; } + { name = "nvim_lsp"; } + { name = "luasnip"; } + { name = "path"; } + { + name = "buffer"; + keyword_length = 3; + max_item_count = 10; + } + { + name = "rg"; + keyword_length = 6; + max_item_count = 10; + option = { additional_arguments = "--ignore-case"; }; + } + ]; + + formatting = { + fields = [ "kind" "abbr" "menu" ]; + format = dsl.rawLua '' + function(entry, vim_item) + local kind_icons = { + Text = "", + Method = "m", + Function = "", + Constructor = "", + Field = "", + Variable = "", + Class = "", + Interface = "", + Module = "", + Property = "", + Unit = "", + Value = "", + Enum = "", + Keyword = "", + Snippet = "", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "", + Struct = "", + Event = "", + Operator = "", + TypeParameter = "", + } + vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) + vim_item.menu = ({ + luasnip = "[Snippet]", + buffer = "[Buffer]", + path = "[Path]", + rg = "[Grep]", + nvim_lsp = "[LSP]", + nvim_lua = "[Lua]", + })[entry.source.name] + return vim_item + end + ''; + }; + + experimental = { + native_menu = false; # Use cmp menu instead of Vim menu + ghost_text = true; # Show preview auto-completion + }; + + }; + + lua = '' + -- Use buffer source for `/` + require('cmp').setup.cmdline("/", { + sources = { + { name = "buffer", keyword_length = 5 }, + }, + }) + + -- Use cmdline & path source for ':' + require('cmp').setup.cmdline(":", { + sources = require('cmp').config.sources({ + { name = "path" }, + }, { + { name = "cmdline" }, + }), + }) + ''; + +} diff --git a/modules/common/neovim/config/gitsigns.lua b/modules/common/neovim/config/gitsigns.lua new file mode 100644 index 0000000..398c085 --- /dev/null +++ b/modules/common/neovim/config/gitsigns.lua @@ -0,0 +1,35 @@ +vim.keymap.set("", "", "", { silent = true }) +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +local gitsigns = require("gitsigns") +vim.keymap.set("n", "gB", gitsigns.blame_line) +vim.keymap.set("n", "gp", gitsigns.preview_hunk) +vim.keymap.set("v", "gp", gitsigns.preview_hunk) +vim.keymap.set("n", "gd", gitsigns.diffthis) +vim.keymap.set("v", "gd", gitsigns.diffthis) +vim.keymap.set("n", "rgf", gitsigns.reset_buffer) +vim.keymap.set("v", "hs", gitsigns.stage_hunk) +vim.keymap.set("n", "hr", gitsigns.reset_hunk) +vim.keymap.set("v", "hr", gitsigns.reset_hunk) + +-- Navigation +vim.keymap.set("n", "]g", function() + if vim.wo.diff then + return "]g" + end + vim.schedule(function() + gitsigns.next_hunk() + end) + return "" +end, { expr = true }) + +vim.keymap.set("n", "[g", function() + if vim.wo.diff then + return "[g" + end + vim.schedule(function() + gitsigns.prev_hunk() + end) + return "" +end, { expr = true }) diff --git a/modules/common/neovim/config/gitsigns.nix b/modules/common/neovim/config/gitsigns.nix new file mode 100644 index 0000000..06777cf --- /dev/null +++ b/modules/common/neovim/config/gitsigns.nix @@ -0,0 +1,5 @@ +{ pkgs, ... }: { + plugins = [ pkgs.vimPlugins.gitsigns-nvim ]; + setup.gitsigns = { }; + lua = builtins.readFile ./gitsigns.lua; +} diff --git a/modules/common/neovim/config/lsp.lua b/modules/common/neovim/config/lsp.lua new file mode 100644 index 0000000..c32d416 --- /dev/null +++ b/modules/common/neovim/config/lsp.lua @@ -0,0 +1,10 @@ +vim.keymap.set("n", "gd", vim.lsp.buf.definition) +vim.keymap.set("n", "gT", vim.lsp.buf.type_definition) +vim.keymap.set("n", "gi", vim.lsp.buf.implementation) +vim.keymap.set("n", "gh", vim.lsp.buf.hover) +-- vim.keymap.set("n", "gr", telescope.lsp_references) +vim.keymap.set("n", "R", vim.lsp.buf.rename) +vim.keymap.set("n", "]e", vim.diagnostic.goto_next) +vim.keymap.set("n", "[e", vim.diagnostic.goto_prev) +vim.keymap.set("n", "de", vim.diagnostic.open_float) +vim.keymap.set("n", "E", vim.lsp.buf.code_action) diff --git a/modules/common/neovim/config/lsp.nix b/modules/common/neovim/config/lsp.nix new file mode 100644 index 0000000..3cca40e --- /dev/null +++ b/modules/common/neovim/config/lsp.nix @@ -0,0 +1,73 @@ +{ pkgs, dsl, ... }: { + + plugins = [ + pkgs.vimPlugins.nvim-lspconfig + pkgs.vimPlugins.lsp-colors-nvim + pkgs.vimPlugins.null-ls-nvim + ]; + + use.lspconfig.lua_ls.setup = dsl.callWith { + settings = { Lua = { diagnostics = { globals = [ "vim" "hs" ]; }; }; }; + capabilities = dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()"; + cmd = [ "${pkgs.lua-language-server}/bin/lua-language-server" ]; + }; + + use.lspconfig.nil_ls.setup = dsl.callWith { + cmd = [ "${pkgs.nil}/bin/nil" ]; + capabilities = dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()"; + }; + + use.lspconfig.pyright.setup = dsl.callWith { + cmd = [ "${pkgs.pyright}/bin/pyright-langserver" "--stdio" ]; + }; + + use.lspconfig.terraformls.setup = + dsl.callWith { cmd = [ "${pkgs.terraform-ls}/bin/terraform-ls" "serve" ]; }; + + vim.api.nvim_create_augroup = dsl.callWith [ "LspFormatting" { } ]; + + lua = '' + ${builtins.readFile ./lsp.lua} + + require("null-ls").setup({ + sources = { + require("null-ls").builtins.formatting.stylua.with({ command = "${pkgs.stylua}/bin/stylua" }), + require("null-ls").builtins.formatting.black.with({ command = "${pkgs.black}/bin/black" }), + require("null-ls").builtins.diagnostics.ruff.with({ command = "${pkgs.ruff}/bin/ruff" }), + require("null-ls").builtins.formatting.fish_indent.with({ command = "${pkgs.fish}/bin/fish_indent" }), + require("null-ls").builtins.formatting.nixfmt.with({ command = "${pkgs.nixfmt}/bin/nixfmt" }), + require("null-ls").builtins.formatting.rustfmt.with({ command = "${pkgs.rustfmt}/bin/rustfmt" }), + require("null-ls").builtins.diagnostics.shellcheck.with({ command = "${pkgs.shellcheck}/bin/shellcheck" }), + require("null-ls").builtins.formatting.shfmt.with({ + command = "${pkgs.shfmt}/bin/shfmt", + extra_args = { "-i", "4", "-ci" }, + }), + require("null-ls").builtins.formatting.terraform_fmt.with({ + command = "${pkgs.terraform}/bin/terraform", + extra_filetypes = { "hcl" }, + }), + }, + + on_attach = function(client, bufnr) + if client.supports_method("textDocument/formatting") then + -- Auto-format on save + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format({ bufnr = bufnr }) + end, + }) + -- Use internal formatting for bindings like gq. + vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + vim.bo[args.buf].formatexpr = nil + end, + }) + end + end, + }) + ''; + +} diff --git a/modules/common/neovim/config/misc.nix b/modules/common/neovim/config/misc.nix new file mode 100644 index 0000000..c25ea76 --- /dev/null +++ b/modules/common/neovim/config/misc.nix @@ -0,0 +1,69 @@ +{ pkgs, dsl, lib, ... }: { + plugins = [ + pkgs.vimPlugins.vim-surround # Keybinds for surround characters + pkgs.vimPlugins.vim-eunuch # File manipulation commands + pkgs.vimPlugins.vim-fugitive # Git commands + pkgs.vimPlugins.vim-repeat # Better repeat using . + pkgs.vimPlugins.comment-nvim # Smart comment commands + pkgs.vimPlugins.glow-nvim # Markdown preview popup + pkgs.vimPlugins.nvim-colorizer-lua # Hex color previews + ]; + + setup.Comment = { }; + setup.colorizer = { }; + + vim.o = { + termguicolors = true; # Set to truecolor + hidden = true; # Don't unload buffers when leaving them + list = true; # Reveal whitespace with dashes + expandtab = true; # Tabs into spaces + shiftwidth = 4; # Amount to shift with > key + softtabstop = 4; # Amount to shift with key + ignorecase = true; # Ignore case when searching + smartcase = true; # Check case when using capitals in search + infercase = true; # Don't match cases when completing suggestions + incsearch = true; # Search while typing + visualbell = true; # No sounds + scrolljump = 1; # Number of lines to scroll + scrolloff = 3; # Margin of lines to see while scrolling + splitright = true; # Vertical splits on the right side + splitbelow = true; # Horizontal splits on the bottom side + pastetoggle = ""; # Use F3 to enter raw paste mode + clipboard = "unnamedplus"; # Uses system clipboard for yanking + updatetime = 300; # Faster diagnostics + mouse = "nv"; # Mouse interaction / scrolling + inccommand = "split"; # Live preview search and replace + }; + + vim.wo = { + number = true; # Show line numbers + relativenumber = true; # Relative numbers instead of absolute + }; + + # Better backup, swap and undo storage + vim.o.backup = true; # Easier to recover and more secure + vim.bo.swapfile = false; # Instead of swaps, create backups + vim.bo.undofile = true; # Keeps undos after quit + vim.o.backupdir = dsl.rawLua ''vim.fn.stdpath("cache") .. "/backup"''; + + # Required for nvim-cmp completion + vim.opt.completeopt = [ "menu" "menuone" "noselect" ]; + + lua = lib.mkBefore '' + vim.loader.enable() + ${builtins.readFile ../lua/keybinds.lua}; + ${builtins.readFile ../lua/settings.lua}; + ''; + + vimscript = '' + " Remember last position when reopening file + au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif + + " LaTeX options + au FileType tex inoremap ;bf \textbf{}i + au BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw! + + " Flash highlight when yanking + au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 250 } + ''; +} diff --git a/modules/common/neovim/config/statusline.nix b/modules/common/neovim/config/statusline.nix new file mode 100644 index 0000000..96c8bf7 --- /dev/null +++ b/modules/common/neovim/config/statusline.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: { + plugins = [ pkgs.vimPlugins.lualine-nvim ]; + setup.lualine = { + options = { + theme = "gruvbox"; + icons_enabled = true; + }; + }; +} diff --git a/modules/common/neovim/config/syntax.nix b/modules/common/neovim/config/syntax.nix new file mode 100644 index 0000000..56b8529 --- /dev/null +++ b/modules/common/neovim/config/syntax.nix @@ -0,0 +1,52 @@ +{ pkgs, ... }: { + + plugins = [ + (pkgs.vimPlugins.nvim-treesitter.withPlugins (_plugins: + with pkgs.tree-sitter-grammars; [ + tree-sitter-hcl + tree-sitter-python + tree-sitter-lua + tree-sitter-nix + tree-sitter-fish + tree-sitter-toml + tree-sitter-yaml + tree-sitter-json + ])) + pkgs.vimPlugins.vim-matchup # Better % jumping in languages + pkgs.vimPlugins.nginx-vim + pkgs.vimPlugins.vim-helm + pkgs.vimPlugins.vim-puppet + ]; + + setup."nvim-treesitter.configs" = { + highlight = { enable = true; }; + indent = { enable = true; }; + + textobjects = { + select = { + enable = true; + lookahead = true; # Jump forward automatically + + keymaps = { + "['af']" = "@function.outer"; + "['if']" = "@function.inner"; + "['ac']" = "@class.outer"; + "['ic']" = "@class.inner"; + "['al']" = "@loop.outer"; + "['il']" = "@loop.inner"; + "['aa']" = "@call.outer"; + "['ia']" = "@call.inner"; + "['ar']" = "@parameter.outer"; + "['ir']" = "@parameter.inner"; + "['aC']" = "@comment.outer"; + "['iC']" = "@comment.outer"; + "['a/']" = "@comment.outer"; + "['i/']" = "@comment.outer"; + "['a;']" = "@statement.outer"; + "['i;']" = "@statement.outer"; + }; + }; + }; + }; + +} diff --git a/modules/common/neovim/config/telescope.lua b/modules/common/neovim/config/telescope.lua new file mode 100644 index 0000000..0f9e979 --- /dev/null +++ b/modules/common/neovim/config/telescope.lua @@ -0,0 +1,70 @@ +local telescope = require("telescope.builtin") +vim.keymap.set("n", "k", telescope.keymaps) +vim.keymap.set("n", "/", telescope.live_grep) +vim.keymap.set("n", "ff", telescope.find_files) +vim.keymap.set("n", "fp", telescope.git_files) +vim.keymap.set("n", "fw", telescope.grep_string) +vim.keymap.set("n", "b", telescope.buffers) +vim.keymap.set("n", "hh", telescope.help_tags) +vim.keymap.set("n", "fr", telescope.oldfiles) +vim.keymap.set("n", "cc", telescope.commands) +vim.keymap.set("n", "gc", telescope.git_commits) +vim.keymap.set("n", "gf", telescope.git_bcommits) +vim.keymap.set("n", "gb", telescope.git_branches) +vim.keymap.set("n", "gs", telescope.git_status) +vim.keymap.set("n", "s", telescope.current_buffer_fuzzy_find) +vim.keymap.set("n", "rr", telescope.resume) + +vim.keymap.set("n", "N", function() + local opts = { + prompt_title = "Search Notes", + cwd = "$NOTES_PATH", + } + telescope.live_grep(opts) +end) + +vim.keymap.set("n", "fN", function() + local opts = { + prompt_title = "Find Notes", + cwd = "$NOTES_PATH", + } + telescope.find_files(opts) +end) + +vim.keymap.set("n", "cr", function() + local opts = require("telescope.themes").get_ivy({ + layout_config = { + bottom_pane = { + height = 15, + }, + }, + }) + telescope.command_history(opts) +end) + +-- Zoxide +vim.keymap.set("n", "fz", require("telescope").extensions.zoxide.list) + +-- Project +require("telescope").load_extension("projects") +vim.keymap.set("n", "", function() + local opts = require("telescope.themes").get_ivy({ + layout_config = { + bottom_pane = { + height = 10, + }, + }, + }) + require("telescope").extensions.projects.projects(opts) +end) + +-- File browser +require("telescope").load_extension("file_browser") +vim.keymap.set("n", "fa", require("telescope").extensions.file_browser.file_browser) +vim.keymap.set("n", "fD", function() + local opts = { + prompt_title = "Find Downloads", + cwd = "~/downloads", + } + require("telescope").extensions.file_browser.file_browser(opts) +end) diff --git a/modules/common/neovim/config/telescope.nix b/modules/common/neovim/config/telescope.nix new file mode 100644 index 0000000..1bd5b5c --- /dev/null +++ b/modules/common/neovim/config/telescope.nix @@ -0,0 +1,35 @@ +{ pkgs, dsl, ... }: { + + plugins = [ + pkgs.vimPlugins.telescope-nvim + pkgs.vimPlugins.project-nvim + pkgs.vimPlugins.telescope-fzy-native-nvim + pkgs.vimPlugins.telescope-file-browser-nvim + pkgs.vimPlugins.telescope-zoxide + ]; + + setup.telescope = { + defaults = { + mappings = { + i = { + "['']" = dsl.rawLua "require('telescope.actions').close"; + "['']" = "which_key"; + }; + }; + }; + pickers = { + find_files = { theme = "ivy"; }; + oldfiles = { theme = "ivy"; }; + buffers = { theme = "dropdown"; }; + }; + extensions = { + fzy_native = { }; + zoxide = { }; + }; + }; + + setup.project_nvim = { }; + + lua = builtins.readFile ./telescope.lua; + +} diff --git a/modules/common/neovim/config/toggleterm.lua b/modules/common/neovim/config/toggleterm.lua new file mode 100644 index 0000000..7499132 --- /dev/null +++ b/modules/common/neovim/config/toggleterm.lua @@ -0,0 +1,40 @@ +vim.keymap.set("t", "", "") --- Exit terminal mode + +-- Only set these keymaps for toggleterm +vim.api.nvim_create_autocmd("TermOpen", { + pattern = "term://*toggleterm#*", + callback = function() + -- vim.keymap.set("t", "", "") --- Exit terminal mode + vim.keymap.set("t", "", "h") + vim.keymap.set("t", "", "j") + vim.keymap.set("t", "", "k") + vim.keymap.set("t", "", "l") + end, +}) + +local terminal = require("toggleterm.terminal").Terminal + +local basicterminal = terminal:new() +function TERM_TOGGLE() + basicterminal:toggle() +end + +local nixpkgs = terminal:new({ cmd = "nix repl ''" }) +function NIXPKGS_TOGGLE() + nixpkgs:toggle() +end + +local gitwatch = terminal:new({ cmd = "fish --interactive --init-command 'gh run watch'" }) +function GITWATCH_TOGGLE() + gitwatch:toggle() +end + +local k9s = terminal:new({ cmd = "k9s" }) +function K9S_TOGGLE() + k9s:toggle() +end + +vim.keymap.set("n", "t", TERM_TOGGLE) +vim.keymap.set("n", "P", NIXPKGS_TOGGLE) +vim.keymap.set("n", "gw", GITWATCH_TOGGLE) +vim.keymap.set("n", "9", K9S_TOGGLE) diff --git a/modules/common/neovim/config/toggleterm.nix b/modules/common/neovim/config/toggleterm.nix new file mode 100644 index 0000000..ee67302 --- /dev/null +++ b/modules/common/neovim/config/toggleterm.nix @@ -0,0 +1,13 @@ +{ pkgs, dsl, ... }: { + + plugins = [ pkgs.vimPlugins.toggleterm-nvim ]; + + use.toggleterm.setup = dsl.callWith { + open_mapping = dsl.rawLua "[[]]"; + hide_numbers = true; + direction = "float"; + }; + + lua = builtins.readFile ./toggleterm.lua; + +} diff --git a/modules/common/neovim/config/tree.nix b/modules/common/neovim/config/tree.nix new file mode 100644 index 0000000..60825c6 --- /dev/null +++ b/modules/common/neovim/config/tree.nix @@ -0,0 +1,74 @@ +{ pkgs, dsl, ... }: { + + plugins = [ pkgs.vimPlugins.nvim-tree-lua pkgs.vimPlugins.nvim-web-devicons ]; + + # Disable netrw eagerly + # https://github.com/kyazdani42/nvim-tree.lua/commit/fb8735e96cecf004fbefb086ce85371d003c5129 + vim.g = { + loaded = 1; + loaded_netrwPlugin = 1; + }; + + setup.nvim-tree = { + disable_netrw = true; + hijack_netrw = true; + sync_root_with_cwd = true; + respect_buf_cwd = true; + update_focused_file = { + enable = true; + update_root = true; + ignore_list = { }; + }; + diagnostics = { + enable = true; + icons = { + hint = ""; + info = ""; + warning = ""; + error = ""; + }; + }; + renderer = { + icons = { + glyphs = { + git = { + unstaged = "~"; + staged = "+"; + unmerged = ""; + renamed = "➜"; + deleted = ""; + untracked = "?"; + ignored = "◌"; + }; + }; + }; + }; + on_attach = dsl.rawLua '' + function (bufnr) + local api = require('nvim-tree.api') + local function opts(desc) + return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + api.config.mappings.default_on_attach(bufnr) + + vim.keymap.set('n', 'l', api.node.open.edit, opts('Open')) + vim.keymap.set('n', '', api.node.open.edit, opts('Open')) + vim.keymap.set('n', 'o', api.node.open.edit, opts('Open')) + vim.keymap.set('n', 'h', api.node.navigate.parent_close, opts('Close Directory')) + vim.keymap.set('n', 'v', api.node.open.vertical, opts('Open: Vertical Split')) + end + ''; + view = { + width = 30; + hide_root_folder = false; + side = "left"; + number = false; + relativenumber = false; + }; + }; + + lua = '' + vim.keymap.set("n", "e", ":NvimTreeFindFileToggle", { silent = true }) + ''; + +} diff --git a/modules/common/neovim/default.nix b/modules/common/neovim/default.nix new file mode 100644 index 0000000..c5d0825 --- /dev/null +++ b/modules/common/neovim/default.nix @@ -0,0 +1,53 @@ +{ config, pkgs, lib, ... }: + +let + + neovim = import ./package { + inherit pkgs; + colors = config.theme.colors; + }; + +in { + + options.neovim.enable = lib.mkEnableOption "Neovim."; + + config = lib.mkIf config.neovim.enable { + home-manager.users.${config.user} = + + { + + home.packages = [ neovim ]; + + programs.git.extraConfig.core.editor = "nvim"; + home.sessionVariables = { + EDITOR = "nvim"; + MANPAGER = "nvim +Man!"; + }; + programs.fish = { + shellAliases = { vim = "nvim"; }; + shellAbbrs = { + v = lib.mkForce "nvim"; + vl = lib.mkForce "nvim -c 'normal! `0' -c 'bdelete 1'"; + vll = "nvim -c 'Telescope oldfiles'"; + }; + }; + programs.kitty.settings.scrollback_pager = lib.mkForce '' + ${neovim}/bin/nvim -c 'setlocal nonumber nolist showtabline=0 foldcolumn=0|Man!' -c "autocmd VimEnter * normal G" -''; + + xdg.desktopEntries.nvim = lib.mkIf pkgs.stdenv.isLinux { + name = "Neovim wrapper"; + exec = "kitty nvim %F"; + }; + xdg.mimeApps.defaultApplications = lib.mkIf pkgs.stdenv.isLinux { + "text/plain" = [ "nvim.desktop" ]; + "text/markdown" = [ "nvim.desktop" ]; + }; + + }; + + # # Used for icons in Vim + # fonts.fonts = with pkgs; [ nerdfonts ]; + + }; + +} diff --git a/modules/neovim/lua/keybinds.lua b/modules/common/neovim/lua/keybinds.lua similarity index 82% rename from modules/neovim/lua/keybinds.lua rename to modules/common/neovim/lua/keybinds.lua index e405bd1..82f3cd5 100644 --- a/modules/neovim/lua/keybinds.lua +++ b/modules/common/neovim/lua/keybinds.lua @@ -48,11 +48,6 @@ key("n", "wv", ":vsplit") key("n", "wh", ":split") key("n", "wm", ":only") --- Vimrc editing -key("n", "rr", ":luafile $HOME/.config/nvim/init.lua") -key("n", "rp", ":luafile $HOME/.config/nvim/init.lua:PackerInstall:") -key("n", "rc", ":luafile $HOME/.config/nvim/init.lua:PackerCompile") - -- Keep cursor in place key("n", "n", "nzz") key("n", "N", "Nzz") @@ -71,8 +66,8 @@ key("n", "", ":vertical resize -2", { silent = true }) key("n", "", ":vertical resize +2", { silent = true }) -- Other -key("n", "", ":noh", { silent = true }) --- Clear search in VimWiki -key("n", "Y", "y$") --- Copy to end of line +key("n", "", ":noh", { silent = true }) --- Clear search in VimWiki +key("n", "Y", "y$") --- Copy to end of line key("v", "", "y:%s/+//gc") --- Substitute selected -key("v", "D", "y'>gp") --- Duplicate selected -key("x", "p", '"_dP') --- Paste but keep register +key("v", "D", "y'>gp") --- Duplicate selected +key("x", "p", '"_dP') --- Paste but keep register diff --git a/modules/common/neovim/lua/settings.lua b/modules/common/neovim/lua/settings.lua new file mode 100644 index 0000000..85a865d --- /dev/null +++ b/modules/common/neovim/lua/settings.lua @@ -0,0 +1,18 @@ +-- =========================================================================== +-- Settings +-- =========================================================================== + +vim.filetype.add({ + pattern = { + [".*%.tfvars"] = "hcl", + [".*%.tf"] = "hcl", + [".*%.rasi"] = "css", + }, +}) + +vim.api.nvim_create_autocmd("FileType", { + pattern = "*.eml", + callback = function() + vim.o.wrapmargin = 79 -- Wrap text automatically + end, +}) diff --git a/modules/common/neovim/package/default.nix b/modules/common/neovim/package/default.nix new file mode 100644 index 0000000..a444654 --- /dev/null +++ b/modules/common/neovim/package/default.nix @@ -0,0 +1,48 @@ +# { inputs, globals, extraConfig ? [ ], ... }: +# +# let +# +# pkgs = import inputs.nixpkgs { +# system = inputs.system; +# overlays = [ +# (import ./modules/neovim/plugins-overlay.nix inputs) +# inputs.nix2vim.overlay +# ]; +# }; +# +# in pkgs.neovimBuilder { +# package = pkgs.neovim-unwrapped; +# imports = [ +# ./modules/common/neovim/plugins/bufferline.nix +# ./modules/common/neovim/plugins/completion.nix +# ./modules/common/neovim/plugins/gitsigns.nix +# ./modules/common/neovim/plugins/lsp.nix +# ./modules/common/neovim/plugins/misc.nix +# ./modules/common/neovim/plugins/statusline.nix +# ./modules/common/neovim/plugins/syntax.nix +# ./modules/common/neovim/plugins/telescope.nix +# ./modules/common/neovim/plugins/toggleterm.nix +# ./modules/common/neovim/plugins/tree.nix +# ] ++ extraConfig; +# } + +{ pkgs, colors, ... }: + +pkgs.neovimBuilder { + package = pkgs.neovim-unwrapped; + inherit colors; + imports = [ + ../config/align.nix + ../config/bufferline.nix + ../config/colors.nix + ../config/completion.nix + ../config/gitsigns.nix + ../config/lsp.nix + ../config/misc.nix + ../config/statusline.nix + ../config/syntax.nix + ../config/telescope.nix + ../config/toggleterm.nix + ../config/tree.nix + ]; +} diff --git a/modules/common/programming/default.nix b/modules/common/programming/default.nix new file mode 100644 index 0000000..f8e9f5d --- /dev/null +++ b/modules/common/programming/default.nix @@ -0,0 +1,12 @@ +{ ... }: { + + imports = [ + ./haskell.nix + ./kubernetes.nix + ./lua.nix + ./nix.nix + ./python.nix + ./terraform.nix + ]; + +} diff --git a/modules/common/programming/haskell.nix b/modules/common/programming/haskell.nix new file mode 100644 index 0000000..203a7c0 --- /dev/null +++ b/modules/common/programming/haskell.nix @@ -0,0 +1,14 @@ +{ config, lib, ... }: { + + options.haskell.enable = lib.mkEnableOption "Haskell programming language."; + + config = lib.mkIf config.haskell.enable { + + # 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://cache.iog.io" ]; + + }; + +} diff --git a/modules/common/programming/kubernetes.nix b/modules/common/programming/kubernetes.nix new file mode 100644 index 0000000..8864b8b --- /dev/null +++ b/modules/common/programming/kubernetes.nix @@ -0,0 +1,145 @@ +{ config, pkgs, lib, ... }: { + + options.kubernetes.enable = lib.mkEnableOption "Kubernetes tools."; + + config = lib.mkIf config.kubernetes.enable { + home-manager.users.${config.user} = { + + home.packages = with pkgs; [ + kubectl # Basic Kubernetes queries + kubernetes-helm # Helm CLI + fluxcd # Bootstrap clusters with Flux + kustomize # Kustomize CLI (for Flux) + ]; + + programs.fish.shellAbbrs = { + k = "kubectl"; + pods = "kubectl get pods -A"; + nodes = "kubectl get nodes"; + deploys = "kubectl get deployments -A"; + dash = "kube-dashboard"; + ks = "k9s"; + }; + + # Terminal Kubernetes UI + programs.k9s = { + enable = true; + # settings = { k9s = { headless = true; }; }; + skin = { + k9s = { + body = { + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base00; + logoColor = config.theme.colors.base02; # *blue ? + }; + # Search bar + prompt = { + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base00; + suggestColor = config.theme.colors.base03; + }; + # Header left side + info = { + fgColor = config.theme.colors.base04; + sectionColor = config.theme.colors.base05; + }; + dialog = { + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base00; + buttonFgColor = config.theme.colors.base06; + buttonBgColor = config.theme.colors.base0E; + buttonFocusFgColor = config.theme.colors.base07; + buttonFocusBgColor = config.theme.colors.base02; # *cyan + labelFgColor = config.theme.colors.base09; + fieldFgColor = config.theme.colors.base06; + }; + frame = { + border = { + fgColor = config.theme.colors.base01; + focusColor = config.theme.colors.base06; + }; + menu = { + fgColor = config.theme.colors.base06; + keyColor = config.theme.colors.base0E; # *magenta + numKeyColor = config.theme.colors.base0E; # *magenta + }; + crumbs = { + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base01; + activeColor = config.theme.colors.base03; + }; + status = { + newColor = config.theme.colors.base04; # *cyan + modifyColor = config.theme.colors.base0D; # *blue + addColor = config.theme.colors.base0B; # *green + errorColor = config.theme.colors.base08; # *red + highlightColor = config.theme.colors.base09; # *orange + killColor = config.theme.colors.base03; # *comment + completedColor = config.theme.colors.base03; # *comment + }; + title = { + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base00; + highlightColor = config.theme.colors.base09; # *orange + counterColor = config.theme.colors.base0D; # *blue + filterColor = config.theme.colors.base0E; # *magenta + }; + }; + views = { + charts = { + bgColor = config.theme.colors.base00; + defaultDialColors = + [ config.theme.colors.base0D config.theme.colors.base08 ]; + # - *blue + # - *red + defaultChartColors = + [ config.theme.colors.base0D config.theme.colors.base08 ]; + # - *blue + # - *red + }; + table = { + # List of resources + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base00; + + # Row selection + cursorFgColor = config.theme.colors.base07; + cursorBgColor = config.theme.colors.base01; + + # Header row + header = { + fgColor = config.theme.colors.base0D; + bgColor = config.theme.colors.base00; + sorterColor = config.theme.colors.base0A; # *selection + }; + }; + xray = { + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base00; + cursorColor = config.theme.colors.base06; + graphicColor = config.theme.colors.base0D; + showIcons = false; + }; + yaml = { + keyColor = config.theme.colors.base0D; + colonColor = config.theme.colors.base04; + fgColor = config.theme.colors.base03; + }; + logs = { + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base00; + indicator = { + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base00; + }; + }; + }; + }; + }; + }; + + }; + + }; + +} diff --git a/modules/common/programming/lua.nix b/modules/common/programming/lua.nix new file mode 100644 index 0000000..127623d --- /dev/null +++ b/modules/common/programming/lua.nix @@ -0,0 +1,12 @@ +{ config, pkgs, lib, ... }: { + + options.lua.enable = lib.mkEnableOption "Lua programming language."; + + config = lib.mkIf config.lua.enable { + home-manager.users.${config.user}.home.packages = with pkgs; [ + stylua # Lua formatter + sumneko-lua-language-server # Lua LSP + ]; + }; + +} diff --git a/modules/common/programming/nix.nix b/modules/common/programming/nix.nix new file mode 100644 index 0000000..20a297d --- /dev/null +++ b/modules/common/programming/nix.nix @@ -0,0 +1,18 @@ +{ config, pkgs, lib, ... }: { + + options.nixlang.enable = lib.mkEnableOption "Nix programming language."; + + config = lib.mkIf config.nixlang.enable { + + home-manager.users.${config.user} = { + + home.packages = with pkgs; [ + nixfmt # Nix file formatter + nil # Nix language server + ]; + + }; + + }; + +} diff --git a/modules/common/programming/python.nix b/modules/common/programming/python.nix new file mode 100644 index 0000000..e3d435f --- /dev/null +++ b/modules/common/programming/python.nix @@ -0,0 +1,22 @@ +{ config, pkgs, lib, ... }: { + + options.python.enable = lib.mkEnableOption "Python programming language."; + + config = lib.mkIf config.python.enable { + + home-manager.users.${config.user} = { + + home.packages = with pkgs; [ + # python310 # Standard Python interpreter + nodePackages.pyright # Python language server + black # Python formatter + python310Packages.flake8 # Python linter + ]; + + programs.fish.shellAbbrs = { py = "python3"; }; + + }; + + }; + +} diff --git a/modules/common/programming/terraform.nix b/modules/common/programming/terraform.nix new file mode 100644 index 0000000..9a5f3e1 --- /dev/null +++ b/modules/common/programming/terraform.nix @@ -0,0 +1,22 @@ +{ config, pkgs, lib, ... }: { + + options.terraform.enable = lib.mkEnableOption "Terraform tools."; + + config = lib.mkIf config.terraform.enable { + + home-manager.users.${config.user} = { + programs.fish.shellAbbrs = { + # Terraform + te = "terraform"; + }; + home.packages = with pkgs; [ + terraform # Terraform executable + terraform-ls # Language server + tflint # Linter + ]; + + }; + + }; + +} diff --git a/modules/common/repositories/default.nix b/modules/common/repositories/default.nix new file mode 100644 index 0000000..f3cec00 --- /dev/null +++ b/modules/common/repositories/default.nix @@ -0,0 +1,5 @@ +{ ... }: { + + imports = [ ./dotfiles.nix ./notes.nix ]; + +} diff --git a/modules/common/repositories/dotfiles.nix b/modules/common/repositories/dotfiles.nix new file mode 100644 index 0000000..5f7ce27 --- /dev/null +++ b/modules/common/repositories/dotfiles.nix @@ -0,0 +1,36 @@ +{ config, pkgs, lib, ... }: { + + options.dotfiles.enable = lib.mkEnableOption "Clone dotfiles."; + + config = lib.mkIf config.dotfiles.enable { + + home-manager.users.${config.user} = { + + home.activation = { + + # Always clone dotfiles repository if it doesn't exist + cloneDotfiles = + config.home-manager.users.${config.user}.lib.dag.entryAfter + [ "writeBoundary" ] '' + if [ ! -d "${config.dotfilesPath}" ]; then + $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG $(dirname "${config.dotfilesPath}") + + # Force HTTPS because anonymous SSH doesn't work + GIT_CONFIG_COUNT=1 \ + GIT_CONFIG_KEY_0="url.https://github.com/.insteadOf" \ + GIT_CONFIG_VALUE_0="git@github.com:" \ + $DRY_RUN_CMD \ + ${pkgs.git}/bin/git clone ${config.dotfilesRepo} "${config.dotfilesPath}" + fi + ''; + + }; + + # Set a variable for dotfiles repo, not necessary but convenient + home.sessionVariables.DOTS = config.dotfilesPath; + + }; + + }; + +} diff --git a/modules/repositories/notes.nix b/modules/common/repositories/notes.nix similarity index 61% rename from modules/repositories/notes.nix rename to modules/common/repositories/notes.nix index c357723..47e521b 100644 --- a/modules/repositories/notes.nix +++ b/modules/common/repositories/notes.nix @@ -3,7 +3,7 @@ home-manager.users.${config.user} = { home.sessionVariables = { - NOTES_PATH = "${config.homePath}/dev/personal/notes"; + NOTES_PATH = "${config.homePath}/dev/personal/notes/content"; }; }; diff --git a/modules/common/shell/bash/default.nix b/modules/common/shell/bash/default.nix new file mode 100644 index 0000000..06a8367 --- /dev/null +++ b/modules/common/shell/bash/default.nix @@ -0,0 +1,20 @@ +{ config, pkgs, lib, ... }: { + + config = { + home-manager.users.${config.user} = { + + programs.bash = { + enable = true; + shellAliases = + config.home-manager.users.${config.user}.programs.fish.shellAliases; + initExtra = ""; + profileExtra = ""; + }; + + programs.starship.enableBashIntegration = false; + programs.zoxide.enableBashIntegration = true; + programs.fzf.enableBashIntegration = true; + + }; + }; +} diff --git a/modules/shell/bash/scripts/ocr.sh b/modules/common/shell/bash/scripts/ocr.sh similarity index 89% rename from modules/shell/bash/scripts/ocr.sh rename to modules/common/shell/bash/scripts/ocr.sh index 1a6b0c7..313a069 100755 --- a/modules/shell/bash/scripts/ocr.sh +++ b/modules/common/shell/bash/scripts/ocr.sh @@ -1,5 +1,4 @@ -#!/usr/bin/env nix-shell -#!nix-shell -i bash -p tesseract +#!/usr/bin/env bash # Yoinked from https://github.com/JJGO/dotfiles # Adapted from https://github.com/sdushantha/bin @@ -9,13 +8,13 @@ TEXT_FILE="/tmp/ocr.txt" IMAGE_FILE="/tmp/ocr.png" function notify-send() { - osascript -e "display notification \"$2\" with title \"OCR\"" + /usr/bin/osascript -e "display notification \"$2\" with title \"OCR\"" } PATH="/usr/local/bin/:$PATH" # Take screenshot by selecting the area -screencapture -i "$IMAGE_FILE" +/usr/sbin/screencapture -i "$IMAGE_FILE" # Get the exit code of the previous command. # So in this case, it is the screenshot command. If it did not exit with an @@ -44,7 +43,7 @@ fi # Copy text to clipboard # xclip -selection clip < "$TEXT_FILE" -pbcopy <"$TEXT_FILE" +/usr/bin/pbcopy <"$TEXT_FILE" # Send a notification with the text that was grabbed using OCR notify-send "ocr" "$(cat $TEXT_FILE)" diff --git a/modules/common/shell/charm.nix b/modules/common/shell/charm.nix new file mode 100644 index 0000000..b2972cf --- /dev/null +++ b/modules/common/shell/charm.nix @@ -0,0 +1,15 @@ +{ config, pkgs, lib, ... }: { + + options.charm.enable = lib.mkEnableOption "Charm utilities."; + + config.home-manager.users.${config.user} = lib.mkIf config.charm.enable { + + home.packages = with pkgs; [ + glow # Markdown previews + skate # Key-value store + charm # Manage account and filesystem + ]; + + }; + +} diff --git a/modules/shell/default.nix b/modules/common/shell/default.nix similarity index 92% rename from modules/shell/default.nix rename to modules/common/shell/default.nix index ac60e9b..82af041 100644 --- a/modules/shell/default.nix +++ b/modules/common/shell/default.nix @@ -1,6 +1,6 @@ { ... }: { imports = [ - ./age.nix + ./bash ./charm.nix ./direnv.nix ./fish diff --git a/modules/shell/direnv.nix b/modules/common/shell/direnv.nix similarity index 63% rename from modules/shell/direnv.nix rename to modules/common/shell/direnv.nix index 90d06ea..b5f5165 100644 --- a/modules/shell/direnv.nix +++ b/modules/common/shell/direnv.nix @@ -6,4 +6,10 @@ config = { whitelist = { prefix = [ config.dotfilesPath ]; }; }; }; + # Prevent garbage collection + nix.extraOptions = '' + keep-outputs = true + keep-derivations = true + ''; + } diff --git a/modules/shell/fish/default.nix b/modules/common/shell/fish/default.nix similarity index 93% rename from modules/shell/fish/default.nix rename to modules/common/shell/fish/default.nix index d4dd300..7b3e9c2 100644 --- a/modules/shell/fish/default.nix +++ b/modules/common/shell/fish/default.nix @@ -7,10 +7,15 @@ home-manager.users.${config.user} = { # Packages used in abbreviations and aliases - home.packages = with pkgs; [ curl ]; + home.packages = with pkgs; [ curl exa ]; programs.fish = { enable = true; + shellAliases = { + bash = "${pkgs.bashInteractive}/bin/bash"; + ls = "exa"; + trash = lib.mkIf pkgs.stdenv.isLinux "${pkgs.trash-cli}/bin/trash-put"; + }; functions = { commandline-git-commits = { description = "Insert commit into commandline"; @@ -41,7 +46,6 @@ description = "Tidy up JSON using jq"; body = "pbpaste | jq '.' | pbcopy"; # Need to fix for non-macOS }; - ls = { body = "${pkgs.exa}/bin/exa $argv"; }; note = { description = "Edit or create a note"; argumentNames = "filename"; @@ -73,7 +77,6 @@ set -g fish_cursor_replace_one underscore ''; loginShellInit = ""; - shellAliases = { }; shellAbbrs = { # Directory aliases @@ -90,6 +93,7 @@ sc = "systemctl"; scs = "systemctl status"; m = "make"; + t = "trash"; # Vim (overwritten by Neovim) v = "vim"; diff --git a/modules/shell/fish/functions/commandline-git-commits.fish b/modules/common/shell/fish/functions/commandline-git-commits.fish similarity index 100% rename from modules/shell/fish/functions/commandline-git-commits.fish rename to modules/common/shell/fish/functions/commandline-git-commits.fish diff --git a/modules/shell/fish/functions/edit.fish b/modules/common/shell/fish/functions/edit.fish similarity index 100% rename from modules/shell/fish/functions/edit.fish rename to modules/common/shell/fish/functions/edit.fish diff --git a/modules/shell/fish/functions/fcd.fish b/modules/common/shell/fish/functions/fcd.fish similarity index 100% rename from modules/shell/fish/functions/fcd.fish rename to modules/common/shell/fish/functions/fcd.fish diff --git a/modules/shell/fish/functions/fish_user_key_bindings.fish b/modules/common/shell/fish/functions/fish_user_key_bindings.fish similarity index 81% rename from modules/shell/fish/functions/fish_user_key_bindings.fish rename to modules/common/shell/fish/functions/fish_user_key_bindings.fish index 04a2915..4c1e991 100644 --- a/modules/shell/fish/functions/fish_user_key_bindings.fish +++ b/modules/common/shell/fish/functions/fish_user_key_bindings.fish @@ -14,7 +14,7 @@ bind -M insert \cp projects bind -M default \cp projects bind -M insert \x1F accept-autosuggestion bind -M default \x1F accept-autosuggestion -bind -M insert \cn 'commandline -r "nix run github:NixOS/nixpkgs/nixpkgs-unstable#"' -bind -M default \cn 'commandline -r "nix run github:NixOS/nixpkgs/nixpkgs-unstable#"' +bind -M insert \cn 'commandline -r "nix run nixpkgs#"' +bind -M default \cn 'commandline -r "nix run nixpkgs#"' bind -M insert \x11F nix-fzf bind -M default \x11F nix-fzf diff --git a/modules/shell/fish/functions/fish_vi_cursor.fish b/modules/common/shell/fish/functions/fish_vi_cursor.fish similarity index 100% rename from modules/shell/fish/functions/fish_vi_cursor.fish rename to modules/common/shell/fish/functions/fish_vi_cursor.fish diff --git a/modules/shell/fish/functions/git-add-fuzzy.fish b/modules/common/shell/fish/functions/git-add-fuzzy.fish similarity index 100% rename from modules/shell/fish/functions/git-add-fuzzy.fish rename to modules/common/shell/fish/functions/git-add-fuzzy.fish diff --git a/modules/shell/fish/functions/git-commits.fish b/modules/common/shell/fish/functions/git-commits.fish similarity index 100% rename from modules/shell/fish/functions/git-commits.fish rename to modules/common/shell/fish/functions/git-commits.fish diff --git a/modules/shell/fish/functions/git-fuzzy-branch.fish b/modules/common/shell/fish/functions/git-fuzzy-branch.fish similarity index 100% rename from modules/shell/fish/functions/git-fuzzy-branch.fish rename to modules/common/shell/fish/functions/git-fuzzy-branch.fish diff --git a/modules/shell/fish/functions/git-history.fish b/modules/common/shell/fish/functions/git-history.fish similarity index 100% rename from modules/shell/fish/functions/git-history.fish rename to modules/common/shell/fish/functions/git-history.fish diff --git a/modules/shell/fish/functions/git-show-fuzzy.fish b/modules/common/shell/fish/functions/git-show-fuzzy.fish similarity index 100% rename from modules/shell/fish/functions/git-show-fuzzy.fish rename to modules/common/shell/fish/functions/git-show-fuzzy.fish diff --git a/modules/shell/fish/functions/git.fish b/modules/common/shell/fish/functions/git.fish similarity index 100% rename from modules/shell/fish/functions/git.fish rename to modules/common/shell/fish/functions/git.fish diff --git a/modules/shell/fish/functions/ip.fish b/modules/common/shell/fish/functions/ip.fish similarity index 100% rename from modules/shell/fish/functions/ip.fish rename to modules/common/shell/fish/functions/ip.fish diff --git a/modules/shell/fish/functions/note.fish b/modules/common/shell/fish/functions/note.fish similarity index 100% rename from modules/shell/fish/functions/note.fish rename to modules/common/shell/fish/functions/note.fish diff --git a/modules/shell/fish/functions/recent.fish b/modules/common/shell/fish/functions/recent.fish similarity index 100% rename from modules/shell/fish/functions/recent.fish rename to modules/common/shell/fish/functions/recent.fish diff --git a/modules/shell/fish/functions/search-and-edit.fish b/modules/common/shell/fish/functions/search-and-edit.fish similarity index 100% rename from modules/shell/fish/functions/search-and-edit.fish rename to modules/common/shell/fish/functions/search-and-edit.fish diff --git a/modules/shell/fish/functions/syncnotes.fish b/modules/common/shell/fish/functions/syncnotes.fish similarity index 100% rename from modules/shell/fish/functions/syncnotes.fish rename to modules/common/shell/fish/functions/syncnotes.fish diff --git a/modules/shell/fish/functions/uncommitted.fish b/modules/common/shell/fish/functions/uncommitted.fish similarity index 100% rename from modules/shell/fish/functions/uncommitted.fish rename to modules/common/shell/fish/functions/uncommitted.fish diff --git a/modules/shell/fzf.nix b/modules/common/shell/fzf.nix similarity index 90% rename from modules/shell/fzf.nix rename to modules/common/shell/fzf.nix index 9f21f47..1f9819b 100644 --- a/modules/shell/fzf.nix +++ b/modules/common/shell/fzf.nix @@ -13,9 +13,8 @@ fd \ --search-path $HOME/dev \ --type directory \ - --hidden \ - "^.git\$" \ - | xargs dirname \ + --exact-depth 2 \ + | sed 's/\\/$//' \ | fzf \ --delimiter '/' \ --with-nth 6.. \ diff --git a/modules/shell/git.nix b/modules/common/shell/git.nix similarity index 94% rename from modules/shell/git.nix rename to modules/common/shell/git.nix index 4b402c3..9502c3c 100644 --- a/modules/shell/git.nix +++ b/modules/common/shell/git.nix @@ -31,6 +31,7 @@ in { pager = { branch = "false"; }; safe = { directory = config.dotfilesPath; }; pull = { ff = "only"; }; + push = { autoSetupRemote = "true"; }; init = { defaultBranch = "master"; }; }; ignores = [ ".direnv/**" "result" ]; @@ -50,7 +51,6 @@ in { gcae = "git commit --amend"; gu = "git pull"; gp = "git push"; - gpp = "git-push-upstream"; gl = "git log --graph --decorate --oneline -20"; gll = "git log --graph --decorate --oneline"; gco = "git checkout"; @@ -113,10 +113,6 @@ in { git-history = { body = builtins.readFile ./fish/functions/git-history.fish; }; - git-push-upstream = { - description = "Create upstream branch"; - body = builtins.readFile ./fish/functions/git-push-upstream.fish; - }; uncommitted = { description = "Find uncommitted git repos"; body = builtins.readFile ./fish/functions/uncommitted.fish; diff --git a/modules/shell/github.nix b/modules/common/shell/github.nix similarity index 95% rename from modules/shell/github.nix rename to modules/common/shell/github.nix index 4487f6f..dbf5267 100644 --- a/modules/shell/github.nix +++ b/modules/common/shell/github.nix @@ -19,6 +19,9 @@ grf = "gh run view --log-failed"; grl = "gh run view --log"; ghpr = "gh pr create && sleep 3 && gh run watch"; + + # https://github.com/cli/cli/discussions/4067 + prs = "gh search prs --state=open --review-requested=@me"; }; functions = { repos = { diff --git a/modules/shell/nixpkgs.nix b/modules/common/shell/nixpkgs.nix similarity index 70% rename from modules/shell/nixpkgs.nix rename to modules/common/shell/nixpkgs.nix index bb2096f..cb8262d 100644 --- a/modules/shell/nixpkgs.nix +++ b/modules/common/shell/nixpkgs.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, ... }: { +{ config, pkgs, ... }: { home-manager.users.${config.user} = { programs.fish = { @@ -12,15 +12,16 @@ nixh = "man home-configuration.nix"; nr = "rebuild-nixos"; nro = "rebuild-nixos offline"; + hm = "rebuild-home"; }; functions = { nix-shell-run = { body = '' set program $argv[1] if test (count $argv) -ge 2 - commandline -r "nix run github:NixOS/nixpkgs/nixpkgs-unstable#$program -- $argv[2..-1]" + commandline -r "nix run nixpkgs#$program -- $argv[2..-1]" else - commandline -r "nix run github:NixOS/nixpkgs/nixpkgs-unstable#$program" + commandline -r "nix run nixpkgs#$program" end commandline -f execute ''; @@ -43,6 +44,13 @@ commandline --function execute ''; }; + rebuild-home = { + body = '' + git -C ${config.dotfilesPath} add --intent-to-add --all + commandline -r "${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#${config.networking.hostName}"; + commandline --function execute + ''; + }; }; }; @@ -59,6 +67,12 @@ # Set channel to flake packages, used for nix-shell commands nixPath = [ "nixpkgs=${pkgs.path}" ]; + # Set registry to this flake's packages, used for nix X commands + registry.nixpkgs.to = { + type = "path"; + path = builtins.toString pkgs.path; + }; + }; } diff --git a/modules/shell/starship.nix b/modules/common/shell/starship.nix similarity index 86% rename from modules/shell/starship.nix rename to modules/common/shell/starship.nix index 3e9443c..0b34535 100644 --- a/modules/shell/starship.nix +++ b/modules/common/shell/starship.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: { +{ config, pkgs, lib, ... }: { home-manager.users.${config.user}.programs.starship = { enable = true; @@ -9,6 +9,7 @@ "$git_branch" "$git_commit" "$git_status" + "$hostname" "$cmd_duration" "$character" ]; @@ -20,7 +21,7 @@ }; cmd_duration = { min_time = 5000; - show_notifications = true; + show_notifications = if pkgs.stdenv.isLinux then false else true; min_time_to_notify = 30000; format = "[$duration]($style) "; }; @@ -47,6 +48,10 @@ deleted = "✘"; style = "red"; }; + hostname = { + ssh_only = true; + format = "on [$hostname](bold red) "; + }; nix_shell = { format = "[$symbol $name]($style)"; symbol = "❄️"; diff --git a/modules/common/shell/utilities.nix b/modules/common/shell/utilities.nix new file mode 100644 index 0000000..2d8e3e8 --- /dev/null +++ b/modules/common/shell/utilities.nix @@ -0,0 +1,71 @@ +{ config, pkgs, ... }: + +let + + ignorePatterns = '' + !.env* + !.github/ + !.gitignore + !*.tfvars + .terraform/ + .target/ + /Library/''; + +in { + + config = { + + home-manager.users.${config.user} = { + + home.packages = with pkgs; [ + age # Encryption + bc # Calculator + dig # DNS lookup + fd # find + htop # Show system processes + inetutils # Includes telnet, whois + jq # JSON manipulation + lf # File viewer + qrencode # Generate qr codes + rsync # Copy folders + ripgrep # grep + sd # sed + tealdeer # Cheatsheets + tree # View directory hierarchy + vimv-rs # Batch rename files + unzip # Extract zips + ]; + + programs.zoxide.enable = true; # Shortcut jump command + + home.file = { + ".rgignore".text = ignorePatterns; + ".fdignore".text = ignorePatterns; + ".digrc".text = "+noall +answer"; # Cleaner dig commands + }; + + programs.bat = { + enable = true; # cat replacement + config = { + theme = config.theme.colors.batTheme; + pager = "less -R"; # Don't auto-exit if one screen + }; + }; + + programs.fish.shellAbbrs = { + cat = "bat"; # Swap cat with bat + }; + + programs.fish.functions = { + ping = { + description = "Improved ping"; + argumentNames = "target"; + body = "${pkgs.prettyping}/bin/prettyping --nolegend $target"; + }; + }; + + }; + + }; + +} diff --git a/modules/darwin/alacritty.nix b/modules/darwin/alacritty.nix index 2100727..0dcab47 100644 --- a/modules/darwin/alacritty.nix +++ b/modules/darwin/alacritty.nix @@ -1,7 +1,7 @@ { config, pkgs, lib, ... }: { # MacOS-specific settings for Alacritty - home-manager.users.${config.user} = { + home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin { programs.alacritty.settings = { font.size = lib.mkForce 20.0; shell.program = "${pkgs.fish}/bin/fish"; diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix index dce21ae..04e385b 100644 --- a/modules/darwin/default.nix +++ b/modules/darwin/default.nix @@ -1,10 +1,12 @@ -{ config, ... }: { +{ ... }: { imports = [ ./alacritty.nix + ./fish.nix ./fonts.nix ./hammerspoon.nix ./homebrew.nix + ./kitty.nix ./networking.nix ./nixpkgs.nix ./system.nix diff --git a/modules/darwin/fish.nix b/modules/darwin/fish.nix new file mode 100644 index 0000000..139568b --- /dev/null +++ b/modules/darwin/fish.nix @@ -0,0 +1,11 @@ +{ pkgs, ... }: { + + config = { + + # MacOS-specific settings for Fish + programs.fish.useBabelfish = true; + programs.fish.babelfishPackage = pkgs.babelfish; + + }; + +} diff --git a/modules/darwin/fonts.nix b/modules/darwin/fonts.nix index 20ea0dc..1edf526 100644 --- a/modules/darwin/fonts.nix +++ b/modules/darwin/fonts.nix @@ -1,12 +1,15 @@ -{ config, pkgs, ... }: { +{ config, pkgs, lib, ... }: { - home-manager.users.${config.user} = { + home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin { home.packages = with pkgs; - [ (nerdfonts.override { fonts = [ "FiraCode" ]; }) ]; + [ (nerdfonts.override { fonts = [ "VictorMono" ]; }) ]; - programs.alacritty.settings = { - font.normal.family = "FiraCode Nerd Font Mono"; + programs.alacritty.settings = { font.normal.family = "VictorMono"; }; + + programs.kitty.font = { + package = (pkgs.nerdfonts.override { fonts = [ "VictorMono" ]; }); + name = "VictorMono Nerd Font Mono"; }; }; diff --git a/modules/darwin/hammerspoon.nix b/modules/darwin/hammerspoon.nix index e0261cb..d4f5f87 100644 --- a/modules/darwin/hammerspoon.nix +++ b/modules/darwin/hammerspoon.nix @@ -1,15 +1,33 @@ -{ config, ... }: { +{ config, pkgs, lib, ... }: { # Hammerspoon - MacOS custom automation scripting - home-manager.users.${config.user} = { - xdg.configFile.hammerspoon = { source = ./hammerspoon; }; + config = lib.mkIf pkgs.stdenv.isDarwin { + + home-manager.users.${config.user} = { + xdg.configFile."hammerspoon/init.lua".source = ./hammerspoon/init.lua; + xdg.configFile."hammerspoon/Spoons/ControlEscape.spoon".source = + ./hammerspoon/Spoons/ControlEscape.spoon; + xdg.configFile."hammerspoon/Spoons/DismissAlerts.spoon".source = + ./hammerspoon/Spoons/DismissAlerts.spoon; + xdg.configFile."hammerspoon/Spoons/Launcher.spoon/init.lua".source = + pkgs.substituteAll { + src = ./hammerspoon/Spoons/Launcher.spoon/init.lua; + firefox = "${pkgs.firefox-bin}/Applications/Firefox.app"; + discord = "${pkgs.discord}/Applications/Discord.app"; + kitty = "${pkgs.kitty}/Applications/kitty.app"; + slack = "${pkgs.slack}/Applications/Slack.app"; + }; + xdg.configFile."hammerspoon/Spoons/MoveWindow.spoon".source = + ./hammerspoon/Spoons/MoveWindow.spoon; + }; + + homebrew.casks = [ "hammerspoon" ]; + + system.activationScripts.postUserActivation.text = '' + defaults write org.hammerspoon.Hammerspoon MJConfigFile "~/.config/hammerspoon/init.lua" + ''; + }; - homebrew.casks = [ "hammerspoon" ]; - - system.activationScripts.postUserActivation.text = '' - defaults write org.hammerspoon.Hammerspoon MJConfigFile "~/.config/hammerspoon/init.lua" - ''; - } diff --git a/modules/darwin/hammerspoon/Spoons/ControlEscape.spoon/init.lua b/modules/darwin/hammerspoon/Spoons/ControlEscape.spoon/init.lua index 7b4d676..df6c769 100644 --- a/modules/darwin/hammerspoon/Spoons/ControlEscape.spoon/init.lua +++ b/modules/darwin/hammerspoon/Spoons/ControlEscape.spoon/init.lua @@ -69,7 +69,7 @@ function obj:init() -- If any other key is pressed, don't send escape self.asModifier = hs.eventtap.new({ hs.eventtap.event.types.keyDown }, function(_) self.sendEscape = false - print("Don't sent escape") + -- print("Don't sent escape") end) -- If mouse is moving significantly, don't send escape diff --git a/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/close_notifications.applescript b/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/close_notifications.applescript new file mode 100644 index 0000000..a5ec015 --- /dev/null +++ b/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/close_notifications.applescript @@ -0,0 +1,21 @@ +# Credit: https://github.com/Ptujec/LaunchBar/blob/f7b5a0dba9919c2fec879513f68a044f78748539/Notifications/Dismiss%20all%20notifications.lbaction/Contents/Scripts/default.applescript + +tell application "System Events" + try + set _groups to groups of UI element 1 of scroll area 1 of group 1 of window "Notification Center" of application process "NotificationCenter" + + repeat with _group in _groups + + set _actions to actions of _group + + repeat with _action in _actions + if description of _action is in {"Schlie§en", "Alle entfernen", "Close", "Clear All"} then + perform _action + + end if + end repeat + + end repeat + + end try +end tell diff --git a/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/init.lua b/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/init.lua index f6a7aba..74ba8b9 100644 --- a/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/init.lua +++ b/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/init.lua @@ -10,7 +10,7 @@ obj.license = "MIT - https://opensource.org/licenses/MIT" function obj:init() hs.hotkey.bind({ "cmd", "alt", "ctrl" }, "k", function() - hs.osascript.javascriptFromFile("Spoons/DismissAlerts.spoon/close_notifications_applescript.js") + hs.osascript.applescriptFromFile("Spoons/DismissAlerts.spoon/close_notifications.applescript") end) end diff --git a/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua b/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua index fa27215..99e708f 100644 --- a/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua +++ b/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua @@ -8,44 +8,44 @@ obj.name = "Launcher" obj.version = "0.1" obj.license = "MIT - https://opensource.org/licenses/MIT" -function DrawSwitcher() - -- Drawing - local width = hs.screen.mainScreen():fullFrame().w - local switcherWidth = 500 - local canv = hs.canvas.new({ - x = width / 2 - switcherWidth / 2, - y = 1, - h = 3, - w = switcherWidth, - }) - canv[#canv + 1] = { - action = "build", - type = "rectangle", - } - canv[#canv + 1] = { - type = "rectangle", - fillColor = { alpha = 1, red = 0.8, green = 0.6, blue = 0.3 }, - action = "fill", - } - return canv:show() -end +local width = hs.screen.mainScreen():fullFrame().w +local switcherWidth = 500 +obj.canvas = hs.canvas.new({ + x = width / 2 - switcherWidth / 2, + y = 1, + h = 3, + w = switcherWidth, +}) +-- Draw switcher +obj.canvas[#obj.canvas + 1] = { + action = "build", + type = "rectangle", +} +obj.canvas[#obj.canvas + 1] = { + type = "rectangle", + fillColor = { alpha = 1, red = 0.8, green = 0.6, blue = 0.3 }, + action = "fill", +} function obj:init() -- Begin launcher mode if self.launcher == nil then self.launcher = hs.hotkey.modal.new("ctrl", "space") + + print(self.canvas) + print(obj.canvas) end -- Behaviors on enter function self.launcher:entered() -- hs.alert("Entered mode") - self.canv = DrawSwitcher() + obj.canvas:show() end -- Behaviors on exit function self.launcher:exited() -- hs.alert("Exited mode") - self.canv:hide() + obj.canvas:hide() end -- Use escape to exit launcher mode @@ -54,31 +54,23 @@ function obj:init() end) -- Launcher shortcuts - self.launcher:bind("ctrl", "space", function() end) + self.launcher:bind("ctrl", "space", function() + end) self.launcher:bind("", "return", function() - self:switch("Alacritty.app") + self:switch("@kitty@") end) self.launcher:bind("", "C", function() self:switch("Calendar.app") end) - self.launcher:bind("", "D", function() - self:switch("Discord.app") - end) self.launcher:bind("", "E", function() self:switch("Mail.app") end) - self.launcher:bind("", "U", function() - self:switch("Music.app") - end) self.launcher:bind("", "F", function() - self:switch("Firefox.app") + self:switch("@firefox@") end) self.launcher:bind("", "H", function() self:switch("Hammerspoon.app") end) - self.launcher:bind("", "G", function() - self:switch("Mimestream.app") - end) self.launcher:bind("", "M", function() self:switch("Messages.app") end) @@ -89,10 +81,11 @@ function obj:init() self:switch("System Preferences.app") end) self.launcher:bind("", "R", function() + hs.console.clearConsole() hs.reload() end) self.launcher:bind("", "S", function() - self:switch("Slack.app") + self:switch("@slack@") end) self.launcher:bind("", "Z", function() self:switch("zoom.us.app") diff --git a/modules/darwin/hammerspoon/Spoons/MoveWindow.spoon/init.lua b/modules/darwin/hammerspoon/Spoons/MoveWindow.spoon/init.lua index 57915c8..50a1f31 100644 --- a/modules/darwin/hammerspoon/Spoons/MoveWindow.spoon/init.lua +++ b/modules/darwin/hammerspoon/Spoons/MoveWindow.spoon/init.lua @@ -29,6 +29,7 @@ function obj:init() win:moveToScreen(screen:previous(), true, true, 0) end) + -- Maximize hs.hotkey.bind({ "alt", "ctrl", "cmd" }, "m", function() -- get the focused window local win = hs.window.focusedWindow() @@ -47,6 +48,34 @@ function obj:init() -- win:maximize() -- end end) + + -- Half-maximize (right) + hs.hotkey.bind({ "alt", "ctrl", "cmd" }, "o", function() + -- get the focused window + local win = hs.window.focusedWindow() + local frame = win:frame() + -- maximize if possible + local max = win:screen():fullFrame() + frame.x = max.w / 2 + frame.y = max.y + frame.w = max.w / 2 + frame.h = max.h + win:setFrame(frame) + end) + + -- Half-maximize (left) + hs.hotkey.bind({ "alt", "ctrl", "cmd" }, "u", function() + -- get the focused window + local win = hs.window.focusedWindow() + local frame = win:frame() + -- maximize if possible + local max = win:screen():fullFrame() + frame.x = max.x + frame.y = max.y + frame.w = max.w / 2 + frame.h = max.h + win:setFrame(frame) + end) end return obj diff --git a/modules/darwin/hammerspoon/Spoons/MoveWindow.spoon/worklayout.lua b/modules/darwin/hammerspoon/Spoons/MoveWindow.spoon/worklayout.lua index 7161ad9..e552ddb 100644 --- a/modules/darwin/hammerspoon/Spoons/MoveWindow.spoon/worklayout.lua +++ b/modules/darwin/hammerspoon/Spoons/MoveWindow.spoon/worklayout.lua @@ -4,12 +4,11 @@ -- License is also available: -- https://github.com/anishathalye/dotfiles-local/blob/ffdadd313e58514eb622736b09b91a7d7eb7c6c9/LICENSE.md -WORK_LEFT_MONITOR = "DELL U2415 (2)" -WORK_RIGHT_MONITOR = "DELL U2415 (1)" +WORK_ONLY_MONITOR = "DELL U4021QW" LAPTOP_MONITOR = "Built-in Retina Display" -- Used to find out the name of the monitor in Hammerspoon -function dump(o) +local function dump(o) if type(o) == "table" then local s = "{ " for k, v in pairs(o) do @@ -23,10 +22,11 @@ function dump(o) return tostring(o) end end --- Turn on when looking for the monitor name --- print(dump(hs.screen.allScreens())) -function concat(...) +-- Turn on when looking for the monitor name +print(dump(hs.screen.allScreens())) + +local function concat(...) local res = {} for _, tab in ipairs({ ... }) do for _, elem in ipairs(tab) do @@ -36,20 +36,21 @@ function concat(...) return res end -function worklayout() +local function worklayout() hs.hotkey.bind({ "alt", "ctrl", "cmd" }, "l", function() local u = hs.geometry.unitrect -- set the layout local left = { - -- { "Alacritty", nil, WORK_LEFT_MONITOR, u(0, 0, 1, 1), nil, nil, visible = true }, + { "kitty", nil, WORK_ONLY_MONITOR, u(0, 0, 1 / 2, 1), nil, nil, visible = true }, } local right = { - { "Slack", nil, WORK_RIGHT_MONITOR, u(0, 0, 1, 1), nil, nil, visible = true }, - { "Mail", nil, WORK_RIGHT_MONITOR, u(0, 0, 1, 1), nil, nil, visible = true }, - { "zoom.us", nil, WORK_RIGHT_MONITOR, u(1 / 4, 1 / 4, 1 / 2, 1 / 2), nil, nil, visible = true }, + { "Slack", nil, WORK_ONLY_MONITOR, u(1 / 2, 0, 1 / 2, 1), nil, nil, visible = true }, + { "Mail", nil, WORK_ONLY_MONITOR, u(1 / 2, 0, 1 / 2, 1), nil, nil, visible = true }, + { "zoom.us", nil, WORK_ONLY_MONITOR, u(5 / 8, 1 / 4, 1 / 4, 1 / 2), nil, nil, visible = true }, } local laptop = { - { "Firefox", nil, LAPTOP_MONITOR, u(0, 0, 1, 1), nil, nil, visible = true }, + { "Firefox", nil, LAPTOP_MONITOR, u(0, 0, 1, 1), nil, nil, visible = true }, + { "Obsidian", nil, LAPTOP_MONITOR, u(0, 0, 1, 1), nil, nil, visible = true }, } local layout = concat(left, right, laptop) hs.layout.apply(layout) diff --git a/modules/darwin/homebrew.nix b/modules/darwin/homebrew.nix index 3621f3e..d88eb49 100644 --- a/modules/darwin/homebrew.nix +++ b/modules/darwin/homebrew.nix @@ -1,51 +1,49 @@ -{ config, ... }: { +{ config, pkgs, lib, ... }: { # Homebrew - Mac-specific packages that aren't in Nix + config = lib.mkIf pkgs.stdenv.isDarwin { - # Requires Homebrew to be installed - system.activationScripts.preUserActivation.text = '' - if ! xcode-select --version 2>/dev/null; then - $DRY_RUN_CMD xcode-select --install - fi - if ! /usr/local/bin/brew --version 2>/dev/null; then - $DRY_RUN_CMD /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - fi - ''; + # Requires Homebrew to be installed + system.activationScripts.preUserActivation.text = '' + if ! xcode-select --version 2>/dev/null; then + $DRY_RUN_CMD xcode-select --install + fi + if ! /usr/local/bin/brew --version 2>/dev/null; then + $DRY_RUN_CMD /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + fi + ''; - homebrew = { - enable = true; - onActivation = { - autoUpdate = false; # Don't update during rebuild - cleanup = "zap"; # Uninstall all programs not declared - upgrade = true; + homebrew = { + enable = true; + onActivation = { + autoUpdate = false; # Don't update during rebuild + cleanup = "zap"; # Uninstall all programs not declared + upgrade = true; + }; + global = { + brewfile = true; # Run brew bundle from anywhere + lockfiles = false; # Don't save lockfile (since running from anywhere) + }; + taps = [ + "homebrew/cask" # Required for casks + "homebrew/cask-drivers" # Used for Logitech G-Hub + ]; + brews = [ + "trash" # Delete files and folders to trash instead of rm + "openjdk" # Required by Apache Directory Studio + ]; + casks = [ + "1password" # 1Password packaging on Nix is broken for macOS + "apache-directory-studio" # Packaging on Nix is not available for macOS + "gitify" # Git notifications in menu bar + "keybase" # GUI on Nix not available for macOS + "logitech-g-hub" # Mouse and keyboard management + "meetingbar" # Show meetings in menu bar + "obsidian" # Obsidian packaging on Nix is not available for macOS + "scroll-reverser" # Different scroll style for mouse vs. trackpad + "steam" # Not packaged for Nix + ]; }; - global = { - brewfile = true; # Run brew bundle from anywhere - lockfiles = false; # Don't save lockfile (since running from anywhere) - }; - taps = [ - "homebrew/cask" # Required for casks - "homebrew/cask-drivers" # Used for Logitech G-Hub - ]; - brews = [ - "trash" # Delete files and folders to trash instead of rm - ]; - casks = [ - "firefox" # Firefox packaging on Nix is broken for MacOS - "1password" # 1Password packaging on Nix is broken for MacOS - "scroll-reverser" # Different scroll style for mouse vs. trackpad - "meetingbar" # Show meetings in menu bar - "gitify" # Git notifications in menu bar - "logitech-g-hub" # Mouse and keyboard management - "mimestream" # Gmail client - "obsidian" # Obsidian packaging on Nix is not available for MacOS - "steam" # Not packaged for Nix - ]; - }; - - home-manager.users.${config.user} = { - - programs.fish.shellAbbrs.t = "trash"; }; diff --git a/modules/darwin/kitty.nix b/modules/darwin/kitty.nix new file mode 100644 index 0000000..7cd61e2 --- /dev/null +++ b/modules/darwin/kitty.nix @@ -0,0 +1,18 @@ +{ config, pkgs, lib, ... }: { + + # MacOS-specific settings for Kitty + home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin { + programs.kitty = { + darwinLaunchOptions = [ "--start-as=fullscreen" ]; + font.size = lib.mkForce 20; + settings = { + shell = "/run/current-system/sw/bin/fish"; + macos_traditional_fullscreen = true; + macos_quit_when_last_window_closed = true; + disable_ligatures = "always"; + macos_option_as_alt = true; + }; + }; + }; + +} diff --git a/modules/darwin/networking.nix b/modules/darwin/networking.nix index 9d72aff..9d191e1 100644 --- a/modules/darwin/networking.nix +++ b/modules/darwin/networking.nix @@ -1,9 +1,11 @@ -{ config, ... }: { +{ config, pkgs, lib, ... }: { - networking = { - computerName = "${config.fullName}'\\''s Mac"; - # Adjust if necessary - # hostName = ""; + config = lib.mkIf pkgs.stdenv.isDarwin { + networking = { + computerName = "${config.fullName}'\\''s Mac"; + # Adjust if necessary + # hostName = ""; + }; }; } diff --git a/modules/darwin/nixpkgs.nix b/modules/darwin/nixpkgs.nix index 3f8fbc1..adbbd3d 100644 --- a/modules/darwin/nixpkgs.nix +++ b/modules/darwin/nixpkgs.nix @@ -1,6 +1,6 @@ -{ config, lib, ... }: { +{ config, pkgs, lib, ... }: { - home-manager.users.${config.user} = { + home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin { programs.fish = { shellAbbrs = { @@ -14,7 +14,14 @@ set option "--option substitute false" end git -C ${config.dotfilesPath} add --intent-to-add --all - commandline -r "darwin-rebuild switch $option --flake ${config.dotfilesPath}#macbook" + commandline -r "darwin-rebuild switch $option --flake ${config.dotfilesPath}#lookingglass" + commandline --function execute + ''; + }; + rebuild-home = lib.mkForce { + body = '' + git -C ${config.dotfilesPath} add --intent-to-add --all + commandline -r "${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#lookingglass"; commandline --function execute ''; }; diff --git a/modules/darwin/system.nix b/modules/darwin/system.nix index 4c2eaa1..5cb107c 100644 --- a/modules/darwin/system.nix +++ b/modules/darwin/system.nix @@ -1,175 +1,192 @@ -{ ... }: { +{ pkgs, lib, ... }: { - services.nix-daemon.enable = true; + config = lib.mkIf pkgs.stdenv.isDarwin { - security.pam.enableSudoTouchIdAuth = true; + services.nix-daemon.enable = true; - system = { - - keyboard = { - remapCapsLockToControl = true; - enableKeyMapping = true; # Allows for skhd + # This setting only applies to Darwin, different on NixOS + nix.gc.interval = { + Hour = 12; + Minute = 15; + Day = 1; }; - defaults = { - NSGlobalDomain = { + environment.shells = [ pkgs.fish ]; - # Set to dark mode - AppleInterfaceStyle = "Dark"; + security.pam.enableSudoTouchIdAuth = true; - # Don't change from dark to light automatically - # AppleInterfaceSwitchesAutomatically = false; + system = { - # Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs) - AppleKeyboardUIMode = 3; - - # Automatically show and hide the menu bar - _HIHideMenuBar = true; - - # Expand save panel by default - NSNavPanelExpandedStateForSaveMode = true; - - # Expand print panel by default - PMPrintingExpandedStateForPrint = true; - - # Replace press-and-hold with key repeat - ApplePressAndHoldEnabled = false; - - # Set a fast key repeat rate - KeyRepeat = 2; - - # Shorten delay before key repeat begins - InitialKeyRepeat = 12; - - # Save to local disk by default, not iCloud - NSDocumentSaveNewDocumentsToCloud = false; - - # Disable autocorrect capitalization - NSAutomaticCapitalizationEnabled = false; - - # Disable autocorrect smart dashes - NSAutomaticDashSubstitutionEnabled = false; - - # Disable autocorrect adding periods - NSAutomaticPeriodSubstitutionEnabled = false; - - # Disable autocorrect smart quotation marks - NSAutomaticQuoteSubstitutionEnabled = false; - - # Disable autocorrect spellcheck - NSAutomaticSpellingCorrectionEnabled = false; + keyboard = { + remapCapsLockToControl = true; + enableKeyMapping = true; # Allows for skhd }; - dock = { - # Automatically show and hide the dock - autohide = true; + defaults = { + NSGlobalDomain = { - # Add translucency in dock for hidden applications - showhidden = true; + # Set to dark mode + AppleInterfaceStyle = "Dark"; - # Enable spring loading on all dock items - enable-spring-load-actions-on-all-items = true; + # Don't change from dark to light automatically + # AppleInterfaceSwitchesAutomatically = false; - # Highlight hover effect in dock stack grid view - mouse-over-hilite-stack = true; + # Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs) + AppleKeyboardUIMode = 3; - mineffect = "genie"; - orientation = "bottom"; - show-recents = false; - tilesize = 44; - }; + # Automatically show and hide the menu bar + _HIHideMenuBar = true; - finder = { + # Expand save panel by default + NSNavPanelExpandedStateForSaveMode = true; - # Default Finder window set to column view - FXPreferredViewStyle = "clmv"; + # Expand print panel by default + PMPrintingExpandedStateForPrint = true; - # Finder search in current folder by default - FXDefaultSearchScope = "SCcf"; + # Replace press-and-hold with key repeat + ApplePressAndHoldEnabled = false; - # Disable warning when changing file extension - FXEnableExtensionChangeWarning = false; + # Set a fast key repeat rate + KeyRepeat = 2; - # Allow quitting of Finder application - QuitMenuItem = true; + # Shorten delay before key repeat begins + InitialKeyRepeat = 12; + + # Save to local disk by default, not iCloud + NSDocumentSaveNewDocumentsToCloud = false; + + # Disable autocorrect capitalization + NSAutomaticCapitalizationEnabled = false; + + # Disable autocorrect smart dashes + NSAutomaticDashSubstitutionEnabled = false; + + # Disable autocorrect adding periods + NSAutomaticPeriodSubstitutionEnabled = false; + + # Disable autocorrect smart quotation marks + NSAutomaticQuoteSubstitutionEnabled = false; + + # Disable autocorrect spellcheck + NSAutomaticSpellingCorrectionEnabled = false; + }; + + dock = { + # Automatically show and hide the dock + autohide = true; + + # Add translucency in dock for hidden applications + showhidden = true; + + # Enable spring loading on all dock items + enable-spring-load-actions-on-all-items = true; + + # Highlight hover effect in dock stack grid view + mouse-over-hilite-stack = true; + + mineffect = "genie"; + orientation = "bottom"; + show-recents = false; + tilesize = 44; + }; + + finder = { + + # Default Finder window set to column view + FXPreferredViewStyle = "clmv"; + + # Finder search in current folder by default + FXDefaultSearchScope = "SCcf"; + + # Disable warning when changing file extension + FXEnableExtensionChangeWarning = false; + + # Allow quitting of Finder application + QuitMenuItem = true; + + }; + + # Disable "Are you sure you want to open" dialog + LaunchServices.LSQuarantine = false; + + # Disable trackpad tap to click + trackpad.Clicking = false; + + # universalaccess = { + + # # Zoom in with Control + Scroll Wheel + # closeViewScrollWheelToggle = true; + # closeViewZoomFollowsFocus = true; + # }; + + # Where to save screenshots + screencapture.location = "~/Downloads"; }; - # Disable "Are you sure you want to open" dialog - LaunchServices.LSQuarantine = false; + # Settings that don't have an option in nix-darwin + activationScripts.postActivation.text = '' + echo "Disable disk image verification" + defaults write com.apple.frameworks.diskimages skip-verify -bool true + defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true + defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true - # Disable trackpad tap to click - trackpad.Clicking = false; + echo "Avoid creating .DS_Store files on network volumes" + defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true - # universalaccess = { + echo "Disable the warning before emptying the Trash" + defaults write com.apple.finder WarnOnEmptyTrash -bool false - # # Zoom in with Control + Scroll Wheel - # closeViewScrollWheelToggle = true; - # closeViewZoomFollowsFocus = true; - # }; + echo "Require password immediately after sleep or screen saver begins" + defaults write com.apple.screensaver askForPassword -int 1 + defaults write com.apple.screensaver askForPasswordDelay -int 0 - # Where to save screenshots - screencapture.location = "~/Downloads"; + echo "Allow apps from anywhere" + SPCTL=$(spctl --status) + if ! [ "$SPCTL" = "assessments disabled" ]; then + sudo spctl --master-disable + fi + + ''; + + # User-level settings + activationScripts.postUserActivation.text = '' + echo "Show the ~/Library folder" + chflags nohidden ~/Library + + echo "Enable dock magnification" + defaults write com.apple.dock magnification -bool true + + echo "Set dock magnification size" + defaults write com.apple.dock largesize -int 48 + + echo "Define dock icon function" + __dock_item() { + printf "%s%s%s%s%s" \ + "tile-datafile-data" \ + "_CFURLString" \ + "$1" \ + "_CFURLStringType0" \ + "" + } + + echo "Choose and order dock icons" + defaults write com.apple.dock persistent-apps -array \ + "$(__dock_item /Applications/1Password.app)" \ + "$(__dock_item ${pkgs.slack}/Applications/Slack.app)" \ + "$(__dock_item /System/Applications/Calendar.app)" \ + "$(__dock_item ${pkgs.firefox-bin}/Applications/Firefox.app)" \ + "$(__dock_item /System/Applications/Messages.app)" \ + "$(__dock_item /System/Applications/Mail.app)" \ + "$(__dock_item /Applications/zoom.us.app)" \ + "$(__dock_item ${pkgs.discord}/Applications/Discord.app)" \ + "$(__dock_item /Applications/Obsidian.app)" \ + "$(__dock_item ${pkgs.kitty}/Applications/kitty.app)" \ + "$(__dock_item /System/Applications/System\ Settings.app)" + ''; }; - # Settings that don't have an option in nix-darwin - activationScripts.postActivation.text = '' - echo "Disable disk image verification" - defaults write com.apple.frameworks.diskimages skip-verify -bool true - defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true - defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true - - echo "Avoid creating .DS_Store files on network volumes" - defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true - - echo "Disable the warning before emptying the Trash" - defaults write com.apple.finder WarnOnEmptyTrash -bool false - - echo "Require password immediately after sleep or screen saver begins" - defaults write com.apple.screensaver askForPassword -int 1 - defaults write com.apple.screensaver askForPasswordDelay -int 0 - - echo "Show the ~/Library folder" - chflags nohidden ~/Library - - echo "Enable dock magnification" - defaults write com.apple.dock magnification -bool true - - echo "Set dock magnification size" - defaults write com.apple.dock largesize -int 48 - - echo "Define dock icon function" - __dock_item() { - printf "%s%s%s%s%s" \ - "tile-datafile-data" \ - "_CFURLString" \ - "$1" \ - "_CFURLStringType0" \ - "" - } - - echo "Choose and order dock icons" - defaults write com.apple.dock persistent-apps -array \ - "$(__dock_item /Applications/1Password.app)" \ - "$(__dock_item /Applications/Slack.app)" \ - "$(__dock_item /System/Applications/Calendar.app)" \ - "$(__dock_item /Applications/Firefox.app)" \ - "$(__dock_item /System/Applications/Messages.app)" \ - "$(__dock_item /System/Applications/Mail.app)" \ - "$(__dock_item /Applications/Mimestream.app)" \ - "$(__dock_item /Applications/zoom.us.app)" \ - "$(__dock_item /Applications/Obsidian.app)" \ - "$(__dock_item /Applications/Alacritty.app)" \ - "$(__dock_item /System/Applications/System\ Preferences.app)" - - echo "Allow apps from anywhere" - SPCTL=$(spctl --status) - if ! [ "$SPCTL" = "assessments disabled" ]; then - sudo spctl --master-disable - fi - - ''; }; } diff --git a/modules/darwin/tmux.nix b/modules/darwin/tmux.nix index 16372e2..252e70e 100644 --- a/modules/darwin/tmux.nix +++ b/modules/darwin/tmux.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: { +{ config, pkgs, lib, ... }: { - home-manager.users.${config.user} = { + options.tmux.enable = lib.mkEnableOption "Tmux terminal multiplexer"; + + config.home-manager.users.${config.user} = lib.mkIf config.tmux.enable { programs.tmux = { enable = true; diff --git a/modules/darwin/user.nix b/modules/darwin/user.nix index 278325f..4ffb691 100644 --- a/modules/darwin/user.nix +++ b/modules/darwin/user.nix @@ -1,8 +1,21 @@ { config, pkgs, lib, ... }: { - users.users."${config.user}" = { # macOS user - home = config.homePath; - shell = pkgs.zsh; # Default shell + config = lib.mkIf pkgs.stdenv.isDarwin { + + users.users."${config.user}" = { + # macOS user + home = config.homePath; + shell = pkgs.fish; # Default shell + + }; + + # Used for aerc + home-manager.users.${config.user} = { + home.sessionVariables = { + XDG_CONFIG_HOME = "${config.homePath}/.config"; + }; + }; + }; } diff --git a/modules/darwin/utilities.nix b/modules/darwin/utilities.nix index ad50645..db43292 100644 --- a/modules/darwin/utilities.nix +++ b/modules/darwin/utilities.nix @@ -1,9 +1,11 @@ -{ config, pkgs, lib, ... }: { +{ config, pkgs, lib, ... }: - home-manager.users.${config.user} = { +{ + + home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin { home.packages = with pkgs; [ - visidata # CSV inspector + # visidata # CSV inspector dos2unix # Convert Windows text files inetutils # Includes telnet youtube-dl # Convert web videos @@ -16,9 +18,12 @@ vault consul noti # Create notifications programmatically - ipcalc - (pkgs.writeScriptBin "ocr" - (builtins.readFile ../shell/bash/scripts/ocr.sh)) + ipcalc # Make IP network calculations + (writeShellApplication { + name = "ocr"; + runtimeInputs = [ tesseract ]; + text = builtins.readFile ../../modules/common/shell/bash/scripts/ocr.sh; + }) ]; programs.fish.shellAbbrs = { diff --git a/modules/gaming/default.nix b/modules/gaming/default.nix deleted file mode 100644 index 7b26dc6..0000000 --- a/modules/gaming/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ config, ... }: { - - imports = [ ./leagueoflegends.nix ./lutris.nix ./steam.nix ./legendary.nix ]; - - config = { - hardware.opengl = { - enable = true; - driSupport32Bit = true; - }; - }; -} diff --git a/modules/gaming/leagueoflegends.nix b/modules/gaming/leagueoflegends.nix deleted file mode 100644 index 3121923..0000000 --- a/modules/gaming/leagueoflegends.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ config, pkgs, lib, ... }: { - - options.gaming.leagueoflegends = lib.mkEnableOption "League of Legends"; - - config = lib.mkIf config.gaming.leagueoflegends { - - # League of Legends anti-cheat requirement - boot.kernel.sysctl = { "abi.vsyscall32" = 0; }; - - environment.systemPackages = with pkgs; [ - - # Lutris requirement to install the game - lutris - amdvlk - wineWowPackages.stable - # vulkan-tools - - # Required according to https://lutris.net/games/league-of-legends/ - openssl - gnome.zenity - - # Don't remember if this is required - dconf - - ]; - - environment.sessionVariables = { QT_X11_NO_MITSHM = "1"; }; - - }; -} diff --git a/modules/gaming/steam.nix b/modules/gaming/steam.nix deleted file mode 100644 index b23bd7c..0000000 --- a/modules/gaming/steam.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ config, pkgs, lib, ... }: { - - options.gaming.steam = lib.mkEnableOption "Steam"; - - config = lib.mkIf config.gaming.steam { - hardware.steam-hardware.enable = true; - unfreePackages = [ "steam" "steam-original" "steamcmd" ]; - environment.systemPackages = with pkgs; [ - - steam - - # Enable terminal interaction - steamPackages.steamcmd - steam-tui - - ]; - }; - -} diff --git a/modules/graphical/default.nix b/modules/graphical/default.nix deleted file mode 100644 index ea6a7a8..0000000 --- a/modules/graphical/default.nix +++ /dev/null @@ -1,55 +0,0 @@ -{ lib, ... }: { - - imports = [ - ./xorg.nix - ./fonts.nix - ./i3.nix - ./polybar.nix - ./picom.nix - # ./dmenu.nix - ./rofi.nix - ]; - - options = with lib; { - - gui = { - compositor.enable = mkEnableOption { - description = "Enable transparency, blur, shadows"; - default = false; - }; - launcherCommand = mkOption { - type = types.str; - description = "Command to use for launching"; - }; - systemdSearch = mkOption { - type = types.str; - description = "Command to use for interacting with systemd"; - }; - altTabCommand = mkOption { - type = types.str; - description = "Command to use for choosing windows"; - }; - toggleBarCommand = lib.mkOption { - type = lib.types.str; - description = "Command to hide and show the status bar."; - }; - gtk.theme = { - name = mkOption { - type = types.str; - description = "Theme name for GTK applications"; - }; - package = mkOption { - type = types.str; - description = "Theme package name for GTK applications"; - default = "gnome-themes-extra"; - }; - }; - wallpaper = mkOption { - type = types.path; - description = "Wallpaper background image file"; - }; - }; - - }; - -} diff --git a/modules/graphical/picom.nix b/modules/graphical/picom.nix deleted file mode 100644 index 6c555b4..0000000 --- a/modules/graphical/picom.nix +++ /dev/null @@ -1,49 +0,0 @@ -{ config, lib, ... }: { - - config = - lib.mkIf (config.services.xserver.enable && config.gui.compositor.enable) { - home-manager.users.${config.user} = { - - services.picom = { - enable = true; - settings = { - blur = false; - blurExclude = [ ]; - inactiveDim = "0.05"; - noDNDShadow = false; - noDockShadow = false; - # shadow-radius = 20 - # ''; - # shadow-radius = 20 - # corner-radius = 10 - # blur-size = 20 - # rounded-corners-exclude = [ - # "window_type = 'dock'", - # "class_g = 'i3-frame'" - # ] - # ''; - }; - fade = false; - experimentalBackends = true; - inactiveOpacity = 1.0; - menuOpacity = 1.0; - opacityRules = [ - "0:_NET_WM_STATE@[0]:32a = '_NET_WM_STATE_HIDDEN'" # Hide tabbed windows - ]; - shadow = false; - shadowExclude = [ ]; - shadowOffsets = [ (-10) (-10) ]; - shadowOpacity = 0.5; - vSync = true; - }; - - xsession.windowManager.i3.config.startup = [{ - command = "systemctl --user restart picom"; - always = true; - notification = false; - }]; - - }; - }; - -} diff --git a/modules/graphical/rofi/brightness.sh b/modules/graphical/rofi/brightness.sh deleted file mode 100755 index 977f433..0000000 --- a/modules/graphical/rofi/brightness.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -# THEME="$HOME/.config/rofi/config.rasi" - -ICON_UP="" -ICON_DOWN="" -ICON_OPT="" -options="$ICON_UP\n$ICON_OPT\n$ICON_DOWN" -chosen="$(echo -e "$options" | rofi -theme-str 'listview { layout:horizontal; }' -dmenu)" -echo "$chosen" diff --git a/modules/hardware/default.nix b/modules/hardware/default.nix deleted file mode 100644 index fd15c7e..0000000 --- a/modules/hardware/default.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ ... }: { - - imports = [ - ./audio.nix - ./boot.nix - ./keyboard.nix - ./monitors.nix - ./mouse.nix - ./networking.nix - ./sleep.nix - ./wifi.nix - ]; - -} diff --git a/modules/hardware/keyboard.nix b/modules/hardware/keyboard.nix deleted file mode 100644 index e5eee1b..0000000 --- a/modules/hardware/keyboard.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ ... }: { - - services.xserver = { - - layout = "us"; - - # Keyboard responsiveness - autoRepeatDelay = 250; - autoRepeatInterval = 40; - - # Swap escape key with caps lock key - xkbOptions = "eurosign:e,caps:swapescape"; - - }; - -} diff --git a/modules/hardware/networking.nix b/modules/hardware/networking.nix deleted file mode 100644 index 4fb79a6..0000000 --- a/modules/hardware/networking.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ ... }: { - - # 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; - networking.interfaces.wlp3s0.useDHCP = true; - -} diff --git a/modules/hardware/sleep.nix b/modules/hardware/sleep.nix deleted file mode 100644 index 3b7d4bb..0000000 --- a/modules/hardware/sleep.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ ... }: { - - # Prevent wake from keyboard - powerManagement.powerDownCommands = '' - for wakeup in /sys/bus/usb/devices/1-*/power/wakeup; do echo disabled > $wakeup; done - ''; - -} diff --git a/modules/hardware/wifi.nix b/modules/hardware/wifi.nix deleted file mode 100644 index 290044e..0000000 --- a/modules/hardware/wifi.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ ... }: { - - # Enables wireless support via wpa_supplicant. - networking.wireless.enable = true; - - # Allows the user to control the WiFi settings. - networking.wireless.userControlled.enable = true; - -} diff --git a/modules/mail/mailpass.age b/modules/mail/mailpass.age deleted file mode 100644 index d422efa..0000000 --- a/modules/mail/mailpass.age +++ /dev/null @@ -1,5 +0,0 @@ -age-encryption.org/v1 --> ssh-ed25519 MgHaOw 8h/ESNjn0gknNXoHM34UobHzPgmRunoP97H+KHOuGQM -qowH+6TlCRECGCscRgKx6kswY+PZezYUD6E+x9e+5pM ---- kFj1JzRdh/D13Uq9aNTzMJIFysEE+kzzthjewOIR2+o -Ȳ6}rCz >&=jW ^Wl!"}MS8=xm =ЇL \ No newline at end of file diff --git a/modules/neovim/default.nix b/modules/neovim/default.nix deleted file mode 100644 index cbb51dd..0000000 --- a/modules/neovim/default.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ config, pkgs, lib, ... }: { - - home-manager.users.${config.user} = { - - home.packages = with pkgs; [ - neovim - gcc # for tree-sitter - shfmt # used everywhere - shellcheck # used everywhere - ]; - - xdg.configFile = { - "nvim/init.lua".source = ./init.lua; - "nvim/lua" = { - source = ./lua; - recursive = true; # Allows adding more files - }; - "nvim/lua/packer/colors.lua".source = config.colorscheme.neovimConfig; - }; - - programs.git.extraConfig.core.editor = "nvim"; - home.sessionVariables = { - EDITOR = "nvim"; - MANPAGER = "nvim +Man!"; - }; - programs.fish = { - shellAliases = { vim = "nvim"; }; - shellAbbrs = { - v = lib.mkForce "nvim"; - vl = lib.mkForce "vim -c 'normal! `0' -c 'bdelete 1'"; - vll = "nvim -c 'Telescope oldfiles'"; - }; - }; - - # Always run packer.nvim sync - home.activation.nvimPackerSync = - config.home-manager.users.${config.user}.lib.dag.entryAfter - [ "writeBoundary" ] '' - $DRY_RUN_CMD ${pkgs.neovim}/bin/nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync' - ''; - - }; - - # Used for icons in Vim - fonts.fonts = with pkgs; [ nerdfonts ]; - -} diff --git a/modules/neovim/init.lua b/modules/neovim/init.lua deleted file mode 100644 index 8267993..0000000 --- a/modules/neovim/init.lua +++ /dev/null @@ -1,3 +0,0 @@ -require("packer_init") -require("settings") -require("keybinds") diff --git a/modules/neovim/lua/packer/completion.lua b/modules/neovim/lua/packer/completion.lua deleted file mode 100644 index be8fc1c..0000000 --- a/modules/neovim/lua/packer/completion.lua +++ /dev/null @@ -1,164 +0,0 @@ --- ======================================================================= --- Completion System --- ======================================================================= - -local M = {} - -M.packer = function(use) - -- Completion sources - use("hrsh7th/cmp-nvim-lsp") --- Language server completion plugin - use("hrsh7th/cmp-buffer") --- Generic text completion - use("hrsh7th/cmp-path") --- Local file completion - use("hrsh7th/cmp-cmdline") --- Command line completion - use("hrsh7th/cmp-nvim-lua") --- Nvim lua api completion - use("saadparwaiz1/cmp_luasnip") --- Luasnip completion - use("lukas-reineke/cmp-rg") --- Ripgrep completion - use("rafamadriz/friendly-snippets") -- Lots of pre-generated snippets - - -- Completion engine - use({ - "hrsh7th/nvim-cmp", - requires = { "L3MON4D3/LuaSnip" }, - config = function() - local cmp = require("cmp") - - local kind_icons = { - Text = "", - Method = "m", - Function = "", - Constructor = "", - Field = "", - Variable = "", - Class = "", - Interface = "", - Module = "", - Property = "", - Unit = "", - Value = "", - Enum = "", - Keyword = "", - Snippet = "", - Color = "", - File = "", - Reference = "", - Folder = "", - EnumMember = "", - Constant = "", - Struct = "", - Event = "", - Operator = "", - TypeParameter = "", - } - - cmp.setup({ - - -- Only enable on non-prompt buffers - -- So don't use in telescope - enabled = function() - if vim.bo.buftype == "prompt" then - return false - end - return true - end, - - -- Setup snippet completion - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - - -- Setup completion keybinds - mapping = { - [""] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.abort(), { "i", "c" }), - [""] = function(_) - cmp.mapping({ - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }) - vim.cmd("stopinsert") --- Abort and leave insert mode - end, - [""] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Insert, - select = true, - }), - [""] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }), - [""] = cmp.mapping(function(_) - if require("luasnip").expand_or_jumpable() then - require("luasnip").expand_or_jump() - end - end, { "i", "s" }), - }, - - -- Setup completion engines - sources = { - { name = "nvim_lua" }, - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "path" }, - { name = "buffer", keyword_length = 3, max_item_count = 10 }, - { - name = "rg", - keyword_length = 6, - max_item_count = 10, - option = { additional_arguments = "--ignore-case" }, - }, - }, - - -- Visual presentation - formatting = { - fields = { "kind", "abbr", "menu" }, - format = function(entry, vim_item) - vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) - vim_item.menu = ({ - luasnip = "[Snippet]", - buffer = "[Buffer]", - path = "[Path]", - rg = "[Grep]", - nvim_lsp = "[LSP]", - nvim_lua = "[Lua]", - })[entry.source.name] - return vim_item - end, - }, - - -- Docs - -- window = { - -- completion = cmp.config.window.bordered(), - -- documentation = cmp.config.window.bordered(), - -- }, - - -- Extra features - experimental = { - native_menu = false, --- Use cmp menu instead of Vim menu - ghost_text = true, --- Show preview auto-completion - }, - }) - - -- Use buffer source for `/` - cmp.setup.cmdline("/", { - sources = { - { name = "buffer", keyword_length = 5 }, - }, - }) - - -- Use cmdline & path source for ':' - cmp.setup.cmdline(":", { - sources = cmp.config.sources({ - { name = "path" }, - }, { - { name = "cmdline" }, - }), - }) - end, - }) -end - -return M diff --git a/modules/neovim/lua/packer/lsp.lua b/modules/neovim/lua/packer/lsp.lua deleted file mode 100644 index 991f2bd..0000000 --- a/modules/neovim/lua/packer/lsp.lua +++ /dev/null @@ -1,153 +0,0 @@ --- ======================================================================= --- Language Server --- ======================================================================= - -local M = {} - -M.packer = function(use) - -- Language server engine - use({ - "neovim/nvim-lspconfig", - requires = { "hrsh7th/cmp-nvim-lsp" }, - config = function() - local function on_path(program) - return vim.fn.executable(program) == 1 - end - - local capabilities = - require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()) - if on_path("lua-language-server") then - require("lspconfig").sumneko_lua.setup({ - capabilities = capabilities, - -- Turn off errors for vim global variable - settings = { - Lua = { - diagnostics = { - globals = { "vim", "hs" }, - }, - }, - }, - }) - end - if on_path("rust-analyzer") then - require("lspconfig").rust_analyzer.setup({ capabilities = capabilities }) - end - if on_path("tflint") then - require("lspconfig").tflint.setup({ capabilities = capabilities }) - end - if on_path("terraform-ls") then - require("lspconfig").terraformls.setup({ capabilities = capabilities }) - end - if on_path("pyright") then - require("lspconfig").pyright.setup({ - on_attach = function() - -- set keymaps (requires 0.7.0) - -- vim.keymap.set("n", "", "", {buffer=0}) - end, - capabilities = capabilities, - }) - end - if on_path("rnix-lsp") then - require("lspconfig").rnix.setup({ capabilities = capabilities }) - end - - vim.keymap.set("n", "gd", vim.lsp.buf.definition) - vim.keymap.set("n", "gT", vim.lsp.buf.type_definition) - vim.keymap.set("n", "gi", vim.lsp.buf.implementation) - vim.keymap.set("n", "gh", vim.lsp.buf.hover) - -- vim.keymap.set("n", "gr", telescope.lsp_references) - vim.keymap.set("n", "R", vim.lsp.buf.rename) - vim.keymap.set("n", "]e", vim.diagnostic.goto_next) - vim.keymap.set("n", "[e", vim.diagnostic.goto_prev) - vim.keymap.set("n", "de", vim.diagnostic.open_float) - vim.keymap.set("n", "E", vim.lsp.buf.code_action) - end, - }) - - -- Pretty highlights - use("folke/lsp-colors.nvim") - - -- Linting - use({ - "jose-elias-alvarez/null-ls.nvim", - branch = "main", - requires = { - "nvim-lua/plenary.nvim", - "neovim/nvim-lspconfig", - }, - config = function() - local function on_path(program) - return vim.fn.executable(program) == 1 - end - - require("null-ls").setup({ - sources = { - require("null-ls").builtins.formatting.stylua.with({ - condition = function() - return on_path("stylua") - end, - }), - require("null-ls").builtins.formatting.black.with({ - condition = function() - return on_path("black") - end, - }), - require("null-ls").builtins.diagnostics.flake8.with({ - condition = function() - return on_path("flake8") - end, - }), - require("null-ls").builtins.formatting.fish_indent.with({ - condition = function() - return on_path("fish_indent") - end, - }), - require("null-ls").builtins.formatting.nixfmt.with({ - condition = function() - return on_path("nixfmt") - end, - }), - require("null-ls").builtins.formatting.rustfmt.with({ - condition = function() - return on_path("rustfmt") - end, - }), - require("null-ls").builtins.diagnostics.shellcheck.with({ - condition = function() - return on_path("shellcheck") - end, - }), - require("null-ls").builtins.formatting.shfmt.with({ - extra_args = { "-i", "4", "-ci" }, - condition = function() - return on_path("shfmt") - end, - }), - require("null-ls").builtins.formatting.terraform_fmt.with({ - condition = function() - return on_path("terraform") - end, - }), - -- require("null-ls").builtins.diagnostics.luacheck, - -- require("null-ls").builtins.diagnostics.markdownlint, - -- require("null-ls").builtins.diagnostics.pylint, - }, - -- Format on save - on_attach = function(client) - if client.resolved_capabilities.document_formatting then - local id = vim.api.nvim_create_augroup("LspFormatting", { - clear = true, - }) - vim.api.nvim_create_autocmd("BufWritePre", { - group = id, - pattern = "*", - callback = vim.lsp.buf.formatting_seq_sync, - }) - end - end, - }) - end, - }) -end - -return M diff --git a/modules/neovim/lua/packer/misc.lua b/modules/neovim/lua/packer/misc.lua deleted file mode 100644 index 5b015a4..0000000 --- a/modules/neovim/lua/packer/misc.lua +++ /dev/null @@ -1,35 +0,0 @@ -local M = {} - -M.packer = function(use) - -- Important tweaks - use("tpope/vim-surround") --- Manipulate parentheses - - -- Convenience tweaks - use("tpope/vim-eunuch") --- File manipulation in Vim - use("tpope/vim-vinegar") --- Fixes netrw file explorer - use("tpope/vim-fugitive") --- Git commands and syntax - use("tpope/vim-repeat") --- Actually repeat using . - - -- Use gc or gcc to add comments - use({ - "numToStr/Comment.nvim", - config = function() - require("Comment").setup() - end, - }) - - -- Alignment tool - use({ - "godlygeek/tabular", - config = function() - vim.keymap.set("", "ta", ":Tabularize /") - vim.keymap.set("", "t#", ":Tabularize /#") - vim.keymap.set("", "tl", ":Tabularize /---") - end, - }) - - -- Markdown renderer / wiki notes - use("vimwiki/vimwiki") -end - -return M diff --git a/modules/neovim/lua/packer/speed.lua b/modules/neovim/lua/packer/speed.lua deleted file mode 100644 index 414715e..0000000 --- a/modules/neovim/lua/packer/speed.lua +++ /dev/null @@ -1,56 +0,0 @@ -local M = {} - -M.packer = function(use) - -- Startup speed hacks - use({ - "lewis6991/impatient.nvim", - config = function() - require("impatient") - end, - }) - - -- Improve speed and filetype detection - use({ - "nathom/filetype.nvim", - config = function() - -- Filetype for .env files - local envfiletype = function() - vim.bo.filetype = "text" - vim.bo.syntax = "sh" - end - -- Force filetype patterns that Vim doesn't know about - require("filetype").setup({ - overrides = { - extensions = { - Brewfile = "brewfile", - muttrc = "muttrc", - tfvars = "terraform", - tf = "terraform", - }, - literal = { - Caskfile = "brewfile", - [".gitignore"] = "gitignore", - config = "config", - }, - complex = { - [".*git/config"] = "gitconfig", - ["tmux.conf%..*link"] = "tmux", - ["gitconfig%..*link"] = "gitconfig", - [".*ignore%..*link"] = "gitignore", - [".*%.toml%..*link"] = "toml", - }, - function_extensions = {}, - function_literal = { - [".envrc"] = envfiletype, - [".env"] = envfiletype, - [".env.dev"] = envfiletype, - [".env.prod"] = envfiletype, - [".env.example"] = envfiletype, - }, - }, - }) - end, - }) -end - -return M diff --git a/modules/neovim/lua/packer/syntax.lua b/modules/neovim/lua/packer/syntax.lua deleted file mode 100644 index 4ee4ade..0000000 --- a/modules/neovim/lua/packer/syntax.lua +++ /dev/null @@ -1,73 +0,0 @@ --- ======================================================================= --- Syntax --- ======================================================================= - -local M = {} - -M.packer = function(use) - -- Syntax engine - use({ - "nvim-treesitter/nvim-treesitter", - commit = "989c75046c46d2ed96bb65c5badd6b8f785e7f09", - run = ":TSUpdate", - config = function() - require("nvim-treesitter.configs").setup({ - ensure_installed = { - "hcl", - "python", - "lua", - "nix", - "fish", - "toml", - "yaml", - "json", - }, - auto_install = true, - highlight = { enable = true }, - indent = { enable = true }, - }) - end, - }) - - -- Syntax-aware Textobjects - use({ - "nvim-treesitter/nvim-treesitter-textobjects", - requires = { "nvim-treesitter/nvim-treesitter" }, - config = function() - require("nvim-treesitter.configs").setup({ - textobjects = { - select = { - enable = true, - lookahead = true, -- Jump forward automatically - keymaps = { - ["af"] = "@function.outer", - ["if"] = "@function.inner", - ["ac"] = "@class.outer", - ["ic"] = "@class.inner", - ["al"] = "@loop.outer", - ["il"] = "@loop.inner", - ["aa"] = "@call.outer", - ["ia"] = "@call.inner", - ["ar"] = "@parameter.outer", - ["ir"] = "@parameter.inner", - ["aC"] = "@comment.outer", - ["iC"] = "@comment.outer", - ["a/"] = "@comment.outer", - ["i/"] = "@comment.outer", - ["a;"] = "@statement.outer", - ["i;"] = "@statement.outer", - }, - }, - }, - }) - end, - }) - - -- Additional syntax sources - use("bfontaine/Brewfile.vim") --- Brewfile syntax - use("chr4/nginx.vim") --- Nginx syntax - use("towolf/vim-helm") --- Helm syntax - use("rodjek/vim-puppet") --- Puppet syntax -end - -return M diff --git a/modules/neovim/lua/packer/telescope.lua b/modules/neovim/lua/packer/telescope.lua deleted file mode 100644 index e6416c7..0000000 --- a/modules/neovim/lua/packer/telescope.lua +++ /dev/null @@ -1,139 +0,0 @@ --- ======================================================================= --- Fuzzy Launcher --- ======================================================================= - -local M = {} - -M.packer = function(use) - use({ - "nvim-telescope/telescope.nvim", - branch = "master", - requires = { "nvim-lua/plenary.nvim" }, - config = function() - -- Telescope: quit instantly with escape - local actions = require("telescope.actions") - require("telescope").setup({ - defaults = { - mappings = { - i = { - [""] = actions.close, - [""] = "which_key", - }, - }, - }, - pickers = { - find_files = { theme = "ivy" }, - oldfiles = { theme = "ivy" }, - buffers = { theme = "dropdown" }, - }, - extensions = { - fzy_native = {}, - zoxide = {}, - project = { - base_dirs = { "~/dev" }, - }, - }, - }) - - local telescope = require("telescope.builtin") - - vim.keymap.set("n", "k", telescope.keymaps) - vim.keymap.set("n", "/", telescope.live_grep) - vim.keymap.set("n", "ff", telescope.find_files) - vim.keymap.set("n", "fp", telescope.git_files) - vim.keymap.set("n", "fw", telescope.grep_string) - vim.keymap.set("n", "b", telescope.buffers) - vim.keymap.set("n", "hh", telescope.help_tags) - vim.keymap.set("n", "fr", telescope.oldfiles) - vim.keymap.set("n", "cc", telescope.commands) - vim.keymap.set("n", "gc", telescope.git_commits) - vim.keymap.set("n", "gf", telescope.git_bcommits) - vim.keymap.set("n", "gb", telescope.git_branches) - vim.keymap.set("n", "gs", telescope.git_status) - vim.keymap.set("n", "s", telescope.current_buffer_fuzzy_find) - - vim.keymap.set("n", "N", function() - local opts = { - prompt_title = "Search Notes", - cwd = "$NOTES_PATH", - } - telescope.live_grep(opts) - end) - - vim.keymap.set("n", "fN", function() - local opts = { - prompt_title = "Find Notes", - cwd = "$NOTES_PATH", - } - telescope.find_files(opts) - end) - - vim.keymap.set("n", "cr", function() - local opts = require("telescope.themes").get_ivy({ - layout_config = { - bottom_pane = { - height = 15, - }, - }, - }) - telescope.command_history(opts) - end) - end, - }) - - -- Faster sorting - use("nvim-telescope/telescope-fzy-native.nvim") - - -- Jump around tmux sessions - -- use("camgraff/telescope-tmux.nvim") - - -- Jump directories - use({ - "jvgrootveld/telescope-zoxide", - requires = { "nvim-lua/popup.nvim", "nvim-telescope/telescope.nvim" }, - config = function() - vim.keymap.set("n", "fz", require("telescope").extensions.zoxide.list) - end, - }) - - -- Jump projects - use({ - "nvim-telescope/telescope-project.nvim", - requires = { "nvim-telescope/telescope.nvim" }, - config = function() - require("telescope").load_extension("project") - - vim.keymap.set("n", "", function() - local opts = require("telescope.themes").get_ivy({ - layout_config = { - bottom_pane = { - height = 10, - }, - }, - }) - require("telescope").extensions.project.project(opts) - end) - end, - }) - - -- File browser - use({ - "nvim-telescope/telescope-file-browser.nvim", - requires = { "nvim-telescope/telescope.nvim" }, - config = function() - require("telescope").load_extension("file_browser") - - vim.keymap.set("n", "fa", require("telescope").extensions.file_browser.file_browser) - - vim.keymap.set("n", "fD", function() - local opts = { - prompt_title = "Find Downloads", - cwd = "~/downloads", - } - require("telescope").extensions.file_browser.file_browser(opts) - end) - end, - }) -end - -return M diff --git a/modules/neovim/lua/packer/toggleterm.lua b/modules/neovim/lua/packer/toggleterm.lua deleted file mode 100644 index 88da4e7..0000000 --- a/modules/neovim/lua/packer/toggleterm.lua +++ /dev/null @@ -1,79 +0,0 @@ -local M = {} - -M.packer = function(use) - use({ - "akinsho/toggleterm.nvim", - tag = "v2.1.0", - config = function() - require("toggleterm").setup({ - open_mapping = [[]], - hide_numbers = true, - direction = "float", - }) - - vim.keymap.set("t", "", "") --- Exit terminal mode - - -- Only set these keymaps for toggleterm - vim.api.nvim_create_autocmd("TermOpen", { - pattern = "term://*toggleterm#*", - callback = function() - -- vim.keymap.set("t", "", "") --- Exit terminal mode - vim.keymap.set("t", "", "h") - vim.keymap.set("t", "", "j") - vim.keymap.set("t", "", "k") - vim.keymap.set("t", "", "l") - end, - }) - - local terminal = require("toggleterm.terminal").Terminal - - local basicterminal = terminal:new() - function TERM_TOGGLE() - basicterminal:toggle() - end - - local nixpkgs = terminal:new({ cmd = "nix repl ''" }) - function NIXPKGS_TOGGLE() - nixpkgs:toggle() - end - - local gitwatch = terminal:new({ cmd = "fish --interactive --init-command 'gh run watch'" }) - function GITWATCH_TOGGLE() - gitwatch:toggle() - end - - local k9s = terminal:new({ cmd = "k9s" }) - function K9S_TOGGLE() - k9s:toggle() - end - - vim.keymap.set("n", "t", TERM_TOGGLE) - vim.keymap.set("n", "P", NIXPKGS_TOGGLE) - vim.keymap.set("n", "gw", GITWATCH_TOGGLE) - vim.keymap.set("n", "", K9S_TOGGLE) - end, - }) - - -- Connect to telescope - -- use({ - -- "https://git.sr.ht/~havi/telescope-toggleterm.nvim", - -- event = "TermOpen", - -- requires = { - -- "akinsho/nvim-toggleterm.lua", - -- "nvim-telescope/telescope.nvim", - -- "nvim-lua/popup.nvim", - -- "nvim-lua/plenary.nvim", - -- }, - -- config = function() - -- require("telescope").load_extension("toggleterm") - -- require("telescope-toggleterm").setup({ - -- telescope_mappings = { - -- -- : kill the terminal buffer (default) . - -- [""] = require("telescope-toggleterm").actions.exit_terminal, - -- }, - -- }) - -- end, - -- }) -end - -return M diff --git a/modules/neovim/lua/packer/visuals.lua b/modules/neovim/lua/packer/visuals.lua deleted file mode 100644 index bca77b3..0000000 --- a/modules/neovim/lua/packer/visuals.lua +++ /dev/null @@ -1,164 +0,0 @@ -local M = {} - -M.packer = function(use) - -- Git next to line numbers - use({ - "lewis6991/gitsigns.nvim", - branch = "main", - requires = { "nvim-lua/plenary.nvim" }, - config = function() - local gitsigns = require("gitsigns") - gitsigns.setup() - vim.keymap.set("n", "gB", gitsigns.blame_line) - vim.keymap.set("n", "gp", gitsigns.preview_hunk) - vim.keymap.set("v", "gp", gitsigns.preview_hunk) - vim.keymap.set("n", "gd", gitsigns.diffthis) - vim.keymap.set("v", "gd", gitsigns.diffthis) - vim.keymap.set("n", "rgf", gitsigns.reset_buffer) - vim.keymap.set("v", "hs", gitsigns.stage_hunk) - vim.keymap.set("v", "hr", gitsigns.reset_hunk) - vim.keymap.set("v", "hr", gitsigns.reset_hunk) - - -- Navigation - vim.keymap.set("n", "]g", function() - if vim.wo.diff then - return "]g" - end - vim.schedule(function() - gitsigns.next_hunk() - end) - return "" - end, { expr = true }) - - vim.keymap.set("n", "[g", function() - if vim.wo.diff then - return "[g" - end - vim.schedule(function() - gitsigns.prev_hunk() - end) - return "" - end, { expr = true }) - end, - }) - - -- Status bar - use({ - "hoob3rt/lualine.nvim", - requires = { "kyazdani42/nvim-web-devicons", opt = true }, - config = function() - require("lualine").setup({ - options = { - theme = "gruvbox", - icons_enabled = true, - }, - }) - end, - }) - - -- Buffer line ("tabs") - use({ - "akinsho/bufferline.nvim", - tag = "v2.4.0", - requires = { "kyazdani42/nvim-web-devicons", "moll/vim-bbye" }, - config = function() - require("bufferline").setup({ - options = { - diagnostics = "nvim_lsp", - always_show_bufferline = false, - separator_style = "slant", - offsets = { { filetype = "NvimTree" } }, - }, - }) - -- Move buffers - vim.keymap.set("n", "L", ":BufferLineCycleNext", { silent = true }) - vim.keymap.set("n", "H", ":BufferLineCyclePrev", { silent = true }) - - -- Kill buffer - vim.keymap.set("n", "x", " :Bdelete", { silent = true }) - - -- Shift buffers - -- vim.keymap.set("n", "", ":BufferLineMoveNext") - -- vim.keymap.set("i", "", ":BufferLineMoveNexti") - -- vim.keymap.set("n", "", ":BufferLineMovePrev") - -- vim.keymap.set("i", "", ":BufferLineMovePrevi") - end, - }) - - -- File explorer - use({ - "kyazdani42/nvim-tree.lua", - requires = { "kyazdani42/nvim-web-devicons" }, - config = function() - require("nvim-tree").setup({ - disable_netrw = true, - hijack_netrw = true, - update_focused_file = { - enable = true, - update_cwd = true, - ignore_list = {}, - }, - diagnostics = { - enable = true, - icons = { - hint = "", - info = "", - warning = "", - error = "", - }, - }, - renderer = { - icons = { - glyphs = { - git = { - unstaged = "~", - staged = "+", - unmerged = "", - renamed = "➜", - deleted = "", - untracked = "?", - ignored = "◌", - }, - }, - }, - }, - view = { - width = 30, - hide_root_folder = false, - side = "left", - mappings = { - custom_only = false, - list = { - { - key = { "l", "", "o" }, - cb = require("nvim-tree.config").nvim_tree_callback("edit"), - }, - { key = "h", cb = require("nvim-tree.config").nvim_tree_callback("close_node") }, - { key = "v", cb = require("nvim-tree.config").nvim_tree_callback("vsplit") }, - }, - }, - number = false, - relativenumber = false, - }, - }) - vim.keymap.set("n", "e", ":NvimTreeFindFileToggle", { silent = true }) - - -- https://github.com/kyazdani42/nvim-tree.lua/commit/fb8735e96cecf004fbefb086ce85371d003c5129 - vim.g.loaded = 1 - vim.g.loaded_netrwPlugin = 1 - end, - }) - - -- Markdown pretty view - use("ellisonleao/glow.nvim") - - -- Hex color previews - use({ - "norcalli/nvim-colorizer.lua", - config = function() - require("colorizer").setup() - end, - }) -end - -return M diff --git a/modules/neovim/lua/packer_init.lua b/modules/neovim/lua/packer_init.lua deleted file mode 100644 index 519c893..0000000 --- a/modules/neovim/lua/packer_init.lua +++ /dev/null @@ -1,34 +0,0 @@ --- Bootstrap the Packer plugin manager -local fn = vim.fn -local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" -if fn.empty(fn.glob(install_path)) > 0 then - PACKER_BOOTSTRAP = fn.system({ - "git", - "clone", - "--depth", - "1", - "https://github.com/wbthomason/packer.nvim", - install_path, - }) -end - -require("packer").startup(function(use) - -- Maintain plugin manager - use("wbthomason/packer.nvim") - - -- Include other files initialized by packer - require("packer.speed").packer(use) - require("packer.misc").packer(use) - require("packer.colors").packer(use) - require("packer.visuals").packer(use) - require("packer.lsp").packer(use) - require("packer.completion").packer(use) - require("packer.syntax").packer(use) - require("packer.telescope").packer(use) - require("packer.toggleterm").packer(use) - - -- Auto-install after bootstrapping - if PACKER_BOOTSTRAP then - require("packer").sync() - end -end) diff --git a/modules/neovim/lua/settings.lua b/modules/neovim/lua/settings.lua deleted file mode 100644 index 913be33..0000000 --- a/modules/neovim/lua/settings.lua +++ /dev/null @@ -1,116 +0,0 @@ --- =========================================================================== --- Settings --- =========================================================================== - -vim.o.termguicolors = true --- Set to truecolor -vim.o.hidden = true --- Don't unload buffers when leaving them -vim.wo.number = true --- Show line numbers -vim.wo.relativenumber = true --- Relative numbers instead of absolute -vim.o.list = true --- Reveal whitespace with dashes -vim.o.expandtab = true --- Tabs into spaces -vim.o.shiftwidth = 4 --- Amount to shift with > key -vim.o.softtabstop = 4 --- Amount to shift with key -vim.o.ignorecase = true --- Ignore case when searching -vim.o.smartcase = true --- Check case when using capitals in search -vim.o.infercase = true --- Don't match cases when completing suggestions -vim.o.incsearch = true --- Search while typing -vim.o.visualbell = true --- No sounds -vim.o.scrolljump = 1 --- Number of lines to scroll -vim.o.scrolloff = 3 --- Margin of lines to see while scrolling -vim.o.splitright = true --- Vertical splits on the right side -vim.o.splitbelow = true --- Horizontal splits on the bottom side -vim.o.pastetoggle = "" --- Use F3 to enter raw paste mode -vim.o.clipboard = "unnamedplus" --- Uses system clipboard for yanking -vim.o.updatetime = 300 --- Faster diagnostics -vim.o.mouse = "nv" --- Mouse interaction / scrolling - --- Neovim features -vim.o.inccommand = "split" --- Live preview search and replace ---- Required for nvim-cmp completion -vim.opt.completeopt = { - "menu", - "menuone", - "noselect", -} --- Required until 0.6.0: do not source the default filetype.vim -vim.g.did_load_filetypes = 1 - --- Remember last position when reopening file -vim.api.nvim_exec( - [[ - au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif -]], - false -) - --- Better backup, swap and undo storage -vim.o.backup = true --- Easier to recover and more secure -vim.bo.swapfile = false --- Instead of swaps, create backups -vim.bo.undofile = true --- Keeps undos after quit - --- Create backup directories if they don't exist --- Should be fixed in 0.6 by https://github.com/neovim/neovim/pull/15433 -vim.o.backupdir = vim.fn.stdpath("cache") .. "/backup" -vim.api.nvim_exec( - [[ - if !isdirectory(&backupdir) - call mkdir(&backupdir, "p") - endif -]], - false -) - --- LaTeX options -vim.api.nvim_exec( - [[ - au FileType tex inoremap ;bf \textbf{}i - au BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw! -]], - false -) - --- Highlight when yanking -vim.api.nvim_exec( - [[ - au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 250 } -]], - false -) - --- Netrw -vim.g.netrw_liststyle = 3 -- Change style to 'tree' view -vim.g.netrw_banner = 0 -- Remove useless banner -vim.g.netrw_winsize = 15 -- Explore window takes % of page -vim.g.netrw_browse_split = 4 -- Open in previous window -vim.g.netrw_altv = 1 -- Always split left - --- VimWiki -vim.g.vimwiki_list = { - { - ["path"] = "$NOTES_PATH", - ["syntax"] = "markdown", - ["index"] = "home", - ["ext"] = ".md", - }, -} -vim.g.vimwiki_key_mappings = { - ["all_maps"] = 1, - ["mouse"] = 1, -} -vim.g.vimwiki_auto_chdir = 1 -- Set local dir to Wiki when open -vim.g.vimwiki_create_link = 0 -- Don't automatically create new links -vim.g.vimwiki_listsyms = " x" -- Set checkbox symbol progression -vim.g.vimwiki_table_mappings = 0 -- VimWiki table keybinds interfere with tab completion -vim.api.nvim_exec( - [[ - au FileType markdown inoremap ;tt :AddTag - - function! PInsert(item) - let @z=a:item - norm "zpx - endfunction - - command! AddTag call fzf#run({'source': 'rg "#[A-Za-z/]+[ |\$]" -o --no-filename --no-line-number | sort | uniq', 'sink': function('PInsert')}) -]], - false -) diff --git a/modules/applications/calibre.nix b/modules/nixos/applications/calibre.nix similarity index 55% rename from modules/applications/calibre.nix rename to modules/nixos/applications/calibre.nix index 09e643a..1a65f0f 100644 --- a/modules/applications/calibre.nix +++ b/modules/nixos/applications/calibre.nix @@ -1,6 +1,15 @@ { config, pkgs, lib, ... }: { - config = lib.mkIf config.gui.enable { + options = { + calibre = { + enable = lib.mkEnableOption { + description = "Enable Calibre."; + default = false; + }; + }; + }; + + config = lib.mkIf (config.gui.enable && config.calibre.enable) { home-manager.users.${config.user} = { home.packages = with pkgs; [ calibre ]; # home.sessionVariables = { CALIBRE_USE_DARK_PALETTE = 1; }; diff --git a/modules/nixos/applications/default.nix b/modules/nixos/applications/default.nix new file mode 100644 index 0000000..4b80379 --- /dev/null +++ b/modules/nixos/applications/default.nix @@ -0,0 +1,5 @@ +{ ... }: { + + imports = [ ./calibre.nix ./nautilus.nix ]; + +} diff --git a/modules/nixos/applications/nautilus.nix b/modules/nixos/applications/nautilus.nix new file mode 100644 index 0000000..89138f5 --- /dev/null +++ b/modules/nixos/applications/nautilus.nix @@ -0,0 +1,55 @@ +{ config, pkgs, lib, ... }: { + + options = { + nautilus = { + enable = lib.mkEnableOption { + description = "Enable Nautilus file manager."; + default = false; + }; + }; + }; + + # Install Nautilus file manager + config = lib.mkIf (config.gui.enable && config.nautilus.enable) { + + # Quick preview with spacebar + services.gnome.sushi.enable = true; + environment.systemPackages = [ pkgs.gnome.nautilus ]; + + home-manager.users.${config.user} = { + + xsession.windowManager.i3.config.keybindings = { + "${ + config.home-manager.users.${config.user}.xsession.windowManager.i3.config.modifier + }+n" = "exec --no-startup-id ${pkgs.gnome.nautilus}/bin/nautilus"; + }; + + programs.fish.functions = { + qr = { + body = + "${pkgs.qrencode}/bin/qrencode $argv[1] -o /tmp/qr.png | ${pkgs.gnome.sushi}/bin/sushi /tmp/qr.png"; + }; + }; + + # Set default for opening directories + xdg.mimeApps = { + associations.added."inode/directory" = [ "org.gnome.Nautilus.desktop" ]; + # associations.removed = { + # "inode/directory" = [ "kitty-open.desktop" ]; + # }; + defaultApplications."inode/directory" = + lib.mkBefore [ "org.gnome.Nautilus.desktop" ]; + }; + }; + + # # Set default for opening directories + # xdg.mime = { + # addedAssociations."inode/directory" = [ "org.gnome.Nautilus.desktop" ]; + # removedAssociations = { "inode/directory" = [ "kitty-open.desktop" ]; }; + # defaultApplications."inode/directory" = + # lib.mkForce [ "org.gnome.Nautilus.desktop" ]; + # }; + + }; + +} diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index b5cc4b8..6fe5346 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -1,9 +1,6 @@ -{ config, ... }: { +{ ... }: { - imports = [ ./user.nix ./timezone.nix ./doas.nix ]; - - # Pin a state version to prevent warnings - system.stateVersion = - config.home-manager.users.${config.user}.home.stateVersion; + imports = + [ ./applications ./gaming ./graphical ./hardware ./services ./system ]; } diff --git a/modules/nixos/doas.nix b/modules/nixos/doas.nix deleted file mode 100644 index bbe48b8..0000000 --- a/modules/nixos/doas.nix +++ /dev/null @@ -1,30 +0,0 @@ -# Replace sudo with doas - -{ config, ... }: { - - security = { - - # Remove sudo - sudo.enable = false; - - # Add doas - doas = { - enable = true; - - # No password required - wheelNeedsPassword = false; - - # Pass environment variables from user to root - # Also requires removing password here - extraRules = [{ - groups = [ "wheel" ]; - noPass = true; - keepEnv = true; - }]; - }; - }; - - home-manager.users.${config.user}.programs.fish.shellAliases = { - sudo = "doas"; - }; -} diff --git a/modules/nixos/gaming/chiaki.nix b/modules/nixos/gaming/chiaki.nix new file mode 100644 index 0000000..520e636 --- /dev/null +++ b/modules/nixos/gaming/chiaki.nix @@ -0,0 +1,10 @@ +{ config, pkgs, lib, ... }: { + + options.gaming.chiaki.enable = + lib.mkEnableOption "Chiaki PlayStation remote play client."; + + config = lib.mkIf config.gaming.chiaki.enable { + environment.systemPackages = with pkgs; [ chiaki ]; + }; + +} diff --git a/modules/nixos/gaming/default.nix b/modules/nixos/gaming/default.nix new file mode 100644 index 0000000..fb12519 --- /dev/null +++ b/modules/nixos/gaming/default.nix @@ -0,0 +1,24 @@ +{ config, pkgs, lib, ... }: { + + imports = [ + ./chiaki.nix + ./dwarf-fortress.nix + ./leagueoflegends.nix + ./legendary.nix + ./lutris.nix + ./minecraft-server.nix + ./ryujinx.nix + ./steam.nix + ]; + + options.gaming.enable = lib.mkEnableOption "Enable gaming features."; + + config = lib.mkIf (config.gaming.enable && pkgs.stdenv.isLinux) { + hardware.opengl = { + enable = true; + driSupport = true; + driSupport32Bit = true; + }; + programs.gamemode.enable = true; + }; +} diff --git a/modules/nixos/gaming/dwarf-fortress.nix b/modules/nixos/gaming/dwarf-fortress.nix new file mode 100644 index 0000000..f48b552 --- /dev/null +++ b/modules/nixos/gaming/dwarf-fortress.nix @@ -0,0 +1,29 @@ +{ config, pkgs, lib, ... }: { + + options.gaming.dwarf-fortress.enable = + lib.mkEnableOption "Dwarf Fortress free edition."; + + config = lib.mkIf config.gaming.dwarf-fortress.enable { + unfreePackages = [ "dwarf-fortress" ]; + environment.systemPackages = let + dfDesktopItem = pkgs.makeDesktopItem { + name = "dwarf-fortress"; + desktopName = "Dwarf Fortress"; + exec = "${pkgs.dwarf-fortress-packages.dwarf-fortress-full}/bin/dfhack"; + terminal = false; + }; + dtDesktopItem = pkgs.makeDesktopItem { + name = "dwarftherapist"; + desktopName = "Dwarf Therapist"; + exec = + "${pkgs.dwarf-fortress-packages.dwarf-fortress-full}/bin/dwarftherapist"; + terminal = false; + }; + in [ + pkgs.dwarf-fortress-packages.dwarf-fortress-full + dfDesktopItem + dtDesktopItem + ]; + }; + +} diff --git a/modules/nixos/gaming/leagueoflegends.nix b/modules/nixos/gaming/leagueoflegends.nix new file mode 100644 index 0000000..2950d47 --- /dev/null +++ b/modules/nixos/gaming/leagueoflegends.nix @@ -0,0 +1,32 @@ +{ config, pkgs, lib, ... }: { + + options.gaming.leagueoflegends.enable = + lib.mkEnableOption "League of Legends"; + + config = + lib.mkIf (config.gaming.leagueoflegends.enable && pkgs.stdenv.isLinux) { + + # League of Legends anti-cheat requirement + boot.kernel.sysctl = { "abi.vsyscall32" = 0; }; + + environment.systemPackages = with pkgs; [ + + # Lutris requirement to install the game + lutris + amdvlk + wineWowPackages.stable + # vulkan-tools + + # Required according to https://lutris.net/games/league-of-legends/ + openssl + gnome.zenity + + # Don't remember if this is required + dconf + + ]; + + environment.sessionVariables = { QT_X11_NO_MITSHM = "1"; }; + + }; +} diff --git a/modules/gaming/legendary.nix b/modules/nixos/gaming/legendary.nix similarity index 88% rename from modules/gaming/legendary.nix rename to modules/nixos/gaming/legendary.nix index 11269bc..ead410f 100644 --- a/modules/gaming/legendary.nix +++ b/modules/nixos/gaming/legendary.nix @@ -4,14 +4,14 @@ let home-packages = config.home-manager.users.${config.user}.home.packages; in { - options.gaming.legendary = - lib.mkEnableOption "Legendary - Epic Games Launcher"; + options.gaming.legendary.enable = + lib.mkEnableOption "Legendary Epic Games launcher."; - config = lib.mkIf config.gaming.legendary { + config = lib.mkIf config.gaming.legendary.enable { environment.systemPackages = with pkgs; [ legendary-gl - rare # GUI for Legendary (not working) wineWowPackages.stable # 32-bit and 64-bit wineWowPackages, see https://nixos.wiki/wiki/Wine + heroic # GUI launcher ]; home-manager.users.${config.user} = { diff --git a/modules/gaming/lutris.nix b/modules/nixos/gaming/lutris.nix similarity index 64% rename from modules/gaming/lutris.nix rename to modules/nixos/gaming/lutris.nix index a8cac00..d2783e3 100644 --- a/modules/gaming/lutris.nix +++ b/modules/nixos/gaming/lutris.nix @@ -1,8 +1,8 @@ { config, pkgs, lib, ... }: { - options.gaming.lutris = lib.mkEnableOption "Lutris"; + options.gaming.lutris.enable = lib.mkEnableOption "Lutris game installer."; - config = lib.mkIf config.gaming.lutris { + config = lib.mkIf config.gaming.lutris.enable { environment.systemPackages = with pkgs; [ lutris amdvlk # Vulkan drivers (probably already installed) diff --git a/modules/nixos/gaming/minecraft-server.nix b/modules/nixos/gaming/minecraft-server.nix new file mode 100644 index 0000000..34c6562 --- /dev/null +++ b/modules/nixos/gaming/minecraft-server.nix @@ -0,0 +1,152 @@ +{ config, pkgs, lib, ... }: + +let + + localPort = 25564; + publicPort = 49732; + rconPort = 25575; + rconPassword = "thiscanbeanything"; + +in { + + options.gaming.minecraft-server.enable = + lib.mkEnableOption "Minecraft Server."; + + config = lib.mkIf config.gaming.minecraft-server.enable { + + unfreePackages = [ "minecraft-server" ]; + + services.minecraft-server = { + enable = true; + eula = true; + declarative = true; + whitelist = { }; + openFirewall = false; + serverProperties = { + server-port = localPort; + difficulty = "normal"; + gamemode = "survival"; + white-list = false; + enforce-whitelist = false; + level-name = "world"; + motd = "Welcome!"; + pvp = true; + player-idle-timeout = 30; + generate-structures = true; + max-players = 20; + snooper-enabled = false; + spawn-npcs = true; + spawn-animals = true; + spawn-monsters = true; + allow-nether = true; + allow-flight = false; + enable-rcon = true; + "rcon.port" = rconPort; + "rcon.password" = rconPassword; + }; + }; + + networking.firewall.allowedTCPPorts = [ publicPort ]; + + ## Automatically start and stop Minecraft server based on player connections + + # Adapted shamelessly from: + # https://dataswamp.org/~solene/2022-08-20-on-demand-minecraft-with-systemd.html + + # Prevent Minecraft from starting by default + systemd.services.minecraft-server = { wantedBy = pkgs.lib.mkForce [ ]; }; + + # Listen for connections on the public port, to trigger the actual + # listen-minecraft service. + systemd.sockets.listen-minecraft = { + wantedBy = [ "sockets.target" ]; + requires = [ "network.target" ]; + listenStreams = [ "${toString publicPort}" ]; + }; + + # Proxy traffic to local port, and trigger hook-minecraft + systemd.services.listen-minecraft = { + path = [ pkgs.systemd ]; + requires = [ "hook-minecraft.service" "listen-minecraft.socket" ]; + after = [ "hook-minecraft.service" "listen-minecraft.socket" ]; + serviceConfig.ExecStart = + "${pkgs.systemd.out}/lib/systemd/systemd-socket-proxyd 127.0.0.1:${ + toString localPort + }"; + }; + + # Start Minecraft if required and wait for it to be available + # Then unlock the listen-minecraft.service + systemd.services.hook-minecraft = { + path = with pkgs; [ systemd libressl busybox ]; + + # Start Minecraft and the auto-shutdown timer + script = '' + systemctl start minecraft-server.service + systemctl start stop-minecraft.timer + ''; + + # Keep checking until the service is available + postStart = '' + for i in $(seq 60); do + if ${pkgs.libressl.nc}/bin/nc -z 127.0.0.1 ${ + toString localPort + } > /dev/null ; then + exit 0 + fi + ${pkgs.busybox.out}/bin/sleep 1 + done + exit 1 + ''; + }; + + # Run a player check on a schedule for auto-shutdown + systemd.timers.stop-minecraft = { + timerConfig = { + OnCalendar = "*-*-* *:*:0/20"; # Every 20 seconds + Unit = "stop-minecraft.service"; + }; + }; + + # If no players are connected, then stop services and prepare to resume again + systemd.services.stop-minecraft = { + serviceConfig.Type = "oneshot"; + script = '' + # Check when service was launched + servicestartsec=$( + date -d \ + "$(systemctl show \ + --property=ActiveEnterTimestamp \ + minecraft-server.service \ + | cut -d= -f2)" \ + +%s) + + # Calculate elapsed time + serviceelapsedsec=$(( $(date +%s) - servicestartsec)) + + # Ignore if service just started + if [ $serviceelapsedsec -lt 180 ] + then + echo "Server was just started" + exit 0 + fi + + PLAYERS=$( + printf "list\n" \ + | ${pkgs.rcon.out}/bin/rcon -m \ + -H 127.0.0.1 -p ${builtins.toString rconPort} -P ${rconPassword} \ + ) + + if echo "$PLAYERS" | grep "are 0 of a" + then + echo "Stopping server" + systemctl stop minecraft-server.service + systemctl stop hook-minecraft.service + systemctl stop stop-minecraft.timer + fi + ''; + }; + + }; + +} diff --git a/modules/nixos/gaming/ryujinx.nix b/modules/nixos/gaming/ryujinx.nix new file mode 100644 index 0000000..d31df5a --- /dev/null +++ b/modules/nixos/gaming/ryujinx.nix @@ -0,0 +1,17 @@ +{ config, pkgs, lib, ... }: { + + options.gaming.ryujinx.enable = + lib.mkEnableOption "Ryujinx Nintendo Switch application."; + + config = lib.mkIf config.gaming.ryujinx.enable { + environment.systemPackages = with pkgs; [ ryujinx ]; + + home-manager.users.${config.user}.xdg.desktopEntries.ryujinx = + lib.mkIf pkgs.stdenv.isLinux { + name = "Ryujinx"; + exec = + "env DOTNET_EnableAlternateStackCheck=1 Ryujinx -r /home/${config.user}/media/games/ryujinx/ %f"; + }; + }; + +} diff --git a/modules/nixos/gaming/steam.nix b/modules/nixos/gaming/steam.nix new file mode 100644 index 0000000..e6dc5ef --- /dev/null +++ b/modules/nixos/gaming/steam.nix @@ -0,0 +1,27 @@ +{ config, pkgs, lib, ... }: { + + options.gaming.steam.enable = lib.mkEnableOption "Steam game launcher."; + + config = lib.mkIf (config.gaming.steam.enable && pkgs.stdenv.isLinux) { + hardware.steam-hardware.enable = true; + unfreePackages = [ "steam" "steam-original" "steamcmd" "steam-run" ]; + + programs.steam = { + enable = true; + remotePlay.openFirewall = true; + }; + + environment.systemPackages = with pkgs; [ + + # Enable terminal interaction + steamPackages.steamcmd + steam-tui + + # Allow downloading of GE-Proton and other versions + protonup-qt + + ]; + + }; + +} diff --git a/modules/nixos/graphical/default.nix b/modules/nixos/graphical/default.nix new file mode 100644 index 0000000..018dd77 --- /dev/null +++ b/modules/nixos/graphical/default.nix @@ -0,0 +1,54 @@ +{ lib, ... }: { + + imports = [ + ./dunst.nix + ./fonts.nix + ./i3.nix + ./picom.nix + ./polybar.nix + ./rofi.nix + ./xorg.nix + ]; + + options = { + + launcherCommand = lib.mkOption { + type = lib.types.str; + description = "Command to use for launching"; + }; + systemdSearch = lib.mkOption { + type = lib.types.str; + description = "Command to use for interacting with systemd"; + }; + altTabCommand = lib.mkOption { + type = lib.types.str; + description = "Command to use for choosing windows"; + }; + audioSwitchCommand = lib.mkOption { + type = lib.types.str; + description = "Command to use for switching audio sink"; + }; + brightnessCommand = lib.mkOption { + type = lib.types.str; + description = "Command to use for adjusting brightness"; + }; + calculatorCommand = lib.mkOption { + type = lib.types.str; + description = "Command to use for quick calculations"; + }; + toggleBarCommand = lib.mkOption { + type = lib.types.str; + description = "Command to hide and show the status bar."; + }; + powerCommand = lib.mkOption { + type = lib.types.str; + description = "Command to use for power options menu"; + }; + wallpaper = lib.mkOption { + type = lib.types.path; + description = "Wallpaper background image file"; + }; + + }; + +} diff --git a/modules/graphical/dmenu.nix b/modules/nixos/graphical/dmenu.nix similarity index 53% rename from modules/graphical/dmenu.nix rename to modules/nixos/graphical/dmenu.nix index 9ada181..962f8ae 100644 --- a/modules/graphical/dmenu.nix +++ b/modules/nixos/graphical/dmenu.nix @@ -2,7 +2,9 @@ { - config = lib.mkIf config.services.xserver.enable { + options.gui.dmenu.enable = lib.mkEnableOption "dmenu launcher."; + + config = lib.mkIf (config.services.xserver.enable && config.dmenu.enable) { home-manager.users.${config.user}.home.packages = [ pkgs.dmenu ]; gui.launcherCommand = "${pkgs.dmenu}/bin/dmenu_run"; diff --git a/modules/nixos/graphical/dunst.nix b/modules/nixos/graphical/dunst.nix new file mode 100644 index 0000000..7700dbf --- /dev/null +++ b/modules/nixos/graphical/dunst.nix @@ -0,0 +1,31 @@ +{ config, ... }: + +{ + + config = { + + home-manager.users.${config.user}.services.dunst = { + enable = false; + settings = { + global = { + width = 300; + height = 200; + offset = "30x50"; + origin = "top-right"; + transparency = 0; + padding = 20; + horizontal_padding = 20; + frame_color = config.theme.colors.base03; + }; + + urgency_normal = { + background = config.theme.colors.base00; + foreground = config.theme.colors.base05; + timeout = 10; + }; + }; + }; + + }; + +} diff --git a/modules/graphical/fonts.nix b/modules/nixos/graphical/fonts.nix similarity index 79% rename from modules/graphical/fonts.nix rename to modules/nixos/graphical/fonts.nix index ae81955..c081450 100644 --- a/modules/graphical/fonts.nix +++ b/modules/nixos/graphical/fonts.nix @@ -4,7 +4,7 @@ let fontName = "Victor Mono"; in { - config = lib.mkIf config.gui.enable { + config = lib.mkIf (config.gui.enable && pkgs.stdenv.isLinux) { fonts.fonts = with pkgs; [ victor-mono # Used for Vim and Terminal @@ -21,6 +21,8 @@ in { services.polybar.config."bar/main".font-0 = "Hack Nerd Font:size=10;2"; programs.rofi.font = "Hack Nerd Font 14"; programs.alacritty.settings.font.normal.family = fontName; + programs.kitty.font.name = fontName; + services.dunst.settings.global.font = "Hack Nerd Font 14"; }; }; diff --git a/modules/graphical/i3.nix b/modules/nixos/graphical/i3.nix similarity index 77% rename from modules/graphical/i3.nix rename to modules/nixos/graphical/i3.nix index 6c01f65..9d6c533 100644 --- a/modules/graphical/i3.nix +++ b/modules/nixos/graphical/i3.nix @@ -5,17 +5,14 @@ let lockCmd = "${pkgs.betterlockscreen}/bin/betterlockscreen --lock --display 1 --blur 0.5 --span"; lockUpdate = - "${pkgs.betterlockscreen}/bin/betterlockscreen --update ${config.gui.wallpaper} --display 1 --span"; + "${pkgs.betterlockscreen}/bin/betterlockscreen --update ${config.wallpaper} --display 1 --span"; in { - config = lib.mkIf config.services.xserver.enable { + config = lib.mkIf pkgs.stdenv.isLinux { services.xserver.windowManager = { - i3 = { - enable = true; - package = pkgs.i3-gaps; - }; + i3 = { enable = config.services.xserver.enable; }; }; environment.systemPackages = with pkgs; [ @@ -25,8 +22,7 @@ in { home-manager.users.${config.user} = { xsession.windowManager.i3 = { - enable = true; - package = pkgs.i3-gaps; + enable = config.services.xserver.enable; config = let modifier = "Mod4"; # Super key ws1 = "1:I"; @@ -43,22 +39,26 @@ in { modifier = modifier; assigns = { "${ws1}" = [{ class = "Firefox"; }]; - "${ws2}" = [{ class = "Alacritty"; }]; + "${ws2}" = [ + { class = "kitty"; } + { class = "aerc"; } + { class = "obsidian"; } + ]; "${ws3}" = [{ class = "discord"; }]; "${ws4}" = [{ class = "Steam"; }]; }; bars = [{ command = "echo"; }]; # Disable i3bar colors = let - background = config.colorscheme.base00; - inactiveBackground = config.colorscheme.base01; - border = config.colorscheme.base01; - inactiveBorder = config.colorscheme.base01; - text = config.colorscheme.base07; - inactiveText = config.colorscheme.base04; - urgentBackground = config.colorscheme.base08; + background = config.theme.colors.base00; + inactiveBackground = config.theme.colors.base01; + border = config.theme.colors.base01; + inactiveBorder = config.theme.colors.base01; + text = config.theme.colors.base07; + inactiveText = config.theme.colors.base04; + urgentBackground = config.theme.colors.base08; indicator = "#00000000"; in { - background = config.colorscheme.base00; + background = config.theme.colors.base00; focused = { inherit background indicator text border; childBorder = background; @@ -111,21 +111,33 @@ in { # Launchers "${modifier}+Return" = - "exec --no-startup-id alacritty; workspace ${ws2}; layout tabbed"; + "exec --no-startup-id kitty; workspace ${ws2}; layout tabbed"; "${modifier}+space" = - "exec --no-startup-id ${config.gui.launcherCommand}"; + "exec --no-startup-id ${config.launcherCommand}"; "${modifier}+Shift+s" = - "exec --no-startup-id ${config.gui.systemdSearch}"; - "Mod1+Tab" = "exec --no-startup-id ${config.gui.altTabCommand}"; + "exec --no-startup-id ${config.systemdSearch}"; + "${modifier}+Shift+a" = + "exec --no-startup-id ${config.audioSwitchCommand}"; + "Mod1+Tab" = "exec --no-startup-id ${config.altTabCommand}"; + "${modifier}+Shift+period" = + "exec --no-startup-id ${config.powerCommand}"; + "${modifier}+Shift+m" = + "exec --no-startup-id ${config.brightnessCommand}"; + "${modifier}+c" = + "exec --no-startup-id ${config.calculatorCommand}"; "${modifier}+Shift+c" = "reload"; "${modifier}+Shift+r" = "restart"; "${modifier}+Shift+q" = '' exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"''; "${modifier}+Shift+x" = "exec ${lockCmd}"; + "${modifier}+Mod1+h" = + "exec --no-startup-id kitty sh -c '${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#${config.networking.hostName} || read'"; + "${modifier}+Mod1+r" = + "exec --no-startup-id kitty sh -c 'doas nixos-rebuild switch --flake ${config.dotfilesPath}#${config.networking.hostName} || read'"; # Window options "${modifier}+q" = "kill"; - "${modifier}+b" = "exec ${config.gui.toggleBarCommand}"; + "${modifier}+b" = "exec ${config.toggleBarCommand}"; "${modifier}+f" = "fullscreen toggle"; "${modifier}+h" = "focus left"; "${modifier}+j" = "focus down"; @@ -205,12 +217,18 @@ in { modes = { }; startup = [ { - command = "feh --bg-fill ${config.gui.wallpaper}"; + command = "feh --bg-fill ${config.wallpaper}"; always = true; notification = false; } { - command = "i3-msg workspace ${ws1}"; + command = + "i3-msg workspace ${ws2}, move workspace to output right"; + notification = false; + } + { + command = + "i3-msg workspace ${ws1}, move workspace to output left"; notification = false; } ]; @@ -238,7 +256,7 @@ in { }; programs.fish.functions = { - update-lock-screen = { + update-lock-screen = lib.mkIf config.services.xserver.enable { description = "Update lockscreen with wallpaper"; body = lockUpdate; }; @@ -247,17 +265,19 @@ in { # Update lock screen cache only if cache is empty home.activation.updateLockScreenCache = let cacheDir = "${config.homePath}/.cache/betterlockscreen/current"; - in config.home-manager.users.${config.user}.lib.dag.entryAfter - [ "writeBoundary" ] '' - if [ ! -d ${cacheDir} ] || [ -z "$(ls ${cacheDir})" ]; then - $DRY_RUN_CMD ${lockUpdate} - fi - ''; + in lib.mkIf config.services.xserver.enable + (config.home-manager.users.${config.user}.lib.dag.entryAfter + [ "writeBoundary" ] '' + if [ ! -d ${cacheDir} ] || [ -z "$(ls ${cacheDir})" ]; then + $DRY_RUN_CMD ${lockUpdate} + fi + ''); }; # Ref: https://github.com/betterlockscreen/betterlockscreen/blob/next/system/betterlockscreen%40.service systemd.services.lock = { + enable = config.services.xserver.enable; description = "Lock the screen on resume from suspend"; before = [ "sleep.target" "suspend.target" ]; serviceConfig = { diff --git a/modules/nixos/graphical/picom.nix b/modules/nixos/graphical/picom.nix new file mode 100644 index 0000000..102d4d5 --- /dev/null +++ b/modules/nixos/graphical/picom.nix @@ -0,0 +1,48 @@ +{ config, pkgs, lib, ... }: { + + config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) { + home-manager.users.${config.user} = { + + services.picom = { + enable = true; + backend = "glx"; + settings = { + blur = false; + blurExclude = [ ]; + inactiveDim = "0.05"; + noDNDShadow = false; + noDockShadow = false; + # shadow-radius = 20 + # ''; + # shadow-radius = 20 + # corner-radius = 10 + # blur-size = 20 + # rounded-corners-exclude = [ + # "window_type = 'dock'", + # "class_g = 'i3-frame'" + # ] + # ''; + }; + fade = false; + inactiveOpacity = 1.0; + menuOpacity = 1.0; + opacityRules = [ + "0:_NET_WM_STATE@[0]:32a = '_NET_WM_STATE_HIDDEN'" # Hide tabbed windows + ]; + shadow = false; + shadowExclude = [ ]; + shadowOffsets = [ (-10) (-10) ]; + shadowOpacity = 0.5; + vSync = true; + }; + + xsession.windowManager.i3.config.startup = [{ + command = "systemctl --user restart picom"; + always = true; + notification = false; + }]; + + }; + }; + +} diff --git a/modules/graphical/polybar.nix b/modules/nixos/graphical/polybar.nix similarity index 69% rename from modules/graphical/polybar.nix rename to modules/nixos/graphical/polybar.nix index 761d2e7..385d938 100644 --- a/modules/graphical/polybar.nix +++ b/modules/nixos/graphical/polybar.nix @@ -1,17 +1,17 @@ { config, pkgs, lib, ... }: { - config = lib.mkIf config.services.xserver.enable { + config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) { - gui.toggleBarCommand = "polybar-msg cmd toggle"; + toggleBarCommand = "polybar-msg cmd toggle"; home-manager.users.${config.user} = { services.polybar = { enable = true; package = pkgs.polybar.override { - i3GapsSupport = true; pulseSupport = true; githubSupport = true; + i3Support = true; }; script = "polybar &"; config = { @@ -23,20 +23,20 @@ # offset-y = -5; # offset-y = "5%"; # dpi = 96; - background = config.colorscheme.base01; - foreground = config.colorscheme.base05; + background = config.theme.colors.base01; + foreground = config.theme.colors.base05; line-size = "3pt"; border-top-size = 0; border-right-size = 0; border-left-size = 0; border-bottom-size = "4pt"; - border-color = config.colorscheme.base00; + border-color = config.theme.colors.base00; padding-left = 2; padding-right = 2; module-margin = 1; modules-left = "i3"; modules-center = "xwindow"; - modules-right = "pulseaudio date"; + modules-right = "mailcount pulseaudio date power"; cursor-click = "pointer"; cursor-scroll = "ns-resize"; enable-ipc = true; @@ -58,35 +58,35 @@ fuzzy-match = true; format = " "; label-focused = "%name%"; - label-focused-foreground = config.colorscheme.base01; - label-focused-background = config.colorscheme.base05; - label-focused-underline = config.colorscheme.base03; + label-focused-foreground = config.theme.colors.base01; + label-focused-background = config.theme.colors.base05; + label-focused-underline = config.theme.colors.base03; label-focused-padding = padding; label-unfocused = "%name%"; label-unfocused-padding = padding; label-visible = "%name%"; - label-visible-underline = config.colorscheme.base01; + label-visible-underline = config.theme.colors.base01; label-visible-padding = padding; label-urgent = "%name%"; - label-urgent-foreground = config.colorscheme.base00; - label-urgent-background = config.colorscheme.base08; - label-urgent-underline = config.colorscheme.base0F; + label-urgent-foreground = config.theme.colors.base00; + label-urgent-background = config.theme.colors.base08; + label-urgent-underline = config.theme.colors.base0F; label-urgent-padding = padding; }; "module/xworkspaces" = { type = "internal/xworkspaces"; label-active = "%name%"; - label-active-background = config.colorscheme.base05; - label-active-foreground = config.colorscheme.base01; - label-active-underline = config.colorscheme.base03; + label-active-background = config.theme.colors.base05; + label-active-foreground = config.theme.colors.base01; + label-active-underline = config.theme.colors.base03; label-active-padding = 1; label-occupied = "%name%"; label-occupied-padding = 1; label-urgent = "%name%"; - label-urgent-background = config.colorscheme.base08; + label-urgent-background = config.theme.colors.base08; label-urgent-padding = 1; label-empty = "%name%"; - label-empty-foreground = config.colorscheme.base06; + label-empty-foreground = config.theme.colors.base06; label-empty-padding = 1; }; "module/xwindow" = { @@ -101,6 +101,23 @@ # label-unmounted = "%mountpoint% not mounted"; # label-unmounted-foreground = colors.disabled; # }; + "module/mailcount" = { + type = "custom/script"; + interval = 10; + format = "