diff --git a/apps/default.nix b/apps/default.nix index 659628c..83ddbc9 100644 --- a/apps/default.nix +++ b/apps/default.nix @@ -1,4 +1,5 @@ -{ pkgs, ... }: rec { +{ pkgs, ... }: +rec { # Show quick helper default = import ./help.nix { inherit pkgs; }; @@ -30,5 +31,4 @@ # 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 index 3a6838a..19f6f32 100644 --- a/apps/encrypt-secret.nix +++ b/apps/encrypt-secret.nix @@ -1,19 +1,19 @@ -{ pkgs, ... }: { +{ 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 ../misc/public-keys - } $tmpfile - rm $tmpfile - ''); - + 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 ../misc/public-keys} $tmpfile + rm $tmpfile + '' + ); } diff --git a/apps/format-root.nix b/apps/format-root.nix index c7449b4..59927c9 100644 --- a/apps/format-root.nix +++ b/apps/format-root.nix @@ -1,39 +1,41 @@ -{ pkgs, ... }: { +{ pkgs, ... }: +{ # This script will partition and format drives; use at your own risk! type = "app"; - program = builtins.toString (pkgs.writeShellScript "format-root" '' - set -e + program = builtins.toString ( + pkgs.writeShellScript "format-root" '' + set -e - DISK=$1 + 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 + 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.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.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}" - - ''); + ${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 index cb31b37..5ac7102 100644 --- a/apps/help.nix +++ b/apps/help.nix @@ -1,23 +1,25 @@ -{ pkgs, ... }: { +{ 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 "" - ''); - + 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/installer.nix b/apps/installer.nix index 69e1b7e..4609c52 100644 --- a/apps/installer.nix +++ b/apps/installer.nix @@ -1,48 +1,50 @@ -{ pkgs, ... }: { +{ pkgs, ... }: +{ # Inspired by https://github.com/cleverca22/nix-tests/blob/master/kexec/justdoit.nix # This script will partition and format drives; use at your own risk! type = "app"; - program = builtins.toString (pkgs.writeShellScript "installer" '' - set -e + program = builtins.toString ( + pkgs.writeShellScript "installer" '' + set -e - DISK=$1 - FLAKE=$2 - PARTITION_PREFIX="" + DISK=$1 + FLAKE=$2 + PARTITION_PREFIX="" - if [ -z "$DISK" ] || [ -z "$FLAKE" ]; then - ${pkgs.gum}/bin/gum style --width 50 --margin "1 2" --padding "2 4" \ - --foreground "#fb4934" \ - "Missing required parameter." \ - "Usage: installer -- " \ - "Example: installer -- nvme0n1 tempest" \ - "Flake example: nix run github:nmasur/dotfiles#installer -- nvme0n1 tempest" - echo "(exiting)" - exit 1 - fi + if [ -z "$DISK" ] || [ -z "$FLAKE" ]; then + ${pkgs.gum}/bin/gum style --width 50 --margin "1 2" --padding "2 4" \ + --foreground "#fb4934" \ + "Missing required parameter." \ + "Usage: installer -- " \ + "Example: installer -- nvme0n1 tempest" \ + "Flake example: nix run github:nmasur/dotfiles#installer -- nvme0n1 tempest" + echo "(exiting)" + exit 1 + fi - case "$DISK" in nvme*) - PARTITION_PREFIX="p" - esac + case "$DISK" in nvme*) + PARTITION_PREFIX="p" + esac - ${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.gum}/bin/gum confirm \ + "This will ERASE ALL DATA on the disk /dev/''${DISK}. Are you sure you want to continue?" \ + --default=false - ${pkgs.parted}/bin/parted /dev/''${DISK} -- mklabel gpt - ${pkgs.parted}/bin/parted /dev/''${DISK} -- mkpart primary 512MiB 100% - ${pkgs.parted}/bin/parted /dev/''${DISK} -- mkpart ESP fat32 1MiB 512MiB - ${pkgs.parted}/bin/parted /dev/''${DISK} -- set 3 esp on - mkfs.ext4 -L nixos /dev/''${DISK}''${PARTITION_PREFIX}1 - mkfs.fat -F 32 -n boot /dev/''${DISK}''${PARTITION_PREFIX}2 + ${pkgs.parted}/bin/parted /dev/''${DISK} -- mklabel gpt + ${pkgs.parted}/bin/parted /dev/''${DISK} -- mkpart primary 512MiB 100% + ${pkgs.parted}/bin/parted /dev/''${DISK} -- mkpart ESP fat32 1MiB 512MiB + ${pkgs.parted}/bin/parted /dev/''${DISK} -- set 3 esp on + mkfs.ext4 -L nixos /dev/''${DISK}''${PARTITION_PREFIX}1 + mkfs.fat -F 32 -n boot /dev/''${DISK}''${PARTITION_PREFIX}2 - mount /dev/disk/by-label/nixos /mnt - mkdir --parents /mnt/boot - mount /dev/disk/by-label/boot /mnt/boot - - ${pkgs.nixos-install-tools}/bin/nixos-install --flake github:nmasur/dotfiles#''${FLAKE} - ''); + mount /dev/disk/by-label/nixos /mnt + mkdir --parents /mnt/boot + mount /dev/disk/by-label/boot /mnt/boot + ${pkgs.nixos-install-tools}/bin/nixos-install --flake github:nmasur/dotfiles#''${FLAKE} + '' + ); } diff --git a/apps/loadkey.nix b/apps/loadkey.nix index 14cbf9c..3d2831a 100644 --- a/apps/loadkey.nix +++ b/apps/loadkey.nix @@ -1,13 +1,15 @@ -{ pkgs, ... }: { +{ 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" - mkdir -p ~/.ssh/ - ${pkgs.melt}/bin/melt restore ~/.ssh/id_ed25519 - printf "\n\nContinuing activation.\n\n" - ''); - + program = builtins.toString ( + pkgs.writeShellScript "loadkey" '' + printf "\nEnter the seed phrase for your SSH key...\n" + printf "\nThen press ^D when complete.\n\n" + mkdir -p ~/.ssh/ + ${pkgs.melt}/bin/melt restore ~/.ssh/id_ed25519 + printf "\n\nContinuing activation.\n\n" + '' + ); } diff --git a/apps/neovim.nix b/apps/neovim.nix index aa4e608..b027fb2 100644 --- a/apps/neovim.nix +++ b/apps/neovim.nix @@ -1,12 +1,12 @@ -{ pkgs, ... }: { +{ pkgs, ... }: +{ type = "app"; program = "${ - (import ../modules/common/neovim/package { - inherit pkgs; - colors = (import ../colorscheme/nord).dark; - }) - }/bin/nvim"; - + (import ../modules/common/neovim/package { + inherit pkgs; + colors = (import ../colorscheme/nord).dark; + }) + }/bin/nvim"; } diff --git a/apps/netdata-cloud.nix b/apps/netdata-cloud.nix index f98dbd7..9275df7 100644 --- a/apps/netdata-cloud.nix +++ b/apps/netdata-cloud.nix @@ -1,19 +1,21 @@ -{ pkgs, ... }: { +{ 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" - ''); - + 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 9507513..51ad625 100644 --- a/apps/readme.nix +++ b/apps/readme.nix @@ -1,9 +1,11 @@ -{ pkgs, ... }: { +{ pkgs, ... }: +{ type = "app"; - program = builtins.toString (pkgs.writeShellScript "readme" '' - ${pkgs.glow}/bin/glow --pager ${builtins.toString ../README.md} - ''); - + program = builtins.toString ( + pkgs.writeShellScript "readme" '' + ${pkgs.glow}/bin/glow --pager ${builtins.toString ../README.md} + '' + ); } diff --git a/apps/rebuild.nix b/apps/rebuild.nix index 973be25..90e69d5 100644 --- a/apps/rebuild.nix +++ b/apps/rebuild.nix @@ -1,15 +1,17 @@ -{ pkgs, ... }: { +{ 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 - ''); - + 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 index b6f1a52..0094c8d 100644 --- a/apps/reencrypt-secrets.nix +++ b/apps/reencrypt-secrets.nix @@ -1,27 +1,27 @@ -{ pkgs, ... }: { +{ 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 ../misc/public-keys - } $tmpfile > $encryptedfile - rm $tmpfile - done - echo "Finished." - ''); - + 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 ../misc/public-keys} $tmpfile > $encryptedfile + rm $tmpfile + done + echo "Finished." + '' + ); } diff --git a/colorscheme/everforest/default.nix b/colorscheme/everforest/default.nix index 3287ee2..ef9d299 100644 --- a/colorscheme/everforest/default.nix +++ b/colorscheme/everforest/default.nix @@ -16,9 +16,7 @@ base0B = "#dbbc7f"; # Strings, Inherited Class, Markup Code, Diff Inserted base0C = "#e69875"; # Support, Regular Expressions, Escape Characters, ... base0D = "#a7c080"; # Functions, Methods, Attribute IDs, Headings - base0E = - "#e67e80"; # Keywords, Storage, Selector, Markup Italic, Diff Changed - base0F = - "#d699b6"; # Deprecated, Opening/Closing Embedded Language Tags, ... + base0E = "#e67e80"; # Keywords, Storage, Selector, Markup Italic, Diff Changed + base0F = "#d699b6"; # Deprecated, Opening/Closing Embedded Language Tags, ... }; } diff --git a/colorscheme/gruvbox-dark/default.nix b/colorscheme/gruvbox-dark/default.nix index d8d84ef..6d01fa2 100644 --- a/colorscheme/gruvbox-dark/default.nix +++ b/colorscheme/gruvbox-dark/default.nix @@ -2,8 +2,7 @@ { name = "gruvbox-dark"; # Dark, Medium - author = - "Dawid Kurek (dawikur@gmail.com), morhetz (https://github.com/morhetz/gruvbox), ElRastaOk (https://www.reddit.com/user/ElRastaOk)"; + 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"; # --- diff --git a/colorscheme/gruvbox/default.nix b/colorscheme/gruvbox/default.nix index 945ba49..a969cda 100644 --- a/colorscheme/gruvbox/default.nix +++ b/colorscheme/gruvbox/default.nix @@ -1,7 +1,6 @@ { name = "gruvbox"; # Dark, Medium - author = - "Dawid Kurek (dawikur@gmail.com), morhetz (https://github.com/morhetz/gruvbox)"; + author = "Dawid Kurek (dawikur@gmail.com), morhetz (https://github.com/morhetz/gruvbox)"; dark = { base00 = "#282828"; # ---- base01 = "#3c3836"; # --- diff --git a/modules/common/applications/1password.nix b/modules/common/applications/1password.nix index 008d9ab..6d56653 100644 --- a/modules/common/applications/1password.nix +++ b/modules/common/applications/1password.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ options = { _1password = { @@ -10,9 +16,16 @@ }; config = lib.mkIf (config.gui.enable && config._1password.enable) { - unfreePackages = [ "1password" "_1password-gui" "1password-cli" ]; + unfreePackages = [ + "1password" + "_1password-gui" + "1password-cli" + ]; home-manager.users.${config.user} = { - home.packages = with pkgs; [ _1password-gui _1password ]; + home.packages = with pkgs; [ + _1password-gui + _1password + ]; }; # https://1password.community/discussion/135462/firefox-extension-does-not-connect-to-linux-app @@ -26,5 +39,4 @@ firefox ''; }; - } diff --git a/modules/common/applications/alacritty.nix b/modules/common/applications/alacritty.nix index e5e5310..9641f49 100644 --- a/modules/common/applications/alacritty.nix +++ b/modules/common/applications/alacritty.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ options = { alacritty = { @@ -28,7 +34,9 @@ opacity = 1.0; }; scrolling.history = 10000; - font = { size = 14.0; }; + font = { + size = 14.0; + }; key_bindings = [ # Used for word completion in fish_user_key_bindings { diff --git a/modules/common/applications/default.nix b/modules/common/applications/default.nix index c43a324..b48a61f 100644 --- a/modules/common/applications/default.nix +++ b/modules/common/applications/default.nix @@ -1,4 +1,5 @@ -{ ... }: { +{ ... }: +{ imports = [ ./1password.nix @@ -12,5 +13,4 @@ ./slack.nix ./yt-dlp.nix ]; - } diff --git a/modules/common/applications/discord.nix b/modules/common/applications/discord.nix index 1e3193c..d4978b6 100644 --- a/modules/common/applications/discord.nix +++ b/modules/common/applications/discord.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ options = { discord = { diff --git a/modules/common/applications/firefox.nix b/modules/common/applications/firefox.nix index 7968c38..f866ace 100644 --- a/modules/common/applications/firefox.nix +++ b/modules/common/applications/firefox.nix @@ -1,4 +1,9 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: { @@ -22,8 +27,7 @@ programs.firefox = { enable = true; - package = - if pkgs.stdenv.isDarwin then pkgs.firefox-bin else pkgs.firefox; + package = if pkgs.stdenv.isDarwin then pkgs.firefox-bin else pkgs.firefox; profiles.default = { id = 0; name = "default"; @@ -49,32 +53,24 @@ "app.update.auto" = false; "browser.aboutConfig.showWarning" = false; "browser.warnOnQuit" = false; - "browser.quitShortcut.disabled" = - if pkgs.stdenv.isLinux then true else false; + "browser.quitShortcut.disabled" = if pkgs.stdenv.isLinux then true else false; "browser.theme.dark-private-windows" = true; "browser.toolbars.bookmarks.visibility" = false; "browser.startup.page" = 3; # Restore previous session "browser.newtabpage.enabled" = false; # Make new tabs blank - "trailhead.firstrun.didSeeAboutWelcome" = - true; # Disable welcome splash + "trailhead.firstrun.didSeeAboutWelcome" = true; # Disable welcome splash "dom.forms.autocomplete.formautofill" = false; # Disable autofill - "extensions.formautofill.creditCards.enabled" = - false; # Disable credit cards + "extensions.formautofill.creditCards.enabled" = false; # Disable credit cards "dom.payments.defaults.saveAddress" = false; # Disable address save "general.autoScroll" = true; # Drag middle-mouse to scroll - "services.sync.prefs.sync.general.autoScroll" = - false; # Prevent disabling autoscroll + "services.sync.prefs.sync.general.autoScroll" = false; # Prevent disabling autoscroll "extensions.pocket.enabled" = false; - "toolkit.legacyUserProfileCustomizations.stylesheets" = - true; # Allow userChrome.css + "toolkit.legacyUserProfileCustomizations.stylesheets" = true; # Allow userChrome.css "layout.css.color-mix.enabled" = true; - "ui.systemUsesDarkTheme" = - if config.theme.dark == true then 1 else 0; - "media.ffmpeg.vaapi.enabled" = - true; # Enable hardware video acceleration + "ui.systemUsesDarkTheme" = if config.theme.dark == true then 1 else 0; + "media.ffmpeg.vaapi.enabled" = true; # Enable hardware video acceleration "cookiebanners.ui.desktop.enabled" = true; # Reject cookie popups - "devtools.command-button-screenshot.enabled" = - true; # Scrolling screenshot of entire page + "devtools.command-button-screenshot.enabled" = true; # Scrolling screenshot of entire page "svg.context-properties.content.enabled" = true; # Sidebery styling }; userChrome = '' @@ -160,33 +156,34 @@ extraConfig = ""; }; - }; xdg.mimeApps = { - associations.added = { "text.html" = [ "firefox.desktop" ]; }; - defaultApplications = { "text.html" = [ "firefox.desktop" ]; }; + associations.added = { + "text.html" = [ "firefox.desktop" ]; + }; + defaultApplications = { + "text.html" = [ "firefox.desktop" ]; + }; }; - xsession.windowManager.i3.config.keybindings = - lib.mkIf pkgs.stdenv.isLinux { - "${ - config.home-manager.users.${config.user}.xsession.windowManager.i3.config.modifier - }+Shift+b" = "exec ${ - # Don't name the script `firefox` or it will affect grep - builtins.toString (pkgs.writeShellScript "focus-ff.sh" '' - count=$(ps aux | grep -c firefox) - if [ "$count" -eq 1 ]; then - i3-msg "exec --no-startup-id firefox" - sleep 0.5 - fi - i3-msg "[class=firefox] focus" - '') - }"; - }; - + xsession.windowManager.i3.config.keybindings = lib.mkIf pkgs.stdenv.isLinux { + "${ + config.home-manager.users.${config.user}.xsession.windowManager.i3.config.modifier + }+Shift+b" = "exec ${ + # Don't name the script `firefox` or it will affect grep + builtins.toString ( + pkgs.writeShellScript "focus-ff.sh" '' + count=$(ps aux | grep -c firefox) + if [ "$count" -eq 1 ]; then + i3-msg "exec --no-startup-id firefox" + sleep 0.5 + fi + i3-msg "[class=firefox] focus" + '' + ) + }"; + }; }; - }; - } diff --git a/modules/common/applications/kitty.nix b/modules/common/applications/kitty.nix index bab7e90..4eb9d1f 100644 --- a/modules/common/applications/kitty.nix +++ b/modules/common/applications/kitty.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ options = { kitty = { @@ -13,20 +19,19 @@ # Set the Rofi-Systemd terminal for viewing logs # Using optionalAttrs because only available in NixOS - environment = { } // lib.attrsets.optionalAttrs - (builtins.hasAttr "sessionVariables" config.environment) { + environment = + { } + // lib.attrsets.optionalAttrs (builtins.hasAttr "sessionVariables" config.environment) { sessionVariables.ROFI_SYSTEMD_TERM = "${pkgs.kitty}/bin/kitty"; }; home-manager.users.${config.user} = { # Set the i3 terminal - xsession.windowManager.i3.config.terminal = - lib.mkIf pkgs.stdenv.isLinux "kitty"; + xsession.windowManager.i3.config.terminal = lib.mkIf pkgs.stdenv.isLinux "kitty"; # Set the Rofi terminal for running programs - programs.rofi.terminal = - lib.mkIf pkgs.stdenv.isLinux "${pkgs.kitty}/bin/kitty"; + programs.rofi.terminal = lib.mkIf pkgs.stdenv.isLinux "${pkgs.kitty}/bin/kitty"; # Display images in the terminal programs.fish.shellAliases = { @@ -48,16 +53,14 @@ # Kitty scrollback nvim "kitty_mod+h" = "kitty_scrollback_nvim"; - "kitty_mod+g" = - "kitty_scrollback_nvim --config ksb_builtin_last_cmd_output"; + "kitty_mod+g" = "kitty_scrollback_nvim --config ksb_builtin_last_cmd_output"; }; settings = { # Required for kitty-scrollback.nvim allow_remote_control = "socket-only"; listen_on = "unix:/tmp/kitty"; - action_alias = - "kitty_scrollback_nvim kitten ${pkgs.vimPlugins.kitty-scrollback-nvim}/python/kitty_scrollback_nvim.py"; + action_alias = "kitty_scrollback_nvim kitten ${pkgs.vimPlugins.kitty-scrollback-nvim}/python/kitty_scrollback_nvim.py"; # Colors (adapted from: https://github.com/kdrag0n/base16-kitty/blob/master/templates/default-256.mustache) background = config.theme.colors.base00; diff --git a/modules/common/applications/media.nix b/modules/common/applications/media.nix index 7ea70e3..8d819ae 100644 --- a/modules/common/applications/media.nix +++ b/modules/common/applications/media.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ options = { media = { @@ -44,7 +50,10 @@ "image/*" = [ "nsxiv.desktop" ]; }; associations.removed = { - "application/pdf" = [ "mupdf.desktop" "wine-extension-pdf.desktop" ]; + "application/pdf" = [ + "mupdf.desktop" + "wine-extension-pdf.desktop" + ]; }; defaultApplications = { "application/pdf" = [ "pwmt.zathura-cb.desktop" ]; @@ -53,9 +62,6 @@ "image/*" = [ "nsxiv.desktop" ]; }; }; - }; - }; - } diff --git a/modules/common/applications/obsidian.nix b/modules/common/applications/obsidian.nix index 189078a..bfe93a3 100644 --- a/modules/common/applications/obsidian.nix +++ b/modules/common/applications/obsidian.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ options = { obsidian = { @@ -18,7 +24,5 @@ # Broken on 2023-12-11 # https://forum.obsidian.md/t/electron-25-is-now-eol-please-upgrade-to-a-newer-version/72878/8 nixpkgs.config.permittedInsecurePackages = [ "electron-25.9.0" ]; - }; - } diff --git a/modules/common/applications/qbittorrent.nix b/modules/common/applications/qbittorrent.nix index 9750648..1f9adc7 100644 --- a/modules/common/applications/qbittorrent.nix +++ b/modules/common/applications/qbittorrent.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ options = { qbittorrent = { @@ -14,8 +20,6 @@ home-manager.users.${config.user} = { home.packages = with pkgs; [ qbittorrent ]; - }; }; - } diff --git a/modules/common/applications/slack.nix b/modules/common/applications/slack.nix index 4bd866f..ee44440 100644 --- a/modules/common/applications/slack.nix +++ b/modules/common/applications/slack.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ options = { slack = { @@ -15,5 +21,4 @@ home.packages = with pkgs; [ slack ]; }; }; - } diff --git a/modules/common/applications/yt-dlp.nix b/modules/common/applications/yt-dlp.nix index 33fab4c..553c43d 100644 --- a/modules/common/applications/yt-dlp.nix +++ b/modules/common/applications/yt-dlp.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ options = { yt-dlp = { @@ -27,9 +33,6 @@ }; programs.fish.shellAbbrs.yt = "yt-dlp"; - }; - }; - } diff --git a/modules/common/default.nix b/modules/common/default.nix index 7cf9c64..a885847 100644 --- a/modules/common/default.nix +++ b/modules/common/default.nix @@ -1,7 +1,19 @@ -{ config, lib, pkgs, ... }: { +{ + config, + lib, + pkgs, + ... +}: +{ - imports = - [ ./applications ./mail ./neovim ./programming ./repositories ./shell ]; + imports = [ + ./applications + ./mail + ./neovim + ./programming + ./repositories + ./shell + ]; options = { user = lib.mkOption { @@ -17,8 +29,7 @@ download = lib.mkOption { type = lib.types.str; description = "XDG directory for downloads"; - default = - if pkgs.stdenv.isDarwin then "$HOME/Downloads" else "$HOME/downloads"; + default = if pkgs.stdenv.isDarwin then "$HOME/Downloads" else "$HOME/downloads"; }; }; identityFile = lib.mkOption { @@ -47,10 +58,9 @@ homePath = lib.mkOption { type = lib.types.path; description = "Path of user's home directory."; - default = builtins.toPath (if pkgs.stdenv.isDarwin then - "/Users/${config.user}" - else - "/home/${config.user}"); + default = builtins.toPath ( + if pkgs.stdenv.isDarwin then "/Users/${config.user}" else "/home/${config.user}" + ); }; dotfilesPath = lib.mkOption { type = lib.types.path; @@ -122,28 +132,33 @@ }; }; - config = let stateVersion = "23.05"; - in { + config = + let + stateVersion = "23.05"; + in + { - # Basic common system packages for all devices - environment.systemPackages = with pkgs; [ git vim wget curl ]; + # 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; + # 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; + # 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; - - }; + # 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/modules/common/mail/aerc.nix b/modules/common/mail/aerc.nix index 15f5bcc..308c2aa 100644 --- a/modules/common/mail/aerc.nix +++ b/modules/common/mail/aerc.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ options.mail.aerc.enable = lib.mkEnableOption "Aerc email."; @@ -75,7 +81,9 @@ "" = ":clear"; }; - "messages:folder=Drafts" = { "" = ":recall"; }; + "messages:folder=Drafts" = { + "" = ":recall"; + }; view = { "/" = ":toggle-key-passthrough /"; @@ -148,21 +156,19 @@ "" = ":prev-tab"; "" = ":next-tab"; }; - }; extraConfig = { general.unsafe-accounts-conf = true; - viewer = { pager = "${pkgs.less}/bin/less -R"; }; + 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/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/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 -"; @@ -184,26 +190,27 @@ 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"; }; + 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/common/mail/default.nix b/modules/common/mail/default.nix index 82b2995..bb05316 100644 --- a/modules/common/mail/default.nix +++ b/modules/common/mail/default.nix @@ -1,6 +1,16 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ - imports = [ ./himalaya.nix ./aerc.nix ./system.nix ]; + imports = [ + ./himalaya.nix + ./aerc.nix + ./system.nix + ]; options = { mail.enable = lib.mkEnableOption "Mail service."; @@ -26,7 +36,9 @@ config = lib.mkIf config.mail.enable { home-manager.users.${config.user} = { - programs.mbsync = { enable = true; }; + programs.mbsync = { + enable = true; + }; # Automatically check for mail and keep files synced locally services.mbsync = lib.mkIf pkgs.stdenv.isLinux { @@ -44,8 +56,11 @@ # Better local mail search programs.notmuch = { enable = true; - new.ignore = - [ ".mbsyncstate.lock" ".mbsyncstate.journal" ".mbsyncstate.new" ]; + new.ignore = [ + ".mbsyncstate.lock" + ".mbsyncstate.journal" + ".mbsyncstate.new" + ]; }; accounts.email = { @@ -54,72 +69,71 @@ maildirBasePath = "${config.homePath}/mail"; accounts = { - home = let address = "${config.mail.user}@${config.mail.server}"; - in { - userName = address; - realName = config.fullName; - primary = true; - inherit address; - aliases = map (user: "${user}@${config.mail.server}") [ - "me" - "hey" - "admin" - ]; + home = + let + address = "${config.mail.user}@${config.mail.server}"; + in + { + userName = address; + realName = config.fullName; + primary = true; + inherit address; + aliases = map (user: "${user}@${config.mail.server}") [ + "me" + "hey" + "admin" + ]; - # Options for contact completion - alot = { }; + # Options for contact completion + alot = { }; - imap = { - host = config.mail.imapHost; - port = 993; - tls.enable = true; - }; + imap = { + host = config.mail.imapHost; + port = 993; + tls.enable = true; + }; - # Watch for mail and run notifications or sync - imapnotify = { - 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'"; - }; + # Watch for mail and run notifications or sync + imapnotify = { + 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'"; + }; - # Name of the directory in maildir for this account - maildir = { path = "main"; }; + # Name of the directory in maildir for this account + maildir = { + path = "main"; + }; - # Bi-directional syncing options for local files - mbsync = { - enable = true; - create = "both"; - expunge = "both"; - remove = "both"; - patterns = [ "*" ]; - extraConfig.channel = { - CopyArrivalDate = "yes"; # Sync time of original message + # Bi-directional syncing options for local files + mbsync = { + enable = true; + create = "both"; + expunge = "both"; + remove = "both"; + patterns = [ "*" ]; + extraConfig.channel = { + CopyArrivalDate = "yes"; # Sync time of original message + }; + }; + + # Enable indexing + notmuch.enable = true; + + # Used to login and send and receive emails + passwordCommand = "${pkgs.age}/bin/age --decrypt --identity ~/.ssh/id_ed25519 ${pkgs.writeText "mailpass.age" (builtins.readFile ../../../private/mailpass.age)}"; + + smtp = { + host = config.mail.smtpHost; + port = 465; + tls.enable = true; }; }; - - # Enable indexing - notmuch.enable = true; - - # Used to login and send and receive emails - passwordCommand = - "${pkgs.age}/bin/age --decrypt --identity ~/.ssh/id_ed25519 ${ - pkgs.writeText "mailpass.age" - (builtins.readFile ../../../private/mailpass.age) - }"; - - smtp = { - host = config.mail.smtpHost; - port = 465; - tls.enable = true; - }; - }; }; }; - }; - }; } diff --git a/modules/common/mail/himalaya.nix b/modules/common/mail/himalaya.nix index f906222..c3f1d98 100644 --- a/modules/common/mail/himalaya.nix +++ b/modules/common/mail/himalaya.nix @@ -1,4 +1,5 @@ -{ config, lib, ... }: { +{ config, lib, ... }: +{ options.mail.himalaya.enable = lib.mkEnableOption "Himalaya email."; @@ -6,7 +7,9 @@ home-manager.users.${config.user} = { - programs.himalaya = { enable = true; }; + programs.himalaya = { + enable = true; + }; accounts.email.accounts.home.himalaya = { enable = true; settings = { @@ -15,9 +18,9 @@ }; }; - programs.fish.shellAbbrs = { hi = "himalaya"; }; - + programs.fish.shellAbbrs = { + hi = "himalaya"; + }; }; - }; } diff --git a/modules/common/mail/system.nix b/modules/common/mail/system.nix index 81476f0..aab3d69 100644 --- a/modules/common/mail/system.nix +++ b/modules/common/mail/system.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ config = lib.mkIf (config.mail.enable || config.server) { @@ -8,17 +14,15 @@ # The system user for sending automatic notifications accounts.email.accounts.system = - let address = "system@${config.mail.server}"; - in { + let + address = "system@${config.mail.server}"; + in + { userName = address; realName = "NixOS System"; primary = !config.mail.enable; # Only primary if mail not enabled inherit address; - passwordCommand = - "${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${ - pkgs.writeText "mailpass-system.age" - (builtins.readFile ../../../private/mailpass-system.age) - }"; + passwordCommand = "${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${pkgs.writeText "mailpass-system.age" (builtins.readFile ../../../private/mailpass-system.age)}"; msmtp.enable = true; smtp = { host = config.mail.smtpHost; @@ -26,9 +30,6 @@ tls.enable = true; }; }; - }; - }; - } diff --git a/modules/common/neovim/config/align.nix b/modules/common/neovim/config/align.nix index 382f75e..96da51d 100644 --- a/modules/common/neovim/config/align.nix +++ b/modules/common/neovim/config/align.nix @@ -1,4 +1,5 @@ -{ pkgs, ... }: { +{ pkgs, ... }: +{ # Plugin for aligning text programmatically diff --git a/modules/common/neovim/config/bufferline.nix b/modules/common/neovim/config/bufferline.nix index c52f21f..aa3c0f1 100644 --- a/modules/common/neovim/config/bufferline.nix +++ b/modules/common/neovim/config/bufferline.nix @@ -1,4 +1,5 @@ -{ pkgs, ... }: { +{ pkgs, ... }: +{ # Shows buffers in a VSCode-style tab layout @@ -11,7 +12,7 @@ diagnostics = "nvim_lsp"; always_show_bufferline = false; separator_style = "slant"; - offsets = [{ filetype = "NvimTree"; }]; + offsets = [ { filetype = "NvimTree"; } ]; }; }; lua = '' diff --git a/modules/common/neovim/config/colors.nix b/modules/common/neovim/config/colors.nix index 9ee4222..7aa048c 100644 --- a/modules/common/neovim/config/colors.nix +++ b/modules/common/neovim/config/colors.nix @@ -1,4 +1,10 @@ -{ pkgs, lib, config, ... }: { +{ + pkgs, + lib, + config, + ... +}: +{ # Sets Neovim colors based on Nix colorscheme @@ -18,5 +24,4 @@ } ''; }; - } diff --git a/modules/common/neovim/config/completion.nix b/modules/common/neovim/config/completion.nix index ba4eae9..7d8f1de 100644 --- a/modules/common/neovim/config/completion.nix +++ b/modules/common/neovim/config/completion.nix @@ -1,4 +1,5 @@ -{ pkgs, dsl, ... }: { +{ pkgs, dsl, ... }: +{ plugins = [ pkgs.vimPlugins.cmp-nvim-lsp @@ -25,21 +26,15 @@ # Basic completion keybinds 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.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 "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({ @@ -72,13 +67,19 @@ name = "rg"; # Grep for text from the current directory keyword_length = 6; max_item_count = 10; - option = { additional_arguments = "--ignore-case"; }; + option = { + additional_arguments = "--ignore-case"; + }; } ]; # Styling of the completion menu formatting = { - fields = [ "kind" "abbr" "menu" ]; + fields = [ + "kind" + "abbr" + "menu" + ]; format = dsl.rawLua '' function(entry, vim_item) local kind_icons = { @@ -125,7 +126,6 @@ native_menu = false; # Use cmp menu instead of Vim menu ghost_text = true; # Show preview auto-completion }; - }; lua = '' @@ -145,5 +145,4 @@ }), }) ''; - } diff --git a/modules/common/neovim/config/gitsigns.nix b/modules/common/neovim/config/gitsigns.nix index 06777cf..fe36ec3 100644 --- a/modules/common/neovim/config/gitsigns.nix +++ b/modules/common/neovim/config/gitsigns.nix @@ -1,4 +1,5 @@ -{ pkgs, ... }: { +{ pkgs, ... }: +{ plugins = [ pkgs.vimPlugins.gitsigns-nvim ]; setup.gitsigns = { }; lua = builtins.readFile ./gitsigns.lua; diff --git a/modules/common/neovim/config/misc.nix b/modules/common/neovim/config/misc.nix index 74f365a..10a1c6d 100644 --- a/modules/common/neovim/config/misc.nix +++ b/modules/common/neovim/config/misc.nix @@ -1,4 +1,10 @@ -{ pkgs, dsl, lib, ... }: { +{ + pkgs, + dsl, + lib, + ... +}: +{ plugins = [ pkgs.vimPlugins.vim-surround # Keybinds for surround characters pkgs.vimPlugins.vim-eunuch # File manipulation commands @@ -13,7 +19,11 @@ # Initialize some plugins setup.Comment = { }; - setup.colorizer = { user_default_options = { names = false; }; }; + setup.colorizer = { + user_default_options = { + names = false; + }; + }; setup.glow = { }; setup.which-key = { }; setup.kitty-scrollback = { }; @@ -54,12 +64,15 @@ 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.expand("~/.local/state/nvim/backup//")''; + vim.o.backupdir = dsl.rawLua ''vim.fn.expand("~/.local/state/nvim/backup//")''; vim.o.undodir = dsl.rawLua ''vim.fn.expand("~/.local/state/nvim/undo//")''; # Required for nvim-cmp completion - vim.opt.completeopt = [ "menu" "menuone" "noselect" ]; + vim.opt.completeopt = [ + "menu" + "menuone" + "noselect" + ]; lua = lib.mkBefore '' vim.loader.enable() diff --git a/modules/common/neovim/config/statusline.nix b/modules/common/neovim/config/statusline.nix index 8771d15..39a8310 100644 --- a/modules/common/neovim/config/statusline.nix +++ b/modules/common/neovim/config/statusline.nix @@ -1,4 +1,5 @@ -{ pkgs, ... }: { +{ pkgs, ... }: +{ plugins = [ pkgs.vimPlugins.lualine-nvim ]; setup.lualine = { options = { diff --git a/modules/common/neovim/config/syntax.nix b/modules/common/neovim/config/syntax.nix index 7814c9f..ec59eaa 100644 --- a/modules/common/neovim/config/syntax.nix +++ b/modules/common/neovim/config/syntax.nix @@ -1,8 +1,9 @@ -{ pkgs, lib, ... }: { +{ pkgs, lib, ... }: +{ plugins = [ - (pkgs.vimPlugins.nvim-treesitter.withPlugins (_plugins: - with pkgs.tree-sitter-grammars; [ + (pkgs.vimPlugins.nvim-treesitter.withPlugins ( + _plugins: with pkgs.tree-sitter-grammars; [ tree-sitter-bash tree-sitter-c tree-sitter-fish @@ -19,7 +20,8 @@ tree-sitter-toml tree-sitter-vimdoc tree-sitter-yaml - ])) + ] + )) pkgs.vimPlugins.vim-matchup # Better % jumping in languages pkgs.vimPlugins.playground # Tree-sitter experimenting pkgs.vimPlugins.nginx-vim @@ -34,9 +36,15 @@ ]; setup."nvim-treesitter.configs" = { - highlight = { enable = true; }; - indent = { enable = true; }; - matchup = { enable = true; }; # Uses vim-matchup + highlight = { + enable = true; + }; + indent = { + enable = true; + }; + matchup = { + enable = true; + }; # Uses vim-matchup textobjects = { select = { @@ -70,5 +78,4 @@ -- Use HCL parser with .tf files vim.treesitter.language.register('hcl', 'terraform') ''; - } diff --git a/modules/common/neovim/config/telescope.nix b/modules/common/neovim/config/telescope.nix index 01c29a4..edad0b8 100644 --- a/modules/common/neovim/config/telescope.nix +++ b/modules/common/neovim/config/telescope.nix @@ -1,4 +1,5 @@ -{ pkgs, dsl, ... }: { +{ pkgs, dsl, ... }: +{ # Telescope is a fuzzy finder that can work with different sub-plugins @@ -20,9 +21,15 @@ }; }; pickers = { - find_files = { theme = "ivy"; }; - oldfiles = { theme = "ivy"; }; - buffers = { theme = "dropdown"; }; + find_files = { + theme = "ivy"; + }; + oldfiles = { + theme = "ivy"; + }; + buffers = { + theme = "dropdown"; + }; }; extensions = { fzy_native = { }; @@ -33,5 +40,4 @@ setup.project_nvim = { }; lua = builtins.readFile ./telescope.lua; - } diff --git a/modules/common/neovim/config/toggleterm.nix b/modules/common/neovim/config/toggleterm.nix index 42fbe73..fbd45f3 100644 --- a/modules/common/neovim/config/toggleterm.nix +++ b/modules/common/neovim/config/toggleterm.nix @@ -1,4 +1,10 @@ -{ pkgs, dsl, config, ... }: { +{ + pkgs, + dsl, + config, + ... +}: +{ # Toggleterm provides a floating terminal inside the editor for quick access @@ -15,5 +21,4 @@ ${if config.github then (builtins.readFile ./github.lua) else ""} ${if config.kubernetes then (builtins.readFile ./kubernetes.lua) else ""} ''; - } diff --git a/modules/common/neovim/config/tree.nix b/modules/common/neovim/config/tree.nix index 53e413b..5da7bfd 100644 --- a/modules/common/neovim/config/tree.nix +++ b/modules/common/neovim/config/tree.nix @@ -1,8 +1,12 @@ -{ pkgs, dsl, ... }: { +{ pkgs, dsl, ... }: +{ # This plugin creates a side drawer for navigating the current project - plugins = [ pkgs.vimPlugins.nvim-tree-lua pkgs.vimPlugins.nvim-web-devicons ]; + plugins = [ + pkgs.vimPlugins.nvim-tree-lua + pkgs.vimPlugins.nvim-web-devicons + ]; # Disable netrw eagerly # https://github.com/kyazdani42/nvim-tree.lua/commit/fb8735e96cecf004fbefb086ce85371d003c5129 @@ -16,12 +20,14 @@ hijack_netrw = true; # Works as the file manager sync_root_with_cwd = true; # Change project whenever currend dir changes respect_buf_cwd = true; # Change to exact location of focused buffer - update_focused_file = { # Change project based on the focused buffer + update_focused_file = { + # Change project based on the focused buffer enable = true; update_root = true; ignore_list = { }; }; - diagnostics = { # Enable LSP and linter integration + diagnostics = { + # Enable LSP and linter integration enable = true; icons = { hint = ""; @@ -30,7 +36,8 @@ error = ""; }; }; - renderer = { # Show files with changes vs. current commit + renderer = { + # Show files with changes vs. current commit icons = { glyphs = { git = { @@ -61,7 +68,8 @@ vim.keymap.set('n', 'v', api.node.open.vertical, opts('Open: Vertical Split')) end ''; - view = { # Set look and feel + view = { + # Set look and feel width = 30; side = "left"; number = false; @@ -73,5 +81,4 @@ lua = '' vim.keymap.set("n", "e", ":NvimTreeFindFileToggle", { silent = true }) ''; - } diff --git a/modules/common/neovim/default.nix b/modules/common/neovim/default.nix index 36311dc..712243e 100644 --- a/modules/common/neovim/default.nix +++ b/modules/common/neovim/default.nix @@ -1,4 +1,9 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: let @@ -9,8 +14,8 @@ let github = true; kubernetes = config.kubernetes.enable; }; - -in { +in +{ options.neovim.enable = lib.mkEnableOption "Neovim."; @@ -33,7 +38,9 @@ in { # Create quick aliases for launching Neovim programs.fish = { - shellAliases = { vim = "nvim"; }; + shellAliases = { + vim = "nvim"; + }; shellAbbrs = { v = lib.mkForce "nvim"; vl = lib.mkForce "nvim -c 'normal! `0' -c 'bdelete 1'"; @@ -45,23 +52,22 @@ in { # Requires removing some of the ANSI escape codes that are sent to the # scrollback using sed and baleia, as well as removing several # unnecessary features. - programs.kitty.settings.scrollback_pager = - "${neovim}/bin/nvim --headless +'KittyScrollbackGenerateKittens' +'set nonumber' +'set norelativenumber' +'%print' +'quit!' 2>&1"; + programs.kitty.settings.scrollback_pager = "${neovim}/bin/nvim --headless +'KittyScrollbackGenerateKittens' +'set nonumber' +'set norelativenumber' +'%print' +'quit!' 2>&1"; # Create a desktop option for launching Neovim from a file manager # (Requires launching the terminal and then executing Neovim) xdg.desktopEntries.nvim = lib.mkIf pkgs.stdenv.isLinux { name = "Neovim wrapper"; exec = "kitty nvim %F"; - mimeType = [ "text/plain" "text/markdown" ]; + mimeType = [ + "text/plain" + "text/markdown" + ]; }; xdg.mimeApps.defaultApplications = lib.mkIf pkgs.stdenv.isLinux { "text/plain" = [ "nvim.desktop" ]; "text/markdown" = [ "nvim.desktop" ]; }; - }; - }; - } diff --git a/modules/common/neovim/package/default.nix b/modules/common/neovim/package/default.nix index 806df38..471f581 100644 --- a/modules/common/neovim/package/default.nix +++ b/modules/common/neovim/package/default.nix @@ -26,13 +26,25 @@ # ] ++ extraConfig; # } -{ pkgs, colors, terraform ? false, github ? false, kubernetes ? false, ... }: +{ + pkgs, + colors, + terraform ? false, + github ? false, + kubernetes ? false, + ... +}: # Comes from nix2vim overlay: # https://github.com/gytis-ivaskevicius/nix2vim/blob/master/lib/neovim-builder.nix pkgs.neovimBuilder { package = pkgs.neovim-unwrapped; - inherit colors terraform github kubernetes; + inherit + colors + terraform + github + kubernetes + ; imports = [ ../config/align.nix ../config/bufferline.nix diff --git a/modules/common/programming/default.nix b/modules/common/programming/default.nix index 7e2593b..f79f364 100644 --- a/modules/common/programming/default.nix +++ b/modules/common/programming/default.nix @@ -1,4 +1,5 @@ -{ ... }: { +{ ... }: +{ imports = [ ./haskell.nix @@ -9,5 +10,4 @@ ./rust.nix ./terraform.nix ]; - } diff --git a/modules/common/programming/haskell.nix b/modules/common/programming/haskell.nix index 203a7c0..4074b99 100644 --- a/modules/common/programming/haskell.nix +++ b/modules/common/programming/haskell.nix @@ -1,14 +1,12 @@ -{ config, lib, ... }: { +{ 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.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 index 8b764d6..895b98b 100644 --- a/modules/common/programming/kubernetes.nix +++ b/modules/common/programming/kubernetes.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ options.kubernetes.enable = lib.mkEnableOption "Kubernetes tools."; @@ -99,12 +105,16 @@ views = { charts = { bgColor = "default"; - defaultDialColors = - [ config.theme.colors.base0D config.theme.colors.base08 ]; + defaultDialColors = [ + config.theme.colors.base0D + config.theme.colors.base08 + ]; # - *blue # - *red - defaultChartColors = - [ config.theme.colors.base0D config.theme.colors.base08 ]; + defaultChartColors = [ + config.theme.colors.base0D + config.theme.colors.base08 + ]; # - *blue # - *red }; @@ -149,9 +159,6 @@ }; }; }; - }; - }; - } diff --git a/modules/common/programming/lua.nix b/modules/common/programming/lua.nix index 127623d..5ff03a6 100644 --- a/modules/common/programming/lua.nix +++ b/modules/common/programming/lua.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ options.lua.enable = lib.mkEnableOption "Lua programming language."; @@ -8,5 +14,4 @@ sumneko-lua-language-server # Lua LSP ]; }; - } diff --git a/modules/common/programming/nix.nix b/modules/common/programming/nix.nix index 6ad9b57..3aee56f 100644 --- a/modules/common/programming/nix.nix +++ b/modules/common/programming/nix.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ options.nixlang.enable = lib.mkEnableOption "Nix programming language."; diff --git a/modules/common/programming/python.nix b/modules/common/programming/python.nix index e3d435f..256ec04 100644 --- a/modules/common/programming/python.nix +++ b/modules/common/programming/python.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ options.python.enable = lib.mkEnableOption "Python programming language."; @@ -13,10 +19,9 @@ python310Packages.flake8 # Python linter ]; - programs.fish.shellAbbrs = { py = "python3"; }; - + programs.fish.shellAbbrs = { + py = "python3"; + }; }; - }; - } diff --git a/modules/common/programming/rust.nix b/modules/common/programming/rust.nix index 30eb403..232f5b8 100644 --- a/modules/common/programming/rust.nix +++ b/modules/common/programming/rust.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ options.rust.enable = lib.mkEnableOption "Rust programming language."; @@ -6,12 +12,16 @@ home-manager.users.${config.user} = { - programs.fish.shellAbbrs = { ca = "cargo"; }; - - home.packages = with pkgs; [ cargo rustc clippy gcc ]; + programs.fish.shellAbbrs = { + ca = "cargo"; + }; + home.packages = with pkgs; [ + cargo + rustc + clippy + gcc + ]; }; - }; - } diff --git a/modules/common/programming/terraform.nix b/modules/common/programming/terraform.nix index e156a34..89ec115 100644 --- a/modules/common/programming/terraform.nix +++ b/modules/common/programming/terraform.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ options.terraform.enable = lib.mkEnableOption "Terraform tools."; @@ -15,9 +21,6 @@ terraform-ls # Language server tflint # Linter ]; - }; - }; - } diff --git a/modules/common/repositories/default.nix b/modules/common/repositories/default.nix index f3cec00..a1af845 100644 --- a/modules/common/repositories/default.nix +++ b/modules/common/repositories/default.nix @@ -1,5 +1,8 @@ -{ ... }: { - - imports = [ ./dotfiles.nix ./notes.nix ]; +{ ... }: +{ + imports = [ + ./dotfiles.nix + ./notes.nix + ]; } diff --git a/modules/common/repositories/dotfiles.nix b/modules/common/repositories/dotfiles.nix index eabb1e5..ae3ccc7 100644 --- a/modules/common/repositories/dotfiles.nix +++ b/modules/common/repositories/dotfiles.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ # Allows me to make sure I can work on my dotfiles locally @@ -11,23 +17,17 @@ 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}") - $DRY_RUN_CMD ${pkgs.git}/bin/git \ - clone ${config.dotfilesRepo} "${config.dotfilesPath}" - fi - ''; - + 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}") + $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/common/shell/atuin.nix b/modules/common/shell/atuin.nix index ad5acd8..07b8de9 100644 --- a/modules/common/shell/atuin.nix +++ b/modules/common/shell/atuin.nix @@ -1,4 +1,5 @@ -{ config, lib, ... }: { +{ config, lib, ... }: +{ # Shell history sync @@ -10,7 +11,10 @@ programs.atuin = { enable = true; - flags = [ "--disable-up-arrow" "--disable-ctrl-r" ]; + flags = [ + "--disable-up-arrow" + "--disable-ctrl-r" + ]; settings = { auto_sync = true; update_check = false; @@ -27,13 +31,9 @@ keymap_mode = "vim-normal"; }; }; - }; # Give root user the same setup - home-manager.users.root.programs.atuin = - config.home-manager.users.${config.user}.programs.atuin; - + home-manager.users.root.programs.atuin = config.home-manager.users.${config.user}.programs.atuin; }; - } diff --git a/modules/common/shell/bash/default.nix b/modules/common/shell/bash/default.nix index 06a8367..13b2ee2 100644 --- a/modules/common/shell/bash/default.nix +++ b/modules/common/shell/bash/default.nix @@ -1,12 +1,17 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ config = { home-manager.users.${config.user} = { programs.bash = { enable = true; - shellAliases = - config.home-manager.users.${config.user}.programs.fish.shellAliases; + shellAliases = config.home-manager.users.${config.user}.programs.fish.shellAliases; initExtra = ""; profileExtra = ""; }; @@ -14,7 +19,6 @@ programs.starship.enableBashIntegration = false; programs.zoxide.enableBashIntegration = true; programs.fzf.enableBashIntegration = true; - }; }; } diff --git a/modules/common/shell/charm.nix b/modules/common/shell/charm.nix index 9b7d574..fd18b1b 100644 --- a/modules/common/shell/charm.nix +++ b/modules/common/shell/charm.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ # Convenience utilities from charm.sh @@ -12,7 +18,5 @@ charm # Manage account and filesystem pop # Send emails from a TUI ]; - }; - } diff --git a/modules/common/shell/default.nix b/modules/common/shell/default.nix index 4ac2f1d..1d47947 100644 --- a/modules/common/shell/default.nix +++ b/modules/common/shell/default.nix @@ -1,4 +1,5 @@ -{ ... }: { +{ ... }: +{ imports = [ ./atuin.nix ./bash diff --git a/modules/common/shell/direnv.nix b/modules/common/shell/direnv.nix index 37877e1..9a62b45 100644 --- a/modules/common/shell/direnv.nix +++ b/modules/common/shell/direnv.nix @@ -1,10 +1,15 @@ -{ config, ... }: { +{ config, ... }: +{ # Enables quickly entering Nix shells when changing directories home-manager.users.${config.user}.programs.direnv = { enable = true; nix-direnv.enable = true; - config = { whitelist = { prefix = [ config.dotfilesPath ]; }; }; + config = { + whitelist = { + prefix = [ config.dotfilesPath ]; + }; + }; }; # programs.direnv.direnvrcExtra = '' @@ -28,5 +33,4 @@ keep-outputs = true keep-derivations = true ''; - } diff --git a/modules/common/shell/fish/default.nix b/modules/common/shell/fish/default.nix index 3a09ddb..ade0666 100644 --- a/modules/common/shell/fish/default.nix +++ b/modules/common/shell/fish/default.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ users.users.${config.user}.shell = pkgs.fish; programs.fish.enable = true; # Needed for LightDM to remember username @@ -46,7 +52,9 @@ fish_user_key_bindings = { body = builtins.readFile ./functions/fish_user_key_bindings.fish; }; - ip = { body = builtins.readFile ./functions/ip.fish; }; + ip = { + body = builtins.readFile ./functions/ip.fish; + }; json = { description = "Tidy up JSON using jq"; body = "pbpaste | jq '.' | pbcopy"; # Need to fix for non-macOS @@ -112,8 +120,7 @@ moon = "curl wttr.in/Moon"; # Cheat Sheets - ssl = - "openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr"; + ssl = "openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr"; fingerprint = "ssh-keyscan myhost.com | ssh-keygen -lf -"; publickey = "ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub"; forloop = "for i in (seq 1 100)"; @@ -122,7 +129,6 @@ dc = "$DOTS/bin/docker_cleanup"; dr = "docker run --rm -it"; db = "docker build . -t"; - }; shellInit = ""; }; @@ -132,6 +138,5 @@ programs.starship.enableFishIntegration = true; programs.zoxide.enableFishIntegration = true; programs.fzf.enableFishIntegration = true; - }; } diff --git a/modules/common/shell/fzf.nix b/modules/common/shell/fzf.nix index a62f5df..3cf55ec 100644 --- a/modules/common/shell/fzf.nix +++ b/modules/common/shell/fzf.nix @@ -1,4 +1,5 @@ -{ config, pkgs, ... }: { +{ config, pkgs, ... }: +{ # FZF is a fuzzy-finder for the terminal @@ -25,17 +26,20 @@ ''; }; }; - shellAbbrs = { lsf = "ls -lh | fzf"; }; + shellAbbrs = { + lsf = "ls -lh | fzf"; + }; }; # Global fzf configuration - home.sessionVariables = let fzfCommand = "fd --type file"; - in { - FZF_DEFAULT_COMMAND = fzfCommand; - FZF_CTRL_T_COMMAND = fzfCommand; - FZF_DEFAULT_OPTS = "-m --height 50% --border"; - }; - + home.sessionVariables = + let + fzfCommand = "fd --type file"; + in + { + FZF_DEFAULT_COMMAND = fzfCommand; + FZF_CTRL_T_COMMAND = fzfCommand; + FZF_DEFAULT_OPTS = "-m --height 50% --border"; + }; }; - } diff --git a/modules/common/shell/git.nix b/modules/common/shell/git.nix index 0d97dab..ecd595f 100644 --- a/modules/common/shell/git.nix +++ b/modules/common/shell/git.nix @@ -1,8 +1,14 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: -let home-packages = config.home-manager.users.${config.user}.home.packages; - -in { +let + home-packages = config.home-manager.users.${config.user}.home.packages; +in +{ options = { gitName = lib.mkOption { @@ -28,16 +34,26 @@ in { userName = config.gitName; userEmail = config.gitEmail; extraConfig = { - core.pager = - "${pkgs.git}/share/git/contrib/diff-highlight/diff-highlight | less -F"; - interactive.difffilter = - "${pkgs.git}/share/git/contrib/diff-highlight/diff-highlight"; - pager = { branch = "false"; }; - safe = { directory = config.dotfilesPath; }; - pull = { ff = "only"; }; - push = { autoSetupRemote = "true"; }; - init = { defaultBranch = "master"; }; - rebase = { autosquash = "true"; }; + core.pager = "${pkgs.git}/share/git/contrib/diff-highlight/diff-highlight | less -F"; + interactive.difffilter = "${pkgs.git}/share/git/contrib/diff-highlight/diff-highlight"; + pager = { + branch = "false"; + }; + safe = { + directory = config.dotfilesPath; + }; + pull = { + ff = "only"; + }; + push = { + autoSetupRemote = "true"; + }; + init = { + defaultBranch = "master"; + }; + rebase = { + autosquash = "true"; + }; gpg = { format = "ssh"; ssh.allowedSignersFile = "~/.config/git/allowed-signers"; @@ -45,11 +61,16 @@ in { # commit.gpgsign = true; # tag.gpgsign = true; }; - ignores = [ ".direnv/**" "result" ]; - includes = [{ - path = "~/.config/git/personal"; - condition = "gitdir:~/dev/personal/"; - }]; + ignores = [ + ".direnv/**" + "result" + ]; + includes = [ + { + path = "~/.config/git/personal"; + condition = "gitdir:~/dev/personal/"; + } + ]; }; # Personal git config @@ -86,8 +107,7 @@ in { gl = "git log --graph --decorate --oneline -20"; gll = "git log --graph --decorate --oneline"; gco = "git checkout"; - gcom = '' - git switch (git symbolic-ref refs/remotes/origin/HEAD | cut -d"/" -f4)''; + gcom = ''git switch (git symbolic-ref refs/remotes/origin/HEAD | cut -d"/" -f4)''; gcob = "git switch -c"; gb = "git branch"; gpd = "git push origin -d"; @@ -101,58 +121,63 @@ in { }; # Required for fish commands - home.packages = with pkgs; [ fish fzf bat ]; + home.packages = with pkgs; [ + fish + fzf + bat + ]; - programs.fish.functions = lib.mkIf (builtins.elem pkgs.fzf home-packages - && builtins.elem pkgs.bat home-packages) { - git = { body = builtins.readFile ./fish/functions/git.fish; }; - git-add-fuzzy = { - body = builtins.readFile ./fish/functions/git-add-fuzzy.fish; + programs.fish.functions = + lib.mkIf (builtins.elem pkgs.fzf home-packages && builtins.elem pkgs.bat home-packages) + { + git = { + body = builtins.readFile ./fish/functions/git.fish; + }; + git-add-fuzzy = { + body = builtins.readFile ./fish/functions/git-add-fuzzy.fish; + }; + git-fuzzy-branch = { + argumentNames = "header"; + body = builtins.readFile ./fish/functions/git-fuzzy-branch.fish; + }; + git-checkout-fuzzy = { + body = '' + set branch (git-fuzzy-branch "checkout branch...") + and git checkout $branch + ''; + }; + git-delete-fuzzy = { + body = '' + set branch (git-fuzzy-branch "delete branch...") + and git branch -d $branch + ''; + }; + git-force-delete-fuzzy = { + body = '' + set branch (git-fuzzy-branch "force delete branch...") + and git branch -D $branch + ''; + }; + git-merge-fuzzy = { + body = '' + set branch (git-fuzzy-branch "merge from...") + and git merge $branch + ''; + }; + git-show-fuzzy = { + body = builtins.readFile ./fish/functions/git-show-fuzzy.fish; + }; + git-commits = { + body = builtins.readFile ./fish/functions/git-commits.fish; + }; + git-history = { + body = builtins.readFile ./fish/functions/git-history.fish; + }; + uncommitted = { + description = "Find uncommitted git repos"; + body = builtins.readFile ./fish/functions/uncommitted.fish; + }; }; - git-fuzzy-branch = { - argumentNames = "header"; - body = builtins.readFile ./fish/functions/git-fuzzy-branch.fish; - }; - git-checkout-fuzzy = { - body = '' - set branch (git-fuzzy-branch "checkout branch...") - and git checkout $branch - ''; - }; - git-delete-fuzzy = { - body = '' - set branch (git-fuzzy-branch "delete branch...") - and git branch -d $branch - ''; - }; - git-force-delete-fuzzy = { - body = '' - set branch (git-fuzzy-branch "force delete branch...") - and git branch -D $branch - ''; - }; - git-merge-fuzzy = { - body = '' - set branch (git-fuzzy-branch "merge from...") - and git merge $branch - ''; - }; - git-show-fuzzy = { - body = builtins.readFile ./fish/functions/git-show-fuzzy.fish; - }; - git-commits = { - body = builtins.readFile ./fish/functions/git-commits.fish; - }; - git-history = { - body = builtins.readFile ./fish/functions/git-history.fish; - }; - uncommitted = { - description = "Find uncommitted git repos"; - body = builtins.readFile ./fish/functions/uncommitted.fish; - }; - }; }; - }; - } diff --git a/modules/common/shell/github.nix b/modules/common/shell/github.nix index 2cc25f9..8a0aadb 100644 --- a/modules/common/shell/github.nix +++ b/modules/common/shell/github.nix @@ -1,40 +1,43 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ home-manager.users.${config.user} = { - programs.gh = - lib.mkIf config.home-manager.users.${config.user}.programs.git.enable { - enable = true; - gitCredentialHelper.enable = true; - settings.git_protocol = "https"; - extensions = [ pkgs.gh-collaborators ]; + programs.gh = lib.mkIf config.home-manager.users.${config.user}.programs.git.enable { + enable = true; + gitCredentialHelper.enable = true; + settings.git_protocol = "https"; + extensions = [ pkgs.gh-collaborators ]; + }; + + programs.fish = lib.mkIf config.home-manager.users.${config.user}.programs.gh.enable { + shellAbbrs = { + ghr = "gh repo view -w"; + gha = "gh run list | head -1 | awk '{ print \\$\\(NF-2\\) }' | xargs gh run view"; + grw = "gh run watch"; + 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"; }; - - programs.fish = - lib.mkIf config.home-manager.users.${config.user}.programs.gh.enable { - shellAbbrs = { - ghr = "gh repo view -w"; - gha = - "gh run list | head -1 | awk '{ print \\$\\(NF-2\\) }' | xargs gh run view"; - grw = "gh run watch"; - 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 = { - description = "Clone GitHub repositories"; - argumentNames = "organization"; - body = '' - set directory (gh-repos $organization) - and cd $directory - ''; - }; + functions = { + repos = { + description = "Clone GitHub repositories"; + argumentNames = "organization"; + body = '' + set directory (gh-repos $organization) + and cd $directory + ''; }; }; + }; home.packages = [ (pkgs.writeShellScriptBin "gh-repos" '' @@ -76,7 +79,5 @@ } '') ]; - }; - } diff --git a/modules/common/shell/jujutsu.nix b/modules/common/shell/jujutsu.nix index 38563ec..52948ad 100644 --- a/modules/common/shell/jujutsu.nix +++ b/modules/common/shell/jujutsu.nix @@ -1,4 +1,5 @@ -{ config, ... }: { +{ config, ... }: +{ config = { @@ -9,12 +10,9 @@ settings = { user = { name = config.home-manager.users.${config.user}.programs.git.userName; - email = - config.home-manager.users.${config.user}.programs.git.userEmail; + email = config.home-manager.users.${config.user}.programs.git.userEmail; }; }; }; - }; - } diff --git a/modules/common/shell/nixpkgs.nix b/modules/common/shell/nixpkgs.nix index 5e10602..d08c8be 100644 --- a/modules/common/shell/nixpkgs.nix +++ b/modules/common/shell/nixpkgs.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ home-manager.users.${config.user} = { programs.fish = { @@ -62,22 +68,22 @@ # Create nix-index if doesn't exist home.activation.createNixIndex = - let cacheDir = "${config.homePath}/.cache/nix-index"; - in lib.mkIf - config.home-manager.users.${config.user}.programs.nix-index.enable - (config.home-manager.users.${config.user}.lib.dag.entryAfter - [ "writeBoundary" ] '' + let + cacheDir = "${config.homePath}/.cache/nix-index"; + in + lib.mkIf config.home-manager.users.${config.user}.programs.nix-index.enable ( + config.home-manager.users.${config.user}.lib.dag.entryAfter [ "writeBoundary" ] '' if [ ! -d ${cacheDir} ]; then $DRY_RUN_CMD ${pkgs.nix-index}/bin/nix-index -f ${pkgs.path} fi - ''); + '' + ); # Set automatic generation cleanup for home-manager nix.gc = { automatic = config.nix.gc.automatic; options = config.nix.gc.options; }; - }; nix = { @@ -92,7 +98,10 @@ }; # For security, only allow specific users - settings.allowed-users = [ "@wheel" config.user ]; + settings.allowed-users = [ + "@wheel" + config.user + ]; # Enable features in Nix commands extraOptions = '' @@ -110,8 +119,7 @@ # Add community Cachix to binary cache # Don't use with macOS because blocked by corporate firewall builders-use-substitutes = true; - substituters = - lib.mkIf (!pkgs.stdenv.isDarwin) [ "https://nix-community.cachix.org" ]; + substituters = lib.mkIf (!pkgs.stdenv.isDarwin) [ "https://nix-community.cachix.org" ]; trusted-public-keys = lib.mkIf (!pkgs.stdenv.isDarwin) [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" ]; @@ -119,9 +127,6 @@ # Scans and hard links identical files in the store # Not working with macOS: https://github.com/NixOS/nix/issues/7273 auto-optimise-store = lib.mkIf (!pkgs.stdenv.isDarwin) true; - }; - }; - } diff --git a/modules/common/shell/starship.nix b/modules/common/shell/starship.nix index 0b34535..6ef3ecf 100644 --- a/modules/common/shell/starship.nix +++ b/modules/common/shell/starship.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ home-manager.users.${config.user}.programs.starship = { enable = true; @@ -29,7 +35,9 @@ truncate_to_repo = true; truncation_length = 100; }; - git_branch = { format = "[$symbol$branch]($style)"; }; + git_branch = { + format = "[$symbol$branch]($style)"; + }; git_commit = { format = "( @ [$hash]($style) )"; only_detached = false; @@ -56,8 +64,9 @@ format = "[$symbol $name]($style)"; symbol = "❄️"; }; - python = { format = "[\${version}\\(\${virtualenv}\\)]($style)"; }; + python = { + format = "[\${version}\\(\${virtualenv}\\)]($style)"; + }; }; }; - } diff --git a/modules/common/shell/utilities.nix b/modules/common/shell/utilities.nix index 00ec551..d1b80e8 100644 --- a/modules/common/shell/utilities.nix +++ b/modules/common/shell/utilities.nix @@ -10,8 +10,8 @@ let .terraform/ .target/ /Library/''; - -in { +in +{ config = { @@ -70,9 +70,6 @@ in { body = "${pkgs.prettyping}/bin/prettyping --nolegend $target"; }; }; - }; - }; - } diff --git a/modules/common/shell/work.nix b/modules/common/shell/work.nix index b8b6544..2b79d6d 100644 --- a/modules/common/shell/work.nix +++ b/modules/common/shell/work.nix @@ -1,46 +1,52 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: { home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin { - home.packages = let - ldap_scheme = "ldaps"; - magic_number = "2"; - magic_end_seq = "corp"; - magic_prefix = "take"; - ldap_host = - "${magic_prefix}${magic_number}.t${magic_number}.${magic_end_seq}"; - ldap_port = 636; - ldap_dc_1 = "${magic_prefix}${magic_number}"; - ldap_dc_2 = "t${magic_number}"; - ldap_dc_3 = magic_end_seq; - ldap_script = pkgs.writeShellScriptBin "ldap" '' - # if ! [ "$LDAP_HOST" ]; then - # echo "No LDAP_HOST specified!" - # exit 1 - # fi - SEARCH_FILTER="$@" - ldapsearch -LLL \ - -B -o ldif-wrap=no \ - -H "${ldap_scheme}://${ldap_host}:${builtins.toString ldap_port}" \ - -D "${pkgs.lib.toUpper magic_prefix}${magic_number}\\${ - pkgs.lib.toLower config.user - }" \ - -w "$(${pkgs._1password}/bin/op item get T${magic_number} --fields label=password)" \ - -b "DC=${ldap_dc_1},DC=${ldap_dc_2},DC=${ldap_dc_3}" \ - -s "sub" -x "(cn=$SEARCH_FILTER)" \ - | jq --slurp \ - --raw-input 'split("\n\n")|map(split("\n")|map(select(.[0:1]!="#" and length>0)) |select(length > 0)|map(capture("^(?[^:]*:?): *(?.*)") |if .key[-1:.key|length] == ":" then .key=.key[0:-1]|.value=(.value|@base64d) else . end)| group_by(.key) | map({key:.[0].key,value:(if .|length > 1 then [.[].value] else .[].value end)}) | from_entries)' | jq -r 'del(.[].thumbnailPhoto)' - ''; - ldapm_script = pkgs.writeShellScriptBin "ldapm" '' - ${ldap_script}/bin/ldap "$@" | jq '[ .[].memberOf] | add' - ''; - ldapg_script = pkgs.writeShellScriptBin "ldapg" '' - ${ldap_script}/bin/ldap "$@" | jq '[ .[].member] | add' - ''; - in [ ldap_script ldapm_script ldapg_script ]; - + home.packages = + let + ldap_scheme = "ldaps"; + magic_number = "2"; + magic_end_seq = "corp"; + magic_prefix = "take"; + ldap_host = "${magic_prefix}${magic_number}.t${magic_number}.${magic_end_seq}"; + ldap_port = 636; + ldap_dc_1 = "${magic_prefix}${magic_number}"; + ldap_dc_2 = "t${magic_number}"; + ldap_dc_3 = magic_end_seq; + ldap_script = pkgs.writeShellScriptBin "ldap" '' + # if ! [ "$LDAP_HOST" ]; then + # echo "No LDAP_HOST specified!" + # exit 1 + # fi + SEARCH_FILTER="$@" + ldapsearch -LLL \ + -B -o ldif-wrap=no \ + -H "${ldap_scheme}://${ldap_host}:${builtins.toString ldap_port}" \ + -D "${pkgs.lib.toUpper magic_prefix}${magic_number}\\${pkgs.lib.toLower config.user}" \ + -w "$(${pkgs._1password}/bin/op item get T${magic_number} --fields label=password)" \ + -b "DC=${ldap_dc_1},DC=${ldap_dc_2},DC=${ldap_dc_3}" \ + -s "sub" -x "(cn=$SEARCH_FILTER)" \ + | jq --slurp \ + --raw-input 'split("\n\n")|map(split("\n")|map(select(.[0:1]!="#" and length>0)) |select(length > 0)|map(capture("^(?[^:]*:?): *(?.*)") |if .key[-1:.key|length] == ":" then .key=.key[0:-1]|.value=(.value|@base64d) else . end)| group_by(.key) | map({key:.[0].key,value:(if .|length > 1 then [.[].value] else .[].value end)}) | from_entries)' | jq -r 'del(.[].thumbnailPhoto)' + ''; + ldapm_script = pkgs.writeShellScriptBin "ldapm" '' + ${ldap_script}/bin/ldap "$@" | jq '[ .[].memberOf] | add' + ''; + ldapg_script = pkgs.writeShellScriptBin "ldapg" '' + ${ldap_script}/bin/ldap "$@" | jq '[ .[].member] | add' + ''; + in + [ + ldap_script + ldapm_script + ldapg_script + ]; }; - } diff --git a/modules/darwin/alacritty.nix b/modules/darwin/alacritty.nix index 0dcab47..9c099ed 100644 --- a/modules/darwin/alacritty.nix +++ b/modules/darwin/alacritty.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ # MacOS-specific settings for Alacritty home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin { @@ -647,5 +653,4 @@ ]; }; }; - } diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix index 04e385b..5a783d4 100644 --- a/modules/darwin/default.nix +++ b/modules/darwin/default.nix @@ -1,4 +1,5 @@ -{ ... }: { +{ ... }: +{ imports = [ ./alacritty.nix @@ -14,5 +15,4 @@ ./user.nix ./utilities.nix ]; - } diff --git a/modules/darwin/fish.nix b/modules/darwin/fish.nix index 139568b..2d87722 100644 --- a/modules/darwin/fish.nix +++ b/modules/darwin/fish.nix @@ -1,11 +1,10 @@ -{ pkgs, ... }: { +{ 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 1edf526..f09a482 100644 --- a/modules/darwin/fonts.nix +++ b/modules/darwin/fonts.nix @@ -1,17 +1,22 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin { - home.packages = with pkgs; - [ (nerdfonts.override { fonts = [ "VictorMono" ]; }) ]; + home.packages = with pkgs; [ (nerdfonts.override { fonts = [ "VictorMono" ]; }) ]; - programs.alacritty.settings = { font.normal.family = "VictorMono"; }; + 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 90315b5..b2db2fe 100644 --- a/modules/darwin/hammerspoon.nix +++ b/modules/darwin/hammerspoon.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ # Hammerspoon - MacOS custom automation scripting @@ -6,30 +12,25 @@ 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"; - obsidian = "${pkgs.obsidian}/Applications/Obsidian.app"; - slack = "${pkgs.slack}/Applications/Slack.app"; - }; - xdg.configFile."hammerspoon/Spoons/MoveWindow.spoon".source = - ./hammerspoon/Spoons/MoveWindow.spoon; + 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"; + obsidian = "${pkgs.obsidian}/Applications/Obsidian.app"; + slack = "${pkgs.slack}/Applications/Slack.app"; + }; + xdg.configFile."hammerspoon/Spoons/MoveWindow.spoon".source = ./hammerspoon/Spoons/MoveWindow.spoon; home.activation.reloadHammerspoon = - config.home-manager.users.${config.user}.lib.dag.entryAfter - [ "writeBoundary" ] '' - $DRY_RUN_CMD /Applications/Hammerspoon.app/Contents/Frameworks/hs/hs -c "hs.reload()" - $DRY_RUN_CMD sleep 1 - $DRY_RUN_CMD /Applications/Hammerspoon.app/Contents/Frameworks/hs/hs -c "hs.console.clearConsole()" - ''; - + config.home-manager.users.${config.user}.lib.dag.entryAfter [ "writeBoundary" ] + '' + $DRY_RUN_CMD /Applications/Hammerspoon.app/Contents/Frameworks/hs/hs -c "hs.reload()" + $DRY_RUN_CMD sleep 1 + $DRY_RUN_CMD /Applications/Hammerspoon.app/Contents/Frameworks/hs/hs -c "hs.console.clearConsole()" + ''; }; homebrew.casks = [ "hammerspoon" ]; @@ -38,7 +39,5 @@ defaults write org.hammerspoon.Hammerspoon MJConfigFile "~/.config/hammerspoon/init.lua" sudo killall Dock ''; - }; - } diff --git a/modules/darwin/homebrew.nix b/modules/darwin/homebrew.nix index fc1f2b6..47501d7 100644 --- a/modules/darwin/homebrew.nix +++ b/modules/darwin/homebrew.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ # Homebrew - Mac-specific packages that aren't in Nix config = lib.mkIf pkgs.stdenv.isDarwin { @@ -14,8 +20,7 @@ ''; # Add homebrew paths to CLI path - home-manager.users.${config.user}.home.sessionPath = - [ "/opt/homebrew/bin/" ]; + home-manager.users.${config.user}.home.sessionPath = [ "/opt/homebrew/bin/" ]; homebrew = { enable = true; @@ -43,7 +48,5 @@ # "epic-games" # Not packaged for Nix ]; }; - }; - } diff --git a/modules/darwin/kitty.nix b/modules/darwin/kitty.nix index c19419f..c0b03e1 100644 --- a/modules/darwin/kitty.nix +++ b/modules/darwin/kitty.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ # MacOS-specific settings for Kitty home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin { @@ -13,5 +19,4 @@ }; }; }; - } diff --git a/modules/darwin/networking.nix b/modules/darwin/networking.nix index 34faf73..dca3caf 100644 --- a/modules/darwin/networking.nix +++ b/modules/darwin/networking.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ config = lib.mkIf pkgs.stdenv.isDarwin { networking = { @@ -7,5 +13,4 @@ # hostName = ""; }; }; - } diff --git a/modules/darwin/nixpkgs.nix b/modules/darwin/nixpkgs.nix index adbbd3d..fb9b823 100644 --- a/modules/darwin/nixpkgs.nix +++ b/modules/darwin/nixpkgs.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin { @@ -27,7 +33,5 @@ }; }; }; - }; - } diff --git a/modules/darwin/system.nix b/modules/darwin/system.nix index 5c83c4b..371c392 100644 --- a/modules/darwin/system.nix +++ b/modules/darwin/system.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ config = lib.mkIf pkgs.stdenv.isDarwin { @@ -102,7 +108,6 @@ "${pkgs.kitty}/Applications/kitty.app" "/System/Applications/System Settings.app" ]; - }; finder = { @@ -118,7 +123,6 @@ # Allow quitting of Finder application QuitMenuItem = true; - }; # Disable "Are you sure you want to open" dialog @@ -165,12 +169,9 @@ eventTimeFormat = ''"show"''; eventTitleFormat = ''"none"''; eventTitleIconFormat = ''"iconCalendar"''; - slackBrowser = - ''{"deletable":true,"arguments":"","name":"Slack","path":""}''; - zoomBrowser = - ''{"deletable":true,"arguments":"","name":"Zoom","path":""}''; - KeyboardShortcuts_joinEventShortcut = - ''{"carbonModifiers":6400,"carbonKeyCode":38}''; + slackBrowser = ''{"deletable":true,"arguments":"","name":"Slack","path":""}''; + zoomBrowser = ''{"deletable":true,"arguments":"","name":"Zoom","path":""}''; + KeyboardShortcuts_joinEventShortcut = ''{"carbonModifiers":6400,"carbonKeyCode":38}''; timeFormat = ''"12-hour"''; }; }; @@ -178,7 +179,6 @@ CustomSystemPreferences = { }; - }; # Settings that don't have an option in nix-darwin @@ -199,9 +199,6 @@ defaults write -globalDomain NSStatusItemSelectionPadding -int 6 defaults write -globalDomain NSStatusItemSpacing -int 6 ''; - }; - }; - } diff --git a/modules/darwin/tmux.nix b/modules/darwin/tmux.nix index 252e70e..ae8f27f 100644 --- a/modules/darwin/tmux.nix +++ b/modules/darwin/tmux.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ options.tmux.enable = lib.mkEnableOption "Tmux terminal multiplexer"; @@ -127,7 +133,5 @@ tan = "tmux attach-session -t noah"; tnn = "tmux new-session -s noah"; }; - }; - } diff --git a/modules/darwin/user.nix b/modules/darwin/user.nix index d11414e..c457f93 100644 --- a/modules/darwin/user.nix +++ b/modules/darwin/user.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ config = lib.mkIf pkgs.stdenv.isDarwin { @@ -6,22 +12,20 @@ # macOS user home = config.homePath; shell = pkgs.fish; # Default shell - }; home-manager.users.${config.user} = { # Default shell setting doesn't work - home.sessionVariables = { SHELL = "${pkgs.fish}/bin/fish"; }; + home.sessionVariables = { + SHELL = "${pkgs.fish}/bin/fish"; + }; # Used for aerc xdg.enable = true; - }; # Fix for: 'Error: HOME is set to "/var/root" but we expect "/var/empty"' home-manager.users.root.home.homeDirectory = lib.mkForce "/var/root"; - }; - } diff --git a/modules/darwin/utilities.nix b/modules/darwin/utilities.nix index ae57843..2a8e7cc 100644 --- a/modules/darwin/utilities.nix +++ b/modules/darwin/utilities.nix @@ -1,8 +1,16 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: { - unfreePackages = [ "consul" "vault-bin" ]; + unfreePackages = [ + "consul" + "vault-bin" + ]; home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin { @@ -38,7 +46,5 @@ # Shortcut to edit hosts file hosts = "sudo nvim /etc/hosts"; }; - }; - } diff --git a/modules/nixos/applications/calibre.nix b/modules/nixos/applications/calibre.nix index 4a95223..b8f44d8 100644 --- a/modules/nixos/applications/calibre.nix +++ b/modules/nixos/applications/calibre.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ options = { calibre = { @@ -16,6 +22,8 @@ }; # Forces Calibre to use dark mode - environment.sessionVariables = { CALIBRE_USE_DARK_PALETTE = "1"; }; + environment.sessionVariables = { + CALIBRE_USE_DARK_PALETTE = "1"; + }; }; } diff --git a/modules/nixos/applications/default.nix b/modules/nixos/applications/default.nix index 4b80379..c81296e 100644 --- a/modules/nixos/applications/default.nix +++ b/modules/nixos/applications/default.nix @@ -1,5 +1,8 @@ -{ ... }: { - - imports = [ ./calibre.nix ./nautilus.nix ]; +{ ... }: +{ + imports = [ + ./calibre.nix + ./nautilus.nix + ]; } diff --git a/modules/nixos/applications/nautilus.nix b/modules/nixos/applications/nautilus.nix index 6e13cc2..12b8beb 100644 --- a/modules/nixos/applications/nautilus.nix +++ b/modules/nixos/applications/nautilus.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ options = { nautilus = { @@ -28,18 +34,15 @@ # Generates a QR code and previews it with sushi programs.fish.functions = { qr = { - body = - "${pkgs.qrencode}/bin/qrencode $argv[1] -o /tmp/qr.png | ${pkgs.gnome.sushi}/bin/sushi /tmp/qr.png"; + body = "${pkgs.qrencode}/bin/qrencode $argv[1] -o /tmp/qr.png | ${pkgs.gnome.sushi}/bin/sushi /tmp/qr.png"; }; }; # Set Nautilus as default for opening directories xdg.mimeApps = { associations.added."inode/directory" = [ "org.gnome.Nautilus.desktop" ]; - defaultApplications."inode/directory" = - lib.mkBefore [ "org.gnome.Nautilus.desktop" ]; + defaultApplications."inode/directory" = lib.mkBefore [ "org.gnome.Nautilus.desktop" ]; }; - }; # Delete Trash files older than 1 week @@ -48,7 +51,5 @@ wantedBy = [ "default.target" ]; script = "${pkgs.trash-cli}/bin/trash-empty 7"; }; - }; - } diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index 6fe5346..af38f80 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -1,6 +1,12 @@ -{ ... }: { - - imports = - [ ./applications ./gaming ./graphical ./hardware ./services ./system ]; +{ ... }: +{ + imports = [ + ./applications + ./gaming + ./graphical + ./hardware + ./services + ./system + ]; } diff --git a/modules/nixos/gaming/chiaki.nix b/modules/nixos/gaming/chiaki.nix index 520e636..6a30a5c 100644 --- a/modules/nixos/gaming/chiaki.nix +++ b/modules/nixos/gaming/chiaki.nix @@ -1,10 +1,14 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ - options.gaming.chiaki.enable = - lib.mkEnableOption "Chiaki PlayStation remote play client."; + 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 index 1e47dc5..edd0e5b 100644 --- a/modules/nixos/gaming/default.nix +++ b/modules/nixos/gaming/default.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ imports = [ ./chiaki.nix diff --git a/modules/nixos/gaming/dwarf-fortress.nix b/modules/nixos/gaming/dwarf-fortress.nix index f48b552..bccb198 100644 --- a/modules/nixos/gaming/dwarf-fortress.nix +++ b/modules/nixos/gaming/dwarf-fortress.nix @@ -1,29 +1,34 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ - options.gaming.dwarf-fortress.enable = - lib.mkEnableOption "Dwarf Fortress free edition."; + 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 - ]; + 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/legendary.nix b/modules/nixos/gaming/legendary.nix index ead410f..e8ee270 100644 --- a/modules/nixos/gaming/legendary.nix +++ b/modules/nixos/gaming/legendary.nix @@ -1,11 +1,16 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: -let home-packages = config.home-manager.users.${config.user}.home.packages; +let + home-packages = config.home-manager.users.${config.user}.home.packages; +in +{ -in { - - options.gaming.legendary.enable = - lib.mkEnableOption "Legendary Epic Games launcher."; + options.gaming.legendary.enable = lib.mkEnableOption "Legendary Epic Games launcher."; config = lib.mkIf config.gaming.legendary.enable { environment.systemPackages = with pkgs; [ @@ -28,29 +33,28 @@ in { log_level = error ''; - home.file = let - ignorePatterns = '' - .wine/ - drive_c/''; - in { - ".rgignore".text = ignorePatterns; - ".fdignore".text = ignorePatterns; - }; - - programs.fish.functions = - lib.mkIf (builtins.elem pkgs.fzf home-packages) { - epic-games = { - body = '' - set game (legendary list 2>/dev/null \ - | awk '/^ \* / { print $0; }' \ - | sed -e 's/ (.*)$//' -e 's/ \* //' \ - | fzf) - and legendary launch "$game" &> /dev/null - ''; - }; + home.file = + let + ignorePatterns = '' + .wine/ + drive_c/''; + in + { + ".rgignore".text = ignorePatterns; + ".fdignore".text = ignorePatterns; }; + programs.fish.functions = lib.mkIf (builtins.elem pkgs.fzf home-packages) { + epic-games = { + body = '' + set game (legendary list 2>/dev/null \ + | awk '/^ \* / { print $0; }' \ + | sed -e 's/ (.*)$//' -e 's/ \* //' \ + | fzf) + and legendary launch "$game" &> /dev/null + ''; + }; + }; }; }; - } diff --git a/modules/nixos/gaming/lutris.nix b/modules/nixos/gaming/lutris.nix index d2783e3..7d11f4e 100644 --- a/modules/nixos/gaming/lutris.nix +++ b/modules/nixos/gaming/lutris.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ options.gaming.lutris.enable = lib.mkEnableOption "Lutris game installer."; @@ -9,5 +15,4 @@ wineWowPackages.stable # 32-bit and 64-bit wineWowPackages ]; }; - } diff --git a/modules/nixos/gaming/minecraft-server.nix b/modules/nixos/gaming/minecraft-server.nix index 869934d..fef0c7a 100644 --- a/modules/nixos/gaming/minecraft-server.nix +++ b/modules/nixos/gaming/minecraft-server.nix @@ -1,4 +1,9 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: let @@ -6,8 +11,8 @@ let publicPort = 49732; rconPort = 25575; rconPassword = "thiscanbeanything"; - -in { +in +{ config = lib.mkIf config.services.minecraft-server.enable { @@ -52,7 +57,9 @@ in { # 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 [ ]; }; + systemd.services.minecraft-server = { + wantedBy = pkgs.lib.mkForce [ ]; + }; # Listen for connections on the public port, to trigger the actual # listen-minecraft service. @@ -65,18 +72,25 @@ in { # 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 - }"; + 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 ]; + path = with pkgs; [ + systemd + libressl + busybox + ]; # Start Minecraft and the auto-shutdown timer script = '' @@ -87,9 +101,7 @@ in { # 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 + 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 @@ -144,7 +156,5 @@ in { fi ''; }; - }; - } diff --git a/modules/nixos/gaming/ryujinx.nix b/modules/nixos/gaming/ryujinx.nix index d31df5a..1bd1191 100644 --- a/modules/nixos/gaming/ryujinx.nix +++ b/modules/nixos/gaming/ryujinx.nix @@ -1,17 +1,19 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ - options.gaming.ryujinx.enable = - lib.mkEnableOption "Ryujinx Nintendo Switch application."; + 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"; - }; + 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 index 51758ce..3393455 100644 --- a/modules/nixos/gaming/steam.nix +++ b/modules/nixos/gaming/steam.nix @@ -1,10 +1,21 @@ -{ config, pkgs, lib, ... }: { +{ + 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" ]; + unfreePackages = [ + "steam" + "steam-original" + "steamcmd" + "steam-run" + ]; programs.steam = { enable = true; @@ -13,8 +24,7 @@ # Adapted in part from: https://github.com/Shawn8901/nix-configuration/blob/1c48be94238a9f463cf0bbd1e1842a4454286514/modules/nixos/steam-compat-tools/default.nix # Based on: https://github.com/NixOS/nixpkgs/issues/73323 extraEnv = { - STEAM_EXTRA_COMPAT_TOOLS_PATHS = - lib.makeBinPath [ pkgs.proton-ge-custom ]; + STEAM_EXTRA_COMPAT_TOOLS_PATHS = lib.makeBinPath [ pkgs.proton-ge-custom ]; }; }; }; @@ -27,13 +37,10 @@ # Allow downloading of GE-Proton and other versions protonup-qt - ]; # Seems like NetworkManager can help speed up Steam launch # https://www.reddit.com/r/archlinux/comments/qguhco/steam_startup_time_arch_1451_seconds_fedora_34/hi8opet/ networking.networkmanager.enable = true; - }; - } diff --git a/modules/nixos/graphical/default.nix b/modules/nixos/graphical/default.nix index 85196de..372abb6 100644 --- a/modules/nixos/graphical/default.nix +++ b/modules/nixos/graphical/default.nix @@ -1,4 +1,5 @@ -{ lib, ... }: { +{ lib, ... }: +{ imports = [ ./dunst.nix @@ -49,7 +50,5 @@ type = lib.types.path; description = "Wallpaper background image file"; }; - }; - } diff --git a/modules/nixos/graphical/dmenu.nix b/modules/nixos/graphical/dmenu.nix index 962f8ae..0895a69 100644 --- a/modules/nixos/graphical/dmenu.nix +++ b/modules/nixos/graphical/dmenu.nix @@ -1,4 +1,9 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: { @@ -8,7 +13,5 @@ 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 index 7700dbf..8926d48 100644 --- a/modules/nixos/graphical/dunst.nix +++ b/modules/nixos/graphical/dunst.nix @@ -25,7 +25,5 @@ }; }; }; - }; - } diff --git a/modules/nixos/graphical/fonts.nix b/modules/nixos/graphical/fonts.nix index 470f492..896b3ac 100644 --- a/modules/nixos/graphical/fonts.nix +++ b/modules/nixos/graphical/fonts.nix @@ -1,8 +1,14 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: -let fontName = "Victor Mono"; - -in { +let + fontName = "Victor Mono"; +in +{ config = lib.mkIf (config.gui.enable && pkgs.stdenv.isLinux) { @@ -24,7 +30,5 @@ in { programs.kitty.font.name = fontName; services.dunst.settings.global.font = "Hack Nerd Font 14"; }; - }; - } diff --git a/modules/nixos/graphical/gtk.nix b/modules/nixos/graphical/gtk.nix index 5afdc11..3ebef73 100644 --- a/modules/nixos/graphical/gtk.nix +++ b/modules/nixos/graphical/gtk.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ options = { gtk.theme = { @@ -18,20 +24,21 @@ home-manager.users.${config.user} = { - gtk = let - gtkExtraConfig = { - gtk-application-prefer-dark-theme = config.theme.dark; + gtk = + let + gtkExtraConfig = { + gtk-application-prefer-dark-theme = config.theme.dark; + }; + in + { + enable = true; + theme = { + name = config.gtk.theme.name; + package = config.gtk.theme.package; + }; + gtk3.extraConfig = gtkExtraConfig; + gtk4.extraConfig = gtkExtraConfig; }; - in { - enable = true; - theme = { - name = config.gtk.theme.name; - package = config.gtk.theme.package; - }; - gtk3.extraConfig = gtkExtraConfig; - gtk4.extraConfig = gtkExtraConfig; - }; - }; # Required for setting GTK theme (for preferred-color-scheme in browser) @@ -44,8 +51,8 @@ package = config.gtk.theme.package; }; - environment.sessionVariables = { GTK_THEME = config.gtk.theme.name; }; - + environment.sessionVariables = { + GTK_THEME = config.gtk.theme.name; + }; }; - } diff --git a/modules/nixos/graphical/i3.nix b/modules/nixos/graphical/i3.nix index c596827..8dba045 100644 --- a/modules/nixos/graphical/i3.nix +++ b/modules/nixos/graphical/i3.nix @@ -1,18 +1,23 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: let - lockCmd = - "${pkgs.betterlockscreen}/bin/betterlockscreen --lock --display 1 --blur 0.5 --span"; - lockUpdate = - "${pkgs.betterlockscreen}/bin/betterlockscreen --update ${config.wallpaper} --display 1 --span"; - -in { + lockCmd = "${pkgs.betterlockscreen}/bin/betterlockscreen --lock --display 1 --blur 0.5 --span"; + lockUpdate = "${pkgs.betterlockscreen}/bin/betterlockscreen --update ${config.wallpaper} --display 1 --span"; +in +{ config = lib.mkIf pkgs.stdenv.isLinux { services.xserver.windowManager = { - i3 = { enable = config.services.xserver.enable; }; + i3 = { + enable = config.services.xserver.enable; + }; }; environment.systemPackages = with pkgs; [ @@ -23,237 +28,221 @@ in { home-manager.users.${config.user} = { xsession.windowManager.i3 = { enable = config.services.xserver.enable; - config = let - modifier = "Mod4"; # Super key - ws1 = "1:I"; - ws2 = "2:II"; - ws3 = "3:III"; - ws4 = "4:IV"; - ws5 = "5:V"; - ws6 = "6:VI"; - ws7 = "7:VII"; - ws8 = "8:VIII"; - ws9 = "9:IX"; - ws10 = "10:X"; - in { - modifier = modifier; - assigns = { - "${ws1}" = [{ class = "Firefox"; }]; - "${ws2}" = [ - { class = "kitty"; } - { class = "aerc"; } - { class = "obsidian"; } + config = + let + modifier = "Mod4"; # Super key + ws1 = "1:I"; + ws2 = "2:II"; + ws3 = "3:III"; + ws4 = "4:IV"; + ws5 = "5:V"; + ws6 = "6:VI"; + ws7 = "7:VII"; + ws8 = "8:VIII"; + ws9 = "9:IX"; + ws10 = "10:X"; + in + { + modifier = modifier; + assigns = { + "${ws1}" = [ { class = "Firefox"; } ]; + "${ws2}" = [ + { class = "kitty"; } + { class = "aerc"; } + { class = "obsidian"; } + ]; + "${ws3}" = [ { class = "discord"; } ]; + "${ws4}" = [ + { class = "steam"; } + { class = "Steam"; } + ]; + }; + bars = [ { command = "echo"; } ]; # Disable i3bar + colors = + let + 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.theme.colors.base00; + focused = { + inherit + background + indicator + text + border + ; + childBorder = background; + }; + focusedInactive = { + inherit indicator; + background = inactiveBackground; + border = inactiveBorder; + childBorder = inactiveBackground; + text = inactiveText; + }; + # placeholder = { }; + unfocused = { + inherit indicator; + background = inactiveBackground; + border = inactiveBorder; + childBorder = inactiveBackground; + text = inactiveText; + }; + urgent = { + inherit text indicator; + background = urgentBackground; + border = urgentBackground; + childBorder = urgentBackground; + }; + }; + floating.modifier = modifier; + focus = { + mouseWarping = true; + newWindow = "urgent"; + followMouse = false; + }; + keybindings = { + + # Adjust screen brightness + "Shift+F12" = + # Disable dynamic sleep + # https://github.com/rockowitz/ddcutil/issues/323 + "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --disable-dynamic-sleep --display 2 setvcp 10 + 30"; + "Shift+F11" = "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --disable-dynamic-sleep --display 2 setvcp 10 - 30"; + "XF86MonBrightnessUp" = "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --disable-dynamic-sleep --display 2 setvcp 10 + 30"; + "XF86MonBrightnessDown" = "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --disable-dynamic-sleep --display 2 setvcp 10 - 30"; + + # Media player controls + "XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; + "XF86AudioStop" = "exec ${pkgs.playerctl}/bin/playerctl stop"; + "XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl next"; + "XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl previous"; + + # Launchers + "${modifier}+Return" = "exec --no-startup-id kitty; workspace ${ws2}; layout tabbed"; + "${modifier}+space" = "exec --no-startup-id ${config.launcherCommand}"; + "${modifier}+Shift+s" = "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.toggleBarCommand}"; + "${modifier}+f" = "fullscreen toggle"; + "${modifier}+h" = "focus left"; + "${modifier}+j" = "focus down"; + "${modifier}+k" = "focus up"; + "${modifier}+l" = "focus right"; + "${modifier}+Left" = "focus left"; + "${modifier}+Down" = "focus down"; + "${modifier}+Up" = "focus up"; + "${modifier}+Right" = "focus right"; + "${modifier}+Shift+h" = "move left"; + "${modifier}+Shift+j" = "move down"; + "${modifier}+Shift+k" = "move up"; + "${modifier}+Shift+l" = "move right"; + "${modifier}+Shift+Left" = "move left"; + "${modifier}+Shift+Down" = "move down"; + "${modifier}+Shift+Up" = "move up"; + "${modifier}+Shift+Right" = "move right"; + + # Tiling + "${modifier}+i" = "split h"; + "${modifier}+v" = "split v"; + "${modifier}+s" = "layout stacking"; + "${modifier}+t" = "layout tabbed"; + "${modifier}+e" = "layout toggle split"; + "${modifier}+Shift+space" = "floating toggle"; + "${modifier}+Control+space" = "focus mode_toggle"; + "${modifier}+a" = "focus parent"; + + # Workspaces + "${modifier}+1" = "workspace ${ws1}"; + "${modifier}+2" = "workspace ${ws2}"; + "${modifier}+3" = "workspace ${ws3}"; + "${modifier}+4" = "workspace ${ws4}"; + "${modifier}+5" = "workspace ${ws5}"; + "${modifier}+6" = "workspace ${ws6}"; + "${modifier}+7" = "workspace ${ws7}"; + "${modifier}+8" = "workspace ${ws8}"; + "${modifier}+9" = "workspace ${ws9}"; + "${modifier}+0" = "workspace ${ws10}"; + + # Move windows + "${modifier}+Shift+1" = "move container to workspace ${ws1}; workspace ${ws1}"; + "${modifier}+Shift+2" = "move container to workspace ${ws2}; workspace ${ws2}"; + "${modifier}+Shift+3" = "move container to workspace ${ws3}; workspace ${ws3}"; + "${modifier}+Shift+4" = "move container to workspace ${ws4}; workspace ${ws4}"; + "${modifier}+Shift+5" = "move container to workspace ${ws5}; workspace ${ws5}"; + "${modifier}+Shift+6" = "move container to workspace ${ws6}; workspace ${ws6}"; + "${modifier}+Shift+7" = "move container to workspace ${ws7}; workspace ${ws7}"; + "${modifier}+Shift+8" = "move container to workspace ${ws8}; workspace ${ws8}"; + "${modifier}+Shift+9" = "move container to workspace ${ws9}; workspace ${ws9}"; + "${modifier}+Shift+0" = "move container to workspace ${ws10}; workspace ${ws10}"; + + # Move screens + "${modifier}+Control+l" = "move workspace to output right"; + "${modifier}+Control+h" = "move workspace to output left"; + + # Resizing + "${modifier}+r" = ''mode "resize"''; + "${modifier}+Control+Shift+h" = "resize shrink width 10 px or 10 ppt"; + "${modifier}+Control+Shift+j" = "resize grow height 10 px or 10 ppt"; + "${modifier}+Control+Shift+k" = "resize shrink height 10 px or 10 ppt"; + "${modifier}+Control+Shift+l" = "resize grow width 10 px or 10 ppt"; + }; + modes = { }; + startup = [ + { + command = "feh --bg-fill ${config.wallpaper}"; + always = true; + notification = false; + } + { + command = "i3-msg workspace ${ws2}, move workspace to output right"; + notification = false; + } + { + command = "i3-msg workspace ${ws1}, move workspace to output left"; + notification = false; + } ]; - "${ws3}" = [{ class = "discord"; }]; - "${ws4}" = [ { class = "steam"; } { class = "Steam"; } ]; - }; - bars = [{ command = "echo"; }]; # Disable i3bar - colors = let - 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.theme.colors.base00; - focused = { - inherit background indicator text border; - childBorder = background; - }; - focusedInactive = { - inherit indicator; - background = inactiveBackground; - border = inactiveBorder; - childBorder = inactiveBackground; - text = inactiveText; - }; - # placeholder = { }; - unfocused = { - inherit indicator; - background = inactiveBackground; - border = inactiveBorder; - childBorder = inactiveBackground; - text = inactiveText; - }; - urgent = { - inherit text indicator; - background = urgentBackground; - border = urgentBackground; - childBorder = urgentBackground; + window = { + border = 0; + hideEdgeBorders = "smart"; + titlebar = false; }; + workspaceAutoBackAndForth = false; + workspaceOutputAssign = [ ]; + # gaps = { + # bottom = 8; + # top = 8; + # left = 8; + # right = 8; + # horizontal = 15; + # vertical = 15; + # inner = 15; + # outer = 0; + # smartBorders = "off"; + # smartGaps = false; + # }; }; - floating.modifier = modifier; - focus = { - mouseWarping = true; - newWindow = "urgent"; - followMouse = false; - }; - keybindings = { - - # Adjust screen brightness - "Shift+F12" = - # Disable dynamic sleep - # https://github.com/rockowitz/ddcutil/issues/323 - "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --disable-dynamic-sleep --display 2 setvcp 10 + 30"; - "Shift+F11" = - "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --disable-dynamic-sleep --display 2 setvcp 10 - 30"; - "XF86MonBrightnessUp" = - "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --disable-dynamic-sleep --display 2 setvcp 10 + 30"; - "XF86MonBrightnessDown" = - "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --disable-dynamic-sleep --display 2 setvcp 10 - 30"; - - # Media player controls - "XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; - "XF86AudioStop" = "exec ${pkgs.playerctl}/bin/playerctl stop"; - "XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl next"; - "XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl previous"; - - # Launchers - "${modifier}+Return" = - "exec --no-startup-id kitty; workspace ${ws2}; layout tabbed"; - "${modifier}+space" = - "exec --no-startup-id ${config.launcherCommand}"; - "${modifier}+Shift+s" = - "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.toggleBarCommand}"; - "${modifier}+f" = "fullscreen toggle"; - "${modifier}+h" = "focus left"; - "${modifier}+j" = "focus down"; - "${modifier}+k" = "focus up"; - "${modifier}+l" = "focus right"; - "${modifier}+Left" = "focus left"; - "${modifier}+Down" = "focus down"; - "${modifier}+Up" = "focus up"; - "${modifier}+Right" = "focus right"; - "${modifier}+Shift+h" = "move left"; - "${modifier}+Shift+j" = "move down"; - "${modifier}+Shift+k" = "move up"; - "${modifier}+Shift+l" = "move right"; - "${modifier}+Shift+Left" = "move left"; - "${modifier}+Shift+Down" = "move down"; - "${modifier}+Shift+Up" = "move up"; - "${modifier}+Shift+Right" = "move right"; - - # Tiling - "${modifier}+i" = "split h"; - "${modifier}+v" = "split v"; - "${modifier}+s" = "layout stacking"; - "${modifier}+t" = "layout tabbed"; - "${modifier}+e" = "layout toggle split"; - "${modifier}+Shift+space" = "floating toggle"; - "${modifier}+Control+space" = "focus mode_toggle"; - "${modifier}+a" = "focus parent"; - - # Workspaces - "${modifier}+1" = "workspace ${ws1}"; - "${modifier}+2" = "workspace ${ws2}"; - "${modifier}+3" = "workspace ${ws3}"; - "${modifier}+4" = "workspace ${ws4}"; - "${modifier}+5" = "workspace ${ws5}"; - "${modifier}+6" = "workspace ${ws6}"; - "${modifier}+7" = "workspace ${ws7}"; - "${modifier}+8" = "workspace ${ws8}"; - "${modifier}+9" = "workspace ${ws9}"; - "${modifier}+0" = "workspace ${ws10}"; - - # Move windows - "${modifier}+Shift+1" = - "move container to workspace ${ws1}; workspace ${ws1}"; - "${modifier}+Shift+2" = - "move container to workspace ${ws2}; workspace ${ws2}"; - "${modifier}+Shift+3" = - "move container to workspace ${ws3}; workspace ${ws3}"; - "${modifier}+Shift+4" = - "move container to workspace ${ws4}; workspace ${ws4}"; - "${modifier}+Shift+5" = - "move container to workspace ${ws5}; workspace ${ws5}"; - "${modifier}+Shift+6" = - "move container to workspace ${ws6}; workspace ${ws6}"; - "${modifier}+Shift+7" = - "move container to workspace ${ws7}; workspace ${ws7}"; - "${modifier}+Shift+8" = - "move container to workspace ${ws8}; workspace ${ws8}"; - "${modifier}+Shift+9" = - "move container to workspace ${ws9}; workspace ${ws9}"; - "${modifier}+Shift+0" = - "move container to workspace ${ws10}; workspace ${ws10}"; - - # Move screens - "${modifier}+Control+l" = "move workspace to output right"; - "${modifier}+Control+h" = "move workspace to output left"; - - # Resizing - "${modifier}+r" = ''mode "resize"''; - "${modifier}+Control+Shift+h" = - "resize shrink width 10 px or 10 ppt"; - "${modifier}+Control+Shift+j" = - "resize grow height 10 px or 10 ppt"; - "${modifier}+Control+Shift+k" = - "resize shrink height 10 px or 10 ppt"; - "${modifier}+Control+Shift+l" = "resize grow width 10 px or 10 ppt"; - }; - modes = { }; - startup = [ - { - command = "feh --bg-fill ${config.wallpaper}"; - always = true; - notification = false; - } - { - command = - "i3-msg workspace ${ws2}, move workspace to output right"; - notification = false; - } - { - command = - "i3-msg workspace ${ws1}, move workspace to output left"; - notification = false; - } - ]; - window = { - border = 0; - hideEdgeBorders = "smart"; - titlebar = false; - }; - workspaceAutoBackAndForth = false; - workspaceOutputAssign = [ ]; - # gaps = { - # bottom = 8; - # top = 8; - # left = 8; - # right = 8; - # horizontal = 15; - # vertical = 15; - # inner = 15; - # outer = 0; - # smartBorders = "off"; - # smartGaps = false; - # }; - }; extraConfig = ""; }; @@ -266,22 +255,26 @@ in { # Update lock screen cache only if cache is empty home.activation.updateLockScreenCache = - let cacheDir = "${config.homePath}/.cache/betterlockscreen/current"; - in lib.mkIf config.services.xserver.enable - (config.home-manager.users.${config.user}.lib.dag.entryAfter - [ "writeBoundary" ] '' + let + cacheDir = "${config.homePath}/.cache/betterlockscreen/current"; + 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" ]; + before = [ + "sleep.target" + "suspend.target" + ]; serviceConfig = { User = config.user; Type = "simple"; @@ -290,9 +283,10 @@ in { ExecStart = lockCmd; ExecStartPost = "${pkgs.coreutils-full}/bin/sleep 1"; }; - wantedBy = [ "sleep.target" "suspend.target" ]; + wantedBy = [ + "sleep.target" + "suspend.target" + ]; }; - }; - } diff --git a/modules/nixos/graphical/picom.nix b/modules/nixos/graphical/picom.nix index 102d4d5..062fa53 100644 --- a/modules/nixos/graphical/picom.nix +++ b/modules/nixos/graphical/picom.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) { home-manager.users.${config.user} = { @@ -31,18 +37,21 @@ ]; shadow = false; shadowExclude = [ ]; - shadowOffsets = [ (-10) (-10) ]; + shadowOffsets = [ + (-10) + (-10) + ]; shadowOpacity = 0.5; vSync = true; }; - xsession.windowManager.i3.config.startup = [{ - command = "systemctl --user restart picom"; - always = true; - notification = false; - }]; - + xsession.windowManager.i3.config.startup = [ + { + command = "systemctl --user restart picom"; + always = true; + notification = false; + } + ]; }; }; - } diff --git a/modules/nixos/graphical/polybar.nix b/modules/nixos/graphical/polybar.nix index 9a1f73e..0f4f9e1 100644 --- a/modules/nixos/graphical/polybar.nix +++ b/modules/nixos/graphical/polybar.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) { @@ -46,33 +52,36 @@ # wm-restack = "i3"; # override-redirect = true; }; - "module/i3" = let padding = 2; - in { - type = "internal/i3"; - pin-workspaces = false; - show-urgent = true; - strip-wsnumbers = true; - index-sort = true; - enable-click = true; - wrapping-scroll = true; - fuzzy-match = true; - format = " "; - label-focused = "%name%"; - 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.theme.colors.base01; - label-visible-padding = padding; - label-urgent = "%name%"; - 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/i3" = + let + padding = 2; + in + { + type = "internal/i3"; + pin-workspaces = false; + show-urgent = true; + strip-wsnumbers = true; + index-sort = true; + enable-click = true; + wrapping-scroll = true; + fuzzy-match = true; + format = " "; + label-focused = "%name%"; + 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.theme.colors.base01; + label-visible-padding = padding; + label-urgent = "%name%"; + 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%"; @@ -105,24 +114,24 @@ type = "custom/script"; interval = 10; format = "