diff --git a/.editorconfig b/.editorconfig index 75c6baf5..2b929268 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,5 +5,9 @@ indent_style = tab insert_final_newline = true trim_trailing_whitespace = true +[*.nix] +indent_style = space +indent_size = 2 + [*.md] trim_trailing_whitespace = false diff --git a/.treefmt.toml b/.treefmt.toml new file mode 100644 index 00000000..909299fd --- /dev/null +++ b/.treefmt.toml @@ -0,0 +1,16 @@ +# SRC: https://github.com/numtide/treefmt +# REF: https://treefmt.com/latest/getting-started/configure/#config-file + +walk = "git" +excludes = [ + "*.key", + "*.patch", + "*.ogg", + "*.lock", + "License" +] + +[formatter.nixfmt-rfc-style] +command = "nixfmt" +options = [ "-s" ] +includes = [ "*.nix" ] diff --git a/Makefile b/Makefile index a5206337..7a4c1310 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -options = --option eval-cache false --fallback --print-build-logs --verbose --extra-experimental-features pipe-operators +options = --option eval-cache false --fallback --print-build-logs --verbose --option extra-experimental-features pipe-operators flake = . hostname = $(shell hostname) @@ -16,7 +16,7 @@ boot: cached: $(eval options := $(subst eval-cache false,eval-cache true,$(options))) -check: +check: format nix flake check --show-trace # HACK: Fix ulimit switch issue. Test sometime in the future again. @@ -28,6 +28,9 @@ check: # fix-unlock: # pkill nixos-rebuild || true +format: + treefmt --no-cache --clear-cache + nixconf: mv /etc/nix/nix.conf_ /etc/nix/nix.conf || true diff --git a/config/AmdCompute.nix b/config/AmdCompute.nix index cd2eb8b8..eacc5693 100644 --- a/config/AmdCompute.nix +++ b/config/AmdCompute.nix @@ -1,16 +1,16 @@ { - config, - lib, - pkgs, - ... -}: let - cfg = config.module.amd.compute; -in { - config = lib.mkIf cfg.enable { - nixpkgs.config.rocmSupport = true; - systemd.tmpfiles.rules = [ "L+ /opt/rocm/hip - - - - ${pkgs.rocmPackages.clr}" ]; - hardware.graphics.extraPackages = with pkgs; [ - rocmPackages.clr.icd - ]; - }; + config, + lib, + pkgs, + ... +}: +let + cfg = config.module.amd.compute; +in +{ + config = lib.mkIf cfg.enable { + nixpkgs.config.rocmSupport = true; + systemd.tmpfiles.rules = [ "L+ /opt/rocm/hip - - - - ${pkgs.rocmPackages.clr}" ]; + hardware.graphics.extraPackages = with pkgs; [ rocmPackages.clr.icd ]; + }; } diff --git a/config/AmdCpu.nix b/config/AmdCpu.nix index e732eb56..3cf70348 100644 --- a/config/AmdCpu.nix +++ b/config/AmdCpu.nix @@ -1,26 +1,24 @@ -{ - config, - lib, - ... -}: let - cfg = config.module.amd.cpu; +{ config, lib, ... }: +let + cfg = config.module.amd.cpu; - controlFile = "/sys/devices/system/cpu/cpufreq/boost"; - disableCmd = "1"; - enableCmd = "0"; -in { - config = lib.mkIf cfg.enable (lib.mkMerge [ - { - boot.kernelModules = [ "kvm-amd" ]; - hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; - } - (lib.mkIf cfg.powersave { - module.powersave = { - enable = true; - cpu.boost = { - inherit controlFile enableCmd disableCmd; - }; - }; - }) - ]); + controlFile = "/sys/devices/system/cpu/cpufreq/boost"; + disableCmd = "1"; + enableCmd = "0"; +in +{ + config = lib.mkIf cfg.enable ( + lib.mkMerge [ + { + boot.kernelModules = [ "kvm-amd" ]; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + } + (lib.mkIf cfg.powersave { + module.powersave = { + enable = true; + cpu.boost = { inherit controlFile enableCmd disableCmd; }; + }; + }) + ] + ); } diff --git a/config/AmdGpu.nix b/config/AmdGpu.nix index 33840827..262d48ee 100644 --- a/config/AmdGpu.nix +++ b/config/AmdGpu.nix @@ -1,29 +1,23 @@ +{ config, lib, ... }: +let + cfg = config.module.amd.gpu; +in { - config, - lib, - ... -}: let - cfg = config.module.amd.gpu; -in { - config = lib.mkIf cfg.enable { - environment.variables.AMD_VULKAN_ICD = "RADV"; - boot.initrd.kernelModules = [ - "amdgpu" - ]; - services.xserver.videoDrivers = [ - "amdgpu" - ]; - hardware.graphics = { - enable = true; - enable32Bit = true; - }; + config = lib.mkIf cfg.enable { + environment.variables.AMD_VULKAN_ICD = "RADV"; + boot.initrd.kernelModules = [ "amdgpu" ]; + services.xserver.videoDrivers = [ "amdgpu" ]; + hardware.graphics = { + enable = true; + enable32Bit = true; + }; - # AMDVLK was broken for me (huge stuttering). So keep it disabled, at least for now. - # hardware.opengl.extraPackages = with pkgs; [ - # amdvlk - # ]; - # hardware.opengl.extraPackages32 = with pkgs; [ - # driversi686Linux.amdvlk - # ]; - }; + # AMDVLK was broken for me (huge stuttering). So keep it disabled, at least for now. + # hardware.opengl.extraPackages = with pkgs; [ + # amdvlk + # ]; + # hardware.opengl.extraPackages32 = with pkgs; [ + # driversi686Linux.amdvlk + # ]; + }; } diff --git a/config/AutoUpdateSigned.nix b/config/AutoUpdateSigned.nix index 57f64002..cfa7d0e4 100644 --- a/config/AutoUpdateSigned.nix +++ b/config/AutoUpdateSigned.nix @@ -3,68 +3,62 @@ # Unlike system.autoUpgrade, this script also verifies my git signature # to prevent unathorized changes to hosts. { - config, - const, - lib, - pkgs, - secret, - util, - ... -}: let - cfg = config.module.autoupdate; -in { - config = lib.mkIf cfg.enable { - programs.git = { - enable = true; - config = { - gpg.ssh.allowedSignersFile = toString secret.crypto.sign.git.allowed; - }; - }; + config, + const, + lib, + pkgs, + secret, + util, + ... +}: +let + cfg = config.module.autoupdate; +in +{ + config = lib.mkIf cfg.enable { + programs.git = { + enable = true; + config = { + gpg.ssh.allowedSignersFile = toString secret.crypto.sign.git.allowed; + }; + }; - systemd.services.autoupdate = util.mkStaticSystemdService { - enable = true; - description = "Signed system auto-update."; - serviceConfig = { - Type = "oneshot"; - }; - path = with pkgs; [ - bash - coreutils - git - gnumake - nixos-rebuild - openssh - ]; - script = '' - pushd /tmp - rm -rf ./nixos - git clone --depth=1 --single-branch --branch=main ${const.url} ./nixos - pushd ./nixos - git verify-commit HEAD && git fsck || { - echo "Verification failed." - exit 1 - }; - timeout 55m make switch - ''; - after = [ - "network-online.target" - ]; - wants = [ - "network-online.target" - ]; - }; + systemd.services.autoupdate = util.mkStaticSystemdService { + enable = true; + after = [ "network-online.target" ]; + description = "Signed system auto-update."; + serviceConfig.Type = "oneshot"; + wants = [ "network-online.target" ]; + path = with pkgs; [ + bash + coreutils + git + gnumake + nixos-rebuild + openssh + ]; + script = '' + pushd /tmp + rm -rf ./nixos + git clone --depth=1 --single-branch --branch=main ${const.url} ./nixos + pushd ./nixos + git verify-commit HEAD && git fsck || { + echo "Verification failed." + exit 1 + }; + timeout 55m make switch + ''; + }; - systemd.timers.autoupdate = { - enable = true; - timerConfig = { - OnCalendar = "hourly"; - Persistent = true; - RandomizedDelaySec = 60; - Unit = "autoupdate.service"; - }; - wantedBy = [ - "timers.target" - ]; - }; - }; + systemd.timers.autoupdate = { + enable = true; + wantedBy = [ "timers.target" ]; + timerConfig = { + OnCalendar = "hourly"; + Persistent = true; + RandomizedDelaySec = 60; + Unit = "autoupdate.service"; + }; + }; + }; } diff --git a/config/Bluetooth.nix b/config/Bluetooth.nix index 9954ec78..f9c1645e 100644 --- a/config/Bluetooth.nix +++ b/config/Bluetooth.nix @@ -1,15 +1,13 @@ +{ config, lib, ... }: +let + cfg = config.module.bluetooth; +in { - config, - lib, - ... -}: let - cfg = config.module.bluetooth; -in { - config = lib.mkIf cfg.enable { - services.blueman.enable = true; - hardware.bluetooth = { - enable = true; - powerOnBoot = true; - }; - }; + config = lib.mkIf cfg.enable { + services.blueman.enable = true; + hardware.bluetooth = { + enable = true; + powerOnBoot = true; + }; + }; } diff --git a/config/Brightness.nix b/config/Brightness.nix index 208818c8..9c579512 100644 --- a/config/Brightness.nix +++ b/config/Brightness.nix @@ -1,11 +1,7 @@ +{ lib, config, ... }: +let + cfg = config.module.brightness; +in { - lib, - config, - ... -}: let - cfg = config.module.brightness; -in { - config = lib.mkIf cfg.enable { - programs.light.enable = true; - }; + config = lib.mkIf cfg.enable { programs.light.enable = true; }; } diff --git a/config/Display.nix b/config/Display.nix index 13b172b4..e447ed56 100644 --- a/config/Display.nix +++ b/config/Display.nix @@ -1,42 +1,51 @@ +{ lib, config, ... }: +let + cfg = config.module.display; +in { - lib, - config, - ... -}: let - cfg = config.module.display; -in { - # REF: https://www.kernel.org/doc/Documentation/fb/fbcon.txt - # REF: https://patchwork.kernel.org/project/dri-devel/patch/20191110154101.26486-10-hdegoede@redhat.com/#22993841 - config = lib.mkMerge [ - # NOTE: `tty` name is special. - (lib.mkIf (cfg.rotate != null) { - boot.kernelParams = lib.mapAttrsToList (name: rotate: - let - hint = - if rotate == 90 then "left_side_up" - else if rotate == 180 then "upside_down" - else if rotate == 270 then "right_side_up" - else "normal"; + # REF: https://www.kernel.org/doc/Documentation/fb/fbcon.txt + # REF: https://patchwork.kernel.org/project/dri-devel/patch/20191110154101.26486-10-hdegoede@redhat.com/#22993841 + config = lib.mkMerge [ + # NOTE: `tty` name is special. + (lib.mkIf (cfg.rotate != null) { + boot.kernelParams = lib.mapAttrsToList ( + name: rotate: + let + # ISSUE: https://github.com/swaywm/sway/issues/8478 + hint = + if rotate == 90 then + "left_side_up" + else if rotate == 180 then + "upside_down" + else if rotate == 270 then + "right_side_up" + else + "normal"; - value = - if rotate == 90 then 1 - else if rotate == 180 then 2 - else if rotate == 270 then 3 - else 0; + value = + if rotate == 90 then + 1 + else if rotate == 180 then + 2 + else if rotate == 270 then + 3 + else + 0; - command = if name == "tty" then - "fbcon=rotate:${toString value}" - else - "video=${name}:rotate=${toString rotate}"; - # "video=${name}:panel_orientation=${hint}"; - # "video=${name}:rotate=${toString rotate},panel_orientation=${hint}"; - in command - ) cfg.rotate; + command = + if name == "tty" then + "fbcon=rotate:${toString value}" + else + "video=${name}:rotate=${toString rotate}"; + in + # "video=${name}:panel_orientation=${hint}"; + # "video=${name}:rotate=${toString rotate},panel_orientation=${hint}"; + command + ) cfg.rotate; - module.sway.extraConfig = lib.mapAttrsToList (name: rotate: - "output ${name} transform ${toString rotate}" - ) cfg.rotate; - }) - ]; + module.sway.extraConfig = lib.mapAttrsToList ( + name: rotate: "output ${name} transform ${toString rotate}" + ) cfg.rotate; + }) + ]; } - diff --git a/config/DisplayManager.nix b/config/DisplayManager.nix deleted file mode 100644 index b896e62b..00000000 --- a/config/DisplayManager.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ - config, - lib, - ... -}: let - cfg = config.module.dm; -in { - config = lib.mkIf cfg.enable { - services.xserver = { - enable = true; - xkb = { - layout = config.module.keyboard.layouts; - options = config.module.keyboard.options; - }; - }; - }; -} diff --git a/config/Distrobox.nix b/config/Distrobox.nix index 5cf0464a..921fed03 100644 --- a/config/Distrobox.nix +++ b/config/Distrobox.nix @@ -1,16 +1,16 @@ { - config, - lib, - pkgs, - ... -}: let - cfg = config.module.distrobox; -in { - config = lib.mkIf cfg.enable { - # Distrobox works best with Podman, so enable it here. - module.podman.enable = true; - environment.systemPackages = with pkgs; [ - distrobox - ]; - }; + config, + lib, + pkgs, + ... +}: +let + cfg = config.module.distrobox; +in +{ + config = lib.mkIf cfg.enable { + # Distrobox works best with Podman, so enable it here. + module.podman.enable = true; + environment.systemPackages = with pkgs; [ distrobox ]; + }; } diff --git a/config/Docker.nix b/config/Docker.nix index f1462197..d3500509 100644 --- a/config/Docker.nix +++ b/config/Docker.nix @@ -1,28 +1,32 @@ +{ lib, config, ... }: +let + cfg = config.module.docker; +in { - lib, - config, - ... -}: let - cfg = config.module.docker; -in { - config = lib.mkIf cfg.enable (lib.mkMerge [ - { - virtualisation.docker.enable = true; + config = lib.mkIf cfg.enable ( + lib.mkMerge [ + { + virtualisation.docker.enable = true; - systemd = if cfg.autostart then { } else { - sockets.docker.wantedBy = lib.mkForce [ ]; - services = { - docker-prune.wantedBy = lib.mkForce [ ]; - docker.wantedBy = lib.mkForce [ ]; - }; - }; - } + systemd = + if cfg.autostart then + { } + else + { + sockets.docker.wantedBy = lib.mkForce [ ]; + services = { + docker-prune.wantedBy = lib.mkForce [ ]; + docker.wantedBy = lib.mkForce [ ]; + }; + }; + } - (lib.mkIf cfg.rootless { - virtualisation.docker.rootless = { - enable = true; - setSocketVariable = true; - }; - }) - ]); + (lib.mkIf cfg.rootless { + virtualisation.docker.rootless = { + enable = true; + setSocketVariable = true; + }; + }) + ] + ); } diff --git a/config/Dpi.nix b/config/Dpi.nix index 75080e3d..5b5c3ee0 100644 --- a/config/Dpi.nix +++ b/config/Dpi.nix @@ -1,77 +1,81 @@ { - config, - lib, - pkgs, - ... -}: let - cfg = config.module.dpi.bypass; + config, + lib, + pkgs, + ... +}: +let + cfg = config.module.dpi.bypass; - whitelist = lib.optionalString ( - (builtins.length cfg.whitelist) != 0 - ) "--hostlist ${pkgs.writeText "zapret-whitelist" (lib.concatStringsSep "\n" cfg.whitelist)}"; + whitelist = lib.optionalString ( + (builtins.length cfg.whitelist) != 0 + ) "--hostlist ${pkgs.writeText "zapret-whitelist" (lib.concatStringsSep "\n" cfg.whitelist)}"; - blacklist = lib.optionalString ( - (builtins.length cfg.blacklist) != 0 - ) "--hostlist-exclude ${pkgs.writeText "zapret-blacklist" (lib.concatStringsSep "\n" cfg.blacklist)}"; + blacklist = + lib.optionalString ((builtins.length cfg.blacklist) != 0) + "--hostlist-exclude ${pkgs.writeText "zapret-blacklist" (lib.concatStringsSep "\n" cfg.blacklist)}"; - params = lib.concatStringsSep " " cfg.params; + params = lib.concatStringsSep " " cfg.params; - qnum = toString cfg.qnum; -in { - disabledModules = [ "services/networking/zapret.nix" ]; - # imports = [ "${inputs.nixpkgsMaster}/nixos/modules/services/networking/zapret.nix" ]; + qnum = toString cfg.qnum; +in +{ + disabledModules = [ "services/networking/zapret.nix" ]; + # imports = [ "${inputs.nixpkgsMaster}/nixos/modules/services/networking/zapret.nix" ]; - config = lib.mkIf cfg.enable (lib.mkMerge [ - { - systemd.services.zapret = { - description = "DPI bypass service"; - wantedBy = [ "multi-user.target" ]; - after = [ "network.target" ]; - serviceConfig = { - ExecStart = "${cfg.package}/bin/nfqws --pidfile=/run/nfqws.pid ${params} ${whitelist} ${blacklist} --qnum=${qnum}"; - Type = "simple"; - PIDFile = "/run/nfqws.pid"; - Restart = "always"; - RuntimeMaxSec = "1h"; # This service loves to crash silently or cause network slowdowns. It also restarts instantly. Restarting it at least hourly provided the best experience. + config = lib.mkIf cfg.enable ( + lib.mkMerge [ + { + systemd.services.zapret = { + description = "DPI bypass service"; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + serviceConfig = { + ExecStart = "${cfg.package}/bin/nfqws --pidfile=/run/nfqws.pid ${params} ${whitelist} ${blacklist} --qnum=${qnum}"; + Type = "simple"; + PIDFile = "/run/nfqws.pid"; + Restart = "always"; + RuntimeMaxSec = "1h"; # This service loves to crash silently or cause network slowdowns. It also restarts instantly. Restarting it at least hourly provided the best experience. - # Hardening. - DevicePolicy = "closed"; - KeyringMode = "private"; - PrivateTmp = true; - PrivateMounts = true; - ProtectHome = true; - ProtectHostname = true; - ProtectKernelModules = true; - ProtectKernelTunables = true; - ProtectSystem = "strict"; - ProtectProc = "invisible"; - RemoveIPC = true; - RestrictNamespaces = true; - RestrictRealtime = true; - RestrictSUIDSGID = true; - SystemCallArchitectures = "native"; - }; - }; - } - # Route system traffic via service for specified ports. - (lib.mkIf cfg.configureFirewall { - networking.firewall.extraCommands = - let - httpParams = lib.optionalString ( - cfg.httpMode == "first" - ) "-m connbytes --connbytes-dir=original --connbytes-mode=packets --connbytes 1:6"; + # Hardening. + DevicePolicy = "closed"; + KeyringMode = "private"; + PrivateTmp = true; + PrivateMounts = true; + ProtectHome = true; + ProtectHostname = true; + ProtectKernelModules = true; + ProtectKernelTunables = true; + ProtectSystem = "strict"; + ProtectProc = "invisible"; + RemoveIPC = true; + RestrictNamespaces = true; + RestrictRealtime = true; + RestrictSUIDSGID = true; + SystemCallArchitectures = "native"; + }; + }; + } + # Route system traffic via service for specified ports. + (lib.mkIf cfg.configureFirewall { + networking.firewall.extraCommands = + let + httpParams = lib.optionalString ( + cfg.httpMode == "first" + ) "-m connbytes --connbytes-dir=original --connbytes-mode=packets --connbytes 1:6"; - udpPorts = lib.concatStringsSep "," cfg.udpPorts; - in - '' - iptables -t mangle -I POSTROUTING -p tcp --dport 443 -m connbytes --connbytes-dir=original --connbytes-mode=packets --connbytes 1:6 -m mark ! --mark 0x40000000/0x40000000 -j NFQUEUE --queue-num ${qnum} --queue-bypass - '' - + lib.optionalString (cfg.httpSupport) '' - iptables -t mangle -I POSTROUTING -p tcp --dport 80 ${httpParams} -m mark ! --mark 0x40000000/0x40000000 -j NFQUEUE --queue-num ${qnum} --queue-bypass - '' - + lib.optionalString (cfg.udpSupport) '' - iptables -t mangle -A POSTROUTING -p udp -m multiport --dports ${udpPorts} -m mark ! --mark 0x40000000/0x40000000 -j NFQUEUE --queue-num ${qnum} --queue-bypass - ''; - }) - ]); + udpPorts = lib.concatStringsSep "," cfg.udpPorts; + in + '' + iptables -t mangle -I POSTROUTING -p tcp --dport 443 -m connbytes --connbytes-dir=original --connbytes-mode=packets --connbytes 1:6 -m mark ! --mark 0x40000000/0x40000000 -j NFQUEUE --queue-num ${qnum} --queue-bypass + '' + + lib.optionalString (cfg.httpSupport) '' + iptables -t mangle -I POSTROUTING -p tcp --dport 80 ${httpParams} -m mark ! --mark 0x40000000/0x40000000 -j NFQUEUE --queue-num ${qnum} --queue-bypass + '' + + lib.optionalString (cfg.udpSupport) '' + iptables -t mangle -A POSTROUTING -p udp -m multiport --dports ${udpPorts} -m mark ! --mark 0x40000000/0x40000000 -j NFQUEUE --queue-num ${qnum} --queue-bypass + ''; + }) + ] + ); } diff --git a/config/Ftpd.nix b/config/Ftpd.nix index 694ac8a3..2c3de60d 100644 --- a/config/Ftpd.nix +++ b/config/Ftpd.nix @@ -1,26 +1,23 @@ +{ config, lib, ... }: +let + cfg = config.module.ftpd; +in { - config, - lib, - util, - ... -}: let - cfg = config.module.ftpd; -in { - config = lib.mkIf cfg.enable { - services.vsftpd = { - enable = true; - allowWriteableChroot = true; - anonymousMkdirEnable = true; - anonymousUmask = "000"; - anonymousUploadEnable = true; - anonymousUser = true; - anonymousUserHome = cfg.storage; - anonymousUserNoPassword = true; - localUsers = false; - writeEnable = true; - extraConfig = util.trimTabs '' - anon_other_write_enable=YES - ''; - }; - }; + config = lib.mkIf cfg.enable { + services.vsftpd = { + enable = true; + allowWriteableChroot = true; + anonymousMkdirEnable = true; + anonymousUmask = "000"; + anonymousUploadEnable = true; + anonymousUser = true; + anonymousUserHome = cfg.storage; + anonymousUserNoPassword = true; + localUsers = false; + writeEnable = true; + extraConfig = '' + anon_other_write_enable=YES + ''; + }; + }; } diff --git a/config/Gnome.nix b/config/Gnome.nix deleted file mode 100644 index e56d8495..00000000 --- a/config/Gnome.nix +++ /dev/null @@ -1,58 +0,0 @@ -# This is pretty much abandoned module. I keep it just in case. -{ - config, - lib, - pkgs, - ... -}: let - cfg = config.module.gnome; -in { - config = lib.mkIf cfg.enable { - module = { - dm.enable = true; - sound.enable = true; - wayland.enable = true; - }; - - services.xserver = { - displayManager.gdm.enable = true; - desktopManager.gnome.enable = true; - }; - - environment.systemPackages = with pkgs; [ - gnome.gnome-tweaks # Gnome "hidden" settings. - openssl # It was needed for something, can't remember. - ]; - - # Disable some Gnome apps. - services.gnome.gnome-keyring.enable = lib.mkForce false; - environment.gnome.excludePackages = with pkgs.gnome; [ - # baobab # Disk usage analyzer. - # cheese # Photo booth. - # epiphany # Web browser. - # simple-scan # Document scanner. - # totem # Video player. - # yelp # Help viewer. - # file-roller # Archive manager. - # geary # Email client. - # seahorse # Password manager. - - # gnome-calculator - # gnome-calendar - # gnome-characters - # gnome-clocks - # gnome-contacts - # gnome-font-viewer - # gnome-keyring - # gnome-logs - # gnome-maps - # gnome-music - # gnome-shell-extensions - gnome-software - # gnome-system-monitor - # gnome-weather - # gnome-disk-utility - # pkgs.gnome-text-editor - ]; - }; -} diff --git a/config/IntelCpu.nix b/config/IntelCpu.nix index 9f2b6443..86ab9d4e 100644 --- a/config/IntelCpu.nix +++ b/config/IntelCpu.nix @@ -1,28 +1,22 @@ # Intel CPU specific configuration. -{ - config, - lib, - ... -}: let - cfg = config.module.intel.cpu; +{ config, lib, ... }: +let + cfg = config.module.intel.cpu; - controlFile = "/sys/devices/system/cpu/intel_pstate/no_turbo"; - disableCmd = "0"; - enableCmd = "1"; -in { - config = lib.mkIf cfg.enable (lib.mkMerge [ - { - boot.kernelModules = [ - "kvm-intel" - ]; - } - (lib.mkIf cfg.powersave { - module.powersave = { - enable = true; - cpu.boost = { - inherit controlFile enableCmd disableCmd; - }; - }; - }) - ]); + controlFile = "/sys/devices/system/cpu/intel_pstate/no_turbo"; + disableCmd = "0"; + enableCmd = "1"; +in +{ + config = lib.mkIf cfg.enable ( + lib.mkMerge [ + { boot.kernelModules = [ "kvm-intel" ]; } + (lib.mkIf cfg.powersave { + module.powersave = { + enable = true; + cpu.boost = { inherit controlFile enableCmd disableCmd; }; + }; + }) + ] + ); } diff --git a/config/Kernel.nix b/config/Kernel.nix index 1a968e11..ebd54e29 100644 --- a/config/Kernel.nix +++ b/config/Kernel.nix @@ -1,62 +1,62 @@ { - config, - lib, - pkgsUnstable, - ... -}: let - cfg = config.module.kernel; -in { - config = lib.mkIf cfg.enable (lib.mkMerge [ - { - boot.kernel.sysctl = { - # Allow sysrq. - "kernel.sysrq" = 1; + config, + lib, + pkgsUnstable, + ... +}: +let + cfg = config.module.kernel; +in +{ + config = lib.mkIf cfg.enable ( + lib.mkMerge [ + { + boot.kernel.sysctl = { + # Allow sysrq. + "kernel.sysrq" = 1; - # Increase file watchers. - "fs.inotify.max_user_event" = 9999999; - "fs.inotify.max_user_instances" = 9999999; - "fs.inotify.max_user_watches" = 9999999; - # "fs.file-max" = 999999; - }; - } + # Increase file watchers. + "fs.inotify.max_user_event" = 9999999; + "fs.inotify.max_user_instances" = 9999999; + "fs.inotify.max_user_watches" = 9999999; + # "fs.file-max" = 999999; + }; + } - (lib.mkIf cfg.hardening { - boot.kernel.sysctl = { - # Spoof protection. - "net.ipv4.conf.all.rp_filter" = 1; - "net.ipv4.conf.default.rp_filter" = 1; + (lib.mkIf cfg.hardening { + boot.kernel.sysctl = { + # Spoof protection. + "net.ipv4.conf.all.rp_filter" = 1; + "net.ipv4.conf.default.rp_filter" = 1; - # Packet forwarding. - "net.ipv4.ip_forward" = 0; - "net.ipv6.conf.all.forwarding" = 0; + # Packet forwarding. + "net.ipv4.ip_forward" = 0; + "net.ipv6.conf.all.forwarding" = 0; - # MITM protection. - "net.ipv4.conf.all.accept_redirects" = 0; - "net.ipv6.conf.all.accept_redirects" = 0; + # MITM protection. + "net.ipv4.conf.all.accept_redirects" = 0; + "net.ipv6.conf.all.accept_redirects" = 0; - # Do not send ICMP redirects (we are not a router). - "net.ipv4.conf.all.send_redirects" = 0; + # Do not send ICMP redirects (we are not a router). + "net.ipv4.conf.all.send_redirects" = 0; - # Do not accept IP source route packets (we are not a router). - "net.ipv4.conf.all.accept_source_route" = 0; - "net.ipv6.conf.all.accept_source_route" = 0; + # Do not accept IP source route packets (we are not a router). + "net.ipv4.conf.all.accept_source_route" = 0; + "net.ipv6.conf.all.accept_source_route" = 0; - # Protect filesystem links. - "fs.protected_hardlinks" = 0; - "fs.protected_symlinks" = 0; + # Protect filesystem links. + "fs.protected_hardlinks" = 0; + "fs.protected_symlinks" = 0; - # Lynis config. - "kernel.core_uses_pid" = 1; - "kernel.kptr_restrict" = 2; - }; - }) + # Lynis config. + "kernel.core_uses_pid" = 1; + "kernel.kptr_restrict" = 2; + }; + }) - (lib.mkIf cfg.hotspotTtlBypass { - boot.kernel.sysctl."net.ipv4.ip_default_ttl" = 65; - }) + (lib.mkIf cfg.hotspotTtlBypass { boot.kernel.sysctl."net.ipv4.ip_default_ttl" = 65; }) - (lib.mkIf cfg.latest { - boot.kernelPackages = pkgsUnstable.linuxPackages_latest; - }) - ]); + (lib.mkIf cfg.latest { boot.kernelPackages = pkgsUnstable.linuxPackages_latest; }) + ] + ); } diff --git a/config/Keyd.nix b/config/Keyd.nix index 557887dd..e2b6c42f 100644 --- a/config/Keyd.nix +++ b/config/Keyd.nix @@ -1,98 +1,96 @@ { - config, - lib, - pkgs, - ... -}: let - cfg = config.module.keyd; -in { - config = lib.mkIf cfg.enable { - environment.systemPackages = with pkgs; [ - keyd - ]; + config, + lib, + pkgs, + ... +}: +let + cfg = config.module.keyd; +in +{ + config = lib.mkIf cfg.enable { + environment.systemPackages = with pkgs; [ keyd ]; - services.keyd = { - enable = true; - keyboards.default = { - ids = [ "*" ]; - settings = { - # NOTE: Use `wev` to find key names. - main = { - backspace = "delete"; # Delete key on backspace. - capslock = "overload(control, esc)"; # Ctrl/esc combo. - compose = "layer(layer_number)"; # Number input layer. - delete = "backslash"; - esc = "print"; # System controls. - leftcontrol = "overload(layer_alternative, leftcontrol)"; # Alternative layer for home, end etc. - rightcontrol = "layer(layer_control)"; # Media and other controls. - rightshift = "backspace"; # Backspace. - }; + services.keyd = { + enable = true; + keyboards.default = { + ids = [ "*" ]; + settings = { + # NOTE: Use `wev` to find key names. + main = { + backspace = "delete"; # Delete key on backspace. + capslock = "overload(control, esc)"; # Ctrl/esc combo. + compose = "layer(layer_number)"; # Number input layer. + delete = "backslash"; + esc = "print"; # System controls. + leftcontrol = "overload(layer_alternative, leftcontrol)"; # Alternative layer for home, end etc. + rightcontrol = "layer(layer_control)"; # Media and other controls. + rightshift = "backspace"; # Backspace. + }; - # Alternative navigation. - layer_alternative = { - a = "home"; - c = "copy"; - d = "end"; - h = "left"; - j = "down"; - k = "up"; - l = "right"; - s = "pagedown"; - v = "paste"; - w = "pageup"; - x = "cut"; - esc = "esc"; - rightcontrol = "leftcontrol"; - capslock = "capslock"; - }; + # Alternative navigation. + layer_alternative = { + a = "home"; + c = "copy"; + d = "end"; + h = "left"; + j = "down"; + k = "up"; + l = "right"; + s = "pagedown"; + v = "paste"; + w = "pageup"; + x = "cut"; + esc = "esc"; + rightcontrol = "leftcontrol"; + capslock = "capslock"; + }; - # Media controls. - layer_control = { - a = "back"; - c = "ejectcd"; - d = "forward"; - e = "nextsong"; - q = "previoussong"; - s = "volumedown"; - v = "micmute"; - w = "volumeup"; - x = "stopcd"; - z = "mute"; - space = "playpause"; - }; + # Media controls. + layer_control = { + a = "back"; + c = "ejectcd"; + d = "forward"; + e = "nextsong"; + q = "previoussong"; + s = "volumedown"; + v = "micmute"; + w = "volumeup"; + x = "stopcd"; + z = "mute"; + space = "playpause"; + }; - # Number inputs. - layer_number = { - "1" = "kpequal"; - "2" = "kpslash"; - "3" = "kpasterisk"; - "4" = "kpminus"; - a = "4"; - c = "3"; - d = "6"; - e = "9"; - f = "kpenter"; - q = "7"; - r = "kpplus"; - s = "5"; - v = "kpcomma"; - w = "8"; - x = "2"; - z = "1"; - shift = "backspace"; - space = "0"; - }; - }; - }; - }; + # Number inputs. + layer_number = { + "1" = "kpequal"; + "2" = "kpslash"; + "3" = "kpasterisk"; + "4" = "kpminus"; + a = "4"; + c = "3"; + d = "6"; + e = "9"; + f = "kpenter"; + q = "7"; + r = "kpplus"; + s = "5"; + v = "kpcomma"; + w = "8"; + x = "2"; + z = "1"; + shift = "backspace"; + space = "0"; + }; + }; + }; + }; - # HACK: Workaround for https://github.com/NixOS/nixpkgs/issues/290161 - users.groups.keyd = { }; - systemd.services.keyd.serviceConfig.CapabilityBoundingSet = [ - "CAP_SETGID" - ]; + # HACK: Workaround for https://github.com/NixOS/nixpkgs/issues/290161 + users.groups.keyd = { }; + systemd.services.keyd.serviceConfig.CapabilityBoundingSet = [ "CAP_SETGID" ]; - # Debug toggle just in case I need it again. - # systemd.services.keyd.environment.KEYD_DEBUG = "1"; - }; + # Debug toggle just in case I need it again. + # systemd.services.keyd.environment.KEYD_DEBUG = "1"; + }; } diff --git a/config/Ollama.nix b/config/Ollama.nix index b39e1790..6726630d 100644 --- a/config/Ollama.nix +++ b/config/Ollama.nix @@ -1,54 +1,55 @@ # SRC: https://github.com/ollama/ollama { - pkgsUnstable, - lib, - config, - util, - ... -}: let - cfg = config.module.ollama; -in { - config = lib.mkIf cfg.enable { - # Specify default model. - # environment.variables.OLLAMA_MODEL = cfg.primaryModel; - # - # systemd.services = { - # # Enable Ollama server. - # ollama = { - # description = "Ollama LLM server"; - # serviceConfig = { - # Type = "simple"; - # }; - # wantedBy = [ - # "multi-user.target" - # ]; - # script = '' - # HOME=/root ${lib.getExe pkgsUnstable.ollama} serve - # ''; - # }; - # - # # Download Ollama models. - # ollama-pull = { - # description = "Ollama LLM model"; - # after = [ - # "NetworkManager-wait-online.service" - # "ollama.service" - # ]; - # wantedBy = [ - # "multi-user.target" - # ]; - # wants = [ - # "NetworkManager-wait-online.service" - # "ollama.service" - # ]; - # serviceConfig = { - # Type = "simple"; - # }; - # script = util.trimTabs '' - # sleep 5 - # ${lib.getExe pkgsUnstable.ollama} pull ${lib.concatStringsSep " " cfg.models} - # ''; - # }; - # }; - }; + pkgsUnstable, + lib, + config, + ... +}: +let + cfg = config.module.ollama; +in +{ + config = lib.mkIf cfg.enable { + # Specify default model. + # environment.variables.OLLAMA_MODEL = cfg.primaryModel; + # + # systemd.services = { + # # Enable Ollama server. + # ollama = { + # description = "Ollama LLM server"; + # serviceConfig = { + # Type = "simple"; + # }; + # wantedBy = [ + # "multi-user.target" + # ]; + # script = '' + # HOME=/root ${lib.getExe pkgsUnstable.ollama} serve + # ''; + # }; + # + # # Download Ollama models. + # ollama-pull = { + # description = "Ollama LLM model"; + # after = [ + # "NetworkManager-wait-online.service" + # "ollama.service" + # ]; + # wantedBy = [ + # "multi-user.target" + # ]; + # wants = [ + # "NetworkManager-wait-online.service" + # "ollama.service" + # ]; + # serviceConfig = { + # Type = "simple"; + # }; + # script = '' + # sleep 5 + # ${lib.getExe pkgsUnstable.ollama} pull ${lib.concatStringsSep " " cfg.models} + # ''; + # }; + # }; + }; } diff --git a/config/Package.nix b/config/Package.nix index cf3358d8..20cf8c13 100644 --- a/config/Package.nix +++ b/config/Package.nix @@ -1,92 +1,90 @@ { - __findFile, - config, - lib, - pkgs, - ... -} @args: let - cfg = config.module.package; - package = import args; -in { - config = lib.mkMerge [ - # Core apps. - (lib.mkIf cfg.core { - environment.systemPackages = package.core; + __findFile, + config, + lib, + pkgs, + ... +}@args: +let + cfg = config.module.package; + package = import args; +in +{ + config = lib.mkMerge [ + # Core apps. + (lib.mkIf cfg.core { + environment.systemPackages = package.core; - programs = { - adb.enable = true; - git.enable = true; - java = { - enable = true; - package = pkgs.corretto21; - }; - }; - services = { - udisks2.enable = true; - }; - }) + programs = { + adb.enable = true; + git.enable = true; + java = { + enable = true; + package = pkgs.corretto21; + }; + }; + services = { + udisks2.enable = true; + }; + }) - # Common apps. - (lib.mkIf cfg.common { - environment.systemPackages = package.common; + # Common apps. + (lib.mkIf cfg.common { + environment.systemPackages = package.common; - xdg.mime.defaultApplications = { - # Use `file -i file.txt` to find file mime type. - # Use `xdg-mime query default "text/plain"` to find default app. - "application/pdf" = "org.gnome.Evince.desktop"; - "application/vnd.openxmlformats-officedocument.*" = "onlyoffice-desktopeditors.desktop"; - "audio/*" = "mpv.desktop"; - "image/*" = "org.gnome.Loupe.desktop"; - "text/*" = "nvim.desktop"; - "video/*" = "mpv.desktop"; - }; + xdg.mime.defaultApplications = { + # Use `file -i file.txt` to find file mime type. + # Use `xdg-mime query default "text/plain"` to find default app. + "application/pdf" = "org.gnome.Evince.desktop"; + "application/vnd.openxmlformats-officedocument.*" = "onlyoffice-desktopeditors.desktop"; + "audio/*" = "mpv.desktop"; + "image/*" = "org.gnome.Loupe.desktop"; + "text/*" = "nvim.desktop"; + "video/*" = "mpv.desktop"; + }; - services.gvfs.enable = true; + services.gvfs.enable = true; - # Chromium config. - environment.etc = let - chromium = import args; - in { - "chromium/initial_preferences".source = lib.mkForce chromium.preferences; - "chromium/policies/managed/extra.json".source = lib.mkForce chromium.policy; - }; - }) + # Chromium config. + environment.etc = + let + chromium = import args; + in + { + "chromium/initial_preferences".source = lib.mkForce chromium.preferences; + "chromium/policies/managed/extra.json".source = lib.mkForce chromium.policy; + }; + }) - # Desktop apps. - (lib.mkIf cfg.desktop { - environment.systemPackages = package.desktop; - }) + # Desktop apps. + (lib.mkIf cfg.desktop { environment.systemPackages = package.desktop; }) - # Gaming. - (lib.mkIf cfg.gaming { - programs.steam.enable = true; - environment.systemPackages = package.gaming; - hardware.graphics = let - packages = with pkgs; [ - dxvk - gamescope - pkgs.mangohud - vkd3d - ]; - in { - extraPackages = packages; - extraPackages32 = packages; - }; - }) + # Gaming. + (lib.mkIf cfg.gaming { + programs.steam.enable = true; + environment.systemPackages = package.gaming; + hardware.graphics = + let + packages = with pkgs; [ + dxvk + gamescope + pkgs.mangohud + vkd3d + ]; + in + { + extraPackages = packages; + extraPackages32 = packages; + }; + }) - # Creativity. - (lib.mkIf cfg.creative { - environment.systemPackages = package.creative; - }) + # Creativity. + (lib.mkIf cfg.creative { environment.systemPackages = package.creative; }) - # Development. - (lib.mkIf cfg.dev { - environment.systemPackages = package.dev; - }) + # Development. + (lib.mkIf cfg.dev { environment.systemPackages = package.dev; }) - # Extras. - (lib.mkIf cfg.extra { - environment.systemPackages = package.extra; - }) - ]; + # Extras. + (lib.mkIf cfg.extra { environment.systemPackages = package.extra; }) + ]; } diff --git a/config/Podman.nix b/config/Podman.nix index 878fda0f..7f7bbfe0 100644 --- a/config/Podman.nix +++ b/config/Podman.nix @@ -1,20 +1,18 @@ +{ lib, config, ... }: +let + cfg = config.module.podman; +in { - lib, - config, - ... -}: let - cfg = config.module.podman; -in { - config = lib.mkIf cfg.enable { - virtualisation.podman = { - enable = true; + config = lib.mkIf cfg.enable { + virtualisation.podman = { + enable = true; - # Free the 53 port ffs. - defaultNetwork.settings.dns_enabled = false; + # Free the 53 port ffs. + defaultNetwork.settings.dns_enabled = false; - # Do not interfere with Docker so we can have both installed at the same time. - # Podman can't replace Docker anyway. - dockerCompat = false; - }; - }; + # Do not interfere with Docker so we can have both installed at the same time. + # Podman can't replace Docker anyway. + dockerCompat = false; + }; + }; } diff --git a/config/Polkit.nix b/config/Polkit.nix index fa0461b4..c111fb83 100644 --- a/config/Polkit.nix +++ b/config/Polkit.nix @@ -1,31 +1,29 @@ # Polkit agent is used by apps to ask for Root password with a popup. { - config, - lib, - pkgs, - ... -}: let - cfg = config.module.polkit; -in { - config = lib.mkIf cfg.enable { - security.polkit.enable = true; - systemd = { - packages = with pkgs; [ - polkit-kde-agent - ]; - user = { - services.plasma-polkit-agent = { - environment.PATH = lib.mkForce null; - serviceConfig = { - Restart = "always"; - RestartSec = 2; - Slice = "session.slice"; - }; - wantedBy = [ - "gui-session.target" - ]; - }; - }; - }; - }; + config, + lib, + pkgs, + ... +}: +let + cfg = config.module.polkit; +in +{ + config = lib.mkIf cfg.enable { + security.polkit.enable = true; + systemd = { + packages = with pkgs; [ polkit-kde-agent ]; + user = { + services.plasma-polkit-agent = { + environment.PATH = lib.mkForce null; + wantedBy = [ "gui-session.target" ]; + serviceConfig = { + Restart = "always"; + RestartSec = 2; + Slice = "session.slice"; + }; + }; + }; + }; + }; } diff --git a/config/Portal.nix b/config/Portal.nix index 78798714..35e42227 100644 --- a/config/Portal.nix +++ b/config/Portal.nix @@ -1,24 +1,24 @@ # Portals are needed for Wayland apps to select files, screen shares etc. { - config, - lib, - pkgs, - ... -}: let - cfg = config.module.portal; -in { - config = lib.mkIf cfg.enable { - xdg.portal = { - enable = true; - wlr.enable = true; - xdgOpenUsePortal = false; - extraPortals = with pkgs; [ - xdg-desktop-portal-gtk - ]; - config.common.default = [ - "gtk" - "wlr" - ]; - }; - }; + config, + lib, + pkgs, + ... +}: +let + cfg = config.module.portal; +in +{ + config = lib.mkIf cfg.enable { + xdg.portal = { + enable = true; + wlr.enable = true; + xdgOpenUsePortal = false; + extraPortals = with pkgs; [ xdg-desktop-portal-gtk ]; + config.common.default = [ + "gtk" + "wlr" + ]; + }; + }; } diff --git a/config/PowerlimitThinkpad.nix b/config/PowerlimitThinkpad.nix index 30b31d47..34550fdc 100644 --- a/config/PowerlimitThinkpad.nix +++ b/config/PowerlimitThinkpad.nix @@ -1,68 +1,65 @@ # ThinkPad charge limits. { - config, - lib, - pkgs, - util, - ... -}: let - cfg = config.module.powerlimit.thinkpad; + config, + lib, + pkgs, + ... +}: +let + cfg = config.module.powerlimit.thinkpad; - controlFileMax = "/sys/class/power_supply/BAT0/charge_control_end_threshold"; - controlFileMin = "/sys/class/power_supply/BAT0/charge_control_start_threshold"; + controlFileMax = "/sys/class/power_supply/BAT0/charge_control_end_threshold"; + controlFileMin = "/sys/class/power_supply/BAT0/charge_control_start_threshold"; - script = pkgs.writeShellScriptBin "powerlimit" (util.trimTabs '' - function toggle() { - if status; then - echo ${toString cfg.offMax} > ${controlFileMax} - echo ${toString cfg.offMin} > ${controlFileMin} - else - echo ${toString cfg.onMin} > ${controlFileMin} - echo ${toString cfg.onMax} > ${controlFileMax} - fi + script = pkgs.writeShellScriptBin "powerlimit" '' + function toggle() { + if status; then + echo ${toString cfg.offMax} > ${controlFileMax} + echo ${toString cfg.offMin} > ${controlFileMin} + else + echo ${toString cfg.onMin} > ${controlFileMin} + echo ${toString cfg.onMax} > ${controlFileMax} + fi - pkill -RTMIN+6 waybar - true - } + pkill -RTMIN+6 waybar + true + } - function widget() { - status && printf '​' || printf '' - } + function widget() { + status && printf '​' || printf '' + } - function status() { - local current=$(cat ${controlFileMax}) - local enabled="${toString cfg.onMax}" + function status() { + local current=$(cat ${controlFileMax}) + local enabled="${toString cfg.onMax}" - [[ "''${current}" = "''${enabled}" ]] - } + [[ "''${current}" = "''${enabled}" ]] + } - ''${@} - ''); -in { - config = lib.mkIf cfg.enable { - environment.systemPackages = [ - script - ]; - systemd = { - services.powerlimit = { - enable = true; - description = "Limit battery charge"; - wantedBy = [ - "multi-user.target" - ]; - serviceConfig = { - Type = "simple"; - RemainAfterExit = "yes"; - ExecStart = "${lib.getExe pkgs.bash} -c 'echo ${toString cfg.onMin} > ${controlFileMin}; echo ${toString cfg.onMax} > ${controlFileMax};'"; - ExecStop = "${lib.getExe pkgs.bash} -c 'echo ${toString cfg.offMax} > ${controlFileMax}; echo ${toString cfg.offMin} > ${controlFileMin};'"; - }; - }; + ''${@} + ''; +in +{ + config = lib.mkIf cfg.enable { + environment.systemPackages = [ script ]; + systemd = { + services.powerlimit = { + enable = true; + description = "Limit battery charge"; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + Type = "simple"; + RemainAfterExit = "yes"; + ExecStart = "${lib.getExe pkgs.bash} -c 'echo ${toString cfg.onMin} > ${controlFileMin}; echo ${toString cfg.onMax} > ${controlFileMax};'"; + ExecStop = "${lib.getExe pkgs.bash} -c 'echo ${toString cfg.offMax} > ${controlFileMax}; echo ${toString cfg.offMin} > ${controlFileMin};'"; + }; + }; - # HACK: Allow user access. - tmpfiles.rules = [ - "z ${controlFileMax} 0777 - - - -" - "z ${controlFileMin} 0777 - - - -" - ]; - }; - }; + # HACK: Allow user access. + tmpfiles.rules = [ + "z ${controlFileMax} 0777 - - - -" + "z ${controlFileMin} 0777 - - - -" + ]; + }; + }; } diff --git a/config/Powersave.nix b/config/Powersave.nix index b2208c69..9feab822 100644 --- a/config/Powersave.nix +++ b/config/Powersave.nix @@ -1,61 +1,56 @@ { - lib, - config, - pkgs, - util, - ... -}: let - cfg = config.module.powersave; + lib, + config, + pkgs, + ... +}: +let + cfg = config.module.powersave; - script = pkgs.writeShellScriptBin "powersave" (util.trimTabs '' - function toggle() { - if status; then - echo ${cfg.cpu.boost.disableCmd} > ${cfg.cpu.boost.controlFile} - else - echo ${cfg.cpu.boost.enableCmd} > ${cfg.cpu.boost.controlFile} - fi + script = pkgs.writeShellScriptBin "powersave" '' + function toggle() { + if status; then + echo ${cfg.cpu.boost.disableCmd} > ${cfg.cpu.boost.controlFile} + else + echo ${cfg.cpu.boost.enableCmd} > ${cfg.cpu.boost.controlFile} + fi - pkill -RTMIN+5 waybar - true - } + pkill -RTMIN+5 waybar + true + } - function widget() { - status && printf '​' || printf '󰓅' - } + function widget() { + status && printf '​' || printf '󰓅' + } - function status() { - local current=$(cat ${cfg.cpu.boost.controlFile}) - local enabled="${cfg.cpu.boost.enableCmd}" + function status() { + local current=$(cat ${cfg.cpu.boost.controlFile}) + local enabled="${cfg.cpu.boost.enableCmd}" - [[ "''${current}" = "''${enabled}" ]] - } + [[ "''${current}" = "''${enabled}" ]] + } - ''${@} - ''); -in { - config = lib.mkIf cfg.enable { - environment.systemPackages = [ - script - ]; - systemd = { - services.powersave-cpu = { - enable = true; - description = "disable CPU Boost"; - wantedBy = [ - "multi-user.target" - ]; - serviceConfig = { - Type = "simple"; - RemainAfterExit = "yes"; - ExecStart = "${lib.getExe pkgs.bash} -c 'echo ${cfg.cpu.boost.enableCmd} > ${cfg.cpu.boost.controlFile}'"; - ExecStop = "${lib.getExe pkgs.bash} -c 'echo ${cfg.cpu.boost.disableCmd} > ${cfg.cpu.boost.controlFile}'"; - }; - }; + ''${@} + ''; +in +{ + config = lib.mkIf cfg.enable { + environment.systemPackages = [ script ]; + systemd = { + services.powersave-cpu = { + enable = true; + description = "disable CPU Boost"; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + Type = "simple"; + RemainAfterExit = "yes"; + ExecStart = "${lib.getExe pkgs.bash} -c 'echo ${cfg.cpu.boost.enableCmd} > ${cfg.cpu.boost.controlFile}'"; + ExecStop = "${lib.getExe pkgs.bash} -c 'echo ${cfg.cpu.boost.disableCmd} > ${cfg.cpu.boost.controlFile}'"; + }; + }; - # HACK: Allow user access. - tmpfiles.rules = [ - "z ${cfg.cpu.boost.controlFile} 0777 - - - -" - ]; - }; - }; + # HACK: Allow user access. + tmpfiles.rules = [ "z ${cfg.cpu.boost.controlFile} 0777 - - - -" ]; + }; + }; } diff --git a/config/Print.nix b/config/Print.nix index defa19fa..505d298c 100644 --- a/config/Print.nix +++ b/config/Print.nix @@ -1,18 +1,15 @@ +{ config, lib, ... }: +let + cfg = config.module.print; +in { - config, - lib, - util, - ... -}: let - cfg = config.module.print; -in { - config = lib.mkIf cfg.enable { - services.printing = { - enable = true; - clientConf = util.trimTabs '' - DigestOptions DenyMD5 - ServerName 10.0.0.1 - ''; - }; - }; + config = lib.mkIf cfg.enable { + services.printing = { + enable = true; + clientConf = '' + DigestOptions DenyMD5 + ServerName 10.0.0.1 + ''; + }; + }; } diff --git a/config/Purpose.nix b/config/Purpose.nix index 11c858c6..202de0c6 100644 --- a/config/Purpose.nix +++ b/config/Purpose.nix @@ -1,151 +1,146 @@ +{ config, lib, ... }: +let + cfg = config.module.purpose; +in { - config, - lib, - ... -}: let - cfg = config.module.purpose; -in { - config = lib.mkMerge [ - (lib.mkIf cfg.creative { - module = { - tablet.enable = true; - package.creative = true; - }; - }) + config = lib.mkMerge [ + (lib.mkIf cfg.creative { + module = { + tablet.enable = true; + package.creative = true; + }; + }) - (lib.mkIf cfg.desktop { - module = { - keyd.enable = true; - sway.enable = true; - kernel = { - enable = true; - latest = true; - }; - package = { - common = true; - core = true; - desktop = true; - }; - }; - }) + (lib.mkIf cfg.desktop { + module = { + keyd.enable = true; + sway.enable = true; + kernel = { + enable = true; + latest = true; + }; + package = { + common = true; + core = true; + desktop = true; + }; + }; + }) - (lib.mkIf cfg.disown { - module = { - autoupdate.enable = true; - kernel = { - enable = true; - hardening = true; - }; - }; - }) + (lib.mkIf cfg.disown { + module = { + autoupdate.enable = true; + kernel = { + enable = true; + hardening = true; + }; + }; + }) - (lib.mkIf cfg.gaming { - module.package.gaming = true; - }) + (lib.mkIf cfg.gaming { module.package.gaming = true; }) - (lib.mkIf cfg.laptop { - services.tlp.enable = true; # Automatic powersaving based on Pluged/AC states. - services.upower.enable = true; - module = { - keyd.enable = true; - sway.enable = true; - kernel = { - enable = true; - hardening = true; - latest = true; - }; - package = { - common = true; - core = true; - desktop = true; - }; - }; - }) + (lib.mkIf cfg.laptop { + services.tlp.enable = true; # Automatic powersaving based on Pluged/AC states. + services.upower.enable = true; + module = { + keyd.enable = true; + sway.enable = true; + kernel = { + enable = true; + hardening = true; + latest = true; + }; + package = { + common = true; + core = true; + desktop = true; + }; + }; + }) - (lib.mkIf cfg.live { - module = { - keyd.enable = true; - sway.enable = true; - kernel.enable = true; - package = { - common = true; - core = true; - creative = true; - desktop = true; - dev = true; - extra = true; - gaming = true; - }; - }; - }) + (lib.mkIf cfg.live { + module = { + keyd.enable = true; + sway.enable = true; + kernel.enable = true; + package = { + common = true; + core = true; + creative = true; + desktop = true; + dev = true; + extra = true; + gaming = true; + }; + }; + }) - (lib.mkIf cfg.phone { - }) + (lib.mkIf cfg.phone { }) - (lib.mkIf cfg.router { - module = { - kernel = { - enable = true; - hardening = true; - }; - package = { - common = true; - core = true; - }; - }; - # De-harden some stuff. - boot.kernel.sysctl = { - # Allow spoofing. - "net.ipv4.conf.all.rp_filter" = lib.mkForce 0; - "net.ipv4.conf.default.rp_filter" = lib.mkForce 0; + (lib.mkIf cfg.router { + module = { + kernel = { + enable = true; + hardening = true; + }; + package = { + common = true; + core = true; + }; + }; + # De-harden some stuff. + boot.kernel.sysctl = { + # Allow spoofing. + "net.ipv4.conf.all.rp_filter" = lib.mkForce 0; + "net.ipv4.conf.default.rp_filter" = lib.mkForce 0; - # Forward packets. - "net.ipv4.ip_forward" = lib.mkForce 1; - "net.ipv6.conf.all.forwarding" = lib.mkForce 1; - "net.ipv4.conf.all.src_valid_mark" = lib.mkForce 1; + # Forward packets. + "net.ipv4.ip_forward" = lib.mkForce 1; + "net.ipv6.conf.all.forwarding" = lib.mkForce 1; + "net.ipv4.conf.all.src_valid_mark" = lib.mkForce 1; - # Allow redirects. - "net.ipv4.conf.all.accept_redirects" = lib.mkForce 1; - "net.ipv6.conf.all.accept_redirects" = lib.mkForce 1; + # Allow redirects. + "net.ipv4.conf.all.accept_redirects" = lib.mkForce 1; + "net.ipv6.conf.all.accept_redirects" = lib.mkForce 1; - # Send ICMP. - "net.ipv4.conf.all.send_redirects" = lib.mkForce 1; + # Send ICMP. + "net.ipv4.conf.all.send_redirects" = lib.mkForce 1; - # Accept IP source route packets. - "net.ipv4.conf.all.accept_source_route" = lib.mkForce 1; - "net.ipv6.conf.all.accept_source_route" = lib.mkForce 1; - }; - }) + # Accept IP source route packets. + "net.ipv4.conf.all.accept_source_route" = lib.mkForce 1; + "net.ipv6.conf.all.accept_source_route" = lib.mkForce 1; + }; + }) - (lib.mkIf cfg.server { - module = { - kernel = { - enable = true; - hardening = true; - }; - package = { - common = true; - core = true; - }; - }; - }) + (lib.mkIf cfg.server { + module = { + kernel = { + enable = true; + hardening = true; + }; + package = { + common = true; + core = true; + }; + }; + }) - (lib.mkIf cfg.work { - module = { - distrobox.enable = true; - ollama.enable = true; - package.dev = true; - virtmanager.enable = true; - docker = { - enable = true; - autostart = false; - rootless = false; - }; - kernel = { - enable = true; - hardening = true; - }; - }; - }) - ]; + (lib.mkIf cfg.work { + module = { + distrobox.enable = true; + ollama.enable = true; + package.dev = true; + virtmanager.enable = true; + docker = { + enable = true; + autostart = false; + rootless = false; + }; + kernel = { + enable = true; + hardening = true; + }; + }; + }) + ]; } diff --git a/config/RemoteBuild.nix b/config/RemoteBuild.nix index 59898f32..7dcb8d0a 100644 --- a/config/RemoteBuild.nix +++ b/config/RemoteBuild.nix @@ -1,106 +1,96 @@ { - config, - lib, - pkgs, - secret, - ... -}: let - cfg = config.module.builder; - serverKeyPath = "/root/.nixbuilder"; - serverSshPublicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFqr7zKGOy/2bbAQCD85Ol+NoGGtvdMbSy3jGb98jM+f"; # Use ssh-keyscan. -in { - config = lib.mkMerge [ - (lib.mkIf cfg.server.enable { - # Service that generates new key on boot if not present. - # Don't forget to add new public key to secret.ssh.buildKeys. - systemd.services.generate-nix-cache-key = { - wantedBy = [ - "multi-user.target" - ]; - serviceConfig = { - Type = "oneshot"; - }; - path = [ - pkgs.nix - ]; - script = '' - [[ -f "${serverKeyPath}/private-key" ]] && exit - mkdir ${serverKeyPath} || true - nix-store --generate-binary-cache-key "nixbuilder-1" "${serverKeyPath}/private-key" "${serverKeyPath}/public-key" - nix store sign --all -k "${serverKeyPath}/private-key" - ''; - }; + config, + lib, + pkgs, + secret, + ... +}: +let + cfg = config.module.builder; + serverKeyPath = "/root/.nixbuilder"; + serverSshPublicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFqr7zKGOy/2bbAQCD85Ol+NoGGtvdMbSy3jGb98jM+f"; # Use ssh-keyscan. +in +{ + config = lib.mkMerge [ + (lib.mkIf cfg.server.enable { + # Service that generates new key on boot if not present. + # Don't forget to add new public key to secret.ssh.buildKeys. + systemd.services.generate-nix-cache-key = { + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + Type = "oneshot"; + }; + path = [ pkgs.nix ]; + script = '' + [[ -f "${serverKeyPath}/private-key" ]] && exit + mkdir ${serverKeyPath} || true + nix-store --generate-binary-cache-key "nixbuilder-1" "${serverKeyPath}/private-key" "${serverKeyPath}/public-key" + nix store sign --all -k "${serverKeyPath}/private-key" + ''; + }; - # Add `nixbuilder` restricted user. - users.groups.nixbuilder = { }; - users.users.nixbuilder = { - createHome = lib.mkForce false; - description = "Nix Remote Builder"; - group = "nixbuilder"; - home = "/"; - isNormalUser = true; - openssh.authorizedKeys.keys = secret.ssh.buildKeys; - uid = 1234; - }; + # Add `nixbuilder` restricted user. + users.groups.nixbuilder = { }; + users.users.nixbuilder = { + createHome = lib.mkForce false; + description = "Nix Remote Builder"; + group = "nixbuilder"; + home = "/"; + isNormalUser = true; + openssh.authorizedKeys.keys = secret.ssh.buildKeys; + uid = 1234; + }; - # Sign store automatically. - # Sign existing store with: nix store sign --all -k /path/to/secret-key-file - nix.settings = { - trusted-users = [ - "nixbuilder" - ]; - secret-key-files = [ - "${serverKeyPath}/private-key" - ]; - }; - }) + # Sign store automatically. + # Sign existing store with: nix store sign --all -k /path/to/secret-key-file + nix.settings = { + trusted-users = [ "nixbuilder" ]; + secret-key-files = [ "${serverKeyPath}/private-key" ]; + }; + }) - (lib.mkIf cfg.client.enable { - # NOTE: Requires host public key to be present in secret.ssh.builderKeys. - nix = { - distributedBuilds = true; - buildMachines = [{ - hostName = "nixbuilder"; - maxJobs = 16; - protocol = "ssh-ng"; - speedFactor = 2; - mandatoryFeatures = [ ]; - systems = [ - "aarch64-linux" - "i686-linux" - "x86_64-linux" - ]; - supportedFeatures = [ - "benchmark" - "big-parallel" - "kvm" - "nixos-test" - ]; - }]; - settings = let - substituters = [ - "ssh-ng://nixbuilder" - ]; - in { - builders-use-substitutes = true; - max-jobs = 0; - substituters = lib.mkForce substituters; - trusted-substituters = substituters ++ [ - "https://cache.nixos.org/" - ]; - trusted-public-keys = [ - secret.ssh.builderKey - ]; - # require-sigs = false; - # substitute = false; - }; - }; - services.openssh.knownHosts.nixbuilder = { - publicKey = serverSshPublicKey; - extraHostNames = [ - "[10.0.0.1]:22143" - ]; - }; - }) - ]; + (lib.mkIf cfg.client.enable { + # NOTE: Requires host public key to be present in secret.ssh.builderKeys. + nix = { + distributedBuilds = true; + buildMachines = [ + { + hostName = "nixbuilder"; + maxJobs = 16; + protocol = "ssh-ng"; + speedFactor = 2; + mandatoryFeatures = [ ]; + systems = [ + "aarch64-linux" + "i686-linux" + "x86_64-linux" + ]; + supportedFeatures = [ + "benchmark" + "big-parallel" + "kvm" + "nixos-test" + ]; + } + ]; + settings = + let + substituters = [ "ssh-ng://nixbuilder" ]; + in + { + builders-use-substitutes = true; + max-jobs = 0; + substituters = lib.mkForce substituters; + trusted-substituters = substituters ++ [ "https://cache.nixos.org/" ]; + trusted-public-keys = [ secret.ssh.builderKey ]; + # require-sigs = false; + # substitute = false; + }; + }; + services.openssh.knownHosts.nixbuilder = { + publicKey = serverSshPublicKey; + extraHostNames = [ "[10.0.0.1]:22143" ]; + }; + }) + ]; } diff --git a/config/Sound.nix b/config/Sound.nix index 4a2cbe09..db770d54 100644 --- a/config/Sound.nix +++ b/config/Sound.nix @@ -1,20 +1,18 @@ +{ config, lib, ... }: +let + cfg = config.module.sound; +in { - config, - lib, - ... -}: let - cfg = config.module.sound; -in { - config = lib.mkIf cfg.enable { - hardware.pulseaudio.enable = false; - security.rtkit.enable = true; - services.pipewire = { - enable = true; - pulse.enable = true; - alsa = { - enable = true; - support32Bit = true; - }; - }; - }; + config = lib.mkIf cfg.enable { + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + pulse.enable = true; + alsa = { + enable = true; + support32Bit = true; + }; + }; + }; } diff --git a/config/Sway.nix b/config/Sway.nix index 1dcfe18a..bf865725 100644 --- a/config/Sway.nix +++ b/config/Sway.nix @@ -1,31 +1,31 @@ { - config, - lib, - pkgs, - ... -}: let - cfg = config.module.sway; -in { - config = lib.mkIf cfg.enable { - services.gnome.gnome-keyring.enable = lib.mkForce false; - environment.variables.XDG_CURRENT_DESKTOP = "sway"; - module = { - bluetooth.enable = true; - brightness.enable = true; - portal.enable = true; - sound.enable = true; - waybar.enable = true; - wayland.enable = true; - }; - programs.sway = { - enable = true; - wrapperFeatures = { - base = true; - gtk = true; - }; - extraPackages = with pkgs; [ - swaykbdd - ]; - }; - }; + config, + lib, + pkgs, + ... +}: +let + cfg = config.module.sway; +in +{ + config = lib.mkIf cfg.enable { + services.gnome.gnome-keyring.enable = lib.mkForce false; + environment.variables.XDG_CURRENT_DESKTOP = "sway"; + module = { + bluetooth.enable = true; + brightness.enable = true; + portal.enable = true; + sound.enable = true; + waybar.enable = true; + wayland.enable = true; + }; + programs.sway = { + enable = true; + extraPackages = with pkgs; [ swaykbdd ]; + wrapperFeatures = { + base = true; + gtk = true; + }; + }; + }; } diff --git a/config/Syncthing.nix b/config/Syncthing.nix index 8c0bb827..c273c6ed 100644 --- a/config/Syncthing.nix +++ b/config/Syncthing.nix @@ -1,84 +1,110 @@ { - config, - lib, - pkgs, - util, - ... -}: let - cfg = config.module.syncthing; -in { - config = lib.mkIf cfg.enable { - # CLI tools. - environment.systemPackages = with pkgs; [ syncthing ]; + config, + lib, + pkgs, + ... +}: +let + cfg = config.module.syncthing; +in +{ + config = lib.mkIf cfg.enable { + # CLI tools. + environment.systemPackages = with pkgs; [ syncthing ]; - # Access at sync.lan. - networking.hosts = { "127.0.0.1" = [ "sync.local" ]; }; - services.nginx.enable = true; - services.nginx.virtualHosts."sync.local".extraConfig = util.trimTabs '' - location / { - allow 127.0.0.1; - deny all; - proxy_pass http://127.0.0.1:8384; - } - ''; + # Access at sync.lan. + networking.hosts = { + "127.0.0.1" = [ "sync.local" ]; + }; + services.nginx.enable = true; + services.nginx.virtualHosts."sync.local".extraConfig = '' + location / { + allow 127.0.0.1; + deny all; + proxy_pass http://127.0.0.1:8384; + } + ''; - services.syncthing = { - inherit (cfg) enable dataDir user group; - openDefaultPorts = false; - systemService = true; - settings = let - myDevices = { - "desktop" = { id = "767Z675-SOCY4FL-JNYEBB6-5E2RG5O-XTZR6OP-BGOBZ7G-XVRLMD6-DQEB2AT"; }; - "home" = { id = "L5A5IPE-2FPJPHP-RJRV2PV-BLMLC3F-QPHSCUQ-4U3NM2I-AFPOE2A-HOPQZQF"; }; - "max" = { id = "3E3N4G4-SZ7LQXE-WQQZX7N-KFXEQKM-7VVN6QP-OMB5356-ICNXUZY-TTLEKAR"; }; - "phone" = { id = "6RO5JXW-2XO4S3E-VCDAHPD-4ADK6LL-HQGMZHU-GD6DE2O-6KNHWXJ-BCSBGQ7"; }; - "work" = { id = "CMG6QMP-WCJJEUG-UQ3KDUI-AHRADRH-666JQ3Z-HYFEPDA-URMAMNP-Z4MSGQT"; }; - }; - dashaDevices = { - "dasha" = { id = "VNRA5VH-LWNPVV4-Y2RF7FJ-446FHRQ-PET7Q4R-D3H5RT3-AUNARH5-5XYB3AT"; }; - "dashaphone" = { id = "QKGXSZC-HGAA6S5-RJJAT5Z-UPUGDAA-3GXEO6C-WHKMBUD-ESKQPZE-TZFNYA6"; }; - }; - in lib.recursiveUpdate cfg.settings { - devices = myDevices // dashaDevices; - folders = let - allMyDevices = lib.mapAttrsToList (n: v: n) myDevices; - allDashaDevices = lib.mapAttrsToList (n: v: n) dashaDevices; - in lib.filterAttrs (n: v: builtins.elem config.networking.hostName v.devices) { - "save" = { - path = "${cfg.dataDir}/save"; - devices = [ - "desktop" - "home" - "max" - "work" - ]; - }; - "photo" = { - path = "${cfg.dataDir}/photo"; - devices = [ - "dashaphone" - "home" - "phone" - ]; - }; - "tmp" = { - path = "${cfg.dataDir}/tmp"; - devices = allMyDevices; - }; - "document" = { - path = "${cfg.dataDir}/document"; - devices = allMyDevices; - }; - "dima" = { - path = "${cfg.dataDir}/dima"; - devices = allMyDevices ++ allDashaDevices; - }; - "dasha" = { - path = "${cfg.dataDir}/dasha"; - devices = allDashaDevices; - }; - }; - }; - }; - }; + services.syncthing = { + inherit (cfg) + enable + dataDir + user + group + ; + openDefaultPorts = false; + systemService = true; + settings = + let + myDevices = { + "desktop" = { + id = "767Z675-SOCY4FL-JNYEBB6-5E2RG5O-XTZR6OP-BGOBZ7G-XVRLMD6-DQEB2AT"; + }; + "home" = { + id = "L5A5IPE-2FPJPHP-RJRV2PV-BLMLC3F-QPHSCUQ-4U3NM2I-AFPOE2A-HOPQZQF"; + }; + "max" = { + id = "3E3N4G4-SZ7LQXE-WQQZX7N-KFXEQKM-7VVN6QP-OMB5356-ICNXUZY-TTLEKAR"; + }; + "phone" = { + id = "6RO5JXW-2XO4S3E-VCDAHPD-4ADK6LL-HQGMZHU-GD6DE2O-6KNHWXJ-BCSBGQ7"; + }; + "work" = { + id = "CMG6QMP-WCJJEUG-UQ3KDUI-AHRADRH-666JQ3Z-HYFEPDA-URMAMNP-Z4MSGQT"; + }; + }; + dashaDevices = { + "dasha" = { + id = "VNRA5VH-LWNPVV4-Y2RF7FJ-446FHRQ-PET7Q4R-D3H5RT3-AUNARH5-5XYB3AT"; + }; + "dashaphone" = { + id = "QKGXSZC-HGAA6S5-RJJAT5Z-UPUGDAA-3GXEO6C-WHKMBUD-ESKQPZE-TZFNYA6"; + }; + }; + in + lib.recursiveUpdate cfg.settings { + devices = myDevices // dashaDevices; + folders = + let + allMyDevices = lib.mapAttrsToList (n: v: n) myDevices; + allDashaDevices = lib.mapAttrsToList (n: v: n) dashaDevices; + in + lib.filterAttrs (n: v: builtins.elem config.networking.hostName v.devices) { + "save" = { + path = "${cfg.dataDir}/save"; + devices = [ + "desktop" + "home" + "max" + "work" + ]; + }; + "photo" = { + path = "${cfg.dataDir}/photo"; + devices = [ + "dashaphone" + "home" + "phone" + ]; + }; + "tmp" = { + path = "${cfg.dataDir}/tmp"; + devices = allMyDevices; + }; + "document" = { + path = "${cfg.dataDir}/document"; + devices = allMyDevices; + }; + "dima" = { + path = "${cfg.dataDir}/dima"; + devices = allMyDevices ++ allDashaDevices; + }; + "dasha" = { + path = "${cfg.dataDir}/dasha"; + devices = allDashaDevices; + }; + }; + }; + }; + }; } diff --git a/config/Tablet.nix b/config/Tablet.nix index 2ea82d22..fd3a8f83 100644 --- a/config/Tablet.nix +++ b/config/Tablet.nix @@ -1,14 +1,10 @@ +{ lib, config, ... }: +let + cfg = config.module.tablet; +in { - lib, - config, - ... -}: let - cfg = config.module.tablet; -in { - config = lib.mkIf cfg.enable { - hardware.opentabletdriver.enable = true; - systemd.user.services.opentabletdriver.wantedBy = [ - "default.target" - ]; - }; + config = lib.mkIf cfg.enable { + hardware.opentabletdriver.enable = true; + systemd.user.services.opentabletdriver.wantedBy = [ "default.target" ]; + }; } diff --git a/config/VirtManager.nix b/config/VirtManager.nix index 2326f30e..fce28a2f 100644 --- a/config/VirtManager.nix +++ b/config/VirtManager.nix @@ -1,20 +1,22 @@ { - config, - lib, - pkgs, - ... -}: let - cfg = config.module.virtmanager; -in { - config = lib.mkIf cfg.enable { - virtualisation.libvirtd.enable = true; - programs.virt-manager.enable = true; + config, + lib, + pkgs, + ... +}: +let + cfg = config.module.virtmanager; +in +{ + config = lib.mkIf cfg.enable { + virtualisation.libvirtd.enable = true; + programs.virt-manager.enable = true; - # HACK: Fixes bug: https://www.reddit.com/r/NixOS/comments/1afbjiu/i_get_a_nonetype_error_when_trying_to_launch_a_vm/ - # May also need to run: `gsettings set org.gnome.desktop.interface cursor-theme "Adwaita"` - environment.systemPackages = with pkgs; [ - # glib - adwaita-icon-theme # default gnome cursors, - ]; - }; + # HACK: Fixes bug: https://www.reddit.com/r/NixOS/comments/1afbjiu/i_get_a_nonetype_error_when_trying_to_launch_a_vm/ + # May also need to run: `gsettings set org.gnome.desktop.interface cursor-theme "Adwaita"` + environment.systemPackages = with pkgs; [ + # glib + adwaita-icon-theme # default gnome cursors, + ]; + }; } diff --git a/config/Waybar.nix b/config/Waybar.nix index e6f09f57..ff155388 100644 --- a/config/Waybar.nix +++ b/config/Waybar.nix @@ -1,14 +1,12 @@ { - config, - lib, - pkgs, - ... -}: let - cfg = config.module.waybar; -in { - config = lib.mkIf cfg.enable { - environment.systemPackages = with pkgs; [ - waybar - ]; - }; + config, + lib, + pkgs, + ... +}: +let + cfg = config.module.waybar; +in +{ + config = lib.mkIf cfg.enable { environment.systemPackages = with pkgs; [ waybar ]; }; } diff --git a/config/Wayland.nix b/config/Wayland.nix index 46e36d48..2e18d77a 100644 --- a/config/Wayland.nix +++ b/config/Wayland.nix @@ -1,28 +1,26 @@ +{ config, pkgs, ... }: +let + cfg = config.module.wayland; +in { - config, - pkgs, - ... -}: let - cfg = config.module.wayland; -in { - config = { - programs.xwayland.enable = true; - environment = { - systemPackages = with pkgs; [ - wl-clipboard # CLI clipboard support. - ]; - variables = { - # Compatibility variables. - ECORE_EVAS_ENGINE = "wayland_egl"; - ELM_ENGINE = "wayland_egl"; - GDK_BACKEND = "wayland"; - MOZ_ENABLE_WAYLAND = "1"; - QT_QPA_PLATFORM = "wayland-egl;wayland;xcb"; - QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; - SAL_USE_VCLPLUGIN = "gtk3"; - SDL_VIDEODRIVER = "wayland"; # NOTE: Can cause issues with games. - _JAVA_AWT_WM_NONREPARENTING = "1"; - }; - }; - }; + config = { + programs.xwayland.enable = true; + environment = { + systemPackages = with pkgs; [ + wl-clipboard # CLI clipboard support. + ]; + variables = { + # Compatibility variables. + ECORE_EVAS_ENGINE = "wayland_egl"; + ELM_ENGINE = "wayland_egl"; + GDK_BACKEND = "wayland"; + MOZ_ENABLE_WAYLAND = "1"; + QT_QPA_PLATFORM = "wayland-egl;wayland;xcb"; + QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; + SAL_USE_VCLPLUGIN = "gtk3"; + SDL_VIDEODRIVER = "wayland"; # NOTE: Can cause issues with games. + _JAVA_AWT_WM_NONREPARENTING = "1"; + }; + }; + }; } diff --git a/flake.nix b/flake.nix index 5f2374c9..7276dfc6 100644 --- a/flake.nix +++ b/flake.nix @@ -1,177 +1,267 @@ { - inputs = { - # SOURCE: https://github.com/NixOS/nixpkgs - nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; - nixpkgsUnstable.url = "github:nixos/nixpkgs/nixos-unstable"; - nixpkgsMaster.url = "github:nixos/nixpkgs/master"; + inputs = { + # SOURCE: https://github.com/NixOS/nixpkgs + nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; + nixpkgsUnstable.url = "github:nixos/nixpkgs/nixos-unstable"; + nixpkgsMaster.url = "github:nixos/nixpkgs/master"; - # SOURCE: https://github.com/nix-community/home-manager - home-manager = { - url = "github:nix-community/home-manager/release-24.11"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + # SOURCE: https://github.com/nix-community/home-manager + home-manager = { + url = "github:nix-community/home-manager/release-24.11"; + inputs.nixpkgs.follows = "nixpkgs"; + }; - # SOURCE: https://github.com/nix-community/nix-on-droid - nix-on-droid = { - url = "github:t184256/nix-on-droid/release-24.05"; - inputs = { - home-manager.follows = "home-manager"; - nixpkgs.follows = "nixpkgs"; - }; - }; + # SOURCE: https://github.com/nix-community/nix-on-droid + nix-on-droid = { + url = "github:t184256/nix-on-droid/release-24.05"; + inputs = { + home-manager.follows = "home-manager"; + nixpkgs.follows = "nixpkgs"; + }; + }; - # SOURCE: https://github.com/LilleAila/nix-cursors - nix-cursors = { - url = "github:LilleAila/nix-cursors"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + # SOURCE: https://github.com/LilleAila/nix-cursors + nix-cursors = { + url = "github:LilleAila/nix-cursors"; + inputs.nixpkgs.follows = "nixpkgs"; + }; - # SOURCE: https://github.com/danth/stylix - stylix = { - url = "github:danth/stylix/release-24.05"; - inputs = { - home-manager.follows = "home-manager"; - nixpkgs.follows = "nixpkgs"; - }; - }; + # SOURCE: https://github.com/danth/stylix + stylix = { + url = "github:danth/stylix/release-24.05"; + inputs = { + home-manager.follows = "home-manager"; + nixpkgs.follows = "nixpkgs"; + }; + }; - nixpkgsJobber.url = "github:nixos/nixpkgs/051f920625ab5aabe37c920346e3e69d7d34400e"; - poetry2nixJobber.url = "github:nix-community/poetry2nix/304f8235fb0729fd48567af34fcd1b58d18f9b95"; + nixpkgsJobber.url = "github:nixos/nixpkgs/051f920625ab5aabe37c920346e3e69d7d34400e"; + poetry2nixJobber.url = "github:nix-community/poetry2nix/304f8235fb0729fd48567af34fcd1b58d18f9b95"; - nvimAlign = { flake = false; url = "github:echasnovski/mini.align"; }; - nvimAutoclose = { flake = false; url = "github:m4xshen/autoclose.nvim"; }; - nvimBufferline = { flake = false; url = "github:akinsho/bufferline.nvim"; }; - nvimCloseBuffers = { flake = false; url = "github:kazhala/close-buffers.nvim"; }; - nvimColorizer = { flake = false; url = "github:brenoprata10/nvim-highlight-colors"; }; - nvimDevicons = { flake = false; url = "github:nvim-tree/nvim-web-devicons"; }; - nvimDressing = { flake = false; url = "github:stevearc/dressing.nvim"; }; - nvimGen = { flake = false; url = "github:David-Kunz/gen.nvim"; }; - nvimGitsigns = { flake = false; url = "github:lewis6991/gitsigns.nvim"; }; - nvimGruvboxMaterial = { flake = false; url = "github:sainnhe/gruvbox-material"; }; - nvimIndentoMatic = { flake = false; url = "github:Darazaki/indent-o-matic"; }; - nvimLspconfig = { flake = false; url = "github:neovim/nvim-lspconfig"; }; - nvimPlenary = { flake = false; url = "github:nvim-lua/plenary.nvim"; }; - nvimTelescope = { flake = false; url = "github:nvim-telescope/telescope.nvim"; }; - nvimTodo = { flake = false; url = "github:folke/todo-comments.nvim"; }; - nvimTree = { flake = false; url = "github:nvim-tree/nvim-tree.lua"; }; - nvimTreesitter = { flake = false; url = "github:nvim-treesitter/nvim-treesitter"; }; - nvimTrouble = { flake = false; url = "github:folke/trouble.nvim"; }; - }; + nvimAlign = { + flake = false; + url = "github:echasnovski/mini.align"; + }; + nvimAutoclose = { + flake = false; + url = "github:m4xshen/autoclose.nvim"; + }; + nvimBufferline = { + flake = false; + url = "github:akinsho/bufferline.nvim"; + }; + nvimCloseBuffers = { + flake = false; + url = "github:kazhala/close-buffers.nvim"; + }; + nvimColorizer = { + flake = false; + url = "github:brenoprata10/nvim-highlight-colors"; + }; + nvimDevicons = { + flake = false; + url = "github:nvim-tree/nvim-web-devicons"; + }; + nvimDressing = { + flake = false; + url = "github:stevearc/dressing.nvim"; + }; + nvimGen = { + flake = false; + url = "github:David-Kunz/gen.nvim"; + }; + nvimGitsigns = { + flake = false; + url = "github:lewis6991/gitsigns.nvim"; + }; + nvimGruvboxMaterial = { + flake = false; + url = "github:sainnhe/gruvbox-material"; + }; + nvimIndentoMatic = { + flake = false; + url = "github:Darazaki/indent-o-matic"; + }; + nvimLspconfig = { + flake = false; + url = "github:neovim/nvim-lspconfig"; + }; + nvimPlenary = { + flake = false; + url = "github:nvim-lua/plenary.nvim"; + }; + nvimTelescope = { + flake = false; + url = "github:nvim-telescope/telescope.nvim"; + }; + nvimTodo = { + flake = false; + url = "github:folke/todo-comments.nvim"; + }; + nvimTree = { + flake = false; + url = "github:nvim-tree/nvim-tree.lua"; + }; + nvimTreesitter = { + flake = false; + url = "github:nvim-treesitter/nvim-treesitter"; + }; + nvimTrouble = { + flake = false; + url = "github:folke/trouble.nvim"; + }; + }; - outputs = { - home-manager, - nix-on-droid, - nixpkgs, - nixpkgsJobber, - nixpkgsMaster, - nixpkgsUnstable, - poetry2nixJobber, - self, - stylix, - ... - } @inputs: let - lib = nixpkgs.lib; + outputs = + { + home-manager, + nix-on-droid, + nixpkgs, + nixpkgsJobber, + nixpkgsMaster, + nixpkgsUnstable, + poetry2nixJobber, + self, + stylix, + ... + }@inputs: + let + lib = nixpkgs.lib; - const = { - droidStateVersion = "24.05"; - stateVersion = "24.11"; - timeZone = "Europe/Moscow"; - url = "https://git.voronind.com/voronind/nix.git"; - }; + const = { + droidStateVersion = "24.05"; + stateVersion = "24.11"; + timeZone = "Europe/Moscow"; + url = "https://git.voronind.com/voronind/nix.git"; + }; - __findFile = _: p: ./${p}; + __findFile = _: p: ./${p}; - ls = path: map (f: "${path}/${f}") ( - builtins.filter (i: builtins.readFileType "${path}/${i}" == "regular") ( - builtins.attrNames (builtins.readDir path) - ) - ); - in { - devShells = let - pkgs = nixpkgs.legacyPackages.${system}; - system = "x86_64-linux"; - in { - ${system}.default = pkgs.mkShell { - nativeBuildInputs = with pkgs; [ - nixd - ]; - # buildInputs = with pkgs; [ ]; + ls = + path: + map (f: "${path}/${f}") ( + builtins.filter (i: builtins.readFileType "${path}/${i}" == "regular") ( + builtins.attrNames (builtins.readDir path) + ) + ); + in + { + devShells = + let + pkgs = nixpkgs.legacyPackages.${system}; + system = "x86_64-linux"; + in + { + ${system}.default = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + nixd + nixfmt-rfc-style + treefmt + ]; + # buildInputs = with pkgs; [ ]; - # LD_LIBRARY_PATH = "${lib.makeLibraryPath buildInputs}"; - # SOURCE_DATE_EPOCH = "${toString self.lastModified}"; - }; - }; + # LD_LIBRARY_PATH = "${lib.makeLibraryPath buildInputs}"; + # SOURCE_DATE_EPOCH = "${toString self.lastModified}"; + }; + }; - nixosConfigurations = let - mkHost = { system, hostname }: lib.nixosSystem { - inherit system; - modules = [ - # Make a device hostname match the one from this config. - { networking.hostName = hostname; } + nixosConfigurations = + let + mkHost = + { system, hostname }: + lib.nixosSystem { + inherit system; + modules = + [ + # Make a device hostname match the one from this config. + { networking.hostName = hostname; } - # Specify current release version. - { system.stateVersion = const.stateVersion; } + # Specify current release version. + { system.stateVersion = const.stateVersion; } - # Add Home Manager module. - home-manager.nixosModules.home-manager + # Add Home Manager module. + home-manager.nixosModules.home-manager - # Add Stylix module. - stylix.nixosModules.stylix + # Add Stylix module. + stylix.nixosModules.stylix - # HM config. - ./home/NixOs.nix - ] - ++ (ls ./host/${system}/${hostname}) - ++ (ls ./option) - ++ (ls ./config) - ++ (ls ./overlay) - ++ (ls ./system) - ; - specialArgs = let - util = import ./lib/Util.nix { inherit lib; }; - in { - inherit const __findFile inputs self poetry2nixJobber util; - pkgsJobber = nixpkgsJobber.legacyPackages.${system}.pkgs; - pkgsMaster = nixpkgsMaster.legacyPackages.${system}.pkgs; - pkgsUnstable = nixpkgsUnstable.legacyPackages.${system}.pkgs; - secret = import ./secret { }; - }; - }; + # HM config. + ./home/NixOs.nix + ] + ++ (ls ./host/${system}/${hostname}) + ++ (ls ./option) + ++ (ls ./config) + ++ (ls ./overlay) + ++ (ls ./system); + specialArgs = + let + util = import ./lib/Util.nix { inherit lib; }; + in + { + inherit + const + __findFile + inputs + self + poetry2nixJobber + util + ; + pkgsJobber = nixpkgsJobber.legacyPackages.${system}.pkgs; + pkgsMaster = nixpkgsMaster.legacyPackages.${system}.pkgs; + pkgsUnstable = nixpkgsUnstable.legacyPackages.${system}.pkgs; + secret = import ./secret { }; + }; + }; - mkSystem = system: hostname: { "${hostname}" = mkHost { inherit system hostname; }; }; + mkSystem = system: hostname: { "${hostname}" = mkHost { inherit system hostname; }; }; - systems = builtins.attrNames (builtins.readDir ./host) |> map (system: { - inherit system; - hosts = builtins.attrNames (builtins.readDir ./host/${system}); - }); + systems = + builtins.attrNames (builtins.readDir ./host) + |> map (system: { + inherit system; + hosts = builtins.attrNames (builtins.readDir ./host/${system}); + }); - hosts = map (system: - map (host: { inherit host; inherit (system) system; }) system.hosts - ) systems |> lib.foldl' (acc: h: acc ++ h) []; + hosts = + map ( + system: + map (host: { + inherit host; + inherit (system) system; + }) system.hosts + ) systems + |> lib.foldl' (acc: h: acc ++ h) [ ]; - configurations = map (cfg: mkSystem cfg.system cfg.host) hosts; - in - lib.foldl' (result: cfg: result // cfg) {} configurations; + configurations = map (cfg: mkSystem cfg.system cfg.host) hosts; + in + lib.foldl' (result: cfg: result // cfg) { } configurations; - nixOnDroidConfigurations.default = let - pkgs = nixpkgs.legacyPackages.${system}.pkgs; - pkgsMaster = nixpkgsMaster.legacyPackages.${system}.pkgs; - pkgsUnstable = nixpkgsUnstable.legacyPackages.${system}.pkgs; - system = "aarch64-linux"; - in nix-on-droid.lib.nixOnDroidConfiguration { - inherit pkgs; - modules = [ - { home.android.enable = true; } - { home-manager.config.stylix.autoEnable = lib.mkForce false; } - ./home/Android.nix - ] - ++ (ls ./option) - ; - extraSpecialArgs = { - inherit inputs self pkgsMaster pkgsUnstable const __findFile; - secret = import ./secret { }; - util = import ./lib/Util.nix { inherit lib; }; - }; - }; - }; + nixOnDroidConfigurations.default = + let + pkgs = nixpkgs.legacyPackages.${system}.pkgs; + pkgsMaster = nixpkgsMaster.legacyPackages.${system}.pkgs; + pkgsUnstable = nixpkgsUnstable.legacyPackages.${system}.pkgs; + system = "aarch64-linux"; + in + nix-on-droid.lib.nixOnDroidConfiguration { + inherit pkgs; + modules = [ + { home.android.enable = true; } + { home-manager.config.stylix.autoEnable = lib.mkForce false; } + ./home/Android.nix + ] ++ (ls ./option); + extraSpecialArgs = { + inherit + inputs + self + pkgsMaster + pkgsUnstable + const + __findFile + ; + secret = import ./secret { }; + util = import ./lib/Util.nix { inherit lib; }; + }; + }; + }; } diff --git a/home/Android.nix b/home/Android.nix index c1493430..4581062e 100644 --- a/home/Android.nix +++ b/home/Android.nix @@ -1,46 +1,44 @@ # This is a common user configuration. { - __findFile, - config, - const, - inputs, - lib, - pkgs, - pkgsMaster, - pkgsUnstable, - self, - ... -} @args: let - cfg = config.home.android; - android = import ./android args; - env = import ./env args; - file = import ./file args; - package = import args; - programs = import ./program args; - stylix = import args; -in { - options.home.android = { - enable = lib.mkEnableOption "the Android HM config."; - }; + __findFile, + config, + const, + inputs, + lib, + pkgs, + pkgsMaster, + pkgsUnstable, + self, + ... +}@args: +let + cfg = config.home.android; + android = import ./android args; + env = import ./env args; + file = import ./file args; + package = import args; + programs = import ./program args; + stylix = import args; +in +{ + options.home.android = { + enable = lib.mkEnableOption "the Android HM config."; + }; - config = lib.mkIf cfg.enable { - environment.packages = package.core; - nix.extraOptions = "experimental-features = nix-command flakes"; - system.stateVersion = const.droidStateVersion; - time.timeZone = const.timeZone; - terminal = { - inherit (android) font colors; - }; - home-manager.config = stylix // { - programs = with programs; core; - imports = [ - inputs.stylix.homeManagerModules.stylix - ]; - home = { - inherit (env) sessionVariables; - inherit file; - stateVersion = const.droidStateVersion; - }; - }; - }; + config = lib.mkIf cfg.enable { + environment.packages = package.core; + nix.extraOptions = "experimental-features = nix-command flakes"; + system.stateVersion = const.droidStateVersion; + time.timeZone = const.timeZone; + terminal = { inherit (android) font colors; }; + home-manager.config = stylix // { + programs = with programs; core; + imports = [ inputs.stylix.homeManagerModules.stylix ]; + home = { + inherit (env) sessionVariables; + inherit file; + stateVersion = const.droidStateVersion; + }; + }; + }; } diff --git a/home/NixOs.nix b/home/NixOs.nix index 1f3de578..1bfbf39d 100644 --- a/home/NixOs.nix +++ b/home/NixOs.nix @@ -1,49 +1,55 @@ # This is a common user configuration. { - __findFile, - config, - const, - lib, - pkgs, - util, - ... -} @args: let - cfg = config.home.nixos; - env = import ./env args; - file = import ./file args; - programs = import ./program args; -in { - imports = (util.ls ); + __findFile, + config, + const, + lib, + pkgs, + util, + ... +}@args: +let + cfg = config.home.nixos; + env = import ./env args; + file = import ./file args; + programs = import ./program args; +in +{ + imports = (util.ls ); - options.home.nixos = { - enable = lib.mkEnableOption "the NixOS user setup."; - users = lib.mkOption { - default = [ ]; - type = with lib.types; listOf attrs; - }; - }; + options.home.nixos = { + enable = lib.mkEnableOption "the NixOS user setup."; + users = lib.mkOption { + default = [ ]; + type = with lib.types; listOf attrs; + }; + }; - config = lib.mkIf cfg.enable { - home-manager = { - backupFileExtension = "backup-" + pkgs.lib.readFile "${pkgs.runCommand "timestamp" { } "echo -n date '+%Y%m%d%H%M%S' > $out"}"; - users = builtins.foldl' (acc: user: - acc // { - ${user.username} = { - home = { - inherit (const) stateVersion; - inherit (env) sessionVariables; - inherit (user) username homeDirectory; - inherit file; + config = lib.mkIf cfg.enable { + home-manager = { + backupFileExtension = + "backup-" + + pkgs.lib.readFile "${pkgs.runCommand "timestamp" { } "echo -n date '+%Y%m%d%H%M%S' > $out"}"; + users = builtins.foldl' ( + acc: user: + acc + // { + ${user.username} = { + home = { + inherit (const) stateVersion; + inherit (env) sessionVariables; + inherit (user) username homeDirectory; + inherit file; - # ISSUE: https://github.com/nix-community/home-manager/issues/5589 - extraActivationPath = with pkgs; [ openssh ]; - }; - xdg = import ./xdg { inherit (user) homeDirectory; }; - programs = with programs; core // desktop; - dconf.settings = util.catSet (util.ls ./file/dconf) args; - }; - } - ) { } cfg.users; - }; - }; + # ISSUE: https://github.com/nix-community/home-manager/issues/5589 + extraActivationPath = with pkgs; [ openssh ]; + }; + xdg = import ./xdg { inherit (user) homeDirectory; }; + programs = with programs; core // desktop; + dconf.settings = util.catSet (util.ls ./file/dconf) args; + }; + } + ) { } cfg.users; + }; + }; } diff --git a/home/android/default.nix b/home/android/default.nix index 729b8bce..b546729b 100644 --- a/home/android/default.nix +++ b/home/android/default.nix @@ -1,15 +1,14 @@ +{ config, pkgs, ... }: { - config, - pkgs, - ... -}: { - font = pkgs.runCommandNoCC "font" { } '' - cp ${pkgs.nerdfonts.override { fonts = [ "Terminus" ]; }}/share/fonts/truetype/NerdFonts/TerminessNerdFontMono-Regular.ttf $out - ''; + font = pkgs.runCommandNoCC "font" { } '' + cp ${ + pkgs.nerdfonts.override { fonts = [ "Terminus" ]; } + }/share/fonts/truetype/NerdFonts/TerminessNerdFontMono-Regular.ttf $out + ''; - colors = with config.module.style.color; { - background = "#${bg.dark}"; - cursor = "#${fg.light}"; - foreground = "#${fg.light}"; - }; + colors = with config.module.style.color; { + background = "#${bg.dark}"; + cursor = "#${fg.light}"; + foreground = "#${fg.light}"; + }; } diff --git a/home/env/Variable.nix b/home/env/Variable.nix index 43f1bb44..7fbf8a80 100644 --- a/home/env/Variable.nix +++ b/home/env/Variable.nix @@ -1,14 +1,12 @@ +{ pkgs, ... }: { - pkgs, - ... -}: { - EDITOR = "nvim"; # Default text editor. - GTK_CSD = 0; # GTK apps compat. - MANGOHUD = "1"; # Enable Mangohud by default. - MANPAGER = "nvim +Man!"; # App to use for man pages. - MOZ_LEGACY_PROFILES = "1"; # Disable Firefox profile switching on rebuild. - NIXPKGS_ALLOW_UNFREE = "1"; # Allow unfree packages in shell. - NIX_CURRENT_SYSTEM = "${pkgs.stdenv.system}"; # Current system architecture. - TERM = "xterm-256color"; # Terminal settings. - WINEFSYNC = "1"; # Use fsync for Wine. + EDITOR = "nvim"; # Default text editor. + GTK_CSD = 0; # GTK apps compat. + MANGOHUD = "1"; # Enable Mangohud by default. + MANPAGER = "nvim +Man!"; # App to use for man pages. + MOZ_LEGACY_PROFILES = "1"; # Disable Firefox profile switching on rebuild. + NIXPKGS_ALLOW_UNFREE = "1"; # Allow unfree packages in shell. + NIX_CURRENT_SYSTEM = "${pkgs.stdenv.system}"; # Current system architecture. + TERM = "xterm-256color"; # Terminal settings. + WINEFSYNC = "1"; # Use fsync for Wine. } diff --git a/home/env/default.nix b/home/env/default.nix index 9ecbc3e9..54ae3abf 100644 --- a/home/env/default.nix +++ b/home/env/default.nix @@ -1,6 +1,4 @@ +{ pkgs, ... }@args: { - pkgs, - ... -} @args: { - sessionVariables = import ./Variable.nix args; + sessionVariables = import ./Variable.nix args; } diff --git a/home/file/btop/default.nix b/home/file/btop/default.nix index 23c7007c..93c07c50 100644 --- a/home/file/btop/default.nix +++ b/home/file/btop/default.nix @@ -1,100 +1,101 @@ -{ - pkgs, - lib, - ... -}: let - config = { - background_update = true; - base_10_sizes = true; - check_temp = true; - clock_format = "%X"; - color_theme = "/usr/share/btop/themes/gruvbox_material_dark.theme"; - cpu_bottom = false; - cpu_core_map = ""; - cpu_graph_lower = "total"; - cpu_graph_upper = "total"; - cpu_invert_lower = true; - cpu_sensor = "Auto"; - cpu_single_graph = false; - custom_cpu_name = ""; - custom_gpu_name0 = ""; - custom_gpu_name1 = ""; - custom_gpu_name2 = ""; - custom_gpu_name3 = ""; - custom_gpu_name4 = ""; - custom_gpu_name5 = ""; - disk_free_priv = false; - disks_filter = "exclude = /boot /boot/efi"; - force_tty = false; - gpu_mirror_graph = true; - graph_symbol = "braille"; - graph_symbol_cpu = "default"; - graph_symbol_gpu = "default"; - graph_symbol_mem = "default"; - graph_symbol_net = "default"; - graph_symbol_proc = "default"; - io_graph_combined = false; - io_graph_speeds = ""; - io_mode = false; - log_level = "WARNING"; - mem_below_net = false; - mem_graphs = true; - net_auto = true; - net_download = 100; - net_iface = ""; - net_sync = true; - net_upload = 100; - nvml_measure_pcie_speeds = true; - only_physical = true; - presets = ""; - proc_aggregate = true; - proc_colors = true; - proc_cpu_graphs = true; - proc_filter_kernel = true; - proc_gradient = false; - proc_info_smaps = false; - proc_left = true; - proc_mem_bytes = true; - proc_per_core = true; - proc_reversed = false; - proc_sorting = "memory"; - proc_tree = false; - rounded_corners = true; - selected_battery = "Auto"; - show_battery = true; - show_coretemp = true; - show_cpu_freq = true; - show_disks = true; - show_gpu_info = "Auto"; - show_io_stat = true; - show_swap = true; - show_uptime = true; - shown_boxes = "cpu mem net proc"; - swap_disk = false; - temp_scale = "celsius"; - theme_background = false; - truecolor = true; - update_ms = 2000; - use_fstab = true; - vim_keys = true; - zfs_arc_cached = true; - zfs_hide_datasets = false; - }; +{ pkgs, lib, ... }: +let + config = { + background_update = true; + base_10_sizes = true; + check_temp = true; + clock_format = "%X"; + color_theme = "/usr/share/btop/themes/gruvbox_material_dark.theme"; + cpu_bottom = false; + cpu_core_map = ""; + cpu_graph_lower = "total"; + cpu_graph_upper = "total"; + cpu_invert_lower = true; + cpu_sensor = "Auto"; + cpu_single_graph = false; + custom_cpu_name = ""; + custom_gpu_name0 = ""; + custom_gpu_name1 = ""; + custom_gpu_name2 = ""; + custom_gpu_name3 = ""; + custom_gpu_name4 = ""; + custom_gpu_name5 = ""; + disk_free_priv = false; + disks_filter = "exclude = /boot /boot/efi"; + force_tty = false; + gpu_mirror_graph = true; + graph_symbol = "braille"; + graph_symbol_cpu = "default"; + graph_symbol_gpu = "default"; + graph_symbol_mem = "default"; + graph_symbol_net = "default"; + graph_symbol_proc = "default"; + io_graph_combined = false; + io_graph_speeds = ""; + io_mode = false; + log_level = "WARNING"; + mem_below_net = false; + mem_graphs = true; + net_auto = true; + net_download = 100; + net_iface = ""; + net_sync = true; + net_upload = 100; + nvml_measure_pcie_speeds = true; + only_physical = true; + presets = ""; + proc_aggregate = true; + proc_colors = true; + proc_cpu_graphs = true; + proc_filter_kernel = true; + proc_gradient = false; + proc_info_smaps = false; + proc_left = true; + proc_mem_bytes = true; + proc_per_core = true; + proc_reversed = false; + proc_sorting = "memory"; + proc_tree = false; + rounded_corners = true; + selected_battery = "Auto"; + show_battery = true; + show_coretemp = true; + show_cpu_freq = true; + show_disks = true; + show_gpu_info = "Auto"; + show_io_stat = true; + show_swap = true; + show_uptime = true; + shown_boxes = "cpu mem net proc"; + swap_disk = false; + temp_scale = "celsius"; + theme_background = false; + truecolor = true; + update_ms = 2000; + use_fstab = true; + vim_keys = true; + zfs_arc_cached = true; + zfs_hide_datasets = false; + }; - mkOption = k: v: lib.generators.mkKeyValueDefault { } " = " k v; -in { - file = pkgs.writeText "BtopConfig" ( - builtins.foldl' (acc: line: acc + "${line}\n") "" ( - lib.mapAttrsToList (k: v: let - value = if builtins.isString v then - "\"${v}\"" - else if builtins.isBool v then - if v then "True" else "False" - else - v - ; - in mkOption k value - ) config - ) - ); + mkOption = k: v: lib.generators.mkKeyValueDefault { } " = " k v; +in +{ + file = pkgs.writeText "BtopConfig" ( + builtins.foldl' (acc: line: acc + "${line}\n") "" ( + lib.mapAttrsToList ( + k: v: + let + value = + if builtins.isString v then + "\"${v}\"" + else if builtins.isBool v then + if v then "True" else "False" + else + v; + in + mkOption k value + ) config + ) + ); } diff --git a/home/file/chromium/default.nix b/home/file/chromium/default.nix index 2d890102..e651d9d4 100644 --- a/home/file/chromium/default.nix +++ b/home/file/chromium/default.nix @@ -1,98 +1,93 @@ +{ pkgs, config, ... }: { - pkgs, - config, - ... -}: { - preferences = (pkgs.formats.json { }).generate "ChromiumConfig" { - name = "Work"; - bookmark_bar.show_on_all_tabs = false; - browser.show_home_button = false; - default_apps_install_state = 2; - download.prompt_for_download = false; - download_bubble.partial_view_enabled = false; - intl.selected_languages = "en-US,en"; - session.restore_on_startup = 1; - side_panel.is_right_aligned = false; - default_search_provider = { - guid = "5761b040-db50-4f8e-9d00-c9ad985779a4"; - synced_guid = "5761b040-db50-4f8e-9d00-c9ad985779a4"; - }; - default_search_provider_data = { - template_url_data = { - id = 11; - is_active = 1; - keyword = "s"; - short_name = "SearX"; - synced_guid = "5761b040-db50-4f8e-9d00-c9ad985779a4"; - url = "https://search.voronind.com/search?q={searchTerms}"; - }; - }; - extensions = { - alerts.initialized = false; - commands = { - "linux:Alt+Shift+L" = { - command_name = "addSite"; - extension = "eimadpbcbfnmbkopoojfekhnkhdbieeh"; - global = false; - }; - "linux:Alt+Shift+B" = { - command_name = "_execute_browser_action"; - extension = "cgbcahbpdhpcegmbfconppldiemgcoii"; - global = false; - }; - "linux:Alt+Shift+K" = { - command_name = "launch-element-zapper"; - extension = "cgbcahbpdhpcegmbfconppldiemgcoii"; - global = false; - }; - "linux:Alt+Shift+J" = { - command_name = "toggle-javascript"; - extension = "cgbcahbpdhpcegmbfconppldiemgcoii"; - global = false; - }; - "linux:Alt+Shift+P" = { - command_name = "_execute_action"; - extension = "gcknhkkoolaabfmlnjonogaaifnjlfnp"; - global = false; - }; - }; - }; - password_manager = { - autofillable_credentials_account_store_login_database = false; - autofillable_credentials_profile_store_login_database = false; - }; - webkit = { - webprefs = { - default_fixed_font_size = 14; - default_font_size = 17; - minimum_font_size = 16; - fonts = let - mono = config.module.style.font.monospace.name; - sans = config.module.style.font.sansSerif.name; - in { - fixed.Zyyy = mono; - sansserif.Zyyy = sans; - serif.Zyyy = sans; - standard.Zyyy = sans; - }; - }; - }; - }; + preferences = (pkgs.formats.json { }).generate "ChromiumConfig" { + name = "Work"; + bookmark_bar.show_on_all_tabs = false; + browser.show_home_button = false; + default_apps_install_state = 2; + download.prompt_for_download = false; + download_bubble.partial_view_enabled = false; + intl.selected_languages = "en-US,en"; + session.restore_on_startup = 1; + side_panel.is_right_aligned = false; + default_search_provider = { + guid = "5761b040-db50-4f8e-9d00-c9ad985779a4"; + synced_guid = "5761b040-db50-4f8e-9d00-c9ad985779a4"; + }; + default_search_provider_data = { + template_url_data = { + id = 11; + is_active = 1; + keyword = "s"; + short_name = "SearX"; + synced_guid = "5761b040-db50-4f8e-9d00-c9ad985779a4"; + url = "https://search.voronind.com/search?q={searchTerms}"; + }; + }; + extensions = { + alerts.initialized = false; + commands = { + "linux:Alt+Shift+L" = { + command_name = "addSite"; + extension = "eimadpbcbfnmbkopoojfekhnkhdbieeh"; + global = false; + }; + "linux:Alt+Shift+B" = { + command_name = "_execute_browser_action"; + extension = "cgbcahbpdhpcegmbfconppldiemgcoii"; + global = false; + }; + "linux:Alt+Shift+K" = { + command_name = "launch-element-zapper"; + extension = "cgbcahbpdhpcegmbfconppldiemgcoii"; + global = false; + }; + "linux:Alt+Shift+J" = { + command_name = "toggle-javascript"; + extension = "cgbcahbpdhpcegmbfconppldiemgcoii"; + global = false; + }; + "linux:Alt+Shift+P" = { + command_name = "_execute_action"; + extension = "gcknhkkoolaabfmlnjonogaaifnjlfnp"; + global = false; + }; + }; + }; + password_manager = { + autofillable_credentials_account_store_login_database = false; + autofillable_credentials_profile_store_login_database = false; + }; + webkit = { + webprefs = { + default_fixed_font_size = 14; + default_font_size = 17; + minimum_font_size = 16; + fonts = + let + mono = config.module.style.font.monospace.name; + sans = config.module.style.font.sansSerif.name; + in + { + fixed.Zyyy = mono; + sansserif.Zyyy = sans; + serif.Zyyy = sans; + standard.Zyyy = sans; + }; + }; + }; + }; - localState = (pkgs.formats.json { }).generate "ChromiumLocalState" { - browser = { - first_run_finished = true; - enabled_labs_experiments = [ - "smooth-scrolling@2" - ]; - }; - }; + localState = (pkgs.formats.json { }).generate "ChromiumLocalState" { + browser = { + first_run_finished = true; + enabled_labs_experiments = [ "smooth-scrolling@2" ]; + }; + }; - # REF: https://chromeenterprise.google/intl/en_us/policies/ - policy = (pkgs.formats.json { }).generate "ChromiumPolicy" { - DefaultBrowserSettingEnabled = false; - URLBlocklist = [ - "darkreader.org" - ]; - }; + # REF: https://chromeenterprise.google/intl/en_us/policies/ + policy = (pkgs.formats.json { }).generate "ChromiumPolicy" { + DefaultBrowserSettingEnabled = false; + URLBlocklist = [ "darkreader.org" ]; + }; } diff --git a/home/file/dconf/Accessibility.nix b/home/file/dconf/Accessibility.nix index 52d86f41..ed4c2db3 100644 --- a/home/file/dconf/Accessibility.nix +++ b/home/file/dconf/Accessibility.nix @@ -1,5 +1,6 @@ -{ ... }: { - "org/gnome/desktop/a11y" = { - always-show-universal-access-status = true; - }; +{ ... }: +{ + "org/gnome/desktop/a11y" = { + always-show-universal-access-status = true; + }; } diff --git a/home/file/dconf/Gtk.nix b/home/file/dconf/Gtk.nix index d35fb669..9afa88a1 100644 --- a/home/file/dconf/Gtk.nix +++ b/home/file/dconf/Gtk.nix @@ -1,27 +1,28 @@ -{ ... }: { - "org/gtk/gtk4/settings/file-chooser" = { - date-format = "regular"; - location-mode = "path-bar"; - show-hidden = false; - show-size-column = true; - show-type-column = true; - sidebar-width = "166"; - sort-column = "modified"; - sort-directories-first = true; - sort-order = "descending"; - type-format = "category"; - view-type = "list"; - }; +{ ... }: +{ + "org/gtk/gtk4/settings/file-chooser" = { + date-format = "regular"; + location-mode = "path-bar"; + show-hidden = false; + show-size-column = true; + show-type-column = true; + sidebar-width = "166"; + sort-column = "modified"; + sort-directories-first = true; + sort-order = "descending"; + type-format = "category"; + view-type = "list"; + }; - "org/gtk/settings/file-chooser" = { - date-format = "regular"; - location-mode = "path-bar"; - show-hidden = false; - show-size-column = true; - show-type-column = true; - sort-column = "modified"; - sort-directories-first = true; - sort-order = "descending"; - type-format = "category"; - }; + "org/gtk/settings/file-chooser" = { + date-format = "regular"; + location-mode = "path-bar"; + show-hidden = false; + show-size-column = true; + show-type-column = true; + sort-column = "modified"; + sort-directories-first = true; + sort-order = "descending"; + type-format = "category"; + }; } diff --git a/home/file/dconf/Input.nix b/home/file/dconf/Input.nix index 5dcaada7..e767a480 100644 --- a/home/file/dconf/Input.nix +++ b/home/file/dconf/Input.nix @@ -1,32 +1,36 @@ +{ lib, config, ... }: { - lib, - config, - ... -}: { - "org/gnome/desktop/input-sources" = with lib.gvariant; let - sources = [ - (mkTuple [ "xkb" "us" ]) - (mkTuple [ "xkb" "ru" ]) - ]; - in { - inherit sources; - current = mkUint32 0; - mru-sources = sources; - per-window = false; - show-all-sources = true; - xkb-options = [ - config.module.keyboard.options - ]; - }; + "org/gnome/desktop/input-sources" = + with lib.gvariant; + let + sources = [ + (mkTuple [ + "xkb" + "us" + ]) + (mkTuple [ + "xkb" + "ru" + ]) + ]; + in + { + inherit sources; + current = mkUint32 0; + mru-sources = sources; + per-window = false; + show-all-sources = true; + xkb-options = [ config.module.keyboard.options ]; + }; - "org/gnome/desktop/peripherals/mouse" = { - accel-profile = "flat"; - natural-scroll = true; - speed = "0.0"; - }; + "org/gnome/desktop/peripherals/mouse" = { + accel-profile = "flat"; + natural-scroll = true; + speed = "0.0"; + }; - "org/gnome/desktop/peripherals/touchpad" = { - tap-to-click = true; - two-finger-scrolling-enabled = true; - }; + "org/gnome/desktop/peripherals/touchpad" = { + tap-to-click = true; + two-finger-scrolling-enabled = true; + }; } diff --git a/home/file/dconf/Interface.nix b/home/file/dconf/Interface.nix index c6b2e9f4..ad378638 100644 --- a/home/file/dconf/Interface.nix +++ b/home/file/dconf/Interface.nix @@ -1,12 +1,12 @@ { ... }: { - "org/gnome/desktop/interface" = { - clock-show-date = true; - clock-show-weekday = true; - color-scheme = "prefer-dark"; - enable-animations = false; - enable-hot-corners = false; - gtk-enable-primary-paste = false; - show-battery-percentage = false; - }; + "org/gnome/desktop/interface" = { + clock-show-date = true; + clock-show-weekday = true; + color-scheme = "prefer-dark"; + enable-animations = false; + enable-hot-corners = false; + gtk-enable-primary-paste = false; + show-battery-percentage = false; + }; } diff --git a/home/file/dconf/Key.nix b/home/file/dconf/Key.nix index 9271e708..429bd682 100644 --- a/home/file/dconf/Key.nix +++ b/home/file/dconf/Key.nix @@ -1,132 +1,134 @@ -{ ... }: let - mod = ""; -in { - "org/gnome/desktop/wm/keybindings" = { - activate-window-menu = [ "" ]; - begin-move = [ "" ]; - begin-resize = [ "${mod}r" ]; - close = [ "${mod}x" ]; - cycle-group = [ "" ]; - cycle-group-backward = [ "" ]; - cycle-panels = [ "" ]; - cycle-panels-backward = [ "" ]; - cycle-windows = [ "" ]; - cycle-windows-backward = [ "" ]; - maximize = [ "" ]; - maximize-horizontally = [ "" ]; - minimize = [ "${mod}s" ]; - move-to-monitor-down = [ "" ]; - move-to-monitor-left = [ "" ]; - move-to-monitor-right = [ "" ]; - move-to-monitor-up = [ "" ]; - move-to-workspace-1 = [ "" ]; - move-to-workspace-2 = [ "" ]; - move-to-workspace-3 = [ "" ]; - move-to-workspace-4 = [ "" ]; - move-to-workspace-last = [ "" ]; - move-to-workspace-left = [ "${mod}q" ]; - move-to-workspace-right = [ "${mod}e" ]; - panel-run-dialog = [ "${mod}space" ]; - show-desktop = [ "${mod}c" ]; - switch-applications = [ "${mod}Tab" ]; - switch-applications-backward = [ "${mod}Tab" ]; - switch-group = [ "Tab" ]; - switch-group-backward = [ "Tab" ]; - switch-input-source = [ "" ]; - switch-input-source-backward = [ "" ]; - switch-panels = [ "" ]; - switch-panels-backward = [ "" ]; - switch-to-workspace-1 = [ "" ]; - switch-to-workspace-2 = [ "" ]; - switch-to-workspace-3 = [ "" ]; - switch-to-workspace-4 = [ "" ]; - switch-to-workspace-last = [ "" ]; - switch-to-workspace-left = [ "${mod}q" ]; - switch-to-workspace-right = [ "${mod}e" ]; - switch-windows = [ "" ]; - switch-windows-backward = [ "" ]; - toggle-fullscreen = [ "${mod}f" ]; - toggle-maximized = [ "${mod}w" ]; - unmaximize = [ "" ]; - }; +{ ... }: +let + mod = ""; +in +{ + "org/gnome/desktop/wm/keybindings" = { + activate-window-menu = [ "" ]; + begin-move = [ "" ]; + begin-resize = [ "${mod}r" ]; + close = [ "${mod}x" ]; + cycle-group = [ "" ]; + cycle-group-backward = [ "" ]; + cycle-panels = [ "" ]; + cycle-panels-backward = [ "" ]; + cycle-windows = [ "" ]; + cycle-windows-backward = [ "" ]; + maximize = [ "" ]; + maximize-horizontally = [ "" ]; + minimize = [ "${mod}s" ]; + move-to-monitor-down = [ "" ]; + move-to-monitor-left = [ "" ]; + move-to-monitor-right = [ "" ]; + move-to-monitor-up = [ "" ]; + move-to-workspace-1 = [ "" ]; + move-to-workspace-2 = [ "" ]; + move-to-workspace-3 = [ "" ]; + move-to-workspace-4 = [ "" ]; + move-to-workspace-last = [ "" ]; + move-to-workspace-left = [ "${mod}q" ]; + move-to-workspace-right = [ "${mod}e" ]; + panel-run-dialog = [ "${mod}space" ]; + show-desktop = [ "${mod}c" ]; + switch-applications = [ "${mod}Tab" ]; + switch-applications-backward = [ "${mod}Tab" ]; + switch-group = [ "Tab" ]; + switch-group-backward = [ "Tab" ]; + switch-input-source = [ "" ]; + switch-input-source-backward = [ "" ]; + switch-panels = [ "" ]; + switch-panels-backward = [ "" ]; + switch-to-workspace-1 = [ "" ]; + switch-to-workspace-2 = [ "" ]; + switch-to-workspace-3 = [ "" ]; + switch-to-workspace-4 = [ "" ]; + switch-to-workspace-last = [ "" ]; + switch-to-workspace-left = [ "${mod}q" ]; + switch-to-workspace-right = [ "${mod}e" ]; + switch-windows = [ "" ]; + switch-windows-backward = [ "" ]; + toggle-fullscreen = [ "${mod}f" ]; + toggle-maximized = [ "${mod}w" ]; + unmaximize = [ "" ]; + }; - "org/gnome/mutter/keybindings" = { - toggle-tiled-left = [ "${mod}a" ]; - toggle-tiled-right = [ "${mod}d" ]; - }; + "org/gnome/mutter/keybindings" = { + toggle-tiled-left = [ "${mod}a" ]; + toggle-tiled-right = [ "${mod}d" ]; + }; - "org/gnome/mutter/wayland/keybindings" = { - restore-shortcuts = [ "" ]; - }; + "org/gnome/mutter/wayland/keybindings" = { + restore-shortcuts = [ "" ]; + }; - "org/gnome/settings-daemon/plugins/media-keys" = { - custom-keybindings = [ - "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/" - "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/" - "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/" - "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3/" - "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom4/" - "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom5/" - ]; - magnifier = [ "" ]; - magnifier-zoom-in = [ "" ]; - magnifier-zoom-out = [ "" ]; - screenreader = [ "" ]; - screensaver = [ "${mod}z" ]; - }; + "org/gnome/settings-daemon/plugins/media-keys" = { + custom-keybindings = [ + "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/" + "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/" + "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/" + "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3/" + "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom4/" + "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom5/" + ]; + magnifier = [ "" ]; + magnifier-zoom-in = [ "" ]; + magnifier-zoom-out = [ "" ]; + screenreader = [ "" ]; + screensaver = [ "${mod}z" ]; + }; - "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0" = { - binding = "${mod}Escape"; - command = "kgx -e bash -c 'tmux new-session -A -s main; bash'"; - name = "gnome-terminal"; - }; + "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0" = { + binding = "${mod}Escape"; + command = "kgx -e bash -c 'tmux new-session -A -s main; bash'"; + name = "gnome-terminal"; + }; - "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1" = { - binding = "printz"; - command = "systemctl suspend -i"; - name = "System Sleep"; - }; + "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1" = { + binding = "printz"; + command = "systemctl suspend -i"; + name = "System Sleep"; + }; - "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2" = { - binding = "printx"; - command = "systemctl poweroff -i"; - name = "System Poweroff"; - }; + "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2" = { + binding = "printx"; + command = "systemctl poweroff -i"; + name = "System Poweroff"; + }; - "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3" = { - binding = "printc"; - command = "systemctl reboot -i"; - name = "System Reboot"; - }; + "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3" = { + binding = "printc"; + command = "systemctl reboot -i"; + name = "System Reboot"; + }; - "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom4" = { - binding = "printp"; - command = "powersave toggle"; - name = "Toggle Powersave"; - }; + "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom4" = { + binding = "printp"; + command = "powersave toggle"; + name = "Toggle Powersave"; + }; - "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom5" = { - binding = "printl"; - command = "powerlimit toggle"; - name = "Toggle Powerlimit"; - }; + "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom5" = { + binding = "printl"; + command = "powerlimit toggle"; + name = "Toggle Powerlimit"; + }; - "org/gnome/shell/keybindings" = { - focus-active-notification = [ "" ]; - open-application-menu = [ "" ]; - show-screenshot-ui = [ "${mod}v" ]; - switch-to-application-1 = [ "" ]; - switch-to-application-2 = [ "" ]; - switch-to-application-3 = [ "" ]; - switch-to-application-4 = [ "" ]; - switch-to-application-5 = [ "" ]; - switch-to-application-6 = [ "" ]; - switch-to-application-7 = [ "" ]; - switch-to-application-8 = [ "" ]; - switch-to-application-9 = [ "" ]; - toggle-application-view = [ "" ]; - toggle-message-tray = [ "" ]; - toggle-overview = [ "" ]; - toggle-quick-settings = [ "" ]; - }; + "org/gnome/shell/keybindings" = { + focus-active-notification = [ "" ]; + open-application-menu = [ "" ]; + show-screenshot-ui = [ "${mod}v" ]; + switch-to-application-1 = [ "" ]; + switch-to-application-2 = [ "" ]; + switch-to-application-3 = [ "" ]; + switch-to-application-4 = [ "" ]; + switch-to-application-5 = [ "" ]; + switch-to-application-6 = [ "" ]; + switch-to-application-7 = [ "" ]; + switch-to-application-8 = [ "" ]; + switch-to-application-9 = [ "" ]; + toggle-application-view = [ "" ]; + toggle-message-tray = [ "" ]; + toggle-overview = [ "" ]; + toggle-quick-settings = [ "" ]; + }; } diff --git a/home/file/dconf/Media.nix b/home/file/dconf/Media.nix index 01e67e1a..fef8d152 100644 --- a/home/file/dconf/Media.nix +++ b/home/file/dconf/Media.nix @@ -1,7 +1,8 @@ -{ ... }: { - "org/gnome/desktop/media-handling" = { - automount = false; - automount-open = false; - autorun-never = true; - }; +{ ... }: +{ + "org/gnome/desktop/media-handling" = { + automount = false; + automount-open = false; + autorun-never = true; + }; } diff --git a/home/file/dconf/Nautilus.nix b/home/file/dconf/Nautilus.nix index e20a08ef..253a8aaf 100644 --- a/home/file/dconf/Nautilus.nix +++ b/home/file/dconf/Nautilus.nix @@ -1,21 +1,22 @@ -{ ... }: { - "org/gnome/nautilus/icon-view" = { - default-zoom-level = "larger"; - }; +{ ... }: +{ + "org/gnome/nautilus/icon-view" = { + default-zoom-level = "larger"; + }; - "org/gnome/nautilus/list-view" = { - default-zoom-level = "small"; - use-tree-view = false; - }; + "org/gnome/nautilus/list-view" = { + default-zoom-level = "small"; + use-tree-view = false; + }; - "org/gnome/nautilus/preferences" = { - click-policy = "single"; - default-folder-viewer = "list-view"; - default-sort-in-reverse-order = false; - default-sort-order = "name"; - migrated-gtk-settings = true; - search-filter-time-type = "last_modified"; - search-view = "list-view"; - show-image-thumbnails = "local-only"; - }; + "org/gnome/nautilus/preferences" = { + click-policy = "single"; + default-folder-viewer = "list-view"; + default-sort-in-reverse-order = false; + default-sort-order = "name"; + migrated-gtk-settings = true; + search-filter-time-type = "last_modified"; + search-view = "list-view"; + show-image-thumbnails = "local-only"; + }; } diff --git a/home/file/dconf/Power.nix b/home/file/dconf/Power.nix index 06ff8c11..01c55d6f 100644 --- a/home/file/dconf/Power.nix +++ b/home/file/dconf/Power.nix @@ -1,10 +1,11 @@ -{ ... }: { - "org/gnome/settings-daemon/plugins/power" = { - ambient-enabled = false; - idle-dim = false; - power-button-action = "nothing"; - sleep-inactive-ac-timeout = "0"; - sleep-inactive-ac-type = "nothing"; - sleep-inactive-battery-type = "nothing"; - }; +{ ... }: +{ + "org/gnome/settings-daemon/plugins/power" = { + ambient-enabled = false; + idle-dim = false; + power-button-action = "nothing"; + sleep-inactive-ac-timeout = "0"; + sleep-inactive-ac-type = "nothing"; + sleep-inactive-battery-type = "nothing"; + }; } diff --git a/home/file/dconf/Privacy.nix b/home/file/dconf/Privacy.nix index e44548a6..f45daf30 100644 --- a/home/file/dconf/Privacy.nix +++ b/home/file/dconf/Privacy.nix @@ -1,18 +1,16 @@ +{ lib, ... }: { - lib, - ... -}: { - "org/gnome/desktop/privacy" = with lib.gvariant; { - disable-camera = false; - disable-microphone = false; - old-files-age = mkUint32 30; - recent-files-max-age = mkUint32 30; - remove-old-temp-files = true; - remove-old-trash-files = true; - report-technical-problems = true; - }; + "org/gnome/desktop/privacy" = with lib.gvariant; { + disable-camera = false; + disable-microphone = false; + old-files-age = mkUint32 30; + recent-files-max-age = mkUint32 30; + remove-old-temp-files = true; + remove-old-trash-files = true; + report-technical-problems = true; + }; - "org/gnome/system/location" = { - enabled = false; - }; + "org/gnome/system/location" = { + enabled = false; + }; } diff --git a/home/file/dconf/Session.nix b/home/file/dconf/Session.nix index 1ad0a135..7e4b7c72 100644 --- a/home/file/dconf/Session.nix +++ b/home/file/dconf/Session.nix @@ -1,8 +1,6 @@ +{ lib, ... }: { - lib, - ... -}: { - "org/gnome/desktop/session" = with lib.gvariant; { - idle-delay = mkUint32 0; - }; + "org/gnome/desktop/session" = with lib.gvariant; { + idle-delay = mkUint32 0; + }; } diff --git a/home/file/dconf/Shell.nix b/home/file/dconf/Shell.nix index 88cec981..9a867f87 100644 --- a/home/file/dconf/Shell.nix +++ b/home/file/dconf/Shell.nix @@ -1,14 +1,15 @@ -{ ... }: { - "org/gnome/shell" = { - disable-extension-version-validation = true; - disable-user-extensions = false; - favorite-apps = [ "" ]; - had-bluetooth-devices-setup = true; - last-selected-power-profile = "power-saver"; - remember-mount-password = false; - }; +{ ... }: +{ + "org/gnome/shell" = { + disable-extension-version-validation = true; + disable-user-extensions = false; + favorite-apps = [ "" ]; + had-bluetooth-devices-setup = true; + last-selected-power-profile = "power-saver"; + remember-mount-password = false; + }; - "system/proxy" = { - mode = "none"; - }; + "system/proxy" = { + mode = "none"; + }; } diff --git a/home/file/dconf/Software.nix b/home/file/dconf/Software.nix index 11303f2b..2c38d0ec 100644 --- a/home/file/dconf/Software.nix +++ b/home/file/dconf/Software.nix @@ -1,8 +1,9 @@ -{ ... }: { - "org/gnome/software" = { - download-updates = false; - download-updates-notify = false; - first-run = false; - show-nonfree-prompt = false; - }; +{ ... }: +{ + "org/gnome/software" = { + download-updates = false; + download-updates-notify = false; + first-run = false; + show-nonfree-prompt = false; + }; } diff --git a/home/file/dconf/Sound.nix b/home/file/dconf/Sound.nix index 743e038d..8a42caa3 100644 --- a/home/file/dconf/Sound.nix +++ b/home/file/dconf/Sound.nix @@ -1,7 +1,8 @@ -{ ... }: { - "org/gnome/desktop/sound" = { - allow-volume-above-100-percent = false; - event-sounds = false; - theme-name = "freedesktop"; - }; +{ ... }: +{ + "org/gnome/desktop/sound" = { + allow-volume-above-100-percent = false; + event-sounds = false; + theme-name = "freedesktop"; + }; } diff --git a/home/file/dconf/Wm.nix b/home/file/dconf/Wm.nix index cdc997be..4b18ba02 100644 --- a/home/file/dconf/Wm.nix +++ b/home/file/dconf/Wm.nix @@ -1,35 +1,33 @@ +{ lib, ... }: { - lib, - ... -}: { - "org/gnome/desktop/wm/preferences" = { - action-middle-click-titlebar = "minimize"; - action-right-click-titlebar = "menu"; - button-layout = "appmenu:close"; - focus-mode = "click"; # `click` or `sloppy`. - }; + "org/gnome/desktop/wm/preferences" = { + action-middle-click-titlebar = "minimize"; + action-right-click-titlebar = "menu"; + button-layout = "appmenu:close"; + focus-mode = "click"; # `click` or `sloppy`. + }; - "org/gnome/mutter" = { - attach-modal-dialogs = true; - center-new-windows = true; - dynamic-workspaces = true; - edge-tiling = true; - workspaces-only-on-primary = true; - }; + "org/gnome/mutter" = { + attach-modal-dialogs = true; + center-new-windows = true; + dynamic-workspaces = true; + edge-tiling = true; + workspaces-only-on-primary = true; + }; - "org/gnome/settings-daemon/plugins/color" = with lib.gvariant; { - night-light-enabled = false; - night-light-schedule-automatic = false; - night-light-schedule-from = "0.0"; - night-light-schedule-to = "0.0"; - night-light-temperature = mkUint32 3700; - }; + "org/gnome/settings-daemon/plugins/color" = with lib.gvariant; { + night-light-enabled = false; + night-light-schedule-automatic = false; + night-light-schedule-from = "0.0"; + night-light-schedule-to = "0.0"; + night-light-temperature = mkUint32 3700; + }; - "org/gnome/shell/app-switcher" = { - current-workspace-only = true; - }; + "org/gnome/shell/app-switcher" = { + current-workspace-only = true; + }; - "org/gnome/shell/overrides" = { - edge-tiling = false; - }; + "org/gnome/shell/overrides" = { + edge-tiling = false; + }; } diff --git a/home/file/default.nix b/home/file/default.nix index 95f2d66c..84225f05 100644 --- a/home/file/default.nix +++ b/home/file/default.nix @@ -1,57 +1,59 @@ { - config, - inputs, - self, - ... -} @args: let - btop = import ./btop args; - chromium = import ./chromium args; - editor = import ./editorconfig args; - foot = import ./foot args; - fuzzel = import ./fuzzel args; - git = import ./git args; - jetbrains = import ./jetbrains args; - keyd = import ./keyd args; - mako = import ./mako args; - mangohud = import ./mangohud args; - nvim = import ./nvim args; - ssh = import ./ssh args; - swappy = import ./swappy args; - sway = import ./sway args; - tmux = import ./tmux args; - waybar = import ./waybar args; - yazi = import ./yazi args; -in { - ".Wallpaper".source = config.module.wallpaper.path; - ".config/MangoHud/MangoHud.conf".source = mangohud.config; - ".config/MangoHud/presets.conf".source = mangohud.presets; - ".config/autostart".text = ""; - ".config/btop/btop.conf".source = btop.file; - ".config/chromium/Default/Preferences".source = chromium.preferences; - ".config/chromium/Local State".source = chromium.localState; - ".config/foot/foot.ini".source = foot.file; - ".config/fuzzel/fuzzel.ini".source = fuzzel.file; - ".config/keyd/app.conf".text = keyd.text; - ".config/mako/config".source = mako.file; - ".config/nvim/init.vim".text = nvim.text; - ".config/swappy/config".source = swappy.config; - ".config/sway/config".text = sway.text; - ".config/tmux/tmux.conf".text = tmux.text; - ".config/waybar/config".source = waybar.config; - ".config/waybar/style.css".source = waybar.style; - ".config/yazi/init.lua".source = yazi.init; - ".config/yazi/keymap.toml".source = yazi.keymap; - ".config/yazi/theme.toml".source = yazi.theme; - ".config/yazi/yazi.toml".source = yazi.yazi; - ".editorconfig".source = editor.file; - ".gitconfig".source = git.file; - ".ideavimrc".text = jetbrains.ideavimrc; - ".nix".source = self; - ".nixpkgs".source = inputs.nixpkgs; - ".parallel/will-cite".text = ""; - ".ssh/config".text = ssh.text; - ".template".source = ./template; - # ".nixpkgs_master".source = inputs.nixpkgs; - # ".nixpkgs_unstable".source = inputs.nixpkgs; - # TODO: Add after migrating to stable. + config, + inputs, + self, + ... +}@args: +let + btop = import ./btop args; + chromium = import ./chromium args; + editor = import ./editorconfig args; + foot = import ./foot args; + fuzzel = import ./fuzzel args; + git = import ./git args; + jetbrains = import ./jetbrains args; + keyd = import ./keyd args; + mako = import ./mako args; + mangohud = import ./mangohud args; + nvim = import ./nvim args; + ssh = import ./ssh args; + swappy = import ./swappy args; + sway = import ./sway args; + tmux = import ./tmux args; + waybar = import ./waybar args; + yazi = import ./yazi args; +in +{ + ".Wallpaper".source = config.module.wallpaper.path; + ".config/MangoHud/MangoHud.conf".source = mangohud.config; + ".config/MangoHud/presets.conf".source = mangohud.presets; + ".config/autostart".text = ""; + ".config/btop/btop.conf".source = btop.file; + ".config/chromium/Default/Preferences".source = chromium.preferences; + ".config/chromium/Local State".source = chromium.localState; + ".config/foot/foot.ini".source = foot.file; + ".config/fuzzel/fuzzel.ini".source = fuzzel.file; + ".config/keyd/app.conf".text = keyd.text; + ".config/mako/config".source = mako.file; + ".config/nvim/init.vim".text = nvim.text; + ".config/swappy/config".source = swappy.config; + ".config/sway/config".text = sway.text; + ".config/tmux/tmux.conf".text = tmux.text; + ".config/waybar/config".source = waybar.config; + ".config/waybar/style.css".source = waybar.style; + ".config/yazi/init.lua".source = yazi.init; + ".config/yazi/keymap.toml".source = yazi.keymap; + ".config/yazi/theme.toml".source = yazi.theme; + ".config/yazi/yazi.toml".source = yazi.yazi; + ".editorconfig".source = editor.file; + ".gitconfig".source = git.file; + ".ideavimrc".text = jetbrains.ideavimrc; + ".nix".source = self; + ".nixpkgs".source = inputs.nixpkgs; + ".parallel/will-cite".text = ""; + ".ssh/config".text = ssh.text; + ".template".source = ./template; + # ".nixpkgs_master".source = inputs.nixpkgs; + # ".nixpkgs_unstable".source = inputs.nixpkgs; + # TODO: Add after migrating to stable. } diff --git a/home/file/editorconfig/default.nix b/home/file/editorconfig/default.nix index eea5c06e..aaf85d4f 100644 --- a/home/file/editorconfig/default.nix +++ b/home/file/editorconfig/default.nix @@ -1,29 +1,28 @@ +{ pkgs, ... }: { - pkgs, - ... -}: { - file = (pkgs.formats.iniWithGlobalSection { }).generate "EditorconfigConfig" { - globalSection = { - root = true; - }; - sections = { - "*" = { - charset = "utf-8"; - end_of_line = "lf"; - indent_size = 8; - indent_style = "tab"; - insert_final_newline = false; - trim_trailing_whitespace = true; - }; - "*.nix" = { - indent_size = 2; - }; - "*.{lua,kt,kts,rs,py}" = { - indent_size = 4; - }; - "*.md" = { - trim_trailing_whitespace = false; - }; - }; - }; + file = (pkgs.formats.iniWithGlobalSection { }).generate "EditorconfigConfig" { + globalSection = { + root = true; + }; + sections = { + "*" = { + charset = "utf-8"; + end_of_line = "lf"; + indent_size = 8; + indent_style = "tab"; + insert_final_newline = false; + trim_trailing_whitespace = true; + }; + "*.nix" = { + indent_style = "space"; + indent_size = 2; + }; + "*.{lua,kt,kts,rs,py}" = { + indent_size = 4; + }; + "*.md" = { + trim_trailing_whitespace = false; + }; + }; + }; } diff --git a/home/file/foot/default.nix b/home/file/foot/default.nix index 56c6bc3d..fc254f0b 100644 --- a/home/file/foot/default.nix +++ b/home/file/foot/default.nix @@ -1,31 +1,29 @@ +{ config, pkgs, ... }: +let + borderSize = toString config.module.style.window.border; + dpiAware = if config.module.display.dpiAware then "yes" else "no"; + fontStep = 1; +in { - config, - pkgs, - ... -}: let - borderSize = toString config.module.style.window.border; - dpiAware = if config.module.display.dpiAware then "yes" else "no"; - fontStep = 1; -in { - file = (pkgs.formats.iniWithGlobalSection { }).generate "FootConfig" { - globalSection = { - dpi-aware = dpiAware; - font = "${config.module.style.font.monospace.name}:size=${toString config.module.style.font.size.terminal}"; - # font-bold = "${config.module.style.font.monospace.name}:size=${toString config.module.style.font.size.terminal}"; - font-bold-italic = "${config.module.style.font.monospace.name}:size=${toString config.module.style.font.size.terminal}"; - font-italic = "${config.module.style.font.monospace.name}:size=${toString config.module.style.font.size.terminal}"; - font-size-adjustment = fontStep; - pad = "${borderSize}x${borderSize} center"; - }; - sections = { - colors = { - alpha = config.module.style.opacity.terminal; - background = config.module.style.color.bg.dark; - foreground = config.module.style.color.fg.light; - }; - key-bindings = { - show-urls-launch = "Mod1+o"; - }; - }; - }; + file = (pkgs.formats.iniWithGlobalSection { }).generate "FootConfig" { + globalSection = { + dpi-aware = dpiAware; + font = "${config.module.style.font.monospace.name}:size=${toString config.module.style.font.size.terminal}"; + # font-bold = "${config.module.style.font.monospace.name}:size=${toString config.module.style.font.size.terminal}"; + font-bold-italic = "${config.module.style.font.monospace.name}:size=${toString config.module.style.font.size.terminal}"; + font-italic = "${config.module.style.font.monospace.name}:size=${toString config.module.style.font.size.terminal}"; + font-size-adjustment = fontStep; + pad = "${borderSize}x${borderSize} center"; + }; + sections = { + colors = { + alpha = config.module.style.opacity.terminal; + background = config.module.style.color.bg.dark; + foreground = config.module.style.color.fg.light; + }; + key-bindings = { + show-urls-launch = "Mod1+o"; + }; + }; + }; } diff --git a/home/file/fuzzel/default.nix b/home/file/fuzzel/default.nix index a31aaddf..f19525df 100644 --- a/home/file/fuzzel/default.nix +++ b/home/file/fuzzel/default.nix @@ -1,38 +1,38 @@ +{ pkgs, config, ... }: +let + dpiAware = if config.module.display.dpiAware then "yes" else "no"; +in { - pkgs, - config, - ... -}: let - dpiAware = if config.module.display.dpiAware then "yes" else "no"; -in { - file = (pkgs.formats.ini { }).generate "FuzzelConfig" { - main = { - dpi-aware = dpiAware; - font = "Minecraftia:size=${toString config.module.style.font.size.popup}"; - lines = 20; - prompt = "\"\""; - show-actions = "yes"; - terminal = "foot"; - width = 40; - }; - border = { - radius = 0; - width = 1; - }; - colors = let - defaultOpacity = "ff"; - in { - background = config.module.style.color.bg.dark + config.module.style.opacity.hex; - border = config.module.style.color.border + config.module.style.opacity.hex; - counter = config.module.style.color.bg.regular + defaultOpacity; - input = config.module.style.color.fg.light + defaultOpacity; - match = config.module.style.color.fg.light + defaultOpacity; - placeholder = config.module.style.color.bg.regular + defaultOpacity; - prompt = config.module.style.color.fg.light + defaultOpacity; - selection = config.module.style.color.bg.regular + defaultOpacity; - selection-match = config.module.style.color.accent + defaultOpacity; - selection-text = config.module.style.color.fg.light + defaultOpacity; - text = config.module.style.color.fg.light + defaultOpacity; - }; - }; + file = (pkgs.formats.ini { }).generate "FuzzelConfig" { + main = { + dpi-aware = dpiAware; + font = "Minecraftia:size=${toString config.module.style.font.size.popup}"; + lines = 20; + prompt = "\"\""; + show-actions = "yes"; + terminal = "foot"; + width = 40; + }; + border = { + radius = 0; + width = 1; + }; + colors = + let + defaultOpacity = "ff"; + in + { + background = config.module.style.color.bg.dark + config.module.style.opacity.hex; + border = config.module.style.color.border + config.module.style.opacity.hex; + counter = config.module.style.color.bg.regular + defaultOpacity; + input = config.module.style.color.fg.light + defaultOpacity; + match = config.module.style.color.fg.light + defaultOpacity; + placeholder = config.module.style.color.bg.regular + defaultOpacity; + prompt = config.module.style.color.fg.light + defaultOpacity; + selection = config.module.style.color.bg.regular + defaultOpacity; + selection-match = config.module.style.color.accent + defaultOpacity; + selection-text = config.module.style.color.fg.light + defaultOpacity; + text = config.module.style.color.fg.light + defaultOpacity; + }; + }; } diff --git a/home/file/git/default.nix b/home/file/git/default.nix index 816d5998..cc96d73b 100644 --- a/home/file/git/default.nix +++ b/home/file/git/default.nix @@ -1,17 +1,14 @@ +{ secret, pkgs, ... }: { - secret, - pkgs, - ... -}: { - file = (pkgs.formats.gitIni { listsAsDuplicateKeys = true; }).generate "GitConfig" { - gpg.format = secret.crypto.sign.git.format; - gpg.ssh.allowedSignersFile = toString secret.crypto.sign.git.allowed; - init.defaultBranch = "main"; - pull.rebase = true; - push.autoSetupRemote = true; - rebase.autoStash = true; - safe.directory = "*"; - user.signingkey = builtins.readFile secret.crypto.sign.git.key; - diff.algorithm = "histogram"; - }; + file = (pkgs.formats.gitIni { listsAsDuplicateKeys = true; }).generate "GitConfig" { + gpg.format = secret.crypto.sign.git.format; + gpg.ssh.allowedSignersFile = toString secret.crypto.sign.git.allowed; + init.defaultBranch = "main"; + pull.rebase = true; + push.autoSetupRemote = true; + rebase.autoStash = true; + safe.directory = "*"; + user.signingkey = builtins.readFile secret.crypto.sign.git.key; + diff.algorithm = "histogram"; + }; } diff --git a/home/file/jetbrains/default.nix b/home/file/jetbrains/default.nix index 155c85c9..7d6fbf8b 100644 --- a/home/file/jetbrains/default.nix +++ b/home/file/jetbrains/default.nix @@ -1,29 +1,27 @@ +{ ... }: { - util, - ... -}: { - ideavimrc = util.trimTabs '' - " Plugins. - Plug 'tpope/vim-commentary' - Plug 'machakann/vim-highlightedyank' - " Plug 'junegunn/vim-easy-align' + ideavimrc = '' + " Plugins. + Plug 'tpope/vim-commentary' + Plug 'machakann/vim-highlightedyank' + " Plug 'junegunn/vim-easy-align' - " General config. - set scrolloff=4 - set incsearch - set hlsearch - set clipboard=unnamedplus - set relativenumber - set number + " General config. + set scrolloff=4 + set incsearch + set hlsearch + set clipboard=unnamedplus + set relativenumber + set number - " Space as a leader. - nnoremap - let mapleader=" " + " Space as a leader. + nnoremap + let mapleader=" " - " Align. ISSUE: Broken. - " vmap a (EasyAlign) + " Align. ISSUE: Broken. + " vmap a (EasyAlign) - " Sort. - vmap A :sort - ''; + " Sort. + vmap A :sort + ''; } diff --git a/home/file/keyd/default.nix b/home/file/keyd/default.nix index 6aa97648..2e1c2ad2 100644 --- a/home/file/keyd/default.nix +++ b/home/file/keyd/default.nix @@ -1,6 +1,4 @@ +{ util, ... }@args: { - util, - ... -} @args: { - text = util.catFile (util.ls ./module) args; + text = util.catFile (util.ls ./module) args; } diff --git a/home/file/keyd/module/Chromium.nix b/home/file/keyd/module/Chromium.nix index b10a73ef..bbee7352 100644 --- a/home/file/keyd/module/Chromium.nix +++ b/home/file/keyd/module/Chromium.nix @@ -1,31 +1,29 @@ +{ pkgs, ... }: { - pkgs, - ... -}: { - file = (pkgs.formats.ini { }).generate "KeydChromiumConfig" { - "chromium-browser" = { - "alt.capslock" = "C-t"; # New tab. - "alt.x" = "C-w"; # Close tab. - "alt.u" = "C-S-t"; # Restore closed tab. - "alt.q" = "C-pageup"; # Prev tab. - "alt.e" = "C-pagedown"; # Next tab. - "alt.Q" = "C-S-pageup"; # Move tab left. - "alt.E" = "C-S-pagedown"; # Move tab right. - "alt.a" = "A-left"; # Go back. - "alt.d" = "A-right"; # Go forward. - "alt.s" = "down"; # Scroll down. - "alt.w" = "up"; # Scroll up. - "alt.f" = "C-f"; # Find text. - "alt.N" = "S-f3"; # Find prev. - "alt.n" = "f3"; # Find next. - "alt.space" = "f6"; # Focus address bar. - "alt.r" = "C-f5"; # Full refresh. - "alt.l" = "A-S-l"; # Toggle dark mode. - "alt.enter" = "C-S-l"; # Fill password. - "alt.p" = "A-S-p"; # Toggle proxy. - "alt.j" = "A-S-j"; # Toggle js. - "alt.k" = "A-S-k"; # Block element. - "alt.b" = "A-S-b"; # Show uBlock. - }; - }; + file = (pkgs.formats.ini { }).generate "KeydChromiumConfig" { + "chromium-browser" = { + "alt.capslock" = "C-t"; # New tab. + "alt.x" = "C-w"; # Close tab. + "alt.u" = "C-S-t"; # Restore closed tab. + "alt.q" = "C-pageup"; # Prev tab. + "alt.e" = "C-pagedown"; # Next tab. + "alt.Q" = "C-S-pageup"; # Move tab left. + "alt.E" = "C-S-pagedown"; # Move tab right. + "alt.a" = "A-left"; # Go back. + "alt.d" = "A-right"; # Go forward. + "alt.s" = "down"; # Scroll down. + "alt.w" = "up"; # Scroll up. + "alt.f" = "C-f"; # Find text. + "alt.N" = "S-f3"; # Find prev. + "alt.n" = "f3"; # Find next. + "alt.space" = "f6"; # Focus address bar. + "alt.r" = "C-f5"; # Full refresh. + "alt.l" = "A-S-l"; # Toggle dark mode. + "alt.enter" = "C-S-l"; # Fill password. + "alt.p" = "A-S-p"; # Toggle proxy. + "alt.j" = "A-S-j"; # Toggle js. + "alt.k" = "A-S-k"; # Block element. + "alt.b" = "A-S-b"; # Show uBlock. + }; + }; } diff --git a/home/file/keyd/module/DRG.nix b/home/file/keyd/module/DRG.nix index 2afd80c4..90fe6cde 100644 --- a/home/file/keyd/module/DRG.nix +++ b/home/file/keyd/module/DRG.nix @@ -1,35 +1,37 @@ +{ pkgs, ... }: { - pkgs, - ... -}: { - file = (pkgs.formats.ini { }).generate "KeydDrgConfig" { - steam-app-548430 = { - "alt.1" = "macro(enter 10ms L e t ' s 10ms space d o 10ms space t h i s 10ms space T e x a s 10ms space s t y l e ! 10ms enter)"; - "alt.2" = "macro(enter 10ms H e c k space y e s ! enter)"; - "alt.3" = "macro(enter 10ms J u s t space a space s i d e - j o b space w h i l e 10ms space w a i t i n g space f o r space a space s e x space u p d a t e . enter)"; - "alt.4" = "macro(enter 10ms < 3 enter)"; - "alt.[" = "macro(enter 10ms W h a t space i s space c r u n c h y 10ms space o n space t h e space o u t s i d e , 10ms space g o o e y space o n space 10ms t h e space i n s i d e ? enter)"; - "alt.]" = "macro(enter 10ms Q ' r o n a r space S h e l l b a c k ! enter)"; - "alt.a" = "macro(enter 10ms Y e s enter)"; - "alt.b" = "macro(enter 10ms I ' m space b a c k enter)"; - "alt.c" = "macro(enter 10ms > space R i g h t enter)"; - "alt.d" = "macro(enter 10ms N o enter)"; - "alt.e" = "macro(enter 10ms S o r r y ! enter)"; - "alt.f" = "macro(enter 10ms I space n e e d space h e l p ! enter)"; - "alt.g" = "macro(enter 10ms g g enter)"; - "alt.j" = "macro(enter 10ms G o o d space j o b enter)"; - "alt.k" = "macro(enter 10ms O k a y enter)"; - "alt.l" = "macro(enter 10ms L e a f space l o v e r enter)"; - "alt.m" = "macro(enter 10ms I space r e p l y space u s i n g space m a c r o s . 10ms space U s e space s o f t w a r e space l i k e space k e y d , 10ms space o r space b u y space a space Q M K space k e y b o a r d . enter)"; - "alt.q" = "macro(enter 10ms T h a n k s ! enter)"; - "alt.r" = "macro(enter 10ms N e e d space m o r e space a m m o enter)"; - "alt.s" = "macro(enter 10ms W a i t enter)"; - "alt.t" = "macro(enter 10ms M a y space I space t a k e space e x t r a ? enter)"; - "alt.v" = "macro(enter 10ms A F K enter)"; - "alt.w" = "macro(enter 10ms r enter)"; - "alt.x" = "macro(enter 10ms > space H e r e space < enter)"; - "alt.z" = "macro(enter 10ms < space L e f t enter)"; - leftshift = "timeout(leftcontrol, 150, leftshift)"; - }; - }; + file = (pkgs.formats.ini { }).generate "KeydDrgConfig" { + steam-app-548430 = { + "alt.1" = + "macro(enter 10ms L e t ' s 10ms space d o 10ms space t h i s 10ms space T e x a s 10ms space s t y l e ! 10ms enter)"; + "alt.2" = "macro(enter 10ms H e c k space y e s ! enter)"; + "alt.3" = + "macro(enter 10ms J u s t space a space s i d e - j o b space w h i l e 10ms space w a i t i n g space f o r space a space s e x space u p d a t e . enter)"; + "alt.4" = "macro(enter 10ms < 3 enter)"; + "alt.[" = + "macro(enter 10ms W h a t space i s space c r u n c h y 10ms space o n space t h e space o u t s i d e , 10ms space g o o e y space o n space 10ms t h e space i n s i d e ? enter)"; + "alt.]" = "macro(enter 10ms Q ' r o n a r space S h e l l b a c k ! enter)"; + "alt.a" = "macro(enter 10ms Y e s enter)"; + "alt.b" = "macro(enter 10ms I ' m space b a c k enter)"; + "alt.c" = "macro(enter 10ms > space R i g h t enter)"; + "alt.d" = "macro(enter 10ms N o enter)"; + "alt.e" = "macro(enter 10ms S o r r y ! enter)"; + "alt.f" = "macro(enter 10ms I space n e e d space h e l p ! enter)"; + "alt.g" = "macro(enter 10ms g g enter)"; + "alt.j" = "macro(enter 10ms G o o d space j o b enter)"; + "alt.k" = "macro(enter 10ms O k a y enter)"; + "alt.l" = "macro(enter 10ms L e a f space l o v e r enter)"; + "alt.m" = + "macro(enter 10ms I space r e p l y space u s i n g space m a c r o s . 10ms space U s e space s o f t w a r e space l i k e space k e y d , 10ms space o r space b u y space a space Q M K space k e y b o a r d . enter)"; + "alt.q" = "macro(enter 10ms T h a n k s ! enter)"; + "alt.r" = "macro(enter 10ms N e e d space m o r e space a m m o enter)"; + "alt.s" = "macro(enter 10ms W a i t enter)"; + "alt.t" = "macro(enter 10ms M a y space I space t a k e space e x t r a ? enter)"; + "alt.v" = "macro(enter 10ms A F K enter)"; + "alt.w" = "macro(enter 10ms r enter)"; + "alt.x" = "macro(enter 10ms > space H e r e space < enter)"; + "alt.z" = "macro(enter 10ms < space L e f t enter)"; + leftshift = "timeout(leftcontrol, 150, leftshift)"; + }; + }; } diff --git a/home/file/keyd/module/Disable.nix b/home/file/keyd/module/Disable.nix index 2db7c4ed..b3462b3d 100644 --- a/home/file/keyd/module/Disable.nix +++ b/home/file/keyd/module/Disable.nix @@ -1,29 +1,29 @@ +{ pkgs, ... }: +let + apps = [ + "gimp" + "gimp-*" + "steam-proton" + "steam-app-*" + ]; + + keys = [ + "escape" + "leftcontrol" + ]; +in { - pkgs, - ... -}: let - apps = [ - "gimp" - "gimp-*" - "steam-proton" - "steam-app-*" - ]; + file = + let + keySets = builtins.map (key: { + name = key; + value = key; + }) keys; - keys = [ - "escape" - "leftcontrol" - ]; -in { - file = let - keySets = builtins.map (key: { - name = key; - value = key; - }) keys; - - appSets = builtins.map (app: { - name = app; - value = builtins.listToAttrs keySets; - }) apps; - in - (pkgs.formats.ini { }).generate "KeydDisableConfig" (builtins.listToAttrs appSets); + appSets = builtins.map (app: { + name = app; + value = builtins.listToAttrs keySets; + }) apps; + in + (pkgs.formats.ini { }).generate "KeydDisableConfig" (builtins.listToAttrs appSets); } diff --git a/home/file/keyd/module/Firefox.nix b/home/file/keyd/module/Firefox.nix index 49fcfad6..992cf40e 100644 --- a/home/file/keyd/module/Firefox.nix +++ b/home/file/keyd/module/Firefox.nix @@ -1,28 +1,26 @@ +{ pkgs, ... }: { - pkgs, - ... -}: { - file = (pkgs.formats.ini { }).generate "KeydFirefoxConfig" { - "firefox-esr" = { - "alt.capslock" = "C-t"; # New tab. - "alt.x" = "C-w"; # Close tab. - "alt.u" = "C-S-t"; # Restore closed tab. - "alt.q" = "C-pageup"; # Prev tab. - "alt.e" = "C-pagedown"; # Next tab. - "alt.Q" = "C-S-pageup"; # Move tab left. - "alt.E" = "C-S-pagedown"; # Move tab right. - "alt.a" = "A-left"; # Go back. - "alt.d" = "A-right"; # Go forward. - "alt.s" = "down"; # Scroll down. - "alt.w" = "up"; # Scroll up. - "alt.f" = "C-f"; # Find text. - "alt.N" = "S-f3"; # Find prev. - "alt.n" = "f3"; # Find next. - "alt.space" = "f6"; # Focus address bar. - "alt.r" = "C-f5"; # Full refresh. - "alt.l" = "A-S-a"; # Toggle dark mode. - "alt.m" = "C-m"; # Toggle tab mute. - "alt.enter" = "C-S-l"; # Fill password. - }; - }; + file = (pkgs.formats.ini { }).generate "KeydFirefoxConfig" { + "firefox-esr" = { + "alt.capslock" = "C-t"; # New tab. + "alt.x" = "C-w"; # Close tab. + "alt.u" = "C-S-t"; # Restore closed tab. + "alt.q" = "C-pageup"; # Prev tab. + "alt.e" = "C-pagedown"; # Next tab. + "alt.Q" = "C-S-pageup"; # Move tab left. + "alt.E" = "C-S-pagedown"; # Move tab right. + "alt.a" = "A-left"; # Go back. + "alt.d" = "A-right"; # Go forward. + "alt.s" = "down"; # Scroll down. + "alt.w" = "up"; # Scroll up. + "alt.f" = "C-f"; # Find text. + "alt.N" = "S-f3"; # Find prev. + "alt.n" = "f3"; # Find next. + "alt.space" = "f6"; # Focus address bar. + "alt.r" = "C-f5"; # Full refresh. + "alt.l" = "A-S-a"; # Toggle dark mode. + "alt.m" = "C-m"; # Toggle tab mute. + "alt.enter" = "C-S-l"; # Fill password. + }; + }; } diff --git a/home/file/keyd/module/Jetbrains.nix b/home/file/keyd/module/Jetbrains.nix index 69a2e87e..80bf821d 100644 --- a/home/file/keyd/module/Jetbrains.nix +++ b/home/file/keyd/module/Jetbrains.nix @@ -1,30 +1,28 @@ +{ pkgs, ... }: { - pkgs, - ... -}: { - file = (pkgs.formats.ini { }).generate "KeydJetbrainsConfig" { - "jetbrains-*" = { - "alt.b" = "C-f8"; # Toggle line breakpoint. - "alt.equal" = "C-A-l"; # Reformat. - "alt.c" = "S-escape"; # Close panel. - "alt.capslock" = "C-A-S-insert"; # New scratch file. - "alt.q" = "A-left"; # Prev tab. - "alt.e" = "A-right"; # Next tab. - "alt.x" = "C-f4"; # Close tab. - "alt.f" = "C-S-f"; # Find text. - "alt.n" = "C-A-n"; # Find next. - "alt.g" = "macro(gd)"; # Go to definition. - "alt.i" = "C-i"; # Implement. - "alt.o" = "C-o"; # Override. - "alt.r" = "S-f10"; # Run. - "alt.z" = "C-f2"; # Stop app. - "alt.d" = "S-f9"; # Run debugger. - "alt.a" = "C-A-5"; # Attach debugger. - "alt.m" = "C-A-s"; # Settings. - "alt.v" = "C-q"; # Show doc under cursor. - "alt.s" = "C-S-A-t"; # Refactor selection. + file = (pkgs.formats.ini { }).generate "KeydJetbrainsConfig" { + "jetbrains-*" = { + "alt.b" = "C-f8"; # Toggle line breakpoint. + "alt.equal" = "C-A-l"; # Reformat. + "alt.c" = "S-escape"; # Close panel. + "alt.capslock" = "C-A-S-insert"; # New scratch file. + "alt.q" = "A-left"; # Prev tab. + "alt.e" = "A-right"; # Next tab. + "alt.x" = "C-f4"; # Close tab. + "alt.f" = "C-S-f"; # Find text. + "alt.n" = "C-A-n"; # Find next. + "alt.g" = "macro(gd)"; # Go to definition. + "alt.i" = "C-i"; # Implement. + "alt.o" = "C-o"; # Override. + "alt.r" = "S-f10"; # Run. + "alt.z" = "C-f2"; # Stop app. + "alt.d" = "S-f9"; # Run debugger. + "alt.a" = "C-A-5"; # Attach debugger. + "alt.m" = "C-A-s"; # Settings. + "alt.v" = "C-q"; # Show doc under cursor. + "alt.s" = "C-S-A-t"; # Refactor selection. - "alt.tab" = "timeout(f8, 150, macro2(0, 0, f7))"; # Tap to step over, hold to step into. - }; - }; + "alt.tab" = "timeout(f8, 150, macro2(0, 0, f7))"; # Tap to step over, hold to step into. + }; + }; } diff --git a/home/file/mako/default.nix b/home/file/mako/default.nix index 5bd8c87e..74c6f6c5 100644 --- a/home/file/mako/default.nix +++ b/home/file/mako/default.nix @@ -1,35 +1,37 @@ { - __findFile, - config, - pkgs, - ... -} @args: let - swayscript = pkgs.callPackage args; - alpha = config.module.style.opacity.hex; - color = config.module.style.color; - max = 2; -in { - file = (pkgs.formats.iniWithGlobalSection { }).generate "MakoConfig" { - globalSection = { - anchor = "top-center"; - background-color = "#${color.highlight}${alpha}"; - border-color = "#${color.border}${alpha}"; - default-timeout = 10000; - font = "${config.module.style.font.serif.name} ${toString config.module.style.font.size.popup}"; - height = 120; - icons = 0; - margin = 32; - max-history = max; - max-visible = max; - on-notify = "exec ${swayscript}/bin/swayscript notify"; - text-color = "#${config.module.style.color.bg.dark}"; - width = 480; - }; - sections = { - "mode=dnd" = { - invisible = 1; - on-notify = "exec ${pkgs.coreutils}/bin/true"; - }; - }; - }; + __findFile, + config, + pkgs, + ... +}@args: +let + swayscript = pkgs.callPackage args; + alpha = config.module.style.opacity.hex; + color = config.module.style.color; + max = 2; +in +{ + file = (pkgs.formats.iniWithGlobalSection { }).generate "MakoConfig" { + globalSection = { + anchor = "top-center"; + background-color = "#${color.highlight}${alpha}"; + border-color = "#${color.border}${alpha}"; + default-timeout = 10000; + font = "${config.module.style.font.serif.name} ${toString config.module.style.font.size.popup}"; + height = 120; + icons = 0; + margin = 32; + max-history = max; + max-visible = max; + on-notify = "exec ${swayscript}/bin/swayscript notify"; + text-color = "#${config.module.style.color.bg.dark}"; + width = 480; + }; + sections = { + "mode=dnd" = { + invisible = 1; + on-notify = "exec ${pkgs.coreutils}/bin/true"; + }; + }; + }; } diff --git a/home/file/mangohud/default.nix b/home/file/mangohud/default.nix index c253d321..2b2592d2 100644 --- a/home/file/mangohud/default.nix +++ b/home/file/mangohud/default.nix @@ -1,45 +1,43 @@ +{ pkgs, ... }: { - pkgs, - ... -}: { - config = (pkgs.formats.iniWithGlobalSection { }).generate "MangoConfig" { - globalSection = { - blacklist = "example"; - fps_sampling_period = 1000; - frame_timing = 0; - preset = "0,1,2"; - toggle_logging = "F2"; - toggle_preset = "F1"; - }; - }; + config = (pkgs.formats.iniWithGlobalSection { }).generate "MangoConfig" { + globalSection = { + blacklist = "example"; + fps_sampling_period = 1000; + frame_timing = 0; + preset = "0,1,2"; + toggle_logging = "F2"; + toggle_preset = "F1"; + }; + }; - presets = (pkgs.formats.ini { }).generate "MangoPresets" { - "preset 0" = { - no_display = 1; - }; - "preset 1" = { - alpha = 1.0; - arch = 0; - background_alpha = 0.5; - battery = 1; - battery_time = 1; - benchmark_percentiles = 0; - cpu_temp = 1; - device_battery = "gamepad,mouse"; - font_size = 12; - fps_sampling_period = 1000; - gpu_junction_temp = 0; - gpu_mem_temp = 1; - gpu_temp = 1; - hud_no_margin = 1; - ram = 1; - swap = 1; - throttling_status = 1; - time = 1; - vram = 1; - }; - "preset 2" = { - full = 1; - }; - }; + presets = (pkgs.formats.ini { }).generate "MangoPresets" { + "preset 0" = { + no_display = 1; + }; + "preset 1" = { + alpha = 1.0; + arch = 0; + background_alpha = 0.5; + battery = 1; + battery_time = 1; + benchmark_percentiles = 0; + cpu_temp = 1; + device_battery = "gamepad,mouse"; + font_size = 12; + fps_sampling_period = 1000; + gpu_junction_temp = 0; + gpu_mem_temp = 1; + gpu_temp = 1; + hud_no_margin = 1; + ram = 1; + swap = 1; + throttling_status = 1; + time = 1; + vram = 1; + }; + "preset 2" = { + full = 1; + }; + }; } diff --git a/home/file/nvim/default.nix b/home/file/nvim/default.nix index 4cfe77e0..133ce98a 100644 --- a/home/file/nvim/default.nix +++ b/home/file/nvim/default.nix @@ -1,91 +1,93 @@ { - inputs, - pkgs, - util, - ... -} @args: let - nvimRc = { runtimes, configs }: let - # Plugin paths to install. - runtimeRc = builtins.foldl' (acc: r: - acc + "set runtimepath+=${r}\n" - ) "" runtimes; + inputs, + pkgs, + util, + ... +}@args: +let + nvimRc = + { runtimes, configs }: + let + # Plugin paths to install. + runtimeRc = builtins.foldl' (acc: r: acc + "set runtimepath+=${r}\n") "" runtimes; - # My configuration files combined into one big file. - config = pkgs.writeText "nvimRc" (util.catText configs args); + # My configuration files combined into one big file. + config = pkgs.writeText "nvimRc" (util.catText configs args); - # Tell Neovim to load this file. - configRc = "lua dofile(\"${config}\")"; - in - runtimeRc + configRc; -in { - text = nvimRc { - runtimes = [ - "~/.cache/nvim" - "~/.cache/nvim/treesitter" - "${inputs.nvimAlign}" - "${inputs.nvimAutoclose}" - "${inputs.nvimBufferline}" - "${inputs.nvimCloseBuffers}" - "${inputs.nvimColorizer}" - "${inputs.nvimDevicons}" - "${inputs.nvimDressing}" - "${inputs.nvimGen}" - "${inputs.nvimGitsigns}" - "${inputs.nvimGruvboxMaterial}" - "${inputs.nvimIndentoMatic}" - "${inputs.nvimLspconfig}" - "${inputs.nvimPlenary}" - "${inputs.nvimTelescope}" - "${inputs.nvimTodo}" - "${inputs.nvimTreesitter}" - "${inputs.nvimTree}" - "${inputs.nvimTrouble}" - ]; + # Tell Neovim to load this file. + configRc = "lua dofile(\"${config}\")"; + in + runtimeRc + configRc; +in +{ + text = nvimRc { + runtimes = [ + "~/.cache/nvim" + "~/.cache/nvim/treesitter" + "${inputs.nvimAlign}" + "${inputs.nvimAutoclose}" + "${inputs.nvimBufferline}" + "${inputs.nvimCloseBuffers}" + "${inputs.nvimColorizer}" + "${inputs.nvimDevicons}" + "${inputs.nvimDressing}" + "${inputs.nvimGen}" + "${inputs.nvimGitsigns}" + "${inputs.nvimGruvboxMaterial}" + "${inputs.nvimIndentoMatic}" + "${inputs.nvimLspconfig}" + "${inputs.nvimPlenary}" + "${inputs.nvimTelescope}" + "${inputs.nvimTodo}" + "${inputs.nvimTreesitter}" + "${inputs.nvimTree}" + "${inputs.nvimTrouble}" + ]; - configs = [ - ./module/key/Rekey.nix - ./module/key/Leader.nix - ./module/config/Autoread.nix - ./module/config/Etc.nix - ./module/config/Search.nix - ./module/config/Tab.nix - ./module/config/Highlight.nix - ./module/plugin/Filetree.nix - ./module/plugin/Gruvbox.nix - ./module/plugin/Bufferline.nix - ./module/plugin/Autoclose.nix - ./module/plugin/Gitsigns.nix - ./module/plugin/Trouble.nix - ./module/plugin/Closebuffers.nix - ./module/plugin/Telescope.nix - ./module/plugin/Todo.nix - ./module/plugin/Indent.nix - ./module/plugin/Align.nix - ./module/plugin/Treesitter.nix - ./module/plugin/Fold.nix - ./module/plugin/Gen.nix - ./module/plugin/Colorizer.nix - ./module/plugin/Dressing.nix - ./module/plugin/lsp/Go.nix - ./module/plugin/lsp/Haskell.nix - ./module/plugin/lsp/Lua.nix - ./module/plugin/lsp/Nix.nix - ./module/plugin/lsp/Rust.nix - ./module/plugin/lsp/Tex.nix - ./module/key/Autocomplete.nix - ./module/key/Buffer.nix - ./module/key/Cmd.nix - ./module/key/Colorscheme.nix - ./module/key/Filetree.nix - ./module/key/Gitsigns.nix - ./module/key/Navigation.nix - ./module/key/Prompt.nix - ./module/key/Save.nix - ./module/key/Sort.nix - ./module/key/TabWidth.nix - ./module/key/Telescope.nix - ./module/key/Terminal.nix - ./module/key/Trouble.nix - ]; - }; + configs = [ + ./module/key/Rekey.nix + ./module/key/Leader.nix + ./module/config/Autoread.nix + ./module/config/Etc.nix + ./module/config/Search.nix + ./module/config/Tab.nix + ./module/config/Highlight.nix + ./module/plugin/Filetree.nix + ./module/plugin/Gruvbox.nix + ./module/plugin/Bufferline.nix + ./module/plugin/Autoclose.nix + ./module/plugin/Gitsigns.nix + ./module/plugin/Trouble.nix + ./module/plugin/Closebuffers.nix + ./module/plugin/Telescope.nix + ./module/plugin/Todo.nix + ./module/plugin/Indent.nix + ./module/plugin/Align.nix + ./module/plugin/Treesitter.nix + ./module/plugin/Fold.nix + ./module/plugin/Gen.nix + ./module/plugin/Colorizer.nix + ./module/plugin/Dressing.nix + ./module/plugin/lsp/Go.nix + ./module/plugin/lsp/Haskell.nix + ./module/plugin/lsp/Lua.nix + ./module/plugin/lsp/Nix.nix + ./module/plugin/lsp/Rust.nix + ./module/plugin/lsp/Tex.nix + ./module/key/Autocomplete.nix + ./module/key/Buffer.nix + ./module/key/Cmd.nix + ./module/key/Colorscheme.nix + ./module/key/Filetree.nix + ./module/key/Gitsigns.nix + ./module/key/Navigation.nix + ./module/key/Prompt.nix + ./module/key/Save.nix + ./module/key/Sort.nix + ./module/key/TabWidth.nix + ./module/key/Telescope.nix + ./module/key/Terminal.nix + ./module/key/Trouble.nix + ]; + }; } diff --git a/home/file/nvim/module/config/Autoread.nix b/home/file/nvim/module/config/Autoread.nix index d62589ef..54c04f8a 100644 --- a/home/file/nvim/module/config/Autoread.nix +++ b/home/file/nvim/module/config/Autoread.nix @@ -1,9 +1,10 @@ -{ ... }: { - text = '' - vim.o.autoread = true - vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "CursorHoldI", "FocusGained" }, { - command = "if mode() != 'c' | checktime | endif", - pattern = { "*" }, - }) - ''; +{ ... }: +{ + text = '' + vim.o.autoread = true + vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "CursorHoldI", "FocusGained" }, { + command = "if mode() != 'c' | checktime | endif", + pattern = { "*" }, + }) + ''; } diff --git a/home/file/nvim/module/config/Etc.nix b/home/file/nvim/module/config/Etc.nix index 86134cf8..34ff0caf 100644 --- a/home/file/nvim/module/config/Etc.nix +++ b/home/file/nvim/module/config/Etc.nix @@ -1,36 +1,37 @@ -{ ... }: { - text = '' - -- TODO: Add comments and separate files. - vim.opt.clipboard = "unnamedplus" - vim.opt.cursorline = false - vim.opt.fixeol = false - vim.opt.incsearch = true - vim.opt.number = true - vim.opt.scrolloff = 4 - vim.opt.splitbelow = true - vim.opt.splitright = true - vim.opt.termguicolors = true - vim.opt.ttyfast = true - vim.opt.wildmode = "longest,list" - -- vim.opt.completeopt = "menuone,noselect" +{ ... }: +{ + text = '' + -- TODO: Add comments and separate files. + vim.opt.clipboard = "unnamedplus" + vim.opt.cursorline = false + vim.opt.fixeol = false + vim.opt.incsearch = true + vim.opt.number = true + vim.opt.scrolloff = 4 + vim.opt.splitbelow = true + vim.opt.splitright = true + vim.opt.termguicolors = true + vim.opt.ttyfast = true + vim.opt.wildmode = "longest,list" + -- vim.opt.completeopt = "menuone,noselect" - -- Disable continuing comments on newline. - vim.cmd("autocmd BufEnter * set fo-=c fo-=r fo-=o") + -- Disable continuing comments on newline. + vim.cmd("autocmd BufEnter * set fo-=c fo-=r fo-=o") - -- Disable mouse. - vim.cmd("set mouse=") + -- Disable mouse. + vim.cmd("set mouse=") - -- Disable signs for diagnostics. - vim.diagnostic.config({ signs = false }) + -- Disable signs for diagnostics. + vim.diagnostic.config({ signs = false }) - -- Display invisible characters. - -- vim.cmd("set list listchars=tab:>\\ ,trail:-,eol:,lead:.") - vim.cmd("set list listchars=tab:>\\ ,trail:-,lead:·") + -- Display invisible characters. + -- vim.cmd("set list listchars=tab:>\\ ,trail:-,eol:,lead:.") + vim.cmd("set list listchars=tab:>\\ ,trail:-,lead:·") - -- Relative line numbers. - vim.wo.relativenumber = true + -- Relative line numbers. + vim.wo.relativenumber = true - -- Disable swap files. - vim.opt.swapfile = false - ''; + -- Disable swap files. + vim.opt.swapfile = false + ''; } diff --git a/home/file/nvim/module/config/Highlight.nix b/home/file/nvim/module/config/Highlight.nix index ff131d04..d6c78ca2 100644 --- a/home/file/nvim/module/config/Highlight.nix +++ b/home/file/nvim/module/config/Highlight.nix @@ -1,49 +1,54 @@ +{ config, lib, ... }: +let + color = config.module.style.color; + mkHighlight = + name: value: + ''vim.api.nvim_set_hl(0, "${name}", ${ + lib.generators.toLua { + multiline = false; + asBindings = false; + } value + })''; + bg = { + bg = "#${color.bg.regular}"; + }; + selection = { + bg = "#${color.selection}"; + bold = true; + fg = "#${color.fg.dark}"; + }; + transparent = { + bg = lib.generators.mkLuaInline "clear"; + }; + border = { + bg = lib.generators.mkLuaInline "clear"; + fg = "#${color.accent}"; + }; +in { - config, - lib, - ... -}: let - color = config.module.style.color; - mkHighlight = name: value: ''vim.api.nvim_set_hl(0, "${name}", ${lib.generators.toLua { multiline = false; asBindings = false; } value})''; - bg = { - bg = "#${color.bg.regular}"; - }; - selection = { - bg = "#${color.selection}"; - bold = true; - fg = "#${color.fg.dark}"; - }; - transparent = { - bg = lib.generators.mkLuaInline "clear"; - }; - border = { - bg = lib.generators.mkLuaInline "clear"; - fg = "#${color.accent}"; - }; -in { - text = '' - vim.api.nvim_create_autocmd({"ColorScheme", "VimEnter"}, { - group = vim.api.nvim_create_augroup('Color', {}), - pattern = "*", - callback = function () - -- Background. - ${mkHighlight "CursorLine" bg} - ${mkHighlight "Pmenu" bg} - ${mkHighlight "PmenuExtra" bg} - ${mkHighlight "TelescopeSelection" bg} + text = '' + vim.api.nvim_create_autocmd({"ColorScheme", "VimEnter"}, { + group = vim.api.nvim_create_augroup('Color', {}), + pattern = "*", + callback = function () + -- Background. + ${mkHighlight "CursorLine" bg} + ${mkHighlight "Pmenu" bg} + ${mkHighlight "PmenuExtra" bg} + ${mkHighlight "TelescopeSelection" bg} - -- Selection. - ${mkHighlight "Visual" selection} - ${mkHighlight "PmenuSel" selection} + -- Selection. + ${mkHighlight "Visual" selection} + ${mkHighlight "PmenuSel" selection} - -- Transparent. - ${mkHighlight "NormalFloat" transparent} + -- Transparent. + ${mkHighlight "NormalFloat" transparent} - -- Border. - ${mkHighlight "FloatBorder" border} - ${mkHighlight "FloatTitle" border} - ${mkHighlight "TelescopeBorder" border} - end - }) - ''; + -- Border. + ${mkHighlight "FloatBorder" border} + ${mkHighlight "FloatTitle" border} + ${mkHighlight "TelescopeBorder" border} + end + }) + ''; } diff --git a/home/file/nvim/module/config/Search.nix b/home/file/nvim/module/config/Search.nix index 5731e340..21842a32 100644 --- a/home/file/nvim/module/config/Search.nix +++ b/home/file/nvim/module/config/Search.nix @@ -1,9 +1,10 @@ -{ ... }: { - text = '' - vim.opt.hlsearch = true - vim.opt.ignorecase = true - vim.opt.incsearch = true - vim.opt.showmatch = true - vim.opt.smartcase = true - ''; +{ ... }: +{ + text = '' + vim.opt.hlsearch = true + vim.opt.ignorecase = true + vim.opt.incsearch = true + vim.opt.showmatch = true + vim.opt.smartcase = true + ''; } diff --git a/home/file/nvim/module/config/Tab.nix b/home/file/nvim/module/config/Tab.nix index 1dfaffba..4db277cd 100644 --- a/home/file/nvim/module/config/Tab.nix +++ b/home/file/nvim/module/config/Tab.nix @@ -1,15 +1,17 @@ -{ ... }: let - indentDefault = 2; -in { - text = '' - vim.opt.autoindent = true - vim.opt.expandtab = false - -- vim.opt.smartindent = true - vim.opt.shiftwidth = ${toString indentDefault} - vim.opt.softtabstop = ${toString indentDefault} - vim.opt.tabstop = ${toString indentDefault} +{ ... }: +let + indentDefault = 2; +in +{ + text = '' + vim.opt.autoindent = true + vim.opt.expandtab = false + -- vim.opt.smartindent = true + vim.opt.shiftwidth = ${toString indentDefault} + vim.opt.softtabstop = ${toString indentDefault} + vim.opt.tabstop = ${toString indentDefault} - -- Disable Markdown forced formatting. - vim.g.markdown_recommended_style = 0 - ''; + -- Disable Markdown forced formatting. + vim.g.markdown_recommended_style = 0 + ''; } diff --git a/home/file/nvim/module/key/Autocomplete.nix b/home/file/nvim/module/key/Autocomplete.nix index 2ca85028..9765db16 100644 --- a/home/file/nvim/module/key/Autocomplete.nix +++ b/home/file/nvim/module/key/Autocomplete.nix @@ -1,9 +1,10 @@ -{ ... }: { - text = '' - -- Autocomplete. - rekey_input("", "") +{ ... }: +{ + text = '' + -- Autocomplete. + rekey_input("", "") - -- LSP autocomplete. - rekey_normal("", "lua vim.lsp.buf.code_action()") - ''; + -- LSP autocomplete. + rekey_normal("", "lua vim.lsp.buf.code_action()") + ''; } diff --git a/home/file/nvim/module/key/Buffer.nix b/home/file/nvim/module/key/Buffer.nix index 7c29a87e..4e468a83 100644 --- a/home/file/nvim/module/key/Buffer.nix +++ b/home/file/nvim/module/key/Buffer.nix @@ -1,16 +1,17 @@ -{ ... }: { - text = '' - -- New empty buffer. - remap_normal("n", "enew") +{ ... }: +{ + text = '' + -- New empty buffer. + remap_normal("n", "enew") - -- Close buffer. - function _buf_close() - pcall(vim.cmd, "w") - vim.cmd[[bp|sp|bn|bd!]] - end - rekey_normal("x", "lua _buf_close()") + -- Close buffer. + function _buf_close() + pcall(vim.cmd, "w") + vim.cmd[[bp|sp|bn|bd!]] + end + rekey_normal("x", "lua _buf_close()") - -- Close all hidden buffers. - rekey_normal("X", "BDelete hidden") - ''; + -- Close all hidden buffers. + rekey_normal("X", "BDelete hidden") + ''; } diff --git a/home/file/nvim/module/key/Cmd.nix b/home/file/nvim/module/key/Cmd.nix index 01138e0a..acc11f00 100644 --- a/home/file/nvim/module/key/Cmd.nix +++ b/home/file/nvim/module/key/Cmd.nix @@ -1,11 +1,12 @@ -{ ... }: { - text = '' - -- Remap ; to :. - rekey_normal(";", ":") - rekey_visual(";", ":") +{ ... }: +{ + text = '' + -- Remap ; to :. + rekey_normal(";", ":") + rekey_visual(";", ":") - -- Repeat previous command. - rekey_normal(".", "@:") - rekey_visual(".", "@:") - ''; + -- Repeat previous command. + rekey_normal(".", "@:") + rekey_visual(".", "@:") + ''; } diff --git a/home/file/nvim/module/key/Colorscheme.nix b/home/file/nvim/module/key/Colorscheme.nix index 3f92dda9..98e76bb7 100644 --- a/home/file/nvim/module/key/Colorscheme.nix +++ b/home/file/nvim/module/key/Colorscheme.nix @@ -1,26 +1,27 @@ -{ ... }: { - text = '' - function toggle_contrast() - if vim.g.gruvbox_material_background == "light" then - vim.g.gruvbox_material_background = "medium" - elseif vim.g.gruvbox_material_background == "medium" then - vim.g.gruvbox_material_background = "hard" - elseif vim.g.gruvbox_material_background == "hard" then - vim.g.gruvbox_material_background = "light" - end - vim.cmd("colorscheme gruvbox-material") - end +{ ... }: +{ + text = '' + function toggle_contrast() + if vim.g.gruvbox_material_background == "light" then + vim.g.gruvbox_material_background = "medium" + elseif vim.g.gruvbox_material_background == "medium" then + vim.g.gruvbox_material_background = "hard" + elseif vim.g.gruvbox_material_background == "hard" then + vim.g.gruvbox_material_background = "light" + end + vim.cmd("colorscheme gruvbox-material") + end - function toggle_light() - if vim.o.background == "light" then - vim.o.background = "dark" - elseif vim.o.background == "dark" then - vim.o.background = "light" - end - -- require("lualine").setup() - end + function toggle_light() + if vim.o.background == "light" then + vim.o.background = "dark" + elseif vim.o.background == "dark" then + vim.o.background = "light" + end + -- require("lualine").setup() + end - rekey_normal("[", "lua toggle_contrast()") - rekey_normal("]", "lua toggle_light()") - ''; + rekey_normal("[", "lua toggle_contrast()") + rekey_normal("]", "lua toggle_light()") + ''; } diff --git a/home/file/nvim/module/key/Filetree.nix b/home/file/nvim/module/key/Filetree.nix index a9847d80..f0cb68a8 100644 --- a/home/file/nvim/module/key/Filetree.nix +++ b/home/file/nvim/module/key/Filetree.nix @@ -1,6 +1,7 @@ -{ ... }: { - text = '' - -- Toggle file tree. - rekey_normal("1", "NvimTreeToggle") - ''; +{ ... }: +{ + text = '' + -- Toggle file tree. + rekey_normal("1", "NvimTreeToggle") + ''; } diff --git a/home/file/nvim/module/key/Gitsigns.nix b/home/file/nvim/module/key/Gitsigns.nix index d6192e3e..bbd41908 100644 --- a/home/file/nvim/module/key/Gitsigns.nix +++ b/home/file/nvim/module/key/Gitsigns.nix @@ -1,6 +1,7 @@ -{ ... }: { - text = '' - -- Toggle Git inspection mode. - rekey_normal("g", "Gitsigns toggle_current_line_blameGitsigns toggle_word_diffGitsigns toggle_linehl") - ''; +{ ... }: +{ + text = '' + -- Toggle Git inspection mode. + rekey_normal("g", "Gitsigns toggle_current_line_blameGitsigns toggle_word_diffGitsigns toggle_linehl") + ''; } diff --git a/home/file/nvim/module/key/Leader.nix b/home/file/nvim/module/key/Leader.nix index 625e37c3..50b832f9 100644 --- a/home/file/nvim/module/key/Leader.nix +++ b/home/file/nvim/module/key/Leader.nix @@ -1,11 +1,12 @@ -{ ... }: { - text = '' - leader = " " +{ ... }: +{ + text = '' + leader = " " - vim.g.mapleader = leader - vim.g.maplocalleader = leader + vim.g.mapleader = leader + vim.g.maplocalleader = leader - -- Disable key press timeout. - vim.cmd("set notimeout nottimeout") - ''; + -- Disable key press timeout. + vim.cmd("set notimeout nottimeout") + ''; } diff --git a/home/file/nvim/module/key/Navigation.nix b/home/file/nvim/module/key/Navigation.nix index b7021cce..7ef08506 100644 --- a/home/file/nvim/module/key/Navigation.nix +++ b/home/file/nvim/module/key/Navigation.nix @@ -1,36 +1,38 @@ -{ ... }: let - stepHorizontal = 4; - stepVertical = 2; -in { - text = '' - -- Switch windows. - rekey_normal("a", "h") - rekey_normal("d", "l") - rekey_normal("s", "j") - rekey_normal("w", "k") +{ ... }: +let + stepHorizontal = 4; + stepVertical = 2; +in +{ + text = '' + -- Switch windows. + rekey_normal("a", "h") + rekey_normal("d", "l") + rekey_normal("s", "j") + rekey_normal("w", "k") - -- Switch buffers. - rekey_normal("E", "BufferLineMoveNext") - rekey_normal("Q", "BufferLineMovePrev") - rekey_normal("e", "BufferLineCycleNext") - rekey_normal("q", "BufferLineCyclePrev") + -- Switch buffers. + rekey_normal("E", "BufferLineMoveNext") + rekey_normal("Q", "BufferLineMovePrev") + rekey_normal("e", "BufferLineCycleNext") + rekey_normal("q", "BufferLineCyclePrev") - -- Splits. - rekey_normal("\\", "vsplit") - rekey_normal("-", "split") - rekey_normal("=", "=") -- Equalize split sizes. - rekey_normal("c", "q") -- Close split. + -- Splits. + rekey_normal("\\", "vsplit") + rekey_normal("-", "split") + rekey_normal("=", "=") -- Equalize split sizes. + rekey_normal("c", "q") -- Close split. - -- Resize splits. - rekey_normal("h", "${toString stepHorizontal}<") - rekey_normal("l", "${toString stepHorizontal}>") - rekey_normal("j", "${toString stepVertical}+") - rekey_normal("k", "${toString stepVertical}-") + -- Resize splits. + rekey_normal("h", "${toString stepHorizontal}<") + rekey_normal("l", "${toString stepHorizontal}>") + rekey_normal("j", "${toString stepVertical}+") + rekey_normal("k", "${toString stepVertical}-") - -- Move splits. - rekey_normal("A", "A") - rekey_normal("D", "D") - rekey_normal("S", "S") - rekey_normal("W", "W") - ''; + -- Move splits. + rekey_normal("A", "A") + rekey_normal("D", "D") + rekey_normal("S", "S") + rekey_normal("W", "W") + ''; } diff --git a/home/file/nvim/module/key/Prompt.nix b/home/file/nvim/module/key/Prompt.nix index a295039e..86a567ca 100644 --- a/home/file/nvim/module/key/Prompt.nix +++ b/home/file/nvim/module/key/Prompt.nix @@ -1,6 +1,7 @@ -{ ... }: { - text = '' - rekey_normal("p", ":Gen") - rekey_visual("p", ":Gen") - ''; +{ ... }: +{ + text = '' + rekey_normal("p", ":Gen") + rekey_visual("p", ":Gen") + ''; } diff --git a/home/file/nvim/module/key/Rekey.nix b/home/file/nvim/module/key/Rekey.nix index 00e052af..a12a2fe7 100644 --- a/home/file/nvim/module/key/Rekey.nix +++ b/home/file/nvim/module/key/Rekey.nix @@ -1,53 +1,54 @@ -{ ... }: { - text = '' - -- Base rekey function. - local function rekey(t, key, command) - vim.api.nvim_set_keymap(t, key, command, { noremap = true }) - end +{ ... }: +{ + text = '' + -- Base rekey function. + local function rekey(t, key, command) + vim.api.nvim_set_keymap(t, key, command, { noremap = true }) + end - -- Base remap function. - local function remap(t, key, command) - vim.api.nvim_set_keymap(t, key, command, { noremap = false }) - end + -- Base remap function. + local function remap(t, key, command) + vim.api.nvim_set_keymap(t, key, command, { noremap = false }) + end - -- Rekey in normal mode. - function rekey_normal(key, command) - rekey("n", key, command) - end + -- Rekey in normal mode. + function rekey_normal(key, command) + rekey("n", key, command) + end - -- Rekey in input mode. - function rekey_input(key, command) - rekey("i", key, command) - end + -- Rekey in input mode. + function rekey_input(key, command) + rekey("i", key, command) + end - -- Rekey in visual mode. - function rekey_visual(key, command) - rekey("v", key, command) - end + -- Rekey in visual mode. + function rekey_visual(key, command) + rekey("v", key, command) + end - -- Rekey in terminal mode. - function rekey_terminal(key, command) - rekey("t", key, command) - end + -- Rekey in terminal mode. + function rekey_terminal(key, command) + rekey("t", key, command) + end - -- Remap in normal mode. - function remap_normal(key, command) - remap("n", key, command) - end + -- Remap in normal mode. + function remap_normal(key, command) + remap("n", key, command) + end - -- Remap in input mode. - function remap_input(key, command) - remap("i", key, command) - end + -- Remap in input mode. + function remap_input(key, command) + remap("i", key, command) + end - -- Remap in visual mode. - function remap_visual(key, command) - remap("v", key, command) - end + -- Remap in visual mode. + function remap_visual(key, command) + remap("v", key, command) + end - -- Remap in terminal mode. - function remap_terminal(key, command) - remap("t", key, command) - end - ''; + -- Remap in terminal mode. + function remap_terminal(key, command) + remap("t", key, command) + end + ''; } diff --git a/home/file/nvim/module/key/Save.nix b/home/file/nvim/module/key/Save.nix index c7d3cba0..be1b72dc 100644 --- a/home/file/nvim/module/key/Save.nix +++ b/home/file/nvim/module/key/Save.nix @@ -1,19 +1,20 @@ -{ ... }: { - text = '' - -- Write all we can and exit. Created this to drop non-writable stuff when piping to nvim. - function bye() - pcall(vim.cmd, "wa") - vim.cmd[[qa!]] - end +{ ... }: +{ + text = '' + -- Write all we can and exit. Created this to drop non-writable stuff when piping to nvim. + function bye() + pcall(vim.cmd, "wa") + vim.cmd[[qa!]] + end - -- Save everything. - rekey_normal("", "wa!") - rekey_input("", "wa!") + -- Save everything. + rekey_normal("", "wa!") + rekey_input("", "wa!") - -- Save all we can and leave. - rekey_normal("z", "lua bye()") + -- Save all we can and leave. + rekey_normal("z", "lua bye()") - -- Just leave, no saves. - rekey_normal("Z", "qa!") - ''; + -- Just leave, no saves. + rekey_normal("Z", "qa!") + ''; } diff --git a/home/file/nvim/module/key/Sort.nix b/home/file/nvim/module/key/Sort.nix index d73396dd..59e496a2 100644 --- a/home/file/nvim/module/key/Sort.nix +++ b/home/file/nvim/module/key/Sort.nix @@ -1,6 +1,7 @@ -{ ... }: { - text = '' - -- Sort visual selection alphabetically. - rekey_visual("A", ":'<,'>sort") - ''; +{ ... }: +{ + text = '' + -- Sort visual selection alphabetically. + rekey_visual("A", ":'<,'>sort") + ''; } diff --git a/home/file/nvim/module/key/TabWidth.nix b/home/file/nvim/module/key/TabWidth.nix index 741760ae..6037dcb1 100644 --- a/home/file/nvim/module/key/TabWidth.nix +++ b/home/file/nvim/module/key/TabWidth.nix @@ -1,21 +1,22 @@ -{ ... }: { - text = '' - function toggle_tab_width() - if vim.bo.shiftwidth == 2 then - vim.bo.shiftwidth = 4 - vim.bo.tabstop = 4 - vim.bo.softtabstop = 4 - elseif vim.bo.shiftwidth == 4 then - vim.bo.shiftwidth = 8 - vim.bo.tabstop = 8 - vim.bo.softtabstop = 8 - elseif vim.bo.shiftwidth == 8 then - vim.bo.shiftwidth = 2 - vim.bo.tabstop = 2 - vim.bo.softtabstop = 2 - end - end +{ ... }: +{ + text = '' + function toggle_tab_width() + if vim.bo.shiftwidth == 2 then + vim.bo.shiftwidth = 4 + vim.bo.tabstop = 4 + vim.bo.softtabstop = 4 + elseif vim.bo.shiftwidth == 4 then + vim.bo.shiftwidth = 8 + vim.bo.tabstop = 8 + vim.bo.softtabstop = 8 + elseif vim.bo.shiftwidth == 8 then + vim.bo.shiftwidth = 2 + vim.bo.tabstop = 2 + vim.bo.softtabstop = 2 + end + end - rekey_normal("", "lua toggle_tab_width()") - ''; + rekey_normal("", "lua toggle_tab_width()") + ''; } diff --git a/home/file/nvim/module/key/Telescope.nix b/home/file/nvim/module/key/Telescope.nix index 8c513311..17f5c84c 100644 --- a/home/file/nvim/module/key/Telescope.nix +++ b/home/file/nvim/module/key/Telescope.nix @@ -1,12 +1,14 @@ -{ ... }: let - mod = "f"; -in { - text = '' - rekey_normal("${mod}a", "Telescope") - rekey_normal("${mod}b", "lua require('telescope.builtin').buffers()") - rekey_normal("${mod}f", "lua require('telescope.builtin').find_files()") - rekey_normal("${mod}g", "lua require('telescope.builtin').live_grep()") - rekey_normal("${mod}h", "lua require('telescope.builtin').help_tags()") - rekey_normal("${mod}t", "Telescope treesitter") - ''; +{ ... }: +let + mod = "f"; +in +{ + text = '' + rekey_normal("${mod}a", "Telescope") + rekey_normal("${mod}b", "lua require('telescope.builtin').buffers()") + rekey_normal("${mod}f", "lua require('telescope.builtin').find_files()") + rekey_normal("${mod}g", "lua require('telescope.builtin').live_grep()") + rekey_normal("${mod}h", "lua require('telescope.builtin').help_tags()") + rekey_normal("${mod}t", "Telescope treesitter") + ''; } diff --git a/home/file/nvim/module/key/Terminal.nix b/home/file/nvim/module/key/Terminal.nix index 319fdd07..f41ba735 100644 --- a/home/file/nvim/module/key/Terminal.nix +++ b/home/file/nvim/module/key/Terminal.nix @@ -1,9 +1,10 @@ -{ ... }: { - text = '' - -- Open terminal window. - rekey_normal("4", "terminal") +{ ... }: +{ + text = '' + -- Open terminal window. + rekey_normal("4", "terminal") - -- Detach from terminal with Esc key. - rekey_terminal("", "") - ''; + -- Detach from terminal with Esc key. + rekey_terminal("", "") + ''; } diff --git a/home/file/nvim/module/key/Trouble.nix b/home/file/nvim/module/key/Trouble.nix index 5b1bd2d2..06eb18cc 100644 --- a/home/file/nvim/module/key/Trouble.nix +++ b/home/file/nvim/module/key/Trouble.nix @@ -1,11 +1,13 @@ -{ ... }: let - focus = true; -in { - text = '' - -- Toggle diagnostics window. - rekey_normal("2", "Trouble diagnostics toggle focus=${toString focus}") +{ ... }: +let + focus = true; +in +{ + text = '' + -- Toggle diagnostics window. + rekey_normal("2", "Trouble diagnostics toggle focus=${toString focus}") - -- Toggle To-do window. - rekey_normal("3", "Trouble todo toggle focus=${toString focus}") - ''; + -- Toggle To-do window. + rekey_normal("3", "Trouble todo toggle focus=${toString focus}") + ''; } diff --git a/home/file/nvim/module/plugin/Align.nix b/home/file/nvim/module/plugin/Align.nix index 76bc5865..c23fd6c3 100644 --- a/home/file/nvim/module/plugin/Align.nix +++ b/home/file/nvim/module/plugin/Align.nix @@ -1,10 +1,11 @@ -{ ... }: { - text = '' - require("mini.align").setup { - mappings = { - start = "a", - -- start_with_preview = 'A', - }, - } - ''; +{ ... }: +{ + text = '' + require("mini.align").setup { + mappings = { + start = "a", + -- start_with_preview = 'A', + }, + } + ''; } diff --git a/home/file/nvim/module/plugin/Autoclose.nix b/home/file/nvim/module/plugin/Autoclose.nix index 28964c42..c2c64878 100644 --- a/home/file/nvim/module/plugin/Autoclose.nix +++ b/home/file/nvim/module/plugin/Autoclose.nix @@ -1,17 +1,18 @@ -{ ... }: { - text = '' - require("autoclose").setup({ - keys = { - ["'"] = { escape = false, close = false, pair = "''''''", disabled_filetypes = {} }, - ["("] = { escape = true, close = true, pair = "()", disabled_filetypes = {} }, - ["<"] = { escape = true, close = true, pair = "<>", disabled_filetypes = {} }, - ["\""] = { escape = true, close = true, pair = "\"\"", disabled_filetypes = {} }, - ["`"] = { escape = true, close = true, pair = "``", disabled_filetypes = {} }, - ["{"] = { escape = true, close = true, pair = "{}", disabled_filetypes = {} }, - }, - -- options = { - -- disabled_filetypes = { "text", "markdown" }, - -- } - }) - ''; +{ ... }: +{ + text = '' + require("autoclose").setup({ + keys = { + ["'"] = { escape = false, close = false, pair = "''''''", disabled_filetypes = {} }, + ["("] = { escape = true, close = true, pair = "()", disabled_filetypes = {} }, + ["<"] = { escape = true, close = true, pair = "<>", disabled_filetypes = {} }, + ["\""] = { escape = true, close = true, pair = "\"\"", disabled_filetypes = {} }, + ["`"] = { escape = true, close = true, pair = "``", disabled_filetypes = {} }, + ["{"] = { escape = true, close = true, pair = "{}", disabled_filetypes = {} }, + }, + -- options = { + -- disabled_filetypes = { "text", "markdown" }, + -- } + }) + ''; } diff --git a/home/file/nvim/module/plugin/Bufferline.nix b/home/file/nvim/module/plugin/Bufferline.nix index 13bb09ac..0339f530 100644 --- a/home/file/nvim/module/plugin/Bufferline.nix +++ b/home/file/nvim/module/plugin/Bufferline.nix @@ -1,5 +1,6 @@ -{ ... }: { - text = '' - require("bufferline").setup() - ''; +{ ... }: +{ + text = '' + require("bufferline").setup() + ''; } diff --git a/home/file/nvim/module/plugin/Closebuffers.nix b/home/file/nvim/module/plugin/Closebuffers.nix index 3aa1f0a1..6736b05b 100644 --- a/home/file/nvim/module/plugin/Closebuffers.nix +++ b/home/file/nvim/module/plugin/Closebuffers.nix @@ -1,11 +1,12 @@ -{ ... }: { - text = '' - require("close_buffers").setup({ - file_glob_ignore = {}, - file_regex_ignore = {}, - filetype_ignore = {}, - next_buffer_cmd = nil, - preserve_window_layout = { "this", "nameless" }, - }) - ''; +{ ... }: +{ + text = '' + require("close_buffers").setup({ + file_glob_ignore = {}, + file_regex_ignore = {}, + filetype_ignore = {}, + next_buffer_cmd = nil, + preserve_window_layout = { "this", "nameless" }, + }) + ''; } diff --git a/home/file/nvim/module/plugin/Colorizer.nix b/home/file/nvim/module/plugin/Colorizer.nix index 1554f849..33c47e8a 100644 --- a/home/file/nvim/module/plugin/Colorizer.nix +++ b/home/file/nvim/module/plugin/Colorizer.nix @@ -1,8 +1,9 @@ -{ ... }: { - text = '' - -- Ensure termguicolors is enabled if not already - vim.opt.termguicolors = true +{ ... }: +{ + text = '' + -- Ensure termguicolors is enabled if not already + vim.opt.termguicolors = true - require('nvim-highlight-colors').setup({}) - ''; + require('nvim-highlight-colors').setup({}) + ''; } diff --git a/home/file/nvim/module/plugin/Dressing.nix b/home/file/nvim/module/plugin/Dressing.nix index e48d2d8d..1f50c94f 100644 --- a/home/file/nvim/module/plugin/Dressing.nix +++ b/home/file/nvim/module/plugin/Dressing.nix @@ -1,5 +1,6 @@ -{ ... }: { - text = '' - require("dressing").setup({ }) - ''; +{ ... }: +{ + text = '' + require("dressing").setup({ }) + ''; } diff --git a/home/file/nvim/module/plugin/Filetree.nix b/home/file/nvim/module/plugin/Filetree.nix index 7acbc96f..20c99b97 100644 --- a/home/file/nvim/module/plugin/Filetree.nix +++ b/home/file/nvim/module/plugin/Filetree.nix @@ -1,40 +1,41 @@ -{ ... }: { - text = '' - -- Disable netrw at the very start of your init.lua. - vim.g.loaded_netrw = 1 - vim.g.loaded_netrwPlugin = 1 +{ ... }: +{ + text = '' + -- Disable netrw at the very start of your init.lua. + vim.g.loaded_netrw = 1 + vim.g.loaded_netrwPlugin = 1 - local function my_on_attach(bufnr) - local api = require "nvim-tree.api" + local function my_on_attach(bufnr) + local api = require "nvim-tree.api" - local function opts(desc) - return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } - end + local function opts(desc) + return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end - -- Default mappings. - api.config.mappings.default_on_attach(bufnr) + -- Default mappings. + api.config.mappings.default_on_attach(bufnr) - -- Custom mappings. - -- vim.keymap.set('n', '', api.tree.change_root_to_node, opts('Cd into')) - end + -- Custom mappings. + -- vim.keymap.set('n', '', api.tree.change_root_to_node, opts('Cd into')) + end - -- Set termguicolors to enable highlight groups. - vim.opt.termguicolors = true + -- Set termguicolors to enable highlight groups. + vim.opt.termguicolors = true - -- Setup nvim-tree. - require("nvim-tree").setup({ - on_attach = my_on_attach, - sort_by = "case_sensitive", - view = { - width = 30, - }, - renderer = { - group_empty = true, - }, - filters = { - dotfiles = false, - git_ignored = false - }, - }) - ''; + -- Setup nvim-tree. + require("nvim-tree").setup({ + on_attach = my_on_attach, + sort_by = "case_sensitive", + view = { + width = 30, + }, + renderer = { + group_empty = true, + }, + filters = { + dotfiles = false, + git_ignored = false + }, + }) + ''; } diff --git a/home/file/nvim/module/plugin/Fold.nix b/home/file/nvim/module/plugin/Fold.nix index b67202cb..e10ae3cb 100644 --- a/home/file/nvim/module/plugin/Fold.nix +++ b/home/file/nvim/module/plugin/Fold.nix @@ -1,7 +1,8 @@ -{ ... }: { - text = '' - vim.opt.foldexpr = "nvim_treesitter#foldexpr()" - vim.opt.foldlevel = 99 - vim.opt.foldmethod = "expr" - ''; +{ ... }: +{ + text = '' + vim.opt.foldexpr = "nvim_treesitter#foldexpr()" + vim.opt.foldlevel = 99 + vim.opt.foldmethod = "expr" + ''; } diff --git a/home/file/nvim/module/plugin/Gen.nix b/home/file/nvim/module/plugin/Gen.nix index 7d741eb7..5926f911 100644 --- a/home/file/nvim/module/plugin/Gen.nix +++ b/home/file/nvim/module/plugin/Gen.nix @@ -1,10 +1,8 @@ +{ config, ... }: { - config, - ... -}: { - text = '' - require("gen").setup { - model = "${config.module.ollama.primaryModel}" - } - ''; + text = '' + require("gen").setup { + model = "${config.module.ollama.primaryModel}" + } + ''; } diff --git a/home/file/nvim/module/plugin/Gitsigns.nix b/home/file/nvim/module/plugin/Gitsigns.nix index dfa413f5..ed357c77 100644 --- a/home/file/nvim/module/plugin/Gitsigns.nix +++ b/home/file/nvim/module/plugin/Gitsigns.nix @@ -1,44 +1,45 @@ -{ ... }: { - text = '' - require("gitsigns").setup { - signs = { - add = { text = "│" }, - change = { text = "│" }, - changedelete = { text = "~" }, - delete = { text = "_" }, - topdelete = { text = "‾" }, - untracked = { text = "┆" }, - }, - linehl = false, - numhl = true, - signcolumn = false, - word_diff = false, - watch_gitdir = { - follow_files = true, - }, - attach_to_untracked = true, - current_line_blame = false, - current_line_blame_opts = { - delay = 1000, - ignore_whitespace = false, - virt_text = true, - virt_text_pos = "eol", - }, - current_line_blame_formatter = ", - ", - max_file_length = 40000, - sign_priority = 6, - status_formatter = nil, - update_debounce = 100, - preview_config = { - border = "single", - col = 1, - relative = "cursor", - row = 0, - style = "minimal", - }, - } +{ ... }: +{ + text = '' + require("gitsigns").setup { + signs = { + add = { text = "│" }, + change = { text = "│" }, + changedelete = { text = "~" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + untracked = { text = "┆" }, + }, + linehl = false, + numhl = true, + signcolumn = false, + word_diff = false, + watch_gitdir = { + follow_files = true, + }, + attach_to_untracked = true, + current_line_blame = false, + current_line_blame_opts = { + delay = 1000, + ignore_whitespace = false, + virt_text = true, + virt_text_pos = "eol", + }, + current_line_blame_formatter = ", - ", + max_file_length = 40000, + sign_priority = 6, + status_formatter = nil, + update_debounce = 100, + preview_config = { + border = "single", + col = 1, + relative = "cursor", + row = 0, + style = "minimal", + }, + } - -- Set custom color. - vim.cmd("highlight gitsignscurrentlineblame guibg=#00000000 guifg=#aaaaaa") - ''; + -- Set custom color. + vim.cmd("highlight gitsignscurrentlineblame guibg=#00000000 guifg=#aaaaaa") + ''; } diff --git a/home/file/nvim/module/plugin/Gruvbox.nix b/home/file/nvim/module/plugin/Gruvbox.nix index 16e338d3..01edadf4 100644 --- a/home/file/nvim/module/plugin/Gruvbox.nix +++ b/home/file/nvim/module/plugin/Gruvbox.nix @@ -1,19 +1,20 @@ -{ ... }: { - text = '' - vim.cmd([[ - if has('termguicolors') - set termguicolors - endif - ]]) +{ ... }: +{ + text = '' + vim.cmd([[ + if has('termguicolors') + set termguicolors + endif + ]]) - vim.o.background = "dark" - vim.g.gruvbox_material_background = "medium" - vim.g.gruvbox_material_foreground = "original" - vim.g.gruvbox_material_transparent_background = 2 - -- vim.g.gruvbox_material_better_performance = 1 -- NOTE: Broken on NixOS. + vim.o.background = "dark" + vim.g.gruvbox_material_background = "medium" + vim.g.gruvbox_material_foreground = "original" + vim.g.gruvbox_material_transparent_background = 2 + -- vim.g.gruvbox_material_better_performance = 1 -- NOTE: Broken on NixOS. - -- vim.cmd("autocmd ColorScheme * highlight Normal ctermbg=NONE guibg=NONE") - vim.cmd("colorscheme gruvbox-material") - vim.cmd("let g:lightline = {'colorscheme' : 'gruvbox_material'}") - ''; + -- vim.cmd("autocmd ColorScheme * highlight Normal ctermbg=NONE guibg=NONE") + vim.cmd("colorscheme gruvbox-material") + vim.cmd("let g:lightline = {'colorscheme' : 'gruvbox_material'}") + ''; } diff --git a/home/file/nvim/module/plugin/Indent.nix b/home/file/nvim/module/plugin/Indent.nix index 58280ca7..e9441397 100644 --- a/home/file/nvim/module/plugin/Indent.nix +++ b/home/file/nvim/module/plugin/Indent.nix @@ -1,10 +1,11 @@ -{ ... }: { - text = '' - -- Auto-detect indentation type. - require("indent-o-matic").setup { - max_lines = 1024, - skip_multiline = true, - standard_widths = { 2, 4, 8 }, - } - ''; +{ ... }: +{ + text = '' + -- Auto-detect indentation type. + require("indent-o-matic").setup { + max_lines = 1024, + skip_multiline = true, + standard_widths = { 2, 4, 8 }, + } + ''; } diff --git a/home/file/nvim/module/plugin/Init.nix b/home/file/nvim/module/plugin/Init.nix index b85ed587..74d8e330 100644 --- a/home/file/nvim/module/plugin/Init.nix +++ b/home/file/nvim/module/plugin/Init.nix @@ -1,53 +1,54 @@ -{ ... }: { - text = '' - local ensure_packer = function() - local fn = vim.fn - local install_path = fn.stdpath("data").."/site/pack/packer/start/packer.nvim" - if fn.empty(fn.glob(install_path)) > 0 then - fn.system({"git", "clone", "--depth", "1", "https://git.voronind.com/mirror/packer.nvim.git", install_path}) - vim.cmd [[packadd packer.nvim]] - return true - end - return false - end +{ ... }: +{ + text = '' + local ensure_packer = function() + local fn = vim.fn + local install_path = fn.stdpath("data").."/site/pack/packer/start/packer.nvim" + if fn.empty(fn.glob(install_path)) > 0 then + fn.system({"git", "clone", "--depth", "1", "https://git.voronind.com/mirror/packer.nvim.git", install_path}) + vim.cmd [[packadd packer.nvim]] + return true + end + return false + end - local packer_bootstrap = ensure_packer() + local packer_bootstrap = ensure_packer() - local available = function(commands) - for _, command in ipairs(commands) do - if vim.fn.executable(command) ~= 1 then - return false - end - end - return true - end + local available = function(commands) + for _, command in ipairs(commands) do + if vim.fn.executable(command) ~= 1 then + return false + end + end + return true + end - return require("packer").startup(function(use) - use "https://git.voronind.com/mirror/SingleComment.nvim.git" - use "https://git.voronind.com/mirror/autoclose.nvim.git" - use "https://git.voronind.com/mirror/bufferline.nvim.git" - use "https://git.voronind.com/mirror/close-buffers.nvim.git" - use "https://git.voronind.com/mirror/gitsigns.nvim.git" - use "https://git.voronind.com/mirror/gruvbox-material.git" - use "https://git.voronind.com/mirror/indent-o-matic.git" - use "https://git.voronind.com/mirror/lualine.nvim.git" - use "https://git.voronind.com/mirror/mini.align.git" - use "https://git.voronind.com/mirror/nvim-lspconfig.git" - use "https://git.voronind.com/mirror/nvim-tree.lua.git" - use "https://git.voronind.com/mirror/nvim-treesitter.git" - use "https://git.voronind.com/mirror/nvim-web-devicons.git" - use "https://git.voronind.com/mirror/packer.nvim.git" - use "https://git.voronind.com/mirror/plenary.nvim.git" - use "https://git.voronind.com/mirror/telescope.nvim.git" - use "https://git.voronind.com/mirror/todo-comments.nvim.git" - use "https://git.voronind.com/mirror/tokyonight.nvim.git" - use "https://git.voronind.com/mirror/trouble.nvim.git" - use "https://git.voronind.com/mirror/which-key.nvim.git" + return require("packer").startup(function(use) + use "https://git.voronind.com/mirror/SingleComment.nvim.git" + use "https://git.voronind.com/mirror/autoclose.nvim.git" + use "https://git.voronind.com/mirror/bufferline.nvim.git" + use "https://git.voronind.com/mirror/close-buffers.nvim.git" + use "https://git.voronind.com/mirror/gitsigns.nvim.git" + use "https://git.voronind.com/mirror/gruvbox-material.git" + use "https://git.voronind.com/mirror/indent-o-matic.git" + use "https://git.voronind.com/mirror/lualine.nvim.git" + use "https://git.voronind.com/mirror/mini.align.git" + use "https://git.voronind.com/mirror/nvim-lspconfig.git" + use "https://git.voronind.com/mirror/nvim-tree.lua.git" + use "https://git.voronind.com/mirror/nvim-treesitter.git" + use "https://git.voronind.com/mirror/nvim-web-devicons.git" + use "https://git.voronind.com/mirror/packer.nvim.git" + use "https://git.voronind.com/mirror/plenary.nvim.git" + use "https://git.voronind.com/mirror/telescope.nvim.git" + use "https://git.voronind.com/mirror/todo-comments.nvim.git" + use "https://git.voronind.com/mirror/tokyonight.nvim.git" + use "https://git.voronind.com/mirror/trouble.nvim.git" + use "https://git.voronind.com/mirror/which-key.nvim.git" - -- Auto-install. - if packer_bootstrap then - require("packer").sync() - end - end) - ''; + -- Auto-install. + if packer_bootstrap then + require("packer").sync() + end + end) + ''; } diff --git a/home/file/nvim/module/plugin/Telescope.nix b/home/file/nvim/module/plugin/Telescope.nix index 9c27059b..3524d954 100644 --- a/home/file/nvim/module/plugin/Telescope.nix +++ b/home/file/nvim/module/plugin/Telescope.nix @@ -1,16 +1,17 @@ -{ ... }: { - text = '' - require("telescope").setup{ - defaults = { - mappings = { - i = { - [""] = "move_selection_previous", - [""] = "move_selection_next", - }, - }, - }, - extensions = { }, - pickers = { }, - } - ''; +{ ... }: +{ + text = '' + require("telescope").setup{ + defaults = { + mappings = { + i = { + [""] = "move_selection_previous", + [""] = "move_selection_next", + }, + }, + }, + extensions = { }, + pickers = { }, + } + ''; } diff --git a/home/file/nvim/module/plugin/Todo.nix b/home/file/nvim/module/plugin/Todo.nix index e6bc8208..970bbbbd 100644 --- a/home/file/nvim/module/plugin/Todo.nix +++ b/home/file/nvim/module/plugin/Todo.nix @@ -1,55 +1,56 @@ -{ ... }: { - text = '' - require("todo-comments").setup { - sign_priority = 8, - signs = false, - keywords = { - FIX = { icon = " ", color = "error", alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, }, - HACK = { icon = " ", color = "warning", alt = { "WTF", "LOL", "KEKW" } }, - LINK = { icon = "󰌷 ", color = "info", alt = { "REF", "SEE", "MORE", "ALSO", "SOURCE", "SRC" } }, - NOTE = { icon = "󰎚 ", color = "hint", alt = { "INFO" } }, - PERF = { icon = " ", color = "default", alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } }, - TEST = { icon = "⏲ ", color = "test", alt = { "TESTING", "PASSED", "FAILED" } }, - TODO = { icon = " ", color = "info", alt = { "LATER", "FUTURE", "ROADMAP" }}, - WARN = { icon = " ", color = "warning", alt = { "WARNING", "XXX" } }, - WIP = { icon = " ", color = "warning", alt = { "PROGRESS" } }, - }, - gui_style = { - bg = "BOLD", - fg = "NONE", - }, - merge_keywords = true, - highlight = { - after = "fg", - before = "", - comments_only = true, - exclude = {}, - keyword = "wide", - max_line_len = 400, - multiline = true, - multiline_context = 10, - multiline_pattern = "^.", - pattern = [[.*<(KEYWORDS)\s*:]], - }, - colors = { - default = { "Identifier", "#7C3AED" }, - error = { "DiagnosticError", "ErrorMsg", "#DC2626" }, - hint = { "DiagnosticHint", "#10B981" }, - info = { "DiagnosticInfo", "#2563EB" }, - test = { "Identifier", "#FF00FF" }, - warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" }, - }, - search = { - command = "rg", - args = { - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - }, - pattern = [[\b(KEYWORDS):]], - }, - } - ''; +{ ... }: +{ + text = '' + require("todo-comments").setup { + sign_priority = 8, + signs = false, + keywords = { + FIX = { icon = " ", color = "error", alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, }, + HACK = { icon = " ", color = "warning", alt = { "WTF", "LOL", "KEKW" } }, + LINK = { icon = "󰌷 ", color = "info", alt = { "REF", "SEE", "MORE", "ALSO", "SOURCE", "SRC" } }, + NOTE = { icon = "󰎚 ", color = "hint", alt = { "INFO" } }, + PERF = { icon = " ", color = "default", alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } }, + TEST = { icon = "⏲ ", color = "test", alt = { "TESTING", "PASSED", "FAILED" } }, + TODO = { icon = " ", color = "info", alt = { "LATER", "FUTURE", "ROADMAP" }}, + WARN = { icon = " ", color = "warning", alt = { "WARNING", "XXX" } }, + WIP = { icon = " ", color = "warning", alt = { "PROGRESS" } }, + }, + gui_style = { + bg = "BOLD", + fg = "NONE", + }, + merge_keywords = true, + highlight = { + after = "fg", + before = "", + comments_only = true, + exclude = {}, + keyword = "wide", + max_line_len = 400, + multiline = true, + multiline_context = 10, + multiline_pattern = "^.", + pattern = [[.*<(KEYWORDS)\s*:]], + }, + colors = { + default = { "Identifier", "#7C3AED" }, + error = { "DiagnosticError", "ErrorMsg", "#DC2626" }, + hint = { "DiagnosticHint", "#10B981" }, + info = { "DiagnosticInfo", "#2563EB" }, + test = { "Identifier", "#FF00FF" }, + warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" }, + }, + search = { + command = "rg", + args = { + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + }, + pattern = [[\b(KEYWORDS):]], + }, + } + ''; } diff --git a/home/file/nvim/module/plugin/Treesitter.nix b/home/file/nvim/module/plugin/Treesitter.nix index c711d7c9..4655911e 100644 --- a/home/file/nvim/module/plugin/Treesitter.nix +++ b/home/file/nvim/module/plugin/Treesitter.nix @@ -1,25 +1,26 @@ -{ ... }: { - text = '' - require("nvim-treesitter.configs").setup { - parser_install_dir = "~/.cache/nvim/treesitter", - auto_install = true, - -- ensure_installed = "all", - sync_install = false, - highlight = { - additional_vim_regex_highlighting = false, - enable = true, - use_languagetree = true, - disable = { "lua" }, - }, - indent = { - enable = true, - }, - autotag = { - enable = true - }, - rainbow = { - enable = true - }, - } - ''; +{ ... }: +{ + text = '' + require("nvim-treesitter.configs").setup { + parser_install_dir = "~/.cache/nvim/treesitter", + auto_install = true, + -- ensure_installed = "all", + sync_install = false, + highlight = { + additional_vim_regex_highlighting = false, + enable = true, + use_languagetree = true, + disable = { "lua" }, + }, + indent = { + enable = true, + }, + autotag = { + enable = true + }, + rainbow = { + enable = true + }, + } + ''; } diff --git a/home/file/nvim/module/plugin/Trouble.nix b/home/file/nvim/module/plugin/Trouble.nix index 73da3584..f2f04fca 100644 --- a/home/file/nvim/module/plugin/Trouble.nix +++ b/home/file/nvim/module/plugin/Trouble.nix @@ -1,5 +1,6 @@ -{ ... }: { - text = '' - require("trouble").setup() - ''; +{ ... }: +{ + text = '' + require("trouble").setup() + ''; } diff --git a/home/file/nvim/module/plugin/lsp/Go.nix b/home/file/nvim/module/plugin/lsp/Go.nix index 7fdadd0f..a78a6419 100644 --- a/home/file/nvim/module/plugin/lsp/Go.nix +++ b/home/file/nvim/module/plugin/lsp/Go.nix @@ -1,7 +1,8 @@ -{ ... }: { - text = '' - local lspconfig = require("lspconfig") +{ ... }: +{ + text = '' + local lspconfig = require("lspconfig") - lspconfig.gopls.setup {} - ''; + lspconfig.gopls.setup {} + ''; } diff --git a/home/file/nvim/module/plugin/lsp/Haskell.nix b/home/file/nvim/module/plugin/lsp/Haskell.nix index 676fbcde..fb312fc6 100644 --- a/home/file/nvim/module/plugin/lsp/Haskell.nix +++ b/home/file/nvim/module/plugin/lsp/Haskell.nix @@ -1,9 +1,10 @@ -{ ... }: { - text = '' - local lspconfig = require("lspconfig") +{ ... }: +{ + text = '' + local lspconfig = require("lspconfig") - lspconfig.hls.setup { - filetypes = { 'haskell', 'lhaskell', 'cabal' }, - } - ''; + lspconfig.hls.setup { + filetypes = { 'haskell', 'lhaskell', 'cabal' }, + } + ''; } diff --git a/home/file/nvim/module/plugin/lsp/Kotlin.nix b/home/file/nvim/module/plugin/lsp/Kotlin.nix index 5c71fbed..089145c8 100644 --- a/home/file/nvim/module/plugin/lsp/Kotlin.nix +++ b/home/file/nvim/module/plugin/lsp/Kotlin.nix @@ -1,7 +1,8 @@ -{ ... }: { - text = '' - local lspconfig = require("lspconfig") +{ ... }: +{ + text = '' + local lspconfig = require("lspconfig") - lspconfig.kotlin_language_server.setup {} - ''; + lspconfig.kotlin_language_server.setup {} + ''; } diff --git a/home/file/nvim/module/plugin/lsp/Lua.nix b/home/file/nvim/module/plugin/lsp/Lua.nix index 8aba4648..325d1a68 100644 --- a/home/file/nvim/module/plugin/lsp/Lua.nix +++ b/home/file/nvim/module/plugin/lsp/Lua.nix @@ -1,7 +1,8 @@ -{ ... }: { - text = '' - local lspconfig = require("lspconfig") +{ ... }: +{ + text = '' + local lspconfig = require("lspconfig") - lspconfig.lua_ls.setup {} - ''; + lspconfig.lua_ls.setup {} + ''; } diff --git a/home/file/nvim/module/plugin/lsp/Nix.nix b/home/file/nvim/module/plugin/lsp/Nix.nix index de8d4ce4..9a12516b 100644 --- a/home/file/nvim/module/plugin/lsp/Nix.nix +++ b/home/file/nvim/module/plugin/lsp/Nix.nix @@ -1,17 +1,18 @@ -{ ... }: { - text = '' - local lspconfig = require("lspconfig") +{ ... }: +{ + text = '' + local lspconfig = require("lspconfig") - lspconfig.nixd.setup({ - settings = { - nixd = { - diagnostic = { - suppress = { - "sema-escaping-with" - }, - }, - }, - }, - }) - ''; + lspconfig.nixd.setup({ + settings = { + nixd = { + diagnostic = { + suppress = { + "sema-escaping-with" + }, + }, + }, + }, + }) + ''; } diff --git a/home/file/nvim/module/plugin/lsp/Python.nix b/home/file/nvim/module/plugin/lsp/Python.nix index 7019fbc8..650f4447 100644 --- a/home/file/nvim/module/plugin/lsp/Python.nix +++ b/home/file/nvim/module/plugin/lsp/Python.nix @@ -1,7 +1,8 @@ -{ ... }: { - text = '' - local lspconfig = require("lspconfig") +{ ... }: +{ + text = '' + local lspconfig = require("lspconfig") - lspconfig.pyright.setup {} - ''; + lspconfig.pyright.setup {} + ''; } diff --git a/home/file/nvim/module/plugin/lsp/Rust.nix b/home/file/nvim/module/plugin/lsp/Rust.nix index f9cc4c65..141cac17 100644 --- a/home/file/nvim/module/plugin/lsp/Rust.nix +++ b/home/file/nvim/module/plugin/lsp/Rust.nix @@ -1,20 +1,21 @@ -{ ... }: { - text = '' - local lspconfig = require("lspconfig") +{ ... }: +{ + text = '' + local lspconfig = require("lspconfig") - lspconfig.rust_analyzer.setup { - settings = { - ["rust-analyzer"] = { - rustfmt = { - extraArgs = { - "--config", - "hard_tabs=true", - } - } - }, - }, - } + lspconfig.rust_analyzer.setup { + settings = { + ["rust-analyzer"] = { + rustfmt = { + extraArgs = { + "--config", + "hard_tabs=true", + } + } + }, + }, + } - vim.g.rust_recommended_style = false - ''; + vim.g.rust_recommended_style = false + ''; } diff --git a/home/file/nvim/module/plugin/lsp/Tex.nix b/home/file/nvim/module/plugin/lsp/Tex.nix index 783eefdf..8cef79d5 100644 --- a/home/file/nvim/module/plugin/lsp/Tex.nix +++ b/home/file/nvim/module/plugin/lsp/Tex.nix @@ -1,64 +1,65 @@ -{ ... }: { - text = '' - local lspconfig = require('lspconfig') - local config = { - filetypes = { - "bib", - "gitcommit", - "markdown", - "org", - "pandoc", - "plaintex", - "rnoweb", - "rst", - "tex", - "text", - }, - settings = { - ["ltex"] = { - language = "auto" - } - } - } +{ ... }: +{ + text = '' + local lspconfig = require('lspconfig') + local config = { + filetypes = { + "bib", + "gitcommit", + "markdown", + "org", + "pandoc", + "plaintex", + "rnoweb", + "rst", + "tex", + "text", + }, + settings = { + ["ltex"] = { + language = "auto" + } + } + } - lspconfig.ltex.setup(config) + lspconfig.ltex.setup(config) - -- Use TeX LSP for spellcheck. - vim.api.nvim_create_user_command("SCOn", function (args) - lspconfig.ltex.setup(config) - end, { desc = "Enable spellcheck." }) + -- Use TeX LSP for spellcheck. + vim.api.nvim_create_user_command("SCOn", function (args) + lspconfig.ltex.setup(config) + end, { desc = "Enable spellcheck." }) - vim.api.nvim_create_user_command("SCOff", function (args) - lspconfig.ltex.setup { filetypes = {} } - end, { desc = "Disable spellcheck." }) + vim.api.nvim_create_user_command("SCOff", function (args) + lspconfig.ltex.setup { filetypes = {} } + end, { desc = "Disable spellcheck." }) - vim.api.nvim_create_user_command("SCLangRU", function (args) - config.settings['ltex'].language = "ru-RU" - lspconfig.ltex.setup(config) - end, { desc = "Set spellcheck to Russian." }) + vim.api.nvim_create_user_command("SCLangRU", function (args) + config.settings['ltex'].language = "ru-RU" + lspconfig.ltex.setup(config) + end, { desc = "Set spellcheck to Russian." }) - vim.api.nvim_create_user_command("SCLangEN", function (args) - config.settings['ltex'].language = "en-US" - lspconfig.ltex.setup(config) - end, { desc = "Set spellcheck to English." }) + vim.api.nvim_create_user_command("SCLangEN", function (args) + config.settings['ltex'].language = "en-US" + lspconfig.ltex.setup(config) + end, { desc = "Set spellcheck to English." }) - vim.api.nvim_create_user_command("SCLangAuto", function (args) - config.settings['ltex'].language = "auto" - lspconfig.ltex.setup(config) - end, { desc = "Set spellcheck to Auto." }) + vim.api.nvim_create_user_command("SCLangAuto", function (args) + config.settings['ltex'].language = "auto" + lspconfig.ltex.setup(config) + end, { desc = "Set spellcheck to Auto." }) - vim.api.nvim_create_user_command("SCForce", function (args) - vim.cmd("setfiletype text") - vim.cmd("SCOn") - end, { desc = "Set buffer type to text." }) + vim.api.nvim_create_user_command("SCForce", function (args) + vim.cmd("setfiletype text") + vim.cmd("SCOn") + end, { desc = "Set buffer type to text." }) - vim.api.nvim_create_user_command("SCReset", function (args) - vim.cmd("filetype detect") - vim.cmd("SCLangAuto") - end, { desc = "Set buffer type to auto." }) + vim.api.nvim_create_user_command("SCReset", function (args) + vim.cmd("filetype detect") + vim.cmd("SCLangAuto") + end, { desc = "Set buffer type to auto." }) - vim.api.nvim_create_user_command("SCInfo", function (args) - vim.cmd("LspInfo") - end, { desc = "Show info about spellcheck." }) - ''; + vim.api.nvim_create_user_command("SCInfo", function (args) + vim.cmd("LspInfo") + end, { desc = "Show info about spellcheck." }) + ''; } diff --git a/home/file/ssh/default.nix b/home/file/ssh/default.nix index 88b753a8..368e3b1b 100644 --- a/home/file/ssh/default.nix +++ b/home/file/ssh/default.nix @@ -1,30 +1,29 @@ +{ ... }: +let + mkHost = name: address: port: user: '' + Host ${name} + HostName ${address} + User ${user} + Port ${toString port} + ''; +in { - util, - ... -}: let - mkHost = name: address: port: user: (util.trimTabs '' - Host ${name} - HostName ${address} - User ${user} - Port ${toString port} - ''); -in { - text = (util.trimTabs '' - Host * - ControlMaster auto - ControlPath ~/.ssh/%C.socket - ControlPersist yes - '') - + mkHost "dasha" "10.0.0.7" 22143 "root" - + mkHost "desktop" "10.0.0.3" 22143 "root" - + mkHost "fmpmaven" "10.30.22.10" 22 "root" - + mkHost "home" "10.0.0.1" 22143 "root" - + mkHost "laptop" "192.168.1.9" 22143 "root" - + mkHost "max" "10.0.0.13" 22143 "root" - + mkHost "nixbuilder" "10.0.0.1" 22143 "nixbuilder" - + mkHost "pi" "192.168.1.6" 22143 "root" - + mkHost "pocket" "192.168.1.11" 22143 "root" - + mkHost "vpn" "194.113.233.38" 22143 "root" - + mkHost "work" "192.168.1.5" 22143 "root" - ; + text = + '' + Host * + ControlMaster auto + ControlPath ~/.ssh/%C.socket + ControlPersist yes + '' + + mkHost "dasha" "10.0.0.7" 22143 "root" + + mkHost "desktop" "10.0.0.3" 22143 "root" + + mkHost "fmpmaven" "10.30.22.10" 22 "root" + + mkHost "home" "10.0.0.1" 22143 "root" + + mkHost "laptop" "192.168.1.9" 22143 "root" + + mkHost "max" "10.0.0.13" 22143 "root" + + mkHost "nixbuilder" "10.0.0.1" 22143 "nixbuilder" + + mkHost "pi" "192.168.1.6" 22143 "root" + + mkHost "pocket" "192.168.1.11" 22143 "root" + + mkHost "vpn" "194.113.233.38" 22143 "root" + + mkHost "work" "192.168.1.5" 22143 "root"; } diff --git a/home/file/swappy/default.nix b/home/file/swappy/default.nix index 4b1374e1..2e5c58d0 100644 --- a/home/file/swappy/default.nix +++ b/home/file/swappy/default.nix @@ -1,18 +1,15 @@ +{ pkgs, config, ... }: { - pkgs, - config, - ... -}: { - config = (pkgs.formats.ini { }).generate "SwappyConfig" { - Default = { - custom_color = with config.module.style.color; "rgba(${accentR},${accentG},${accentB},1)"; - early_exit = true; - fill_shape = false; - line_size = 4; - paint_mode = "arrow"; - show_panel = false; - text_font = config.module.style.font.serif.name; - text_size = config.module.style.font.size.popup * 3; - }; - }; + config = (pkgs.formats.ini { }).generate "SwappyConfig" { + Default = { + custom_color = with config.module.style.color; "rgba(${accentR},${accentG},${accentB},1)"; + early_exit = true; + fill_shape = false; + line_size = 4; + paint_mode = "arrow"; + show_panel = false; + text_font = config.module.style.font.serif.name; + text_size = config.module.style.font.size.popup * 3; + }; + }; } diff --git a/home/file/sway/default.nix b/home/file/sway/default.nix index fa07c8b5..00753cf4 100644 --- a/home/file/sway/default.nix +++ b/home/file/sway/default.nix @@ -1,38 +1,40 @@ { - config, - lib, - util, - ... -} @args: let - swayRc = util.catText [ - ./module/Mod.nix - ./module/Style.nix - ./module/Display.nix - ./module/Input.nix - ./module/Font.nix - ./module/Launcher.nix - ./module/Terminal.nix - ./module/TitleBar.nix - ./module/Navigation.nix - ./module/Notification.nix - ./module/Resize.nix - ./module/ScratchPad.nix - ./module/Screenshot.nix - ./module/Sound.nix - ./module/Tiling.nix - ./module/Workspace.nix - ./module/Session.nix - ./module/Keyd.nix - ./module/Waybar.nix - ./module/System.nix - ./module/Mouse.nix - ] args; -in { - text = (util.trimTabs '' - # Read `man 5 sway` for a complete reference. - include /etc/sway/config.d/* - '') - + swayRc - + lib.concatStringsSep "\n" config.module.sway.extraConfig - ; + config, + lib, + util, + ... +}@args: +let + swayRc = util.catText [ + ./module/Mod.nix + ./module/Style.nix + ./module/Display.nix + ./module/Input.nix + ./module/Font.nix + ./module/Launcher.nix + ./module/Terminal.nix + ./module/TitleBar.nix + ./module/Navigation.nix + ./module/Notification.nix + ./module/Resize.nix + ./module/ScratchPad.nix + ./module/Screenshot.nix + ./module/Sound.nix + ./module/Tiling.nix + ./module/Workspace.nix + ./module/Session.nix + ./module/Keyd.nix + ./module/Waybar.nix + ./module/System.nix + ./module/Mouse.nix + ] args; +in +{ + text = + '' + # Read `man 5 sway` for a complete reference. + include /etc/sway/config.d/* + '' + + swayRc + + lib.concatStringsSep "\n" config.module.sway.extraConfig; } diff --git a/home/file/sway/module/Display.nix b/home/file/sway/module/Display.nix index 405067b5..94f33b74 100644 --- a/home/file/sway/module/Display.nix +++ b/home/file/sway/module/Display.nix @@ -1,6 +1,7 @@ -{ ... }: { - text = '' - # You can get the names of your outputs by running: swaymsg -t get_outputs - output * scale 1 - ''; +{ ... }: +{ + text = '' + # You can get the names of your outputs by running: swaymsg -t get_outputs + output * scale 1 + ''; } diff --git a/home/file/sway/module/Font.nix b/home/file/sway/module/Font.nix index 2b669991..d8d80a39 100644 --- a/home/file/sway/module/Font.nix +++ b/home/file/sway/module/Font.nix @@ -1,10 +1,9 @@ +{ config, ... }: +let + fontName = config.module.style.font.sansSerif.name; +in { - config, - ... -}: let - fontName = config.module.style.font.sansSerif.name; -in { - text = '' - font "${fontName} Medium 0.01" - ''; + text = '' + font "${fontName} Medium 0.01" + ''; } diff --git a/home/file/sway/module/Input.nix b/home/file/sway/module/Input.nix index 3a048ce8..bb0bd12f 100644 --- a/home/file/sway/module/Input.nix +++ b/home/file/sway/module/Input.nix @@ -1,49 +1,47 @@ +{ config, ... }: { - config, - ... -}:{ - text = '' - ### Input configuration - # - # Example configuration: - # - # input "2:14:SynPS/2_Synaptics_TouchPad" { - # dwt enabled - # tap enabled - # natural_scroll enabled - # middle_emulation enabled - # } - # - # You can get the names of your inputs by running: swaymsg -t get_inputs - # Read `man 5 sway-input` for more information about this section. + text = '' + ### Input configuration + # + # Example configuration: + # + # input "2:14:SynPS/2_Synaptics_TouchPad" { + # dwt enabled + # tap enabled + # natural_scroll enabled + # middle_emulation enabled + # } + # + # You can get the names of your inputs by running: swaymsg -t get_inputs + # Read `man 5 sway-input` for more information about this section. - input type:pointer { - accel_profile flat - pointer_accel 0 - dwt enabled - tap enabled - natural_scroll enabled - middle_emulation enabled - } + input type:pointer { + accel_profile flat + pointer_accel 0 + dwt enabled + tap enabled + natural_scroll enabled + middle_emulation enabled + } - input type:touchpad { - accel_profile flat - pointer_accel 0 - dwt enabled - tap enabled - natural_scroll enabled - middle_emulation enabled - } + input type:touchpad { + accel_profile flat + pointer_accel 0 + dwt enabled + tap enabled + natural_scroll enabled + middle_emulation enabled + } - input type:keyboard { - xkb_layout ${config.module.keyboard.layouts} - xkb_options ${config.module.keyboard.options} - } + input type:keyboard { + xkb_layout ${config.module.keyboard.layouts} + xkb_options ${config.module.keyboard.options} + } - # Hide mouse cursor after a period of inactivity. - seat seat0 hide_cursor 5000 + # Hide mouse cursor after a period of inactivity. + seat seat0 hide_cursor 5000 - # Per-window languages. - exec swaykbdd - ''; + # Per-window languages. + exec swaykbdd + ''; } diff --git a/home/file/sway/module/Keyd.nix b/home/file/sway/module/Keyd.nix index 6975b56c..7429d2e4 100644 --- a/home/file/sway/module/Keyd.nix +++ b/home/file/sway/module/Keyd.nix @@ -1,5 +1,6 @@ -{ ... }: { - text = '' - exec keyd-application-mapper -d - ''; +{ ... }: +{ + text = '' + exec keyd-application-mapper -d + ''; } diff --git a/home/file/sway/module/Launcher.nix b/home/file/sway/module/Launcher.nix index efc852fe..82b9949b 100644 --- a/home/file/sway/module/Launcher.nix +++ b/home/file/sway/module/Launcher.nix @@ -1,10 +1,11 @@ -{ ... }: { - text = '' - # Application launcher. - # Note: pass the final command to swaymsg so that the resulting window can be opened - # on the original workspace that the command was run on. - set $menu fuzzel +{ ... }: +{ + text = '' + # Application launcher. + # Note: pass the final command to swaymsg so that the resulting window can be opened + # on the original workspace that the command was run on. + set $menu fuzzel - bindsym $mod+space exec $menu - ''; + bindsym $mod+space exec $menu + ''; } diff --git a/home/file/sway/module/Mod.nix b/home/file/sway/module/Mod.nix index 726b34e7..9041bf15 100644 --- a/home/file/sway/module/Mod.nix +++ b/home/file/sway/module/Mod.nix @@ -1,7 +1,8 @@ -{ ... }: { - text = '' - # Meta key. Use Mod1 for Alt. - set $mod Mod4 - set $sysmod print - ''; +{ ... }: +{ + text = '' + # Meta key. Use Mod1 for Alt. + set $mod Mod4 + set $sysmod print + ''; } diff --git a/home/file/sway/module/Mouse.nix b/home/file/sway/module/Mouse.nix index b846df23..cb5c66f3 100644 --- a/home/file/sway/module/Mouse.nix +++ b/home/file/sway/module/Mouse.nix @@ -1,7 +1,8 @@ -{ ... }: { - text = '' - bindsym --whole-window $mod+button2 kill - bindsym --whole-window $mod+button8 floating toggle - bindsym --whole-window $mod+button9 fullscreen - ''; +{ ... }: +{ + text = '' + bindsym --whole-window $mod+button2 kill + bindsym --whole-window $mod+button8 floating toggle + bindsym --whole-window $mod+button9 fullscreen + ''; } diff --git a/home/file/sway/module/Navigation.nix b/home/file/sway/module/Navigation.nix index 8eeb99e3..361eb27f 100644 --- a/home/file/sway/module/Navigation.nix +++ b/home/file/sway/module/Navigation.nix @@ -1,18 +1,19 @@ -{ ... }: { - text = '' - # Move focus. - bindsym --to-code $mod+a focus left - bindsym --to-code $mod+d focus right - bindsym --to-code $mod+s focus down - bindsym --to-code $mod+w focus up +{ ... }: +{ + text = '' + # Move focus. + bindsym --to-code $mod+a focus left + bindsym --to-code $mod+d focus right + bindsym --to-code $mod+s focus down + bindsym --to-code $mod+w focus up - # Move the focused window. - bindsym --to-code $mod+Shift+a move left - bindsym --to-code $mod+Shift+d move right - bindsym --to-code $mod+Shift+s move down - bindsym --to-code $mod+Shift+w move up + # Move the focused window. + bindsym --to-code $mod+Shift+a move left + bindsym --to-code $mod+Shift+d move right + bindsym --to-code $mod+Shift+s move down + bindsym --to-code $mod+Shift+w move up - # Focus mouse following. - focus_follows_mouse yes - ''; + # Focus mouse following. + focus_follows_mouse yes + ''; } diff --git a/home/file/sway/module/Notification.nix b/home/file/sway/module/Notification.nix index 28e21b18..928e8fd1 100644 --- a/home/file/sway/module/Notification.nix +++ b/home/file/sway/module/Notification.nix @@ -1,9 +1,10 @@ -{ ... }: { - text = '' - # Show last notification. - bindsym --to-code $mod+shift+n exec makoctl restore +{ ... }: +{ + text = '' + # Show last notification. + bindsym --to-code $mod+shift+n exec makoctl restore - # Hide all notifications. - bindsym --to-code $mod+n exec makoctl dismiss --all - ''; + # Hide all notifications. + bindsym --to-code $mod+n exec makoctl dismiss --all + ''; } diff --git a/home/file/sway/module/Resize.nix b/home/file/sway/module/Resize.nix index 65196145..d26e8f77 100644 --- a/home/file/sway/module/Resize.nix +++ b/home/file/sway/module/Resize.nix @@ -1,11 +1,13 @@ -{ ... }: let - stepHorizontal = 10; - stepVertical = 10; -in { - text = '' - bindsym --to-code $mod+j resize grow height ${toString stepVertical}px - bindsym --to-code $mod+k resize shrink height ${toString stepVertical}px - bindsym --to-code $mod+h resize shrink width ${toString stepHorizontal}px - bindsym --to-code $mod+l resize grow width ${toString stepHorizontal}px - ''; +{ ... }: +let + stepHorizontal = 10; + stepVertical = 10; +in +{ + text = '' + bindsym --to-code $mod+j resize grow height ${toString stepVertical}px + bindsym --to-code $mod+k resize shrink height ${toString stepVertical}px + bindsym --to-code $mod+h resize shrink width ${toString stepHorizontal}px + bindsym --to-code $mod+l resize grow width ${toString stepHorizontal}px + ''; } diff --git a/home/file/sway/module/ScratchPad.nix b/home/file/sway/module/ScratchPad.nix index 2d6f8a91..dd4496e7 100644 --- a/home/file/sway/module/ScratchPad.nix +++ b/home/file/sway/module/ScratchPad.nix @@ -1,52 +1,53 @@ -{ ... }: { - text = '' - # Sway has a "scratchpad", which is a bag of holding for windows. - # You can send windows there and get them back later. - # NOTE: Get id with `swaymsg -t get_tree`. +{ ... }: +{ + text = '' + # Sway has a "scratchpad", which is a bag of holding for windows. + # You can send windows there and get them back later. + # NOTE: Get id with `swaymsg -t get_tree`. - # Show the next scratchpad window or hide the focused scratchpad window. - # If there are multiple scratchpad windows, this command cycles through them. - bindsym --to-code $mod+c scratchpad show - bindsym --to-code $mod+shift+C move scratchpad - bindsym --to-code $mod+shift+X exec swayscript scratchpad_kill + # Show the next scratchpad window or hide the focused scratchpad window. + # If there are multiple scratchpad windows, this command cycles through them. + bindsym --to-code $mod+c scratchpad show + bindsym --to-code $mod+shift+C move scratchpad + bindsym --to-code $mod+shift+X exec swayscript scratchpad_kill - # Fix for a goddamn Firefox WebRTC indicator. - for_window [app_id="firefox" title="Firefox — Sharing Indicator"] { - kill - } + # Fix for a goddamn Firefox WebRTC indicator. + for_window [app_id="firefox" title="Firefox — Sharing Indicator"] { + kill + } - # NetworkManager. - for_window [app_id="nm-connection-editor"] { - move scratchpad - scratchpad show - } + # NetworkManager. + for_window [app_id="nm-connection-editor"] { + move scratchpad + scratchpad show + } - # Bluetooth. - for_window [app_id=".blueman-manager-wrapped"] { - move scratchpad - scratchpad show - } + # Bluetooth. + for_window [app_id=".blueman-manager-wrapped"] { + move scratchpad + scratchpad show + } - # Sound. - for_window [app_id="pavucontrol"] { - move scratchpad - scratchpad show - } + # Sound. + for_window [app_id="pavucontrol"] { + move scratchpad + scratchpad show + } - # Android emulator controls. - for_window [title="Emulator" window_type="utility"] { - move scratchpad - } + # Android emulator controls. + for_window [title="Emulator" window_type="utility"] { + move scratchpad + } - # Calculator. - for_window [app_id="org.gnome.Calculator"] { - move scratchpad - scratchpad show - } + # Calculator. + for_window [app_id="org.gnome.Calculator"] { + move scratchpad + scratchpad show + } - # JamesDsp. - for_window [title="JamesDSP for Linux"] { - move scratchpad - } - ''; + # JamesDsp. + for_window [title="JamesDSP for Linux"] { + move scratchpad + } + ''; } diff --git a/home/file/sway/module/Screenshot.nix b/home/file/sway/module/Screenshot.nix index 30dd5558..984c7041 100644 --- a/home/file/sway/module/Screenshot.nix +++ b/home/file/sway/module/Screenshot.nix @@ -1,162 +1,165 @@ { - __findFile, - config, - lib, - pkgs, - util, - ... -}: let - codec = "libsvtav1"; - color = config.module.style.color; - container = "mp4"; - format = "%Y-%m-%d_%H-%M-%S"; - framerate = 10; - opacity = "26"; - pixfmt = "yuv420p10le"; - selection = "slurp -d -b ${color.bg.light}${opacity} -c ${color.fg.light} -w 0 -s 00000000"; -in { - text = let - notifyStart = ''swayscript notify_short''; - notifyEnd = ''swayscript notify_long''; - picEdit = ''swappy -f - -o -''; - picFull = ''-o $(swaymsg -t get_outputs | jq -r ".[] | select(.focused) | .name") -''; - picPrepFile = prepFile "\${XDG_PICTURES_DIR[0]}" "png"; - picRefLatestFile = refLatestFile "png"; - picSelected = ''-g "''${scrSelection}" -''; - picToBuffer = ''wl-copy -t image/png''; - picToFile = ''tee "''${scrFile}"''; - screenshot = ''grim''; - updateWaybar = ''{ pkill -RTMIN+4 waybar; } & disown''; # NOTE: Might need to add a delay here if it becomes inconsistent one day. - vidFull = ''-o $(swaymsg -t get_outputs | jq -r ".[] | select(.focused) | .name") -''; - vidPrepFile = prepFile "\${XDG_VIDEOS_DIR[0]}" container; - vidRefLatestFile = refLatestFile container; - vidSelected = ''--geometry "''${scrSelection}"''; - vidStop = ''pkill -SIGINT wf-recorder''; + __findFile, + config, + lib, + pkgs, + ... +}: +let + codec = "libsvtav1"; + color = config.module.style.color; + container = "mp4"; + format = "%Y-%m-%d_%H-%M-%S"; + framerate = 10; + opacity = "26"; + pixfmt = "yuv420p10le"; + selection = "slurp -d -b ${color.bg.light}${opacity} -c ${color.fg.light} -w 0 -s 00000000"; +in +{ + text = + let + notifyStart = ''swayscript notify_short''; + notifyEnd = ''swayscript notify_long''; + picEdit = ''swappy -f - -o -''; + picFull = ''-o $(swaymsg -t get_outputs | jq -r ".[] | select(.focused) | .name") -''; + picPrepFile = prepFile "\${XDG_PICTURES_DIR[0]}" "png"; + picRefLatestFile = refLatestFile "png"; + picSelected = ''-g "''${scrSelection}" -''; + picToBuffer = ''wl-copy -t image/png''; + picToFile = ''tee "''${scrFile}"''; + screenshot = ''grim''; + updateWaybar = ''{ pkill -RTMIN+4 waybar; } & disown''; # NOTE: Might need to add a delay here if it becomes inconsistent one day. + vidFull = ''-o $(swaymsg -t get_outputs | jq -r ".[] | select(.focused) | .name") -''; + vidPrepFile = prepFile "\${XDG_VIDEOS_DIR[0]}" container; + vidRefLatestFile = refLatestFile container; + vidSelected = ''--geometry "''${scrSelection}"''; + vidStop = ''pkill -SIGINT wf-recorder''; - prepFile = path: ext: util.trimTabs '' - # Focused app id by default. - curWindow=$(parse_snake $(swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | .app_id')) + prepFile = path: ext: '' + # Focused app id by default. + curWindow=$(parse_snake $(swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | .app_id')) - # If no id (i.e. xwayland), then use a name (title). - [[ "''${curWindow}" = "null" ]] && curWindow=$(parse_snake $(swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | .name')) + # If no id (i.e. xwayland), then use a name (title). + [[ "''${curWindow}" = "null" ]] && curWindow=$(parse_snake $(swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | .name')) - # If no app in focus, use "unknown" dir. - [[ "''${curWindow}" =~ ^[0-9]+$ ]] && curWindow="unknown" + # If no app in focus, use "unknown" dir. + [[ "''${curWindow}" =~ ^[0-9]+$ ]] && curWindow="unknown" - # Prepare dir and file path. - scrPath="${path}" - scrDir="${path}/''${curWindow}" - mkdir -p "''${scrDir}" - scrName="$(date +${format}).${ext}" - scrFile="''${scrDir}/''${scrName}" - scrLatestRef="./''${curWindow}/''${scrName}" - ''; + # Prepare dir and file path. + scrPath="${path}" + scrDir="${path}/''${curWindow}" + mkdir -p "''${scrDir}" + scrName="$(date +${format}).${ext}" + scrFile="''${scrDir}/''${scrName}" + scrLatestRef="./''${curWindow}/''${scrName}" + ''; - refLatestFile = ext: util.trimTabs '' - scrLatest="''${scrPath}/Latest.${ext}" - rm "''${scrLatest}" - ln -s "''${scrLatestRef}" "''${scrLatest}" - ''; + refLatestFile = ext: '' + scrLatest="''${scrPath}/Latest.${ext}" + rm "''${scrLatest}" + ln -s "''${scrLatestRef}" "''${scrLatest}" + ''; - getSelection = util.trimTabs '' - scrSelection=$(${selection}) - [[ -n "''${scrSelection}" ]] || exit - ''; + getSelection = '' + scrSelection=$(${selection}) + [[ -n "''${scrSelection}" ]] || exit + ''; - getTransform = util.trimTabs '' - scrTransform="$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .transform')" - [[ "''${scrTransform}" = "normal" ]] && scrTransform="" - ''; + getTransform = '' + scrTransform="$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .transform')" + [[ "''${scrTransform}" = "normal" ]] && scrTransform="" + ''; - vidStart = util.trimTabs '' - wf-recorder \ - --no-damage \ - --codec ${codec} \ - --file "''${scrFile}" \ - --framerate ${toString framerate} \ - --pixel-format ${pixfmt} \ - ''; + vidStart = '' + wf-recorder \ + --no-damage \ + --codec ${codec} \ + --file "''${scrFile}" \ + --framerate ${toString framerate} \ + --pixel-format ${pixfmt} \ + ''; - vidMuxAudio = util.trimTabs '' - ffmpeg \ - -f lavfi \ - -i anullsrc=channel_layout=stereo:sample_rate=44100 \ - -i "''${scrFile}" \ - -c:v copy \ - -c:a libopus \ - -shortest \ - -f ${container} \ - "''${scrFile}_" \ - && mv "''${scrFile}_" "''${scrFile}" \ - || rm "''${scrFile}_" - ''; + vidMuxAudio = '' + ffmpeg \ + -f lavfi \ + -i anullsrc=channel_layout=stereo:sample_rate=44100 \ + -i "''${scrFile}" \ + -c:v copy \ + -c:a libopus \ + -shortest \ + -f ${container} \ + "''${scrFile}_" \ + && mv "''${scrFile}_" "''${scrFile}" \ + || rm "''${scrFile}_" + ''; - vidTransform = util.trimTabs '' - if [[ -n "''${scrTransform}" ]]; then - ffmpeg \ - -display_rotation ''${scrTransform} \ - -i "''${scrFile}" \ - -c copy \ - -f ${container} \ - "''${scrFile}_" \ - && mv "''${scrFile}_" "''${scrFile}" \ - || rm "''${scrFile}_" - fi - ''; + vidTransform = '' + if [[ -n "''${scrTransform}" ]]; then + ffmpeg \ + -display_rotation ''${scrTransform} \ + -i "''${scrFile}" \ + -c copy \ + -f ${container} \ + "''${scrFile}_" \ + && mv "''${scrFile}_" "''${scrFile}" \ + || rm "''${scrFile}_" + fi + ''; - SelectRecording = pkgs.writeShellScriptBin "SelectRecording" (util.trimTabs '' - ${vidStop} || { - ${getSelection} - ${getTransform} - ${vidPrepFile} - ${notifyStart} - ${updateWaybar} - ${vidStart} ${vidSelected} - ${notifyEnd} - ${updateWaybar} - ${vidMuxAudio} - ${vidTransform} - ${vidRefLatestFile} - }; - ''); + SelectRecording = pkgs.writeShellScriptBin "SelectRecording" '' + ${vidStop} || { + ${getSelection} + ${getTransform} + ${vidPrepFile} + ${notifyStart} + ${updateWaybar} + ${vidStart} ${vidSelected} + ${notifyEnd} + ${updateWaybar} + ${vidMuxAudio} + ${vidTransform} + ${vidRefLatestFile} + }; + ''; - FullscreenRecording = pkgs.writeShellScriptBin "FullscreenRecording" (util.trimTabs '' - ${vidStop} || { - ${getTransform} - ${vidPrepFile} - ${notifyStart} - ${updateWaybar} - ${vidStart} ${vidFull} - ${notifyEnd} - ${updateWaybar} - ${vidMuxAudio} - ${vidTransform} - ${vidRefLatestFile} - }; - ''); + FullscreenRecording = pkgs.writeShellScriptBin "FullscreenRecording" '' + ${vidStop} || { + ${getTransform} + ${vidPrepFile} + ${notifyStart} + ${updateWaybar} + ${vidStart} ${vidFull} + ${notifyEnd} + ${updateWaybar} + ${vidMuxAudio} + ${vidTransform} + ${vidRefLatestFile} + }; + ''; - FullscreenScreenshot = pkgs.writeShellScriptBin "FullscreenScreenshot" (util.trimTabs '' - ${notifyEnd} - ${picPrepFile} + FullscreenScreenshot = pkgs.writeShellScriptBin "FullscreenScreenshot" '' + ${notifyEnd} + ${picPrepFile} - ${screenshot} ${picFull} | ${picToFile} | ${picToBuffer} - ${picRefLatestFile} - ''); + ${screenshot} ${picFull} | ${picToFile} | ${picToBuffer} + ${picRefLatestFile} + ''; - SelectScreenshot = pkgs.writeShellScriptBin "SelectScreenshot" (util.trimTabs '' - ${getSelection} - ${notifyStart} - ${picPrepFile} + SelectScreenshot = pkgs.writeShellScriptBin "SelectScreenshot" '' + ${getSelection} + ${notifyStart} + ${picPrepFile} - ${screenshot} ${picSelected} | ${picEdit} | ${picToFile} | ${picToBuffer} - ${notifyEnd} - ${picRefLatestFile} - ''); - in '' - bindsym --to-code $mod+y exec ${lib.getExe FullscreenScreenshot} - bindsym --to-code $mod+shift+y exec ${lib.getExe FullscreenRecording} + ${screenshot} ${picSelected} | ${picEdit} | ${picToFile} | ${picToBuffer} + ${notifyEnd} + ${picRefLatestFile} + ''; + in + '' + bindsym --to-code $mod+y exec ${lib.getExe FullscreenScreenshot} + bindsym --to-code $mod+shift+y exec ${lib.getExe FullscreenRecording} - bindsym --to-code $mod+v exec ${lib.getExe SelectScreenshot} - bindsym --to-code $mod+shift+v exec ${lib.getExe SelectRecording} - ''; + bindsym --to-code $mod+v exec ${lib.getExe SelectScreenshot} + bindsym --to-code $mod+shift+v exec ${lib.getExe SelectRecording} + ''; } diff --git a/home/file/sway/module/Session.nix b/home/file/sway/module/Session.nix index f2821e51..3f174eb5 100644 --- a/home/file/sway/module/Session.nix +++ b/home/file/sway/module/Session.nix @@ -1,11 +1,10 @@ +{ config, ... }: +let + lock = "swaylock -f -F -c 000000 -k --font \"${config.module.style.font.serif.name}\" --font-size ${toString config.module.style.font.size.desktop}"; +in { - config, - ... -}: let - lock = "swaylock -f -F -c 000000 -k --font \"${config.module.style.font.serif.name}\" --font-size ${toString config.module.style.font.size.desktop}"; -in { - text = '' - bindsym --to-code $mod+z exec '_twice 1 ${lock}' - bindsym --to-code $mod+Shift+Z exec _twice 1 bash -c '${lock}; systemctl suspend -i' - ''; + text = '' + bindsym --to-code $mod+z exec '_twice 1 ${lock}' + bindsym --to-code $mod+Shift+Z exec _twice 1 bash -c '${lock}; systemctl suspend -i' + ''; } diff --git a/home/file/sway/module/Sound.nix b/home/file/sway/module/Sound.nix index 6320142c..90a64883 100644 --- a/home/file/sway/module/Sound.nix +++ b/home/file/sway/module/Sound.nix @@ -1,20 +1,22 @@ -{ ... }: let - step_music = 10; - step_volume = 5; -in { - text = '' - bindsym XF86AudioRaiseVolume exec 'pactl set-sink-volume @DEFAULT_SINK@ +${toString step_volume}%' - bindsym XF86AudioLowerVolume exec 'pactl set-sink-volume @DEFAULT_SINK@ -${toString step_volume}%' - bindsym XF86AudioMute exec 'pactl set-sink-mute @DEFAULT_SINK@ toggle' - bindsym XF86AudioMicMute exec 'pactl set-source-mute @DEFAULT_SOURCE@ toggle' +{ ... }: +let + step_music = 10; + step_volume = 5; +in +{ + text = '' + bindsym XF86AudioRaiseVolume exec 'pactl set-sink-volume @DEFAULT_SINK@ +${toString step_volume}%' + bindsym XF86AudioLowerVolume exec 'pactl set-sink-volume @DEFAULT_SINK@ -${toString step_volume}%' + bindsym XF86AudioMute exec 'pactl set-sink-mute @DEFAULT_SINK@ toggle' + bindsym XF86AudioMicMute exec 'pactl set-source-mute @DEFAULT_SOURCE@ toggle' - bindsym XF86AudioPlay exec 'playerctl play-pause' - bindsym XF86AudioPause exec 'playerctl pause' - bindsym XF86AudioStop exec 'playerctl stop' - bindsym XF86AudioNext exec 'playerctl next' - bindsym XF86AudioPrev exec 'playerctl previous' - bindsym XF86Forward exec 'playerctl position ${toString step_music}+' - bindsym XF86Back exec 'playerctl position ${toString step_music}-' - bindsym XF86Eject exec 'swayscript sound_output_cycle' - ''; + bindsym XF86AudioPlay exec 'playerctl play-pause' + bindsym XF86AudioPause exec 'playerctl pause' + bindsym XF86AudioStop exec 'playerctl stop' + bindsym XF86AudioNext exec 'playerctl next' + bindsym XF86AudioPrev exec 'playerctl previous' + bindsym XF86Forward exec 'playerctl position ${toString step_music}+' + bindsym XF86Back exec 'playerctl position ${toString step_music}-' + bindsym XF86Eject exec 'swayscript sound_output_cycle' + ''; } diff --git a/home/file/sway/module/Style.nix b/home/file/sway/module/Style.nix index 99e040a2..04e92d85 100644 --- a/home/file/sway/module/Style.nix +++ b/home/file/sway/module/Style.nix @@ -1,18 +1,17 @@ +{ config, ... }: +let + accent = config.module.style.color.accent + alpha; + alpha = config.module.style.opacity.hex; + border = config.module.style.color.border + alpha; + fg = config.module.style.color.fg.light; +in { - config, - ... -}: let - accent = config.module.style.color.accent + alpha; - alpha = config.module.style.opacity.hex; - border = config.module.style.color.border + alpha; - fg = config.module.style.color.fg.light; -in { - text = '' - output * bg ${config.module.wallpaper.path} fill - client.focused "#${accent}" "#${accent}" "#${fg}" "#${accent}" "#${accent}" - client.focused_inactive "#${border}" "#${border}" "#${fg}" "#${border}" "#${border}" - client.unfocused "#${border}" "#${border}" "#${fg}" "#${border}" "#${border}" - client.urgent "#${border}" "#${border}" "#${fg}" "#${border}" "#${border}" - client.placeholder "#${border}" "#${border}" "#${fg}" "#${border}" "#${border}" - ''; + text = '' + output * bg ${config.module.wallpaper.path} fill + client.focused "#${accent}" "#${accent}" "#${fg}" "#${accent}" "#${accent}" + client.focused_inactive "#${border}" "#${border}" "#${fg}" "#${border}" "#${border}" + client.unfocused "#${border}" "#${border}" "#${fg}" "#${border}" "#${border}" + client.urgent "#${border}" "#${border}" "#${fg}" "#${border}" "#${border}" + client.placeholder "#${border}" "#${border}" "#${fg}" "#${border}" "#${border}" + ''; } diff --git a/home/file/sway/module/System.nix b/home/file/sway/module/System.nix index aed2ebd7..e536b8bd 100644 --- a/home/file/sway/module/System.nix +++ b/home/file/sway/module/System.nix @@ -1,23 +1,25 @@ -{ ... }: let - brstep = 5; -in { - text = '' - bindsym $sysmod input * xkb_switch_layout 0 - bindsym --to-code $sysmod+a exec 'swayscript network' - bindsym --to-code $sysmod+c exec 'systemctl reboot -i' - bindsym --to-code $sysmod+d exec 'swayscript dnd' - bindsym --to-code $sysmod+g exec 'swayscript gaming' - bindsym --to-code $sysmod+l exec 'powerlimit toggle' - bindsym --to-code $sysmod+m exec 'swayscript monitor' - bindsym --to-code $sysmod+p exec 'powersave toggle' - bindsym --to-code $sysmod+r exec 'swayscript reload' - bindsym --to-code $sysmod+v exec 'swayscript vpn' - bindsym --to-code $sysmod+x exec 'systemctl poweroff -i' - bindsym --to-code $sysmod+z exec 'systemctl suspend -i' +{ ... }: +let + brstep = 5; +in +{ + text = '' + bindsym $sysmod input * xkb_switch_layout 0 + bindsym --to-code $sysmod+a exec 'swayscript network' + bindsym --to-code $sysmod+c exec 'systemctl reboot -i' + bindsym --to-code $sysmod+d exec 'swayscript dnd' + bindsym --to-code $sysmod+g exec 'swayscript gaming' + bindsym --to-code $sysmod+l exec 'powerlimit toggle' + bindsym --to-code $sysmod+m exec 'swayscript monitor' + bindsym --to-code $sysmod+p exec 'powersave toggle' + bindsym --to-code $sysmod+r exec 'swayscript reload' + bindsym --to-code $sysmod+v exec 'swayscript vpn' + bindsym --to-code $sysmod+x exec 'systemctl poweroff -i' + bindsym --to-code $sysmod+z exec 'systemctl suspend -i' - bindsym --to-code $sysmod+w exec light -A ${toString brstep} - bindsym XF86MonBrightnessUp exec light -A ${toString brstep} - bindsym --to-code $sysmod+s exec light -U ${toString brstep} - bindsym XF86MonBrightnessDown exec light -U ${toString brstep} - ''; + bindsym --to-code $sysmod+w exec light -A ${toString brstep} + bindsym XF86MonBrightnessUp exec light -A ${toString brstep} + bindsym --to-code $sysmod+s exec light -U ${toString brstep} + bindsym XF86MonBrightnessDown exec light -U ${toString brstep} + ''; } diff --git a/home/file/sway/module/Terminal.nix b/home/file/sway/module/Terminal.nix index 57214ed4..c7cd3574 100644 --- a/home/file/sway/module/Terminal.nix +++ b/home/file/sway/module/Terminal.nix @@ -1,7 +1,8 @@ -{ ... }: { - text = '' - set $term foot +{ ... }: +{ + text = '' + set $term foot - bindsym --to-code $mod+Escape exec $term -e bash -i -c "tmux new-session -A -s $USER; bash -i" - ''; + bindsym --to-code $mod+Escape exec $term -e bash -i -c "tmux new-session -A -s $USER; bash -i" + ''; } diff --git a/home/file/sway/module/Tiling.nix b/home/file/sway/module/Tiling.nix index 5ad64b73..a8f57acc 100644 --- a/home/file/sway/module/Tiling.nix +++ b/home/file/sway/module/Tiling.nix @@ -1,38 +1,36 @@ +{ config, ... }: { - config, - ... -}: { - text = '' - # Toggle tiling. - bindsym --to-code $mod+shift+f floating toggle + text = '' + # Toggle tiling. + bindsym --to-code $mod+shift+f floating toggle - # Swap focus between the tiling area and the floating area - bindsym --to-code $mod+r focus mode_toggle + # Swap focus between the tiling area and the floating area + bindsym --to-code $mod+r focus mode_toggle - # Split directions. - bindsym --to-code $mod+backslash splith - bindsym --to-code $mod+minus splitv + # Split directions. + bindsym --to-code $mod+backslash splith + bindsym --to-code $mod+minus splitv - # Switch the current container between different layout styles. - bindsym --to-code $mod+Tab layout toggle split tabbed + # Switch the current container between different layout styles. + bindsym --to-code $mod+Tab layout toggle split tabbed - # Fullscreen. - bindsym --to-code $mod+f fullscreen + # Fullscreen. + bindsym --to-code $mod+f fullscreen - # Drag floating windows by holding down $mod and left mouse button. - # Resize them with right mouse button + $mod. - # Despite the name, also works for non-floating windows. - # Change normal to inverse to use left mouse button for resizing and right - # mouse button for dragging. - floating_modifier $mod normal + # Drag floating windows by holding down $mod and left mouse button. + # Resize them with right mouse button + $mod. + # Despite the name, also works for non-floating windows. + # Change normal to inverse to use left mouse button for resizing and right + # mouse button for dragging. + floating_modifier $mod normal - # Kill focused window. - bindsym --to-code $mod+x kill + # Kill focused window. + bindsym --to-code $mod+x kill - # Add gaps. - gaps inner ${toString config.module.style.window.gap} + # Add gaps. + gaps inner ${toString config.module.style.window.gap} - # Launch everything tiled. - # for_window [all] floating disable - ''; + # Launch everything tiled. + # for_window [all] floating disable + ''; } diff --git a/home/file/sway/module/TitleBar.nix b/home/file/sway/module/TitleBar.nix index 9644e43d..a6397380 100644 --- a/home/file/sway/module/TitleBar.nix +++ b/home/file/sway/module/TitleBar.nix @@ -1,14 +1,13 @@ +{ config, ... }: +let + borderSize = toString config.module.style.window.border; +in { - config, - ... -}: let - borderSize = toString config.module.style.window.border; -in { - text = '' - # Disable title bar. - default_border pixel ${borderSize} - default_floating_border pixel ${borderSize} - titlebar_padding 1 - titlebar_border_thickness 0 - ''; + text = '' + # Disable title bar. + default_border pixel ${borderSize} + default_floating_border pixel ${borderSize} + titlebar_padding 1 + titlebar_border_thickness 0 + ''; } diff --git a/home/file/sway/module/Waybar.nix b/home/file/sway/module/Waybar.nix index 630ba9a0..e895e76f 100644 --- a/home/file/sway/module/Waybar.nix +++ b/home/file/sway/module/Waybar.nix @@ -1,6 +1,7 @@ -{ ... }: { - text = '' - bindsym --to-code $mod+shift+r exec 'pkill waybar || exec waybar' - exec waybar - ''; +{ ... }: +{ + text = '' + bindsym --to-code $mod+shift+r exec 'pkill waybar || exec waybar' + exec waybar + ''; } diff --git a/home/file/sway/module/Workspace.nix b/home/file/sway/module/Workspace.nix index 7e9930ab..da9e3937 100644 --- a/home/file/sway/module/Workspace.nix +++ b/home/file/sway/module/Workspace.nix @@ -1,37 +1,38 @@ -{ ... }: { - text = '' - # Switch to workspace. - bindsym --to-code $mod+1 workspace number 1 - bindsym --to-code $mod+2 workspace number 2 - bindsym --to-code $mod+3 workspace number 3 - bindsym --to-code $mod+4 workspace number 4 - bindsym --to-code $mod+5 workspace number 5 - bindsym --to-code $mod+6 workspace number 6 - bindsym --to-code $mod+7 workspace number 7 - bindsym --to-code $mod+8 workspace number 8 - bindsym --to-code $mod+9 workspace number 9 - bindsym --to-code $mod+0 workspace number 10 +{ ... }: +{ + text = '' + # Switch to workspace. + bindsym --to-code $mod+1 workspace number 1 + bindsym --to-code $mod+2 workspace number 2 + bindsym --to-code $mod+3 workspace number 3 + bindsym --to-code $mod+4 workspace number 4 + bindsym --to-code $mod+5 workspace number 5 + bindsym --to-code $mod+6 workspace number 6 + bindsym --to-code $mod+7 workspace number 7 + bindsym --to-code $mod+8 workspace number 8 + bindsym --to-code $mod+9 workspace number 9 + bindsym --to-code $mod+0 workspace number 10 - # Move focused container to workspace. - bindsym --to-code $mod+Shift+1 move container to workspace number 1 - bindsym --to-code $mod+Shift+2 move container to workspace number 2 - bindsym --to-code $mod+Shift+3 move container to workspace number 3 - bindsym --to-code $mod+Shift+4 move container to workspace number 4 - bindsym --to-code $mod+Shift+5 move container to workspace number 5 - bindsym --to-code $mod+Shift+6 move container to workspace number 6 - bindsym --to-code $mod+Shift+7 move container to workspace number 7 - bindsym --to-code $mod+Shift+8 move container to workspace number 8 - bindsym --to-code $mod+Shift+9 move container to workspace number 9 - bindsym --to-code $mod+Shift+0 move container to workspace number 10 - # Note: workspaces can have any name you want, not just numbers. - # We just use 1-10 as the default. + # Move focused container to workspace. + bindsym --to-code $mod+Shift+1 move container to workspace number 1 + bindsym --to-code $mod+Shift+2 move container to workspace number 2 + bindsym --to-code $mod+Shift+3 move container to workspace number 3 + bindsym --to-code $mod+Shift+4 move container to workspace number 4 + bindsym --to-code $mod+Shift+5 move container to workspace number 5 + bindsym --to-code $mod+Shift+6 move container to workspace number 6 + bindsym --to-code $mod+Shift+7 move container to workspace number 7 + bindsym --to-code $mod+Shift+8 move container to workspace number 8 + bindsym --to-code $mod+Shift+9 move container to workspace number 9 + bindsym --to-code $mod+Shift+0 move container to workspace number 10 + # Note: workspaces can have any name you want, not just numbers. + # We just use 1-10 as the default. - # Switch left-right. - bindsym --to-code $mod+e workspace next - bindsym --to-code $mod+q workspace prev + # Switch left-right. + bindsym --to-code $mod+e workspace next + bindsym --to-code $mod+q workspace prev - # Move left-right. - bindsym --to-code $mod+Shift+e move container to workspace next - bindsym --to-code $mod+Shift+q move container to workspace prev - ''; + # Move left-right. + bindsym --to-code $mod+Shift+e move container to workspace next + bindsym --to-code $mod+Shift+q move container to workspace prev + ''; } diff --git a/home/file/template/Android.nix b/home/file/template/Android.nix index 5e98f24d..65e30b71 100644 --- a/home/file/template/Android.nix +++ b/home/file/template/Android.nix @@ -1,67 +1,66 @@ { - description = "Android dev environment."; + description = "Android dev environment."; - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - }; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + }; - outputs = { self, nixpkgs } @inputs: let - buildTools = "31.0.0"; - jdk = pkgs.jdk11; - lib = nixpkgs.lib; - system = "x86_64-linux"; - androidSdk = androidComposition.androidsdk; - pkgs = import nixpkgs { - system = system; - config = { - allowUnfree = true; - android_sdk.accept_license = true; - }; - }; - androidComposition = pkgs.androidenv.composeAndroidPackages { - cmdLineToolsVersion = "8.0"; - includeEmulator = false; - includeNDK = false; - includeSources = false; - includeSystemImages = false; - platformToolsVersion = "34.0.5"; - toolsVersion = "26.1.1"; - useGoogleAPIs = false; - useGoogleTVAddOns = false; - abiVersions = [ - "arm64-v8a" - "armeabi-v7a" - ]; - buildToolsVersions = [ - buildTools - ]; - platformVersions = [ - "31" - ]; - # cmakeVersions = [ "3.10.2" ]; - # emulatorVersion = "30.3.4"; - # includeExtras = [ "extras;google;gcm" ]; - # ndkVersions = ["22.0.7026061"]; - # systemImageTypes = [ "google_apis_playstore" ]; - }; - in { - devShells.${system} = { - default = pkgs.mkShell rec { - nativeBuildInputs = with pkgs; [ - android-tools - androidSdk - glibc - gnumake - jdk - ]; - buildInputs = with pkgs; [ ]; + outputs = + { self, nixpkgs }@inputs: + let + buildTools = "31.0.0"; + jdk = pkgs.jdk11; + lib = nixpkgs.lib; + system = "x86_64-linux"; + androidSdk = androidComposition.androidsdk; + pkgs = import nixpkgs { + system = system; + config = { + allowUnfree = true; + android_sdk.accept_license = true; + }; + }; + androidComposition = pkgs.androidenv.composeAndroidPackages { + cmdLineToolsVersion = "8.0"; + includeEmulator = false; + includeNDK = false; + includeSources = false; + includeSystemImages = false; + platformToolsVersion = "34.0.5"; + toolsVersion = "26.1.1"; + useGoogleAPIs = false; + useGoogleTVAddOns = false; + abiVersions = [ + "arm64-v8a" + "armeabi-v7a" + ]; + buildToolsVersions = [ buildTools ]; + platformVersions = [ "31" ]; + # cmakeVersions = [ "3.10.2" ]; + # emulatorVersion = "30.3.4"; + # includeExtras = [ "extras;google;gcm" ]; + # ndkVersions = ["22.0.7026061"]; + # systemImageTypes = [ "google_apis_playstore" ]; + }; + in + { + devShells.${system} = { + default = pkgs.mkShell rec { + nativeBuildInputs = with pkgs; [ + android-tools + androidSdk + glibc + gnumake + jdk + ]; + buildInputs = with pkgs; [ ]; - ANDROID_SDK_ROOT = "${androidSdk}/libexec/android-sdk/"; - GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride = ${androidSdk}/libexec/android-sdk/build-tools/${buildTools}/aapt2"; - JAVA_HOME = "${jdk}"; - LD_LIBRARY_PATH = "${lib.makeLibraryPath buildInputs}"; - SOURCE_DATE_EPOCH = "${toString self.lastModified}"; - }; - }; - }; + ANDROID_SDK_ROOT = "${androidSdk}/libexec/android-sdk/"; + GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride = ${androidSdk}/libexec/android-sdk/build-tools/${buildTools}/aapt2"; + JAVA_HOME = "${jdk}"; + LD_LIBRARY_PATH = "${lib.makeLibraryPath buildInputs}"; + SOURCE_DATE_EPOCH = "${toString self.lastModified}"; + }; + }; + }; } diff --git a/home/file/template/DevShell.nix b/home/file/template/DevShell.nix index 1d6700ea..ad4f58ce 100644 --- a/home/file/template/DevShell.nix +++ b/home/file/template/DevShell.nix @@ -1,23 +1,26 @@ { - description = ""; + description = ""; - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - }; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + }; - outputs = { self, nixpkgs } @inputs: let - lib = nixpkgs.lib; - pkgs = nixpkgs.legacyPackages.${system}; - system = "x86_64-linux"; - in { - devShells.${system} = { - default = pkgs.mkShell rec { - nativeBuildInputs = with pkgs; [ ]; - buildInputs = with pkgs; [ ]; + outputs = + { self, nixpkgs }@inputs: + let + lib = nixpkgs.lib; + pkgs = nixpkgs.legacyPackages.${system}; + system = "x86_64-linux"; + in + { + devShells.${system} = { + default = pkgs.mkShell rec { + nativeBuildInputs = with pkgs; [ ]; + buildInputs = with pkgs; [ ]; - LD_LIBRARY_PATH = "${lib.makeLibraryPath buildInputs}"; - SOURCE_DATE_EPOCH = "${toString self.lastModified}"; - }; - }; - }; + LD_LIBRARY_PATH = "${lib.makeLibraryPath buildInputs}"; + SOURCE_DATE_EPOCH = "${toString self.lastModified}"; + }; + }; + }; } diff --git a/home/file/template/FHSEnv.nix b/home/file/template/FHSEnv.nix index d2161639..a4bed08b 100644 --- a/home/file/template/FHSEnv.nix +++ b/home/file/template/FHSEnv.nix @@ -1,20 +1,25 @@ { - description = ""; + description = ""; - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - }; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + }; - outputs = { self, nixpkgs } @inputs: let - lib = nixpkgs.lib; - pkgs = nixpkgs.legacyPackages.${system}; - system = "x86_64-linux"; - in { - devShells.${system} = { - default = with pkgs; (buildFHSEnv { - name = "FHSEnv"; - targetPkgs = pkgs: with pkgs; [ ]; - }).env; - }; - }; + outputs = + { self, nixpkgs }@inputs: + let + lib = nixpkgs.lib; + pkgs = nixpkgs.legacyPackages.${system}; + system = "x86_64-linux"; + in + { + devShells.${system} = { + default = + with pkgs; + (buildFHSEnv { + name = "FHSEnv"; + targetPkgs = pkgs: with pkgs; [ ]; + }).env; + }; + }; } diff --git a/home/file/template/Latex.nix b/home/file/template/Latex.nix index d1f49419..d9922b85 100644 --- a/home/file/template/Latex.nix +++ b/home/file/template/Latex.nix @@ -1,57 +1,59 @@ { - description = "LuaLaTeX build env."; + description = "LuaLaTeX build env."; - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - }; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + }; - outputs = { self, nixpkgs } @inputs: let - lib = nixpkgs.lib; - pkgs = nixpkgs.legacyPackages.${system}; - system = "x86_64-linux"; - tex = ( - pkgs.texlive.combine { - inherit (pkgs.texlive) - amsmath - babel - capt-of - catchfile - collection-fontsextra - cyrillic - dvipng - dvisvgm - environ - etoolbox - fancyhdr - fontspec - geometry - hyperref - listofitems - luacode - luatexbase - montserrat - parskip - pgf - scheme-basic - tcolorbox - tocloft - ulem - wrapfig - xcolor - ; + outputs = + { self, nixpkgs }@inputs: + let + lib = nixpkgs.lib; + pkgs = nixpkgs.legacyPackages.${system}; + system = "x86_64-linux"; + tex = ( + pkgs.texlive.combine { + inherit (pkgs.texlive) + amsmath + babel + capt-of + catchfile + collection-fontsextra + cyrillic + dvipng + dvisvgm + environ + etoolbox + fancyhdr + fontspec + geometry + hyperref + listofitems + luacode + luatexbase + montserrat + parskip + pgf + scheme-basic + tcolorbox + tocloft + ulem + wrapfig + xcolor + ; - #(setq org-latex-compiler "lualatex") - #(setq org-preview-latex-default-process 'dvisvgm) - } - ); - in - { - devShells.${system} = { - default = pkgs.mkShell rec { - nativeBuildInputs = with pkgs; [ tex ]; - buildInputs = with pkgs; [ ]; - SOURCE_DATE_EPOCH = "${toString self.lastModified}"; - }; - }; - }; + #(setq org-latex-compiler "lualatex") + #(setq org-preview-latex-default-process 'dvisvgm) + } + ); + in + { + devShells.${system} = { + default = pkgs.mkShell rec { + nativeBuildInputs = with pkgs; [ tex ]; + buildInputs = with pkgs; [ ]; + SOURCE_DATE_EPOCH = "${toString self.lastModified}"; + }; + }; + }; } diff --git a/home/file/template/Rust.nix b/home/file/template/Rust.nix index 94346768..7012ffb4 100644 --- a/home/file/template/Rust.nix +++ b/home/file/template/Rust.nix @@ -1,37 +1,40 @@ { - description = "Rust shell env."; + description = "Rust shell env."; - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - }; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + }; - outputs = { self, nixpkgs } @inputs: let - lib = nixpkgs.lib; - pkgs = nixpkgs.legacyPackages.${system}; - system = "x86_64-linux"; - in { - devShell.${system} = pkgs.mkShell rec { - nativeBuildInputs = with pkgs; [ - cargo - cmake - fontconfig - pkg-config - rust-analyzer - rustc - rustfmt - ]; - buildInputs = with pkgs; [ - libGL - libxkbcommon - wayland - xorg.libX11 - xorg.libXcursor - xorg.libXi - xorg.libXinerama - xorg.libXrandr - ]; - LD_LIBRARY_PATH = "${lib.makeLibraryPath buildInputs}"; - SOURCE_DATE_EPOCH = "${toString self.lastModified}"; - }; - }; + outputs = + { self, nixpkgs }@inputs: + let + lib = nixpkgs.lib; + pkgs = nixpkgs.legacyPackages.${system}; + system = "x86_64-linux"; + in + { + devShell.${system} = pkgs.mkShell rec { + nativeBuildInputs = with pkgs; [ + cargo + cmake + fontconfig + pkg-config + rust-analyzer + rustc + rustfmt + ]; + buildInputs = with pkgs; [ + libGL + libxkbcommon + wayland + xorg.libX11 + xorg.libXcursor + xorg.libXi + xorg.libXinerama + xorg.libXrandr + ]; + LD_LIBRARY_PATH = "${lib.makeLibraryPath buildInputs}"; + SOURCE_DATE_EPOCH = "${toString self.lastModified}"; + }; + }; } diff --git a/home/file/tmux/default.nix b/home/file/tmux/default.nix index 0f43d621..7f756ad3 100644 --- a/home/file/tmux/default.nix +++ b/home/file/tmux/default.nix @@ -1,7 +1,4 @@ +{ util, config, ... }@args: { - util, - config, - ... -} @args: { - text = util.catText (util.ls ./module) args; + text = util.catText (util.ls ./module) args; } diff --git a/home/file/tmux/module/Config.nix b/home/file/tmux/module/Config.nix index 57863a5c..3b7f4a7c 100644 --- a/home/file/tmux/module/Config.nix +++ b/home/file/tmux/module/Config.nix @@ -1,8 +1,9 @@ -{ ... }: { - text = '' - unbind-key C-b - set-option -g prefix C-[ - bind-key C-[ send-prefix - bind -n M-r source-file ~/.config/tmux/tmux.conf - ''; +{ ... }: +{ + text = '' + unbind-key C-b + set-option -g prefix C-[ + bind-key C-[ send-prefix + bind -n M-r source-file ~/.config/tmux/tmux.conf + ''; } diff --git a/home/file/tmux/module/Copy.nix b/home/file/tmux/module/Copy.nix index c9836272..4377e195 100644 --- a/home/file/tmux/module/Copy.nix +++ b/home/file/tmux/module/Copy.nix @@ -1,9 +1,10 @@ -{ ... }: { - text = '' - setw -g mode-keys vi - bind -n M-v copy-mode - bind -n M-p choose-buffer; - bind -T copy-mode-vi v send -X begin-selection - bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy" - ''; +{ ... }: +{ + text = '' + setw -g mode-keys vi + bind -n M-v copy-mode + bind -n M-p choose-buffer; + bind -T copy-mode-vi v send -X begin-selection + bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy" + ''; } diff --git a/home/file/tmux/module/Env.nix b/home/file/tmux/module/Env.nix index 4e7ea758..513710ef 100644 --- a/home/file/tmux/module/Env.nix +++ b/home/file/tmux/module/Env.nix @@ -1,10 +1,11 @@ -{ ... }: { - text = '' - set -sg escape-time 0 - set-option -g default-terminal "tmux-256color" - set-option -g focus-events on - set-option -sa terminal-features "RGB" - set -g allow-passthrough on - set-option -g update-environment "SSH_CLIENT SSH_TTY DOCKER_CONFIG DOCKER_HOST DISPLAY XAUTHORITY BASH_PATH SWAY_SOCK TERM TERM_PROGRAM" - ''; +{ ... }: +{ + text = '' + set -sg escape-time 0 + set-option -g default-terminal "tmux-256color" + set-option -g focus-events on + set-option -sa terminal-features "RGB" + set -g allow-passthrough on + set-option -g update-environment "SSH_CLIENT SSH_TTY DOCKER_CONFIG DOCKER_HOST DISPLAY XAUTHORITY BASH_PATH SWAY_SOCK TERM TERM_PROGRAM" + ''; } diff --git a/home/file/tmux/module/Scroll.nix b/home/file/tmux/module/Scroll.nix index 7c7f362f..cf8a145b 100644 --- a/home/file/tmux/module/Scroll.nix +++ b/home/file/tmux/module/Scroll.nix @@ -1,6 +1,7 @@ -{ ... }: { - text = '' - bind -n M-K copy-mode -u - bind -n M-J send-keys Pagedown - ''; +{ ... }: +{ + text = '' + bind -n M-K copy-mode -u + bind -n M-J send-keys Pagedown + ''; } diff --git a/home/file/tmux/module/Session.nix b/home/file/tmux/module/Session.nix index 248c468d..4cf290b1 100644 --- a/home/file/tmux/module/Session.nix +++ b/home/file/tmux/module/Session.nix @@ -1,12 +1,13 @@ -{ ... }: { - text = '' - bind -n M-z detach-client - bind -n M-Z detach-client -a +{ ... }: +{ + text = '' + bind -n M-z detach-client + bind -n M-Z detach-client -a - bind -n M-, switch-client -p - bind -n M-. switch-client -n - bind -n M-g choose-session -Z + bind -n M-, switch-client -p + bind -n M-. switch-client -n + bind -n M-g choose-session -Z - set -g window-size smallest - ''; + set -g window-size smallest + ''; } diff --git a/home/file/tmux/module/Split.nix b/home/file/tmux/module/Split.nix index da56a06c..6bd1e752 100644 --- a/home/file/tmux/module/Split.nix +++ b/home/file/tmux/module/Split.nix @@ -1,31 +1,33 @@ -{ ... }: let - stepHorizontal = 1; - stepVertical = 1; -in { - text = '' - bind -n M-\\ split-window -h -c "#{pane_current_path}" - bind -n M-- split-window -v -c "#{pane_current_path}" - bind -n M-= select-layout tiled - bind -n M-_ select-layout even-vertical - bind -n M-| select-layout even-horizontal - bind -n M-+ select-layout main-vertical - bind -n M-k resize-pane -U ${toString stepVertical} - bind -n M-j resize-pane -D ${toString stepVertical} - bind -n M-h resize-pane -L ${toString stepHorizontal} - bind -n M-l resize-pane -R ${toString stepHorizontal} - bind -n M-A swap-pane -U - bind -n M-W swap-pane -U - bind -n M-D swap-pane -D - bind -n M-S swap-pane -D - unbind '"' - unbind % +{ ... }: +let + stepHorizontal = 1; + stepVertical = 1; +in +{ + text = '' + bind -n M-\\ split-window -h -c "#{pane_current_path}" + bind -n M-- split-window -v -c "#{pane_current_path}" + bind -n M-= select-layout tiled + bind -n M-_ select-layout even-vertical + bind -n M-| select-layout even-horizontal + bind -n M-+ select-layout main-vertical + bind -n M-k resize-pane -U ${toString stepVertical} + bind -n M-j resize-pane -D ${toString stepVertical} + bind -n M-h resize-pane -L ${toString stepHorizontal} + bind -n M-l resize-pane -R ${toString stepHorizontal} + bind -n M-A swap-pane -U + bind -n M-W swap-pane -U + bind -n M-D swap-pane -D + bind -n M-S swap-pane -D + unbind '"' + unbind % - bind -n M-a select-pane -L - bind -n M-d select-pane -R - bind -n M-w select-pane -U - bind -n M-s select-pane -D + bind -n M-a select-pane -L + bind -n M-d select-pane -R + bind -n M-w select-pane -U + bind -n M-s select-pane -D - bind -n M-c kill-pane - bind -n M-C kill-pane -a - ''; + bind -n M-c kill-pane + bind -n M-C kill-pane -a + ''; } diff --git a/home/file/tmux/module/Status.nix b/home/file/tmux/module/Status.nix index f2260304..e319118a 100644 --- a/home/file/tmux/module/Status.nix +++ b/home/file/tmux/module/Status.nix @@ -1,19 +1,20 @@ -{ ... }: { - text = '' - bind-key -n M-f set-option -g status; - set -g status-left-length 50 - set -g status-position bottom - set -g status-justify left +{ ... }: +{ + text = '' + bind-key -n M-f set-option -g status; + set -g status-left-length 50 + set -g status-position bottom + set -g status-justify left - set -g status-left "#[bold] #H-#S #[default]" - set -g status-right "" + set -g status-left "#[bold] #H-#S #[default]" + set -g status-right "" - set-window-option -g window-status-separator "" + set-window-option -g window-status-separator "" - setw -g window-status-current-format " #W " - setw -g window-status-format " #W " + setw -g window-status-current-format " #W " + setw -g window-status-format " #W " - set-window-option -g visual-bell off - setw -g window-status-bell-style "bold blink" - ''; + set-window-option -g visual-bell off + setw -g window-status-bell-style "bold blink" + ''; } diff --git a/home/file/tmux/module/Style.nix b/home/file/tmux/module/Style.nix index d08e4447..1053d2f2 100644 --- a/home/file/tmux/module/Style.nix +++ b/home/file/tmux/module/Style.nix @@ -1,37 +1,36 @@ +{ config, ... }: +let + accent = config.module.style.color.accent; + bg = config.module.style.color.bg.regular; + fg = config.module.style.color.fg.light; + selectionBg = config.module.style.color.selection; + selectionFg = config.module.style.color.fg.dark; +in { - config, - ... -}: let - accent = config.module.style.color.accent; - bg = config.module.style.color.bg.regular; - fg = config.module.style.color.fg.light; - selectionBg = config.module.style.color.selection; - selectionFg = config.module.style.color.fg.dark; -in { - # ISSUE: No way to specify `choose` mode style. - # SEE: https://github.com/tmux/tmux/issues/4264 - text = '' - set -g mode-style "fg=#${fg} bg=#${bg} bold" + # ISSUE: No way to specify `choose` mode style. + # SEE: https://github.com/tmux/tmux/issues/4264 + text = '' + set -g mode-style "fg=#${fg} bg=#${bg} bold" - setw -g window-status-current-style "fg=#${accent} bold" - setw -g window-status-style "" + setw -g window-status-current-style "fg=#${accent} bold" + setw -g window-status-style "" - set -g pane-border-style "fg=#${bg}" - set -g pane-active-border-style "fg=#${accent}" + set -g pane-border-style "fg=#${bg}" + set -g pane-active-border-style "fg=#${accent}" - set -g status-style "fg=#${fg}" + set -g status-style "fg=#${fg}" - set -g menu-style "fg=#${fg}" - set -g menu-selected-style "fg=#${fg} bg=#${bg} bold" - set -g menu-border-style "fg=#${bg}" + set -g menu-style "fg=#${fg}" + set -g menu-selected-style "fg=#${fg} bg=#${bg} bold" + set -g menu-border-style "fg=#${bg}" - set -g popup-style "fg=#${fg}" - set -g popup-border-style "fg=#${bg}" + set -g popup-style "fg=#${fg}" + set -g popup-border-style "fg=#${bg}" - set -g display-panes-colour "#${bg}" - set -g display-panes-active-colour "#${accent}" + set -g display-panes-colour "#${bg}" + set -g display-panes-active-colour "#${accent}" - set -g copy-mode-position-style "fg=#${selectionBg} bg=#${selectionFg} bold" - set -g copy-mode-selection-style "fg=#${selectionFg} bg=#${selectionBg} bold" - ''; + set -g copy-mode-position-style "fg=#${selectionBg} bg=#${selectionFg} bold" + set -g copy-mode-selection-style "fg=#${selectionFg} bg=#${selectionBg} bold" + ''; } diff --git a/home/file/tmux/module/Window.nix b/home/file/tmux/module/Window.nix index f8721c8b..5adfeb27 100644 --- a/home/file/tmux/module/Window.nix +++ b/home/file/tmux/module/Window.nix @@ -1,15 +1,16 @@ -{ ... }: { - text = '' - bind -n M-Escape new-window -c "#{pane_current_path}" - bind -n M-t new-window -c "#{pane_current_path}" +{ ... }: +{ + text = '' + bind -n M-Escape new-window -c "#{pane_current_path}" + bind -n M-t new-window -c "#{pane_current_path}" - bind -n M-x kill-window - bind -n M-X kill-window -a + bind -n M-x kill-window + bind -n M-X kill-window -a - bind -n M-e next-window - bind -n M-q previous-window + bind -n M-e next-window + bind -n M-q previous-window - bind -n M-E swap-window -t +1\; select-window -t +1 - bind -n M-Q swap-window -t -1\; select-window -t -1 - ''; + bind -n M-E swap-window -t +1\; select-window -t +1 + bind -n M-Q swap-window -t -1\; select-window -t -1 + ''; } diff --git a/home/file/waybar/config/default.nix b/home/file/waybar/config/default.nix index f56d11f4..fad4f837 100644 --- a/home/file/waybar/config/default.nix +++ b/home/file/waybar/config/default.nix @@ -1,206 +1,202 @@ +{ config, pkgs, ... }: +let + refreshInterval = 2; +in { - config, - pkgs, - ... -}: let - refreshInterval = 2; -in { - file = (pkgs.formats.json { }).generate "WaybarConfig" { - height = 34; - layer = "top"; - margin-left = config.module.style.window.gap; - margin-right = config.module.style.window.gap; - margin-top = config.module.style.window.gap; - mode = "dock"; - position = "top"; - spacing = 4; - start_hidden = false; - output = [ - config.module.display.primary - ]; - modules-left = [ - "clock" - "sway/scratchpad" - "mpris" - ]; - modules-center = [ - "sway/workspaces" - ]; - modules-right = [ - "group/hardware" - "group/batteryinfo" - "pulseaudio" - "custom/display" - "custom/network" - ]; - "sway/workspaces" = { - all-outputs = true; - }; - "sway/scratchpad" = { - format = "{icon} {count}"; - on-click = "swaymsg 'scratchpad show'"; - on-click-middle = "swayscript scratchpad_kill"; - show-empty = false; - tooltip = true; - tooltip-format = "{app}: {title}"; - format-icons = [ - "" - "" - ]; - }; - clock = { - format-alt = "{:%H:%M %a %d %b}"; - on-click-right = "xdg-open https://cloud.voronind.com/apps/calendar/"; - tooltip-format = "{calendar}"; - }; - battery = { - format = "{capacity}% {icon}"; - format-alt = "{time} {icon}"; - format-charging = "{capacity}% "; - format-plugged = "{capacity}% "; - interval = refreshInterval; - on-click-right = "powerlimit toggle"; - states = { - good = 60; - warning = 40; - critical = 20; - }; - format-icons = [ - "󰂎" - "󱊡" - "󱊢" - "󱊣" - "󱊣" - ]; - }; - "custom/powerlimit" = { - exec = "powerlimit widget"; - hide-empty-text = false; - on-click-right = "powerlimit toggle"; - signal = 6; - tooltip = false; - }; - "group/batteryinfo" = { - orientation = "horizontal"; - modules = [ - "custom/tagbt1" - "battery" - "custom/powerlimit" - "custom/tagbt2" - ]; - }; - pulseaudio = { - format = "{volume}%{icon}{format_source}"; - format-muted = "󰸈{format_source}"; - format-source = ""; - format-source-muted = " 󰍭"; - on-click = "pavucontrol"; - on-click-middle = "pactl set-sink-mute @DEFAULT_SINK@ toggle"; - on-click-right = "pactl set-source-mute @DEFAULT_SOURCE@ toggle"; - scroll-step = 5; - }; - mpris = let - maxLength = 32; - in { - album-len = maxLength; - artist-len = maxLength; - format = "{player_icon} {title} - {artist}"; - format-paused = "{status_icon} {title} - {artist}"; - on-click-middle = "playerctl stop"; - title-len = maxLength; - tooltip-format = "{player}: {dynamic}"; - player-icons = { - "default" = ""; - "firefox" = "󰈹"; - "mpv" = ""; - }; - status-icons = { - "paused" = ""; - }; - }; - "cpu#usage" = { - format = "{usage}%"; - interval = refreshInterval; - on-click = "foot -e bash -c btop"; - on-click-right = "powersave toggle"; - states.critical = 100; - tooltip = false; - }; - "cpu#load" = { - format = "({load})"; - interval = refreshInterval; - on-click = "foot -e bash -c btop"; - on-click-right = "powersave toggle"; - tooltip = false; - }; - memory = { - format = "{percentage}%"; - interval = refreshInterval; - on-click = "foot -e bash -c btop"; - on-click-right = "powersave toggle"; - states.critical = 80; - }; - temperature = { - critical-threshold = 80; - format = "{temperatureC}°C"; - hwmon-path-abs = "${config.module.hwmon.path}"; - input-filename = "${config.module.hwmon.file}"; - interval = refreshInterval; - on-click = "foot -e bash -c btop"; - on-click-right = "powersave toggle"; - tooltip = false; - }; - "custom/powersave" = { - exec = "powersave widget"; - on-click = "foot -e bash -c btop"; - on-click-right = "powersave toggle"; - signal = 5; - tooltip = false; - }; - "group/hardware" = { - orientation = "horizontal"; - modules = [ - "custom/taghw1" - "cpu#usage" - "cpu#load" - "temperature" - "memory" - "custom/powersave" - "custom/taghw2" - ]; - }; - "custom/display" = { - exec = "swayscript displaywidget"; - on-click = "sleep 0.1 && swayscript dnd"; # HACK: https://github.com/Alexays/Waybar/issues/2166 & https://github.com/Alexays/Waybar/issues/1968 - on-click-middle = "sleep 0.1 && swayscript displayreset"; - on-click-right = "sleep 0.1 && swayscript monitor"; - return-type = "json"; - signal = 4; - }; - "custom/network" = { - exec = "swayscript networkwidget"; - # interval = refreshInterval; - on-click = "blueman-manager"; - on-click-middle = "swayscript network"; - on-click-right = "nm-connection-editor"; - return-type = "json"; - signal = 7; - }; - "custom/taghw1" = { - exec = "echo ​"; - tooltip = false; - }; - "custom/taghw2" = { - exec = "echo ​"; - tooltip = false; - }; - "custom/tagbt1" = { - exec = "test -e /sys/class/power_supply/BAT*/capacity && echo ​"; - tooltip = false; - }; - "custom/tagbt2" = { - exec = "test -e /sys/class/power_supply/BAT*/capacity && echo ​"; - tooltip = false; - }; - }; + file = (pkgs.formats.json { }).generate "WaybarConfig" { + height = 34; + layer = "top"; + margin-left = config.module.style.window.gap; + margin-right = config.module.style.window.gap; + margin-top = config.module.style.window.gap; + mode = "dock"; + position = "top"; + spacing = 4; + start_hidden = false; + output = [ config.module.display.primary ]; + modules-left = [ + "clock" + "sway/scratchpad" + "mpris" + ]; + modules-center = [ "sway/workspaces" ]; + modules-right = [ + "group/hardware" + "group/batteryinfo" + "pulseaudio" + "custom/display" + "custom/network" + ]; + "sway/workspaces" = { + all-outputs = true; + }; + "sway/scratchpad" = { + format = "{icon} {count}"; + on-click = "swaymsg 'scratchpad show'"; + on-click-middle = "swayscript scratchpad_kill"; + show-empty = false; + tooltip = true; + tooltip-format = "{app}: {title}"; + format-icons = [ + "" + "" + ]; + }; + clock = { + format-alt = "{:%H:%M %a %d %b}"; + on-click-right = "xdg-open https://cloud.voronind.com/apps/calendar/"; + tooltip-format = "{calendar}"; + }; + battery = { + format = "{capacity}% {icon}"; + format-alt = "{time} {icon}"; + format-charging = "{capacity}% "; + format-plugged = "{capacity}% "; + interval = refreshInterval; + on-click-right = "powerlimit toggle"; + states = { + good = 60; + warning = 40; + critical = 20; + }; + format-icons = [ + "󰂎" + "󱊡" + "󱊢" + "󱊣" + "󱊣" + ]; + }; + "custom/powerlimit" = { + exec = "powerlimit widget"; + hide-empty-text = false; + on-click-right = "powerlimit toggle"; + signal = 6; + tooltip = false; + }; + "group/batteryinfo" = { + orientation = "horizontal"; + modules = [ + "custom/tagbt1" + "battery" + "custom/powerlimit" + "custom/tagbt2" + ]; + }; + pulseaudio = { + format = "{volume}%{icon}{format_source}"; + format-muted = "󰸈{format_source}"; + format-source = ""; + format-source-muted = " 󰍭"; + on-click = "pavucontrol"; + on-click-middle = "pactl set-sink-mute @DEFAULT_SINK@ toggle"; + on-click-right = "pactl set-source-mute @DEFAULT_SOURCE@ toggle"; + scroll-step = 5; + }; + mpris = + let + maxLength = 32; + in + { + album-len = maxLength; + artist-len = maxLength; + format = "{player_icon} {title} - {artist}"; + format-paused = "{status_icon} {title} - {artist}"; + on-click-middle = "playerctl stop"; + title-len = maxLength; + tooltip-format = "{player}: {dynamic}"; + player-icons = { + "default" = ""; + "firefox" = "󰈹"; + "mpv" = ""; + }; + status-icons = { + "paused" = ""; + }; + }; + "cpu#usage" = { + format = "{usage}%"; + interval = refreshInterval; + on-click = "foot -e bash -c btop"; + on-click-right = "powersave toggle"; + states.critical = 100; + tooltip = false; + }; + "cpu#load" = { + format = "({load})"; + interval = refreshInterval; + on-click = "foot -e bash -c btop"; + on-click-right = "powersave toggle"; + tooltip = false; + }; + memory = { + format = "{percentage}%"; + interval = refreshInterval; + on-click = "foot -e bash -c btop"; + on-click-right = "powersave toggle"; + states.critical = 80; + }; + temperature = { + critical-threshold = 80; + format = "{temperatureC}°C"; + hwmon-path-abs = "${config.module.hwmon.path}"; + input-filename = "${config.module.hwmon.file}"; + interval = refreshInterval; + on-click = "foot -e bash -c btop"; + on-click-right = "powersave toggle"; + tooltip = false; + }; + "custom/powersave" = { + exec = "powersave widget"; + on-click = "foot -e bash -c btop"; + on-click-right = "powersave toggle"; + signal = 5; + tooltip = false; + }; + "group/hardware" = { + orientation = "horizontal"; + modules = [ + "custom/taghw1" + "cpu#usage" + "cpu#load" + "temperature" + "memory" + "custom/powersave" + "custom/taghw2" + ]; + }; + "custom/display" = { + exec = "swayscript displaywidget"; + on-click = "sleep 0.1 && swayscript dnd"; # HACK: https://github.com/Alexays/Waybar/issues/2166 & https://github.com/Alexays/Waybar/issues/1968 + on-click-middle = "sleep 0.1 && swayscript displayreset"; + on-click-right = "sleep 0.1 && swayscript monitor"; + return-type = "json"; + signal = 4; + }; + "custom/network" = { + exec = "swayscript networkwidget"; + # interval = refreshInterval; + on-click = "blueman-manager"; + on-click-middle = "swayscript network"; + on-click-right = "nm-connection-editor"; + return-type = "json"; + signal = 7; + }; + "custom/taghw1" = { + exec = "echo ​"; + tooltip = false; + }; + "custom/taghw2" = { + exec = "echo ​"; + tooltip = false; + }; + "custom/tagbt1" = { + exec = "test -e /sys/class/power_supply/BAT*/capacity && echo ​"; + tooltip = false; + }; + "custom/tagbt2" = { + exec = "test -e /sys/class/power_supply/BAT*/capacity && echo ​"; + tooltip = false; + }; + }; } diff --git a/home/file/waybar/default.nix b/home/file/waybar/default.nix index 69c0a9f4..d314fbe7 100644 --- a/home/file/waybar/default.nix +++ b/home/file/waybar/default.nix @@ -1,8 +1,5 @@ +{ util, pkgs, ... }@args: { - util, - pkgs, - ... -} @args: { - config = (import ./config args).file; - style = pkgs.writeText "WaybarStyle" (util.catText (util.ls ./style) args); + config = (import ./config args).file; + style = pkgs.writeText "WaybarStyle" (util.catText (util.ls ./style) args); } diff --git a/home/file/waybar/style/Common.nix b/home/file/waybar/style/Common.nix index 14fea4f1..d9d09cd6 100644 --- a/home/file/waybar/style/Common.nix +++ b/home/file/waybar/style/Common.nix @@ -1,12 +1,10 @@ +{ config, ... }: { - config, - ... -}: { - text = '' - * { - font-family: "${config.module.style.font.serif.name}", "Terminess Nerd Font Propo"; - font-size: ${toString config.module.style.font.size.desktop}px; - color: #${config.module.style.color.fg.light}; - } - ''; + text = '' + * { + font-family: "${config.module.style.font.serif.name}", "Terminess Nerd Font Propo"; + font-size: ${toString config.module.style.font.size.desktop}px; + color: #${config.module.style.color.fg.light}; + } + ''; } diff --git a/home/file/waybar/style/Plugin.nix b/home/file/waybar/style/Plugin.nix index 9837bb64..21470066 100644 --- a/home/file/waybar/style/Plugin.nix +++ b/home/file/waybar/style/Plugin.nix @@ -1,96 +1,95 @@ +{ config, ... }: +let + paddingH = "12px"; + paddingV = "0"; +in { - config, - ... -}: let - paddingH = "12px"; - paddingV = "0"; -in { - # ISSUE: https://github.com/Alexays/Waybar/issues/3303 - # This way I am forced to apply the padding to children of each group - # instead of the whole group. - text = '' - /* See the ISSUE above. */ - #custom-taghw1, - #custom-tagbt1 { - padding-left: ${paddingH}; - } + # ISSUE: https://github.com/Alexays/Waybar/issues/3303 + # This way I am forced to apply the padding to children of each group + # instead of the whole group. + text = '' + /* See the ISSUE above. */ + #custom-taghw1, + #custom-tagbt1 { + padding-left: ${paddingH}; + } - #custom-taghw2, - #custom-tagbt2 { - padding-right: ${paddingH}; - } + #custom-taghw2, + #custom-tagbt2 { + padding-right: ${paddingH}; + } - /* Padding for global widgets. */ - #clock, - #custom-display, - #custom-network, - #mpris, - #pulseaudio, - #scratchpad { - padding: ${paddingV} ${paddingH}; - } + /* Padding for global widgets. */ + #clock, + #custom-display, + #custom-network, + #mpris, + #pulseaudio, + #scratchpad { + padding: ${paddingV} ${paddingH}; + } - /* Padding for combined widgets. */ - #cpu.load, - #custom-powerlimit, - #custom-powersave, - #memory, - #temperature { - padding-left: 4px; - } + /* Padding for combined widgets. */ + #cpu.load, + #custom-powerlimit, + #custom-powersave, + #memory, + #temperature { + padding-left: 4px; + } - /* Hover style. */ - #batteryinfo:hover, - #clock:hover, - #custom-display:hover, - #custom-network:hover, - #hardware:hover, - #mpris:hover, - #pulseaudio:hover, - #scratchpad:hover, - #workspaces button:hover { - background-color: rgba(${config.module.style.color.borderR},${config.module.style.color.borderG},${config.module.style.color.borderB},${toString config.module.style.opacity.desktop}); - } + /* Hover style. */ + #batteryinfo:hover, + #clock:hover, + #custom-display:hover, + #custom-network:hover, + #hardware:hover, + #mpris:hover, + #pulseaudio:hover, + #scratchpad:hover, + #workspaces button:hover { + background-color: rgba(${config.module.style.color.borderR},${config.module.style.color.borderG},${config.module.style.color.borderB},${toString config.module.style.opacity.desktop}); + } - /* Critical state. */ - #battery, - #cpu.usage, - #custom-display, - #custom-network, - #memory, - #pulseaudio, - #temperature { - border-top: ${toString config.module.style.window.border}px solid transparent; - border-bottom: ${toString config.module.style.window.border}px solid transparent; - } + /* Critical state. */ + #battery, + #cpu.usage, + #custom-display, + #custom-network, + #memory, + #pulseaudio, + #temperature { + border-top: ${toString config.module.style.window.border}px solid transparent; + border-bottom: ${toString config.module.style.window.border}px solid transparent; + } - #battery.critical, - #cpu.usage.critical, - #custom-display.modified, - #custom-network.issue, - #custom-network.vpn, - #custom-network.btlow, - #memory.critical, - #pulseaudio.muted, - #pulseaudio.source-muted, - #temperature.critical { - border-top: ${toString config.module.style.window.border}px solid #${config.module.style.color.accent}; - } + #battery.critical, + #cpu.usage.critical, + #custom-display.modified, + #custom-network.issue, + #custom-network.vpn, + #custom-network.btlow, + #memory.critical, + #pulseaudio.muted, + #pulseaudio.source-muted, + #temperature.critical { + border-top: ${toString config.module.style.window.border}px solid #${config.module.style.color.accent}; + } - /* Widget-specific styling. */ - #workspaces button { - padding: ${paddingV} 4px; - border-top: ${toString config.module.style.window.border}px solid transparent; - border-bottom: ${toString config.module.style.window.border}px solid transparent; - border-radius: 0; - } + /* Widget-specific styling. */ + #workspaces button { + padding: ${paddingV} 4px; + border-top: ${toString config.module.style.window.border}px solid transparent; + border-bottom: ${toString config.module.style.window.border}px solid transparent; + border-radius: 0; + } - #workspaces button.focused { - border-top: ${toString config.module.style.window.border}px solid #${config.module.style.color.accent}; - } + #workspaces button.focused { + border-top: ${toString config.module.style.window.border}px solid #${config.module.style.color.accent}; + } - #clock { - font-weight: bold; - } - ''; + #clock { + font-weight: bold; + } + ''; } diff --git a/home/file/waybar/style/Window.nix b/home/file/waybar/style/Window.nix index 9b78e183..fef9880b 100644 --- a/home/file/waybar/style/Window.nix +++ b/home/file/waybar/style/Window.nix @@ -1,19 +1,17 @@ +{ config, ... }: { - config, - ... -}: { - text = '' - window#waybar { - background-color: rgba(${config.module.style.color.bgR},${config.module.style.color.bgG},${config.module.style.color.bgB},${toString config.module.style.opacity.desktop}); - border: ${toString config.module.style.window.border}px solid rgba(${config.module.style.color.borderR},${config.module.style.color.borderG},${config.module.style.color.borderB},${toString config.module.style.opacity.desktop}); - } + text = '' + window#waybar { + background-color: rgba(${config.module.style.color.bgR},${config.module.style.color.bgG},${config.module.style.color.bgB},${toString config.module.style.opacity.desktop}); + border: ${toString config.module.style.window.border}px solid rgba(${config.module.style.color.borderR},${config.module.style.color.borderG},${config.module.style.color.borderB},${toString config.module.style.opacity.desktop}); + } - .modules-left > widget:first-child > #workspaces { - margin-left: ${toString config.module.style.window.border}px; - } + .modules-left > widget:first-child > #workspaces { + margin-left: ${toString config.module.style.window.border}px; + } - .modules-right > widget:last-child > #workspaces { - margin-right: ${toString config.module.style.window.border}px; - } - ''; + .modules-right > widget:last-child > #workspaces { + margin-right: ${toString config.module.style.window.border}px; + } + ''; } diff --git a/home/file/yazi/default.nix b/home/file/yazi/default.nix index 8f633aca..ef168cc5 100644 --- a/home/file/yazi/default.nix +++ b/home/file/yazi/default.nix @@ -1,11 +1,12 @@ { - config, - pkgs, - util, - ... -} @args: { - init = (import ./module/Init.nix args).file; - keymap = (import ./module/Keymap.nix args).file; - theme = (import ./module/Theme.nix args).file; - yazi = (import ./module/Yazi.nix args).file; + config, + pkgs, + util, + ... +}@args: +{ + init = (import ./module/Init.nix args).file; + keymap = (import ./module/Keymap.nix args).file; + theme = (import ./module/Theme.nix args).file; + yazi = (import ./module/Yazi.nix args).file; } diff --git a/home/file/yazi/module/Init.nix b/home/file/yazi/module/Init.nix index 56282207..8e745c94 100644 --- a/home/file/yazi/module/Init.nix +++ b/home/file/yazi/module/Init.nix @@ -1,13 +1,11 @@ +{ pkgs, ... }: { - pkgs, - ... -}: { - file = pkgs.writeText "YaziInitConfig" '' - -- Hide Status Bar. - -- function Status:render() return {} end - -- local old_manager_render = Manager.render - -- function Manager:render(area) - -- return old_manager_render(self, ui.Rect { x = area.x, y = area.y, w = area.w, h = area.h + 1 }) - -- end - ''; + file = pkgs.writeText "YaziInitConfig" '' + -- Hide Status Bar. + -- function Status:render() return {} end + -- local old_manager_render = Manager.render + -- function Manager:render(area) + -- return old_manager_render(self, ui.Rect { x = area.x, y = area.y, w = area.w, h = area.h + 1 }) + -- end + ''; } diff --git a/home/file/yazi/module/Keymap.nix b/home/file/yazi/module/Keymap.nix index 60bb9a9a..33f978c6 100644 --- a/home/file/yazi/module/Keymap.nix +++ b/home/file/yazi/module/Keymap.nix @@ -1,40 +1,182 @@ +{ pkgs, ... }: { - pkgs, - ... -}: { - # REF: https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/keymap.toml - file = (pkgs.formats.toml { }).generate "YaziKeymapConfig" { - manager = { - prepend_keymap = [ - { on = ""; desc = "Spawn shell here"; run = ''shell "SHELL_NAME=yazi $SHELL" --block --confirm''; } - { on = ""; desc = "New tab"; run = "tab_create --current"; } - { on = "?"; desc = "Show help"; run = "help"; } - { on = "D"; desc = "Force delete"; run = "remove --permanently --force"; } - { on = "E"; desc = "Move to next tab"; run = "tab_swap 1 --relative"; } - { on = "O"; desc = "Open default"; run = "open"; } - { on = "Q"; desc = "Move to prev tab"; run = "tab_swap -1 --relative"; } - { on = "R"; desc = "Rename completely"; run = "rename --empty=stem --cursor=start"; } - { on = "Z"; desc = "Exit yazi"; run = "quit"; } - { on = "="; desc = "Hardlink"; run = "hardlink --follow"; } - { on = "d"; desc = "Delete"; run = "remove --permanently"; } - { on = "e"; desc = "Next tab"; run = "tab_switch 1 --relative"; } - { on = "o"; desc = "Open interactively"; run = "open --interactive"; } - { on = "q"; desc = "Prev tab"; run = "tab_switch -1 --relative"; } - { on = "z"; desc = "Close tab"; run = "close"; } - { on = [ "g" "M" ]; desc = "Go to mnt"; run = "cd /mnt"; } - { on = [ "g" "R" ]; desc = "Go to root"; run = "cd /"; } - { on = [ "g" "S" ]; desc = "Go to storage"; run = "cd /storage"; } - { on = [ "g" "T" ]; desc = "Go to system tmp"; run = "cd /tmp"; } - { on = [ "g" "U" ]; desc = "Go to user"; run = "cd /run/user/$UID"; } - # { on = [ "g" "c" ]; desc = "Go to configs"; run = "noop"; } - { on = [ "g" "d" ]; desc = "Go to downloads"; run = "cd $XDG_DOWNLOAD_DIR"; } - { on = [ "g" "l" ]; desc = "Go to locker"; run = "cd ~/locker"; } - { on = [ "g" "n" ]; desc = "Go to nix"; run = "cd ~/nix"; } - { on = [ "g" "p" ]; desc = "Go to project"; run = "cd ~/project"; } - { on = [ "g" "s" ]; desc = "Go to sync"; run = "cd ~/sync"; } - { on = [ "g" "t" ]; desc = "Go to tmp"; run = "cd ~/tmp"; } - { on = [ "g" "w" ]; desc = "Go to game"; run = "cd ~/game"; } - ]; - }; - }; + # REF: https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/keymap.toml + file = (pkgs.formats.toml { }).generate "YaziKeymapConfig" { + manager = { + prepend_keymap = [ + { + on = ""; + desc = "Spawn shell here"; + run = ''shell "SHELL_NAME=yazi $SHELL" --block --confirm''; + } + { + on = ""; + desc = "New tab"; + run = "tab_create --current"; + } + { + on = "?"; + desc = "Show help"; + run = "help"; + } + { + on = "D"; + desc = "Force delete"; + run = "remove --permanently --force"; + } + { + on = "E"; + desc = "Move to next tab"; + run = "tab_swap 1 --relative"; + } + { + on = "O"; + desc = "Open default"; + run = "open"; + } + { + on = "Q"; + desc = "Move to prev tab"; + run = "tab_swap -1 --relative"; + } + { + on = "R"; + desc = "Rename completely"; + run = "rename --empty=stem --cursor=start"; + } + { + on = "Z"; + desc = "Exit yazi"; + run = "quit"; + } + { + on = "="; + desc = "Hardlink"; + run = "hardlink --follow"; + } + { + on = "d"; + desc = "Delete"; + run = "remove --permanently"; + } + { + on = "e"; + desc = "Next tab"; + run = "tab_switch 1 --relative"; + } + { + on = "o"; + desc = "Open interactively"; + run = "open --interactive"; + } + { + on = "q"; + desc = "Prev tab"; + run = "tab_switch -1 --relative"; + } + { + on = "z"; + desc = "Close tab"; + run = "close"; + } + { + on = [ + "g" + "M" + ]; + desc = "Go to mnt"; + run = "cd /mnt"; + } + { + on = [ + "g" + "R" + ]; + desc = "Go to root"; + run = "cd /"; + } + { + on = [ + "g" + "S" + ]; + desc = "Go to storage"; + run = "cd /storage"; + } + { + on = [ + "g" + "T" + ]; + desc = "Go to system tmp"; + run = "cd /tmp"; + } + { + on = [ + "g" + "U" + ]; + desc = "Go to user"; + run = "cd /run/user/$UID"; + } + # { on = [ "g" "c" ]; desc = "Go to configs"; run = "noop"; } + { + on = [ + "g" + "d" + ]; + desc = "Go to downloads"; + run = "cd $XDG_DOWNLOAD_DIR"; + } + { + on = [ + "g" + "l" + ]; + desc = "Go to locker"; + run = "cd ~/locker"; + } + { + on = [ + "g" + "n" + ]; + desc = "Go to nix"; + run = "cd ~/nix"; + } + { + on = [ + "g" + "p" + ]; + desc = "Go to project"; + run = "cd ~/project"; + } + { + on = [ + "g" + "s" + ]; + desc = "Go to sync"; + run = "cd ~/sync"; + } + { + on = [ + "g" + "t" + ]; + desc = "Go to tmp"; + run = "cd ~/tmp"; + } + { + on = [ + "g" + "w" + ]; + desc = "Go to game"; + run = "cd ~/game"; + } + ]; + }; + }; } diff --git a/home/file/yazi/module/Theme.nix b/home/file/yazi/module/Theme.nix index cf8e4f78..a260e458 100644 --- a/home/file/yazi/module/Theme.nix +++ b/home/file/yazi/module/Theme.nix @@ -1,121 +1,121 @@ +{ pkgs, config, ... }: +let + color = config.module.style.color; + border = { + fg = "#${color.border}"; + }; + borderLight = { + fg = "#${color.accent}"; + }; + hover = { + bg = "#${color.bg.regular}"; + fg = "#${color.fg.light}"; + }; + select = { + bg = "#${color.selection}"; + fg = "#${color.fg.dark}"; + bold = true; + }; + text = { + fg = "#${color.fg.light}"; + }; +in { - pkgs, - config, - ... -}: let - color = config.module.style.color; - border = { - fg = "#${color.border}"; - }; - borderLight = { - fg = "#${color.accent}"; - }; - hover = { - bg = "#${color.bg.regular}"; - fg = "#${color.fg.light}"; - }; - select = { - bg = "#${color.selection}"; - fg = "#${color.fg.dark}"; - bold = true; - }; - text = { - fg = "#${color.fg.light}"; - }; -in { - # REF: https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/theme.toml - file = (pkgs.formats.toml { }).generate "YaziThemeConfig" { - manager = let - mkMarker = markerColor: { - bg = "#${markerColor}"; - fg = "#${markerColor}"; - }; + # REF: https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/theme.toml + file = (pkgs.formats.toml { }).generate "YaziThemeConfig" { + manager = + let + mkMarker = markerColor: { + bg = "#${markerColor}"; + fg = "#${markerColor}"; + }; - mkCounter = counterColor: { - bg = "#${counterColor}"; - fg = "#${color.fg.light}"; - }; - in { - border_style = border; - border_symbol = " "; - count_copied = mkCounter color.positive; - count_cut = mkCounter color.negative; - count_selected = mkCounter color.neutral; - cwd = text; - hovered = hover; - marker_copied = mkMarker color.accent; - marker_cut = mkMarker color.accent; - marker_marked = mkMarker color.highlight; - marker_selected = mkMarker color.selection; - preview_hovered = hover; - tab_active = mkCounter color.selection; - }; - select = { - active = select; - border = borderLight; - inactive = text; - }; - input = { - border = borderLight; # ISSUE: Currently broken, stays blue. - selected = select; - title = borderLight; - value = text; - }; - completion = { - active = hover; - border = borderLight; - inactive = text; - }; - tasks = { - border = borderLight; - hovered = hover; - title = borderLight; - }; - which = { - cand = text; - cols = 3; - desc = text; - mask = hover; - rest = text; - separator = " - "; - separator_style = text; - }; - help = { - desc = text; - footer = text; - hovered = hover; - on = text; - run = text; - }; - confirm = { - border = borderLight; - title = borderLight; - }; - status = { - mode_normal = hover; - mode_select = select; - permissions_r = text; - permissions_s = text; - permissions_t = text; - permissions_w = text; - permissions_x = text; - progress_label = hover; - progress_normal = hover; - separator_close = ""; - separator_open = ""; - # NOTE: Inversed because yazi dev is fckin weird. Also add manpages ffs. - separator_style = { - bg = "#${config.module.style.color.fg.light}"; - fg = "#${config.module.style.color.bg.regular}"; - }; - mode_unset = { - bg = "#${config.module.style.color.neutral}"; - fg = "#${config.module.style.color.fg.light}"; - }; - progress_error = { - bg = "#${config.module.style.color.negative}"; - fg = "#${config.module.style.color.fg.light}"; - }; - }; - }; + mkCounter = counterColor: { + bg = "#${counterColor}"; + fg = "#${color.fg.light}"; + }; + in + { + border_style = border; + border_symbol = " "; + count_copied = mkCounter color.positive; + count_cut = mkCounter color.negative; + count_selected = mkCounter color.neutral; + cwd = text; + hovered = hover; + marker_copied = mkMarker color.accent; + marker_cut = mkMarker color.accent; + marker_marked = mkMarker color.highlight; + marker_selected = mkMarker color.selection; + preview_hovered = hover; + tab_active = mkCounter color.selection; + }; + select = { + active = select; + border = borderLight; + inactive = text; + }; + input = { + border = borderLight; # ISSUE: Currently broken, stays blue. + selected = select; + title = borderLight; + value = text; + }; + completion = { + active = hover; + border = borderLight; + inactive = text; + }; + tasks = { + border = borderLight; + hovered = hover; + title = borderLight; + }; + which = { + cand = text; + cols = 3; + desc = text; + mask = hover; + rest = text; + separator = " - "; + separator_style = text; + }; + help = { + desc = text; + footer = text; + hovered = hover; + on = text; + run = text; + }; + confirm = { + border = borderLight; + title = borderLight; + }; + status = { + mode_normal = hover; + mode_select = select; + permissions_r = text; + permissions_s = text; + permissions_t = text; + permissions_w = text; + permissions_x = text; + progress_label = hover; + progress_normal = hover; + separator_close = ""; + separator_open = ""; + # NOTE: Inversed because yazi dev is fckin weird. Also add manpages ffs. + separator_style = { + bg = "#${config.module.style.color.fg.light}"; + fg = "#${config.module.style.color.bg.regular}"; + }; + mode_unset = { + bg = "#${config.module.style.color.neutral}"; + fg = "#${config.module.style.color.fg.light}"; + }; + progress_error = { + bg = "#${config.module.style.color.negative}"; + fg = "#${config.module.style.color.fg.light}"; + }; + }; + }; } diff --git a/home/file/yazi/module/Yazi.nix b/home/file/yazi/module/Yazi.nix index 2b144ed1..77e09652 100644 --- a/home/file/yazi/module/Yazi.nix +++ b/home/file/yazi/module/Yazi.nix @@ -1,176 +1,236 @@ +{ pkgs, ... }: { - pkgs, - ... -}: { - # REF: https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/yazi.toml - file = (pkgs.formats.toml { }).generate "YaziYaziConfig" { - manager = { - # linemode = "mtime"; - mouse_events = [ ]; - ratio = [ 1 4 3 ]; - scrolloff = 1; - show_hidden = false; - show_symlink = true; - sort_by = "natural"; - sort_dir_first = true; - sort_sensitive = true; - sort_translit = true; - }; + # REF: https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/yazi.toml + file = (pkgs.formats.toml { }).generate "YaziYaziConfig" { + manager = { + # linemode = "mtime"; + mouse_events = [ ]; + ratio = [ + 1 + 4 + 3 + ]; + scrolloff = 1; + show_hidden = false; + show_symlink = true; + sort_by = "natural"; + sort_dir_first = true; + sort_sensitive = true; + sort_translit = true; + }; - preview = { - # image_filter = "triangle"; - image_filter = "lanczos3"; - image_quality = 80; - }; + preview = { + # image_filter = "triangle"; + image_filter = "lanczos3"; + image_quality = 80; + }; - opener = let - openWith = app: "${app} \"$@\""; - in { - default = [{ - desc = "Default"; - orphan = true; - run = openWith "xdg-open"; - }]; - archive = [{ - desc = "Archive"; - run = openWith "archive"; - }]; - archive_fast = [{ - desc = "Archive Fast"; - run = openWith "archive_fast"; - }]; - audio = [{ - desc = "Audio"; - orphan = true; - run = openWith "mpv --no-video"; - }]; - audio_shuffle = [{ - desc = "Audio Shuffle"; - orphan = true; - run = "mpv --no-video --shuffle \"$@\"/**"; - }]; - browser = [{ - desc = "Browser"; - orphan = true; - run = openWith "firefox-esr"; - }]; - document = [{ - desc = "Document"; - orphan = true; - run = openWith "onlyoffice-desktopeditors"; - }]; - hex = [{ - desc = "Hex"; - block = true; - run = openWith "radare2 -c V -w"; - }]; - picture = [{ - desc = "Picture"; - orphan = true; - run = openWith "loupe"; - }]; - picture_edit = [{ - desc = "Picture Edit"; - orphan = true; - run = openWith "gimp"; - }]; - picture_edit_quick = [{ - desc = "Picture Quick Edit"; - orphan = true; - run = openWith "pic_edit"; - }]; - picture_copy = [{ - desc = "Picture Copy"; - run = openWith "pic_copy"; - }]; - mount = [{ - desc = "Mount"; - run = openWith "fmount"; - }]; - pdf = [{ - desc = "Pdf"; - orphan = true; - run = openWith "evince"; - }]; - switch_install = [{ - desc = "Switch Install"; - run = openWith "switch_install"; - }]; - steam_run = [{ - desc = "Run"; - run = openWith "steam-run"; - }]; - bottle_run = [{ - desc = "Run bottle"; - run = openWith "btp"; - }]; - unlock = [{ - desc = "Unlock"; - block = true; - run = openWith "funlock"; - }]; - text = [{ - desc = "Text"; - block = true; - run = openWith "nvim"; - }]; - video = [{ - desc = "Video"; - orphan = true; - run = openWith "mpv"; - }]; - unpack = [{ - desc = "Unpack"; - run = openWith "unpack"; - }]; - }; + opener = + let + openWith = app: "${app} \"$@\""; + in + { + default = [ + { + desc = "Default"; + orphan = true; + run = openWith "xdg-open"; + } + ]; + archive = [ + { + desc = "Archive"; + run = openWith "archive"; + } + ]; + archive_fast = [ + { + desc = "Archive Fast"; + run = openWith "archive_fast"; + } + ]; + audio = [ + { + desc = "Audio"; + orphan = true; + run = openWith "mpv --no-video"; + } + ]; + audio_shuffle = [ + { + desc = "Audio Shuffle"; + orphan = true; + run = "mpv --no-video --shuffle \"$@\"/**"; + } + ]; + browser = [ + { + desc = "Browser"; + orphan = true; + run = openWith "firefox-esr"; + } + ]; + document = [ + { + desc = "Document"; + orphan = true; + run = openWith "onlyoffice-desktopeditors"; + } + ]; + hex = [ + { + desc = "Hex"; + block = true; + run = openWith "radare2 -c V -w"; + } + ]; + picture = [ + { + desc = "Picture"; + orphan = true; + run = openWith "loupe"; + } + ]; + picture_edit = [ + { + desc = "Picture Edit"; + orphan = true; + run = openWith "gimp"; + } + ]; + picture_edit_quick = [ + { + desc = "Picture Quick Edit"; + orphan = true; + run = openWith "pic_edit"; + } + ]; + picture_copy = [ + { + desc = "Picture Copy"; + run = openWith "pic_copy"; + } + ]; + mount = [ + { + desc = "Mount"; + run = openWith "fmount"; + } + ]; + pdf = [ + { + desc = "Pdf"; + orphan = true; + run = openWith "evince"; + } + ]; + switch_install = [ + { + desc = "Switch Install"; + run = openWith "switch_install"; + } + ]; + steam_run = [ + { + desc = "Run"; + run = openWith "steam-run"; + } + ]; + bottle_run = [ + { + desc = "Run bottle"; + run = openWith "btp"; + } + ]; + unlock = [ + { + desc = "Unlock"; + block = true; + run = openWith "funlock"; + } + ]; + text = [ + { + desc = "Text"; + block = true; + run = openWith "nvim"; + } + ]; + video = [ + { + desc = "Video"; + orphan = true; + run = openWith "mpv"; + } + ]; + unpack = [ + { + desc = "Unpack"; + run = openWith "unpack"; + } + ]; + }; - open = { - rules = let - defaultUse = [ - "text" - "archive_fast" - "hex" - ]; - mkMime = mime: use: { - inherit mime; - use = use ++ defaultUse; - }; - mkName = name: use: { - inherit name; - use = use ++ defaultUse; - }; - in [ - (mkName "*.xlsx" [ "document" ]) - (mkName "*.mka" [ "audio" ]) - (mkName "*.nsp" [ "switch_install" ]) - (mkName "*.nsz" [ "switch_install" ]) + open = { + rules = + let + defaultUse = [ + "text" + "archive_fast" + "hex" + ]; + mkMime = mime: use: { + inherit mime; + use = use ++ defaultUse; + }; + mkName = name: use: { + inherit name; + use = use ++ defaultUse; + }; + in + [ + (mkName "*.xlsx" [ "document" ]) + (mkName "*.mka" [ "audio" ]) + (mkName "*.nsp" [ "switch_install" ]) + (mkName "*.nsz" [ "switch_install" ]) - # Use `file -i file.txt` to find file mime type. - # Use `xdg-mime query default "text/plain"` to find default app. - (mkMime "application/gzip" [ "unpack" ]) - (mkMime "application/x-tar" [ "unpack" ]) - (mkMime "application/x-xz" [ "unpack" ]) - (mkMime "application/zip" [ "unpack" ]) - (mkMime "application/x-7z-compressed" [ "unpack" ]) - (mkMime "application/x-iso9660-image" [ "mount" ]) - (mkMime "application/x-raw-disk-image" [ "unlock" ]) - (mkMime "application/pdf" [ "pdf" ]) - (mkMime "audio/*" [ "audio" ]) - (mkMime "image/*" [ "picture" "picture_copy" "picture_edit" "picture_edit_quick" ]) - (mkMime "video/*" [ "video" ]) - (mkMime "text/html" [ "browser" ]) - (mkMime "application/vnd.openxmlformats-officedocument.*" [ "document" ]) - (mkMime "application/x-executable" [ "steam_run" ]) + # Use `file -i file.txt` to find file mime type. + # Use `xdg-mime query default "text/plain"` to find default app. + (mkMime "application/gzip" [ "unpack" ]) + (mkMime "application/x-tar" [ "unpack" ]) + (mkMime "application/x-xz" [ "unpack" ]) + (mkMime "application/zip" [ "unpack" ]) + (mkMime "application/x-7z-compressed" [ "unpack" ]) + (mkMime "application/x-iso9660-image" [ "mount" ]) + (mkMime "application/x-raw-disk-image" [ "unlock" ]) + (mkMime "application/pdf" [ "pdf" ]) + (mkMime "audio/*" [ "audio" ]) + (mkMime "image/*" [ + "picture" + "picture_copy" + "picture_edit" + "picture_edit_quick" + ]) + (mkMime "video/*" [ "video" ]) + (mkMime "text/html" [ "browser" ]) + (mkMime "application/vnd.openxmlformats-officedocument.*" [ "document" ]) + (mkMime "application/x-executable" [ "steam_run" ]) - { mime = "inode/directory"; use = [ "archive" "bottle_run" "audio_shuffle" ]; } - (mkMime "*" [ ]) - ]; - }; + { + mime = "inode/directory"; + use = [ + "archive" + "bottle_run" + "audio_shuffle" + ]; + } + (mkMime "*" [ ]) + ]; + }; - which = { - sort_by = "key"; - sort_sensitive = false; - }; - }; + which = { + sort_by = "key"; + sort_sensitive = false; + }; + }; } diff --git a/home/program/bash/default.nix b/home/program/bash/default.nix index 5e0627e2..9bc695cc 100644 --- a/home/program/bash/default.nix +++ b/home/program/bash/default.nix @@ -1,42 +1,42 @@ +{ util, pkgs, ... }@args: +let + modules = util.catText (util.ls ./module) args; + modulesFile = pkgs.writeText "BashModules" modules; +in { - util, - pkgs, - ... -} @args: let - modules = util.catText (util.ls ./module) args; - modulesFile = pkgs.writeText "BashModules" modules; -in { - inherit modules modulesFile; + inherit modules modulesFile; - bashrc = modules + '' - # Find all functions. - function find_function() { - /usr/bin/env cat ${modulesFile} | /usr/bin/env grep "^function.*()" | /usr/bin/env sed -e "s/^function //" -e "s/().*//" - } + bashrc = + modules + + '' + # Find all functions. + function find_function() { + /usr/bin/env cat ${modulesFile} | /usr/bin/env grep "^function.*()" | /usr/bin/env sed -e "s/^function //" -e "s/().*//" + } - # Export all functions. - export -f $(find_function | tr '\n' ' ') - export -f find_function + # Export all functions. + export -f $(find_function | tr '\n' ' ') + export -f find_function - # Autostart Sway. - if [[ -z $DISPLAY ]] && [[ "$(tty)" = "/dev/tty1" ]]; then - exec sway - fi - ''; + # Autostart Sway. + if [[ -z $DISPLAY ]] && [[ "$(tty)" = "/dev/tty1" ]]; then + exec sway + fi + ''; - # bash_profile = '' - # # Home manager. - # [ -e ~/.nix-profile/etc/profile.d/nix.sh ] && source ~/.nix-profile/etc/profile.d/nix.sh + # bash_profile = '' + # # Home manager. + # [ -e ~/.nix-profile/etc/profile.d/nix.sh ] && source ~/.nix-profile/etc/profile.d/nix.sh - # # Bashrc. - # [ -f ~/.bashrc ] && source ~/.bashrc + # # Bashrc. + # [ -f ~/.bashrc ] && source ~/.bashrc - # # Profile. - # [ -f ~/.profile ] && source ~/.profile - # ''; + # # Profile. + # [ -f ~/.profile ] && source ~/.profile + # ''; - # profile = '' - # # Load HM vars. - # [ -e ~/.nix-profile/etc/profile.d/hm-session-vars.sh ] && source ~/.nix-profile/etc/profile.d/hm-session-vars.sh - # ''; + # profile = '' + # # Load HM vars. + # [ -e ~/.nix-profile/etc/profile.d/hm-session-vars.sh ] && source ~/.nix-profile/etc/profile.d/hm-session-vars.sh + # ''; } diff --git a/home/program/bash/module/Archive.nix b/home/program/bash/module/Archive.nix index 6e8606eb..b0ed304f 100644 --- a/home/program/bash/module/Archive.nix +++ b/home/program/bash/module/Archive.nix @@ -1,422 +1,423 @@ -{ ... }: { - text = '' - export _archive_pattern="_[0-9]{12}-[[:alnum:]]{40}" - export _archive_pattern_compressed="_[0-9]{12}-[[:alnum:]]{40}\.t(ar|gz|xz)$" - export _archive_pattern_fast="_[0-9]{12}-[[:alnum:]]{40}\.tar$" - - # Archive using multiple threads. Uses 75% of free RAM. - # All directories by default. - # Supports .archiveignore exclude file. - # Usage: archive [DIRS] - function archive() { - local IFS=$'\n' - local targets=(''${@}) - [[ "''${targets}" = "" ]] && targets=($(_ls_dir)) - - process() { - # Skip if already an archive. - _is_archive "''${target}" && { - _iterate_skip "Already an archive." - return 0 - }; - - # Cut full paths. - [[ "''${target##*/}" = "" ]] || target="''${target##*/}" - - local date=$(_archive_date) - - # Parse name. - local name=$(parse_pascal ''${target}) - - # Exclude support. - local exclude="" - [[ -f ".archiveignore" ]] && exclude="--exclude-from=.archiveignore" - [[ -f "''${target}/.archiveignore" ]] && exclude="--exclude-from=''${target}/.archiveignore" - - # Create archive. - local hash=$(tar ''${exclude} -c ''${target} | pv -s $(/usr/bin/env du -sb ''${target} | awk '{print $1}') | xz -9e --threads=0 --memlimit=$(_archive_memlimit) | tee ''${name}.txz | sha1sum | cut -d\ -f1) - - # Append hash to target name. - local new_name="''${name}_''${date}-''${hash}.txz" - mv -- ''${name}.txz ''${new_name} && echo ''${new_name} - } - - _iterate_targets process ''${targets[@]} - } - - # Creates a simple archive. - # If it is a file, it just reformats file name to match archive name. - # For dirs, it first creates a tar archive. - # All files by default. - # Usage: archive_fast [DIRS] - function archive_fast() { - local IFS=$'\n' - local targets=("''${@}") - [[ "''${targets}" = "" ]] && targets=($(_ls_file)) - - process() { - # Skip if already an archive. - _is_archive "''${target}" && { - _iterate_skip "Already an archive." - return 0 - }; - - # Cut full paths. - [[ "''${target##*/}" = "" ]] || target="''${target##*/}" - - # Start timestamp. - local date=$(_archive_date) - - # Exclude support. - local exclude - [[ -f ".archiveignore" ]] && exclude="--exclude-from=.archiveignore" - [[ -f "''${target}/.archiveignore" ]] && exclude="--exclude-from=''${target}/.archiveignore" - - local name - local extension - - if [[ -d "''${target}" ]]; then - name=$(parse_pascal "''${target}") - - # Create archive. - local hash=$(tar ''${exclude} -c "''${target}" | pv -s $(/usr/bin/env du -sb "''${target}" | awk '{print $1}') | tee "''${name}".tar | sha1sum | cut -d\ -f1) - - # Append hash to target name. - local new_name="''${name}_''${date}-''${hash}.tar" - mv -- "''${name}".tar ''${new_name} && echo ''${new_name} - else - name=$(parse_pascal "''${target%.*}") - extension=".''${target##*.}" - - # Check if extension matches name, then drop it. - [[ "''${extension}" = ".''${target%.*}" ]] && extension="" - - local hash=$(pv "''${target}" | sha1sum | cut -d\ -f1) - local new_name="''${name}_''${date}-''${hash}''${extension}" - mv -- "''${target}" "''${new_name}" && echo ''${new_name} - fi - } - - _iterate_targets process ''${targets[@]} - } - - # Check archives integrity. - # Checks all archives by default. - # Usage: archive_check [FILES] - function archive_check() { - local IFS=$'\n' - local targets=(''${@}) - [[ "''${targets}" = "" ]] && targets=($(_ls_archive)) - - process() { - _archive_check "''${target}" - } - - _iterate_targets process ''${targets[@]} - } - - # Delete old versions of an archive. - # All archives with 1 version by default. - # Usage: archive_prune [NAME] [VERSIONS] - function archive_prune() { - local IFS=$'\n' - local targets=(''${1}) - local versions=''${2} - - [[ "''${targets}" = "" ]] && targets=($(_archive_names)) - [[ "''${versions}" = "" ]] && versions=1 - - if [[ ''${#} -gt 2 ]]; then - help archive_prune - return 2 - fi - - process() { - local prune=($(ls | grep -E "^''${target}''${_archive_pattern}" | sort -r | sed -e "1,''${versions}d")) - - for archive in ''${prune[@]}; do - rm -- "''${archive}" && echo "''${archive}" - done - } - - _iterate_targets process ''${targets[@]} - } - - # Delete specified or all archive files. - # Usage: archive_rm [FILES] - function archive_rm() { - local IFS=$'\n' - local targets=(''${@}) - [[ "''${targets}" = "" ]] && targets=($(_ls_archive)) - - process() { - rm -- "''${target}" && echo "''${target}" - } - - _iterate_targets process ''${targets[@]} - } - - # Recompress previously created archive_fast with better compression. - # Usage: archive_compress [FILES] - function archive_compress() { - local IFS=$'\n' - local targets=(''${@}) - [[ "''${targets}" = "" ]] && targets=$(_ls_archive_fast) - - process() { - local data=($(_archive_parse "''${target}")) - local tmp="''${data[0]}.txz" - - # Check that old format. - if [[ "''${data[3]}" != "tar" ]]; then - _iterate_skip "Not in .tar format!" - return 0 - fi - - # Check integrity. - _archive_check "''${target}" || return 1 - - # Recompress. - local hash=$(pv "''${target}" | xz -9e --threads=0 --memlimit=$(_archive_memlimit) | tee "''${tmp}" | sha1sum | cut -d\ -f1) - - # Rename. - local new_name="''${data[0]}_''${data[1]}-''${hash}.txz" - mv -- ''${tmp} ''${new_name} && rm ''${target} && echo ''${new_name} - } - - _iterate_targets process ''${targets[@]} - } - - # Rename archives. - # If no name specified, it simplifies archive's name. - # If no archives specified, apply to all archives. - # Usage: archive_name [ARCHIVE] [NAME] - function archive_name() { - local IFS=$'\n' - local targets="''${1}" - local name="''${2}" - [[ "''${targets}" = "" ]] && targets=($(_ls_archive)) - - process() { - # Simplify name by default. - if [[ "''${name}" = "" || ''${count} -gt 1 ]]; then - name="''${target%_*}" - name="$(parse_pascal ''${name})" - fi - - # Remove old name. - local data="''${target##*_}" - local new_name="''${name}_''${data}" - - # Check for the same name. - [[ "''${target}" = "''${new_name}" ]] && return 0 - - # Check for existing target. - if [[ -f "''${new_name}" ]]; then - _error "''${new_name}: Already exists!" - return 1 - fi - - # Rename. - mv -- ''${target} ''${new_name} && echo ''${new_name} - } - - _iterate_targets process ''${targets[@]} - } - - # Extract previously created archive with checksum validation. - # Supports unarchiving exact paths from the remote machines (rsync syntax). - # Usage: unarchive [HOST:FILES] - function unarchive() { - local IFS=$'\n' - local targets=(''${@}) - [[ "''${targets}" = "" ]] && targets=$(_ls_archive_compressed) - - process() { - # Validate. - # _archive_check "''${target}" || return 1 - if ! _is_compressed_archive "''${target}"; then - _iterate_skip "Not a compressed archive." - return 0 - fi - - # Remote archives. - local remote - local file="''${target}" - - if [[ "''${target//\\:/}" == *:* ]]; then - local host="''${target%%:*}" - file="''${target#*:}" - remote=(trysudo ssh ''${host}) - fi - - # Extract. - case "''${file##*.}" in - "txz") - ''${remote[@]} pv -f ''${file} | xz -d | tar -xf - - ;; - "tar") - ''${remote[@]} pv -f ''${file} | tar -xf - - ;; - "tgz") - ''${remote[@]} pv -f ''${file} | gzip -d | tar -xf - - ;; - esac - } - - _iterate_targets process ''${targets[@]} - } - - # Change archive's filesystem time to match creation date. - # Usage: archive_touch [FILES] - function archive_touch() { - local IFS=$'\n' - local targets=(''${@}) - [[ "''${targets}" = "" ]] && targets=$(_ls_archive) - - process() { - local data=($(_archive_parse "''${target}")) - local date=''${data[1]} - touch -t ''${date} -- ''${target} - } - - _iterate_targets process ''${targets[@]} - } - - # Parse archive file name to get: name, date, hash and format. - # Usage: _archive_parse - function _archive_parse() { - local input="''${1}" - local name="''${input%_*}" - local format="''${input##*.}" - local data="''${input##*_}"; data="''${data%.*}" - local date="''${data%%-*}" - local hash="''${data##*-}" - - # No extension if no dots. - [[ "''${input}" = *\.* ]] || format="" - - echo "''${name}" - echo "''${date}" - echo "''${hash}" - echo "''${format}" - } - - # Autocomplete for archive_name function. - # First arg is the archives list, second one is selected archive's current name. - function _comp_archive_name() { - local IFS=$'\n' - COMPREPLY=() - - local cur="''${COMP_WORDS[COMP_CWORD]}" - local prev="''${COMP_WORDS[COMP_CWORD-1]}" - local command="''${COMP_WORDS[0]}" - - if [[ "''${prev}" = "''${command}" ]]; then - COMPREPLY=( $(compgen -W "$(ls | grep -E ''${_archive_pattern})" -- ''${cur}) ) - return 0 - else - local data=($(_archive_parse ''${prev})) - local name="''${data[0]}" - COMPREPLY=( $(compgen -W "''${name}" -- ''${cur}) ) - return 0 - fi - } - - # Autocomplete with archives in current dir. - function _comp_archive_grep() { - _autocomplete_grep ''${_archive_pattern} - } - - # Autocomplete with fast archives in current dir. - function _comp_archive_grep_fast() { - _autocomplete_grep ''${_archive_pattern_fast} - } - - # Get date for a new archive. - function _archive_date() { - date +%Y%m%d%H%M - } - - # Get names of all archives. - function _archive_names() { - local IFS=$'\n' - local archives=($(_ls_archive)) - local names=() - - for archive in ''${archives[@]}; do - local data=($(_archive_parse ''${archive})) - names+=(''${data[0]}) - done - - # Remove copies. - names=($(printf '%s\n' "''${names[@]}" | sort -u)) - - printf '%s\n' "''${names[@]}" - } - - # Autocomplete with names of all archives. - function _comp_archive_names() { - _autocomplete $(_archive_names) - } - - # Check if file is an archive. - function _is_archive() { - local target="''${*}" - local out=$(echo "''${target##*/}" | grep -E ''${_archive_pattern}) - - [[ "''${out}" != "" ]] - } - - # Check if file is a compressed archive. - function _is_compressed_archive() { - local out=$(echo "''${*}" | grep -E ''${_archive_pattern_compressed}) - - [[ "''${out}" != "" ]] - } - - # List all archives. - function _ls_archive() { - ls | grep -E ''${_archive_pattern} - } - - # List fast archives. - function _ls_archive_fast() { - ls | grep -E ''${_archive_pattern_fast} - } - - # List fast archives. - function _ls_archive_compressed() { - ls | grep -E ''${_archive_pattern_compressed} - } - - # Filter input for archives only. - function _filter_archive() { - grep -E ''${_archive_pattern} - } - - function _archive_memlimit() { - local mem_free=$(_mem_free) - local mem_limit=$((mem_free*3/4)) - - echo "''${mem_limit}MiB" - } - - function _archive_check() { - # Extract hash from name. - local data=($(_archive_parse ''${target})) - local saved=''${data[2]} - - # Calculate actual hash. - local actual=$(pv ''${target} | sha1sum | cut -d\ -f1) - - # Compare hashes. - [[ "''${actual}" = "''${saved}" ]] || _error "Archive check failed." - } - - # complete -o filenames -F _comp_archive_grep archive_check unarchive archive_rm archive_touch - # complete -o filenames -F _comp_archive_grep_fast archive_xz - complete -o filenames -F _comp_archive_name archive_name - complete -o filenames -F _comp_archive_names archive_prune - ''; +{ ... }: +{ + text = '' + export _archive_pattern="_[0-9]{12}-[[:alnum:]]{40}" + export _archive_pattern_compressed="_[0-9]{12}-[[:alnum:]]{40}\.t(ar|gz|xz)$" + export _archive_pattern_fast="_[0-9]{12}-[[:alnum:]]{40}\.tar$" + + # Archive using multiple threads. Uses 75% of free RAM. + # All directories by default. + # Supports .archiveignore exclude file. + # Usage: archive [DIRS] + function archive() { + local IFS=$'\n' + local targets=(''${@}) + [[ "''${targets}" = "" ]] && targets=($(_ls_dir)) + + process() { + # Skip if already an archive. + _is_archive "''${target}" && { + _iterate_skip "Already an archive." + return 0 + }; + + # Cut full paths. + [[ "''${target##*/}" = "" ]] || target="''${target##*/}" + + local date=$(_archive_date) + + # Parse name. + local name=$(parse_pascal ''${target}) + + # Exclude support. + local exclude="" + [[ -f ".archiveignore" ]] && exclude="--exclude-from=.archiveignore" + [[ -f "''${target}/.archiveignore" ]] && exclude="--exclude-from=''${target}/.archiveignore" + + # Create archive. + local hash=$(tar ''${exclude} -c ''${target} | pv -s $(/usr/bin/env du -sb ''${target} | awk '{print $1}') | xz -9e --threads=0 --memlimit=$(_archive_memlimit) | tee ''${name}.txz | sha1sum | cut -d\ -f1) + + # Append hash to target name. + local new_name="''${name}_''${date}-''${hash}.txz" + mv -- ''${name}.txz ''${new_name} && echo ''${new_name} + } + + _iterate_targets process ''${targets[@]} + } + + # Creates a simple archive. + # If it is a file, it just reformats file name to match archive name. + # For dirs, it first creates a tar archive. + # All files by default. + # Usage: archive_fast [DIRS] + function archive_fast() { + local IFS=$'\n' + local targets=("''${@}") + [[ "''${targets}" = "" ]] && targets=($(_ls_file)) + + process() { + # Skip if already an archive. + _is_archive "''${target}" && { + _iterate_skip "Already an archive." + return 0 + }; + + # Cut full paths. + [[ "''${target##*/}" = "" ]] || target="''${target##*/}" + + # Start timestamp. + local date=$(_archive_date) + + # Exclude support. + local exclude + [[ -f ".archiveignore" ]] && exclude="--exclude-from=.archiveignore" + [[ -f "''${target}/.archiveignore" ]] && exclude="--exclude-from=''${target}/.archiveignore" + + local name + local extension + + if [[ -d "''${target}" ]]; then + name=$(parse_pascal "''${target}") + + # Create archive. + local hash=$(tar ''${exclude} -c "''${target}" | pv -s $(/usr/bin/env du -sb "''${target}" | awk '{print $1}') | tee "''${name}".tar | sha1sum | cut -d\ -f1) + + # Append hash to target name. + local new_name="''${name}_''${date}-''${hash}.tar" + mv -- "''${name}".tar ''${new_name} && echo ''${new_name} + else + name=$(parse_pascal "''${target%.*}") + extension=".''${target##*.}" + + # Check if extension matches name, then drop it. + [[ "''${extension}" = ".''${target%.*}" ]] && extension="" + + local hash=$(pv "''${target}" | sha1sum | cut -d\ -f1) + local new_name="''${name}_''${date}-''${hash}''${extension}" + mv -- "''${target}" "''${new_name}" && echo ''${new_name} + fi + } + + _iterate_targets process ''${targets[@]} + } + + # Check archives integrity. + # Checks all archives by default. + # Usage: archive_check [FILES] + function archive_check() { + local IFS=$'\n' + local targets=(''${@}) + [[ "''${targets}" = "" ]] && targets=($(_ls_archive)) + + process() { + _archive_check "''${target}" + } + + _iterate_targets process ''${targets[@]} + } + + # Delete old versions of an archive. + # All archives with 1 version by default. + # Usage: archive_prune [NAME] [VERSIONS] + function archive_prune() { + local IFS=$'\n' + local targets=(''${1}) + local versions=''${2} + + [[ "''${targets}" = "" ]] && targets=($(_archive_names)) + [[ "''${versions}" = "" ]] && versions=1 + + if [[ ''${#} -gt 2 ]]; then + help archive_prune + return 2 + fi + + process() { + local prune=($(ls | grep -E "^''${target}''${_archive_pattern}" | sort -r | sed -e "1,''${versions}d")) + + for archive in ''${prune[@]}; do + rm -- "''${archive}" && echo "''${archive}" + done + } + + _iterate_targets process ''${targets[@]} + } + + # Delete specified or all archive files. + # Usage: archive_rm [FILES] + function archive_rm() { + local IFS=$'\n' + local targets=(''${@}) + [[ "''${targets}" = "" ]] && targets=($(_ls_archive)) + + process() { + rm -- "''${target}" && echo "''${target}" + } + + _iterate_targets process ''${targets[@]} + } + + # Recompress previously created archive_fast with better compression. + # Usage: archive_compress [FILES] + function archive_compress() { + local IFS=$'\n' + local targets=(''${@}) + [[ "''${targets}" = "" ]] && targets=$(_ls_archive_fast) + + process() { + local data=($(_archive_parse "''${target}")) + local tmp="''${data[0]}.txz" + + # Check that old format. + if [[ "''${data[3]}" != "tar" ]]; then + _iterate_skip "Not in .tar format!" + return 0 + fi + + # Check integrity. + _archive_check "''${target}" || return 1 + + # Recompress. + local hash=$(pv "''${target}" | xz -9e --threads=0 --memlimit=$(_archive_memlimit) | tee "''${tmp}" | sha1sum | cut -d\ -f1) + + # Rename. + local new_name="''${data[0]}_''${data[1]}-''${hash}.txz" + mv -- ''${tmp} ''${new_name} && rm ''${target} && echo ''${new_name} + } + + _iterate_targets process ''${targets[@]} + } + + # Rename archives. + # If no name specified, it simplifies archive's name. + # If no archives specified, apply to all archives. + # Usage: archive_name [ARCHIVE] [NAME] + function archive_name() { + local IFS=$'\n' + local targets="''${1}" + local name="''${2}" + [[ "''${targets}" = "" ]] && targets=($(_ls_archive)) + + process() { + # Simplify name by default. + if [[ "''${name}" = "" || ''${count} -gt 1 ]]; then + name="''${target%_*}" + name="$(parse_pascal ''${name})" + fi + + # Remove old name. + local data="''${target##*_}" + local new_name="''${name}_''${data}" + + # Check for the same name. + [[ "''${target}" = "''${new_name}" ]] && return 0 + + # Check for existing target. + if [[ -f "''${new_name}" ]]; then + _error "''${new_name}: Already exists!" + return 1 + fi + + # Rename. + mv -- ''${target} ''${new_name} && echo ''${new_name} + } + + _iterate_targets process ''${targets[@]} + } + + # Extract previously created archive with checksum validation. + # Supports unarchiving exact paths from the remote machines (rsync syntax). + # Usage: unarchive [HOST:FILES] + function unarchive() { + local IFS=$'\n' + local targets=(''${@}) + [[ "''${targets}" = "" ]] && targets=$(_ls_archive_compressed) + + process() { + # Validate. + # _archive_check "''${target}" || return 1 + if ! _is_compressed_archive "''${target}"; then + _iterate_skip "Not a compressed archive." + return 0 + fi + + # Remote archives. + local remote + local file="''${target}" + + if [[ "''${target//\\:/}" == *:* ]]; then + local host="''${target%%:*}" + file="''${target#*:}" + remote=(trysudo ssh ''${host}) + fi + + # Extract. + case "''${file##*.}" in + "txz") + ''${remote[@]} pv -f ''${file} | xz -d | tar -xf - + ;; + "tar") + ''${remote[@]} pv -f ''${file} | tar -xf - + ;; + "tgz") + ''${remote[@]} pv -f ''${file} | gzip -d | tar -xf - + ;; + esac + } + + _iterate_targets process ''${targets[@]} + } + + # Change archive's filesystem time to match creation date. + # Usage: archive_touch [FILES] + function archive_touch() { + local IFS=$'\n' + local targets=(''${@}) + [[ "''${targets}" = "" ]] && targets=$(_ls_archive) + + process() { + local data=($(_archive_parse "''${target}")) + local date=''${data[1]} + touch -t ''${date} -- ''${target} + } + + _iterate_targets process ''${targets[@]} + } + + # Parse archive file name to get: name, date, hash and format. + # Usage: _archive_parse + function _archive_parse() { + local input="''${1}" + local name="''${input%_*}" + local format="''${input##*.}" + local data="''${input##*_}"; data="''${data%.*}" + local date="''${data%%-*}" + local hash="''${data##*-}" + + # No extension if no dots. + [[ "''${input}" = *\.* ]] || format="" + + echo "''${name}" + echo "''${date}" + echo "''${hash}" + echo "''${format}" + } + + # Autocomplete for archive_name function. + # First arg is the archives list, second one is selected archive's current name. + function _comp_archive_name() { + local IFS=$'\n' + COMPREPLY=() + + local cur="''${COMP_WORDS[COMP_CWORD]}" + local prev="''${COMP_WORDS[COMP_CWORD-1]}" + local command="''${COMP_WORDS[0]}" + + if [[ "''${prev}" = "''${command}" ]]; then + COMPREPLY=( $(compgen -W "$(ls | grep -E ''${_archive_pattern})" -- ''${cur}) ) + return 0 + else + local data=($(_archive_parse ''${prev})) + local name="''${data[0]}" + COMPREPLY=( $(compgen -W "''${name}" -- ''${cur}) ) + return 0 + fi + } + + # Autocomplete with archives in current dir. + function _comp_archive_grep() { + _autocomplete_grep ''${_archive_pattern} + } + + # Autocomplete with fast archives in current dir. + function _comp_archive_grep_fast() { + _autocomplete_grep ''${_archive_pattern_fast} + } + + # Get date for a new archive. + function _archive_date() { + date +%Y%m%d%H%M + } + + # Get names of all archives. + function _archive_names() { + local IFS=$'\n' + local archives=($(_ls_archive)) + local names=() + + for archive in ''${archives[@]}; do + local data=($(_archive_parse ''${archive})) + names+=(''${data[0]}) + done + + # Remove copies. + names=($(printf '%s\n' "''${names[@]}" | sort -u)) + + printf '%s\n' "''${names[@]}" + } + + # Autocomplete with names of all archives. + function _comp_archive_names() { + _autocomplete $(_archive_names) + } + + # Check if file is an archive. + function _is_archive() { + local target="''${*}" + local out=$(echo "''${target##*/}" | grep -E ''${_archive_pattern}) + + [[ "''${out}" != "" ]] + } + + # Check if file is a compressed archive. + function _is_compressed_archive() { + local out=$(echo "''${*}" | grep -E ''${_archive_pattern_compressed}) + + [[ "''${out}" != "" ]] + } + + # List all archives. + function _ls_archive() { + ls | grep -E ''${_archive_pattern} + } + + # List fast archives. + function _ls_archive_fast() { + ls | grep -E ''${_archive_pattern_fast} + } + + # List fast archives. + function _ls_archive_compressed() { + ls | grep -E ''${_archive_pattern_compressed} + } + + # Filter input for archives only. + function _filter_archive() { + grep -E ''${_archive_pattern} + } + + function _archive_memlimit() { + local mem_free=$(_mem_free) + local mem_limit=$((mem_free*3/4)) + + echo "''${mem_limit}MiB" + } + + function _archive_check() { + # Extract hash from name. + local data=($(_archive_parse ''${target})) + local saved=''${data[2]} + + # Calculate actual hash. + local actual=$(pv ''${target} | sha1sum | cut -d\ -f1) + + # Compare hashes. + [[ "''${actual}" = "''${saved}" ]] || _error "Archive check failed." + } + + # complete -o filenames -F _comp_archive_grep archive_check unarchive archive_rm archive_touch + # complete -o filenames -F _comp_archive_grep_fast archive_xz + complete -o filenames -F _comp_archive_name archive_name + complete -o filenames -F _comp_archive_names archive_prune + ''; } diff --git a/home/program/bash/module/Ask.nix b/home/program/bash/module/Ask.nix index deade895..42e45450 100644 --- a/home/program/bash/module/Ask.nix +++ b/home/program/bash/module/Ask.nix @@ -1,27 +1,28 @@ -{ ... }: { - text = '' - # Ask general AI. - # Usage: ask - function ask() { - curl http://localhost:11434/api/generate -d "{ - \"model\":\"''${OLLAMA_MODEL}\", - \"raw\":true, - \"prompt\":\"''${*}\" - }" 2> /dev/null | parallel -j1 -- "printf '%s\n' {} | jq -r .response | sed -e 's/^$/\+\+\+/' | tr -d '\n' | sed -e 's/\+\+\+/\n/'" - echo - } +{ ... }: +{ + text = '' + # Ask general AI. + # Usage: ask + function ask() { + curl http://localhost:11434/api/generate -d "{ + \"model\":\"''${OLLAMA_MODEL}\", + \"raw\":true, + \"prompt\":\"''${*}\" + }" 2> /dev/null | parallel -j1 -- "printf '%s\n' {} | jq -r .response | sed -e 's/^$/\+\+\+/' | tr -d '\n' | sed -e 's/\+\+\+/\n/'" + echo + } - # Specify ask model. - function ask_model() { - export OLLAMA_MODEL="''${1}" - } + # Specify ask model. + function ask_model() { + export OLLAMA_MODEL="''${1}" + } - function _complete_ask_model() { - local IFS=$'\n' - local models=($(ollama list | sed -e "1d" | cut -f1)) - _autocomplete ''${models[@]} - } + function _complete_ask_model() { + local IFS=$'\n' + local models=($(ollama list | sed -e "1d" | cut -f1)) + _autocomplete ''${models[@]} + } - complete -F _complete_ask_model ask_model - ''; + complete -F _complete_ask_model ask_model + ''; } diff --git a/home/program/bash/module/Autocomplete.nix b/home/program/bash/module/Autocomplete.nix index 56b56c06..9fa6df9f 100644 --- a/home/program/bash/module/Autocomplete.nix +++ b/home/program/bash/module/Autocomplete.nix @@ -1,43 +1,44 @@ -{ ... }: { - text = '' - # Bash autocomplete. - # There are also options like -o nospace. see man for more info. - # Usage: _foo() { _autocomplete "{foo,bar}" } ; complete -F _foo foo - function _autocomplete() { - local iter use cur - cur=''${COMP_WORDS[COMP_CWORD]} - use="''${@//\\ /___}" - for iter in $use; do - if [[ $iter =~ ^$cur ]]; then - COMPREPLY+=( $(printf "%q" "''${iter//___/ }") ) - fi - done - } +{ ... }: +{ + text = '' + # Bash autocomplete. + # There are also options like -o nospace. see man for more info. + # Usage: _foo() { _autocomplete "{foo,bar}" } ; complete -F _foo foo + function _autocomplete() { + local iter use cur + cur=''${COMP_WORDS[COMP_CWORD]} + use="''${@//\\ /___}" + for iter in $use; do + if [[ $iter =~ ^$cur ]]; then + COMPREPLY+=( $(printf "%q" "''${iter//___/ }") ) + fi + done + } - # Autocomplete by grepping file names. - function _autocomplete_grep() { - local IFS=$'\n' - COMPREPLY=() + # Autocomplete by grepping file names. + function _autocomplete_grep() { + local IFS=$'\n' + COMPREPLY=() - local pattern="''${1}" - local candidates=$("$(ls | grep -E ''${pattern})") - _autocomplete ''${candidates} - } + local pattern="''${1}" + local candidates=$("$(ls | grep -E ''${pattern})") + _autocomplete ''${candidates} + } - # Autocomplete nested program. - function _autocomplete_nested() { - # local IFS=$'\n' - local cur prev words cword split i - _init_completion -s || return + # Autocomplete nested program. + function _autocomplete_nested() { + # local IFS=$'\n' + local cur prev words cword split i + _init_completion -s || return - for ((i = 1; i <= cword; i++)); do - if [[ ''${words[i]} != -* ]]; then - local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin - local root_command=''${words[i]} - _command_offset ''${i} - return - fi - done - } - ''; + for ((i = 1; i <= cword; i++)); do + if [[ ''${words[i]} != -* ]]; then + local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin + local root_command=''${words[i]} + _command_offset ''${i} + return + fi + done + } + ''; } diff --git a/home/program/bash/module/Battery.nix b/home/program/bash/module/Battery.nix index 4013582a..3ca1c899 100644 --- a/home/program/bash/module/Battery.nix +++ b/home/program/bash/module/Battery.nix @@ -1,16 +1,17 @@ -{ ... }: { - text = '' - # Print current battery charge level in percents. - function battery_level() { - head -c -1 /sys/class/power_supply/BAT*/capacity - echo '%' - } +{ ... }: +{ + text = '' + # Print current battery charge level in percents. + function battery_level() { + head -c -1 /sys/class/power_supply/BAT*/capacity + echo '%' + } - # Get battery's info. - function battery_info() { - local IFS=$'\n' - local battery=("$(upower --enumerate | grep battery_BAT)") - upower -i "''${battery[0]}" - } - ''; + # Get battery's info. + function battery_info() { + local IFS=$'\n' + local battery=("$(upower --enumerate | grep battery_BAT)") + upower -i "''${battery[0]}" + } + ''; } diff --git a/home/program/bash/module/Binwalk.nix b/home/program/bash/module/Binwalk.nix index 62ea87ab..70544bdf 100644 --- a/home/program/bash/module/Binwalk.nix +++ b/home/program/bash/module/Binwalk.nix @@ -1,10 +1,11 @@ -{ ... }: { - text = '' - # Extract all formats with binwalk. - # Use -M for recursive extract. - # Usage: binwalke - function binwalke() { - binwalk --dd='.*' "$@" - } - ''; +{ ... }: +{ + text = '' + # Extract all formats with binwalk. + # Use -M for recursive extract. + # Usage: binwalke + function binwalke() { + binwalk --dd='.*' "$@" + } + ''; } diff --git a/home/program/bash/module/Bottle.nix b/home/program/bash/module/Bottle.nix index ab9ed7b8..fbd646d6 100644 --- a/home/program/bash/module/Bottle.nix +++ b/home/program/bash/module/Bottle.nix @@ -1,89 +1,90 @@ -{ ... }: { - text = '' - # Switch bottle. - # Usage: bt - function bt() { - export SHELL_NAME="''${*}" - } +{ ... }: +{ + text = '' + # Switch bottle. + # Usage: bt + function bt() { + export SHELL_NAME="''${*}" + } - # Create new bottle. - # Usage: btc [ENV] [EXTRA] - function btc() { - local env="''${1}" - [[ "''${env}" = "" ]] && env="gaming" - bottles-cli new --bottle-name "''${SHELL_NAME}" --environment "''${env}" "''${@:2}" - } + # Create new bottle. + # Usage: btc [ENV] [EXTRA] + function btc() { + local env="''${1}" + [[ "''${env}" = "" ]] && env="gaming" + bottles-cli new --bottle-name "''${SHELL_NAME}" --environment "''${env}" "''${@:2}" + } - # Run a file inside a bottle. - # Usage: btre [EXTRA] - function btre() { - bottles-cli run -b "''${SHELL_NAME}" -e "''${@}" - } + # Run a file inside a bottle. + # Usage: btre [EXTRA] + function btre() { + bottles-cli run -b "''${SHELL_NAME}" -e "''${@}" + } - # Run a program inside a bottle. - # Usage: btr [EXTRA] - function btr() { - bottles-cli run -b "''${SHELL_NAME}" -p "''${@}" - } + # Run a program inside a bottle. + # Usage: btr [EXTRA] + function btr() { + bottles-cli run -b "''${SHELL_NAME}" -p "''${@}" + } - # List bottles. - function btl() { - bottles-cli list bottles 2> /dev/null - } + # List bottles. + function btl() { + bottles-cli list bottles 2> /dev/null + } - # List programs in a bottle. - function btlp() { - bottles-cli programs -b "''${SHELL_NAME}" 2> /dev/null - } + # List programs in a bottle. + function btlp() { + bottles-cli programs -b "''${SHELL_NAME}" 2> /dev/null + } - # Add a program to bottle. - # Usage: bta [EXTRA] - function bta() { - local name="''${1}" - local exe=$(realpath "''${2}") - if [[ "''${exe}" = "" ]]; then - help bta - return 2 - fi + # Add a program to bottle. + # Usage: bta [EXTRA] + function bta() { + local name="''${1}" + local exe=$(realpath "''${2}") + if [[ "''${exe}" = "" ]]; then + help bta + return 2 + fi - bottles-cli add -b "''${SHELL_NAME}" -n "''${name}" -p "''${exe}" "''${@:3}" 2> /dev/null - } + bottles-cli add -b "''${SHELL_NAME}" -n "''${name}" -p "''${exe}" "''${@:3}" 2> /dev/null + } - # Set bottle env var. - # Usage: bte - function bte() { - local env="''${1}" - if [[ "''${env}" = "" ]]; then - help bte - return 2 - fi + # Set bottle env var. + # Usage: bte + function bte() { + local env="''${1}" + if [[ "''${env}" = "" ]]; then + help bte + return 2 + fi - bottles-cli edit -b "''${SHELL_NAME}" --env-var "''${@}" 2> /dev/null - } + bottles-cli edit -b "''${SHELL_NAME}" --env-var "''${@}" 2> /dev/null + } - # Play bottle. - # Usage: btp - function btp() { - local bottle="''${1##*/}" - if [[ "''${bottle}" = "" ]]; then - help btp - return 2 - fi + # Play bottle. + # Usage: btp + function btp() { + local bottle="''${1##*/}" + if [[ "''${bottle}" = "" ]]; then + help btp + return 2 + fi - local program=$(bottles-cli programs -b "''${bottle}" 2> /dev/null | sed -n -e "s/^- //; 2p") - bottles-cli run -b "''${bottle}" -p "''${program}" - } + local program=$(bottles-cli programs -b "''${bottle}" 2> /dev/null | sed -n -e "s/^- //; 2p") + bottles-cli run -b "''${bottle}" -p "''${program}" + } - function _comp_bottles_list() { - _autocomplete $(bottles-cli list bottles 2> /dev/null | sed -e "1d; s/^- //") - } + function _comp_bottles_list() { + _autocomplete $(bottles-cli list bottles 2> /dev/null | sed -e "1d; s/^- //") + } - function _comp_programs_list() { - local IFS=$'\n' - _autocomplete $(bottles-cli programs -b "''${SHELL_NAME}" 2> /dev/null | sed -e "1d; s/^- //") - } + function _comp_programs_list() { + local IFS=$'\n' + _autocomplete $(bottles-cli programs -b "''${SHELL_NAME}" 2> /dev/null | sed -e "1d; s/^- //") + } - complete -F _comp_bottles_list bt btp - complete -F _comp_programs_list btr - ''; + complete -F _comp_bottles_list bt btp + complete -F _comp_programs_list btr + ''; } diff --git a/home/program/bash/module/Brightness.nix b/home/program/bash/module/Brightness.nix index e681f271..eb45300e 100644 --- a/home/program/bash/module/Brightness.nix +++ b/home/program/bash/module/Brightness.nix @@ -1,22 +1,23 @@ -{ ... }: { - text = '' - # Set display brightness to a minimum. - function brmin() { - light -S 0.01 - } +{ ... }: +{ + text = '' + # Set display brightness to a minimum. + function brmin() { + light -S 0.01 + } - # Set display brightness to a maximum. - function brmax() { - light -S 100 - } + # Set display brightness to a maximum. + function brmax() { + light -S 100 + } - # Set display brightness in percent, 50% default. - # Usage: brset [LEVEL] - function brset() { - local level=''${1} - [[ "''${level}" = "" ]] && level=50 + # Set display brightness in percent, 50% default. + # Usage: brset [LEVEL] + function brset() { + local level=''${1} + [[ "''${level}" = "" ]] && level=50 - light -S ''${level} - } - ''; + light -S ''${level} + } + ''; } diff --git a/home/program/bash/module/Cd.nix b/home/program/bash/module/Cd.nix index c02f3699..0a5c1a4f 100644 --- a/home/program/bash/module/Cd.nix +++ b/home/program/bash/module/Cd.nix @@ -1,73 +1,74 @@ -{ ... }: { - text = '' - # CD (back to) directory. - # Goes to the exact-match dir first. If no exact match found, it finds first directory that contains the input (case-insensitive). - # Usage: cdd - function cdd() { - local target="''${1}" +{ ... }: +{ + text = '' + # CD (back to) directory. + # Goes to the exact-match dir first. If no exact match found, it finds first directory that contains the input (case-insensitive). + # Usage: cdd + function cdd() { + local target="''${1}" - if [[ "''${target}" = "" ]]; then - help cdd - return 2 - fi + if [[ "''${target}" = "" ]]; then + help cdd + return 2 + fi - local array=($(_cdd_directories)) - local result + local array=($(_cdd_directories)) + local result - # Check for exact match ELSE look for containing. - if _contains ''${target} ''${array[@]}; then - local current="''${PWD%/*}" - result="''${current%\/$target\/*}/''${target}" - else - # Make search case-insensitive. - shopt -s nocasematch + # Check for exact match ELSE look for containing. + if _contains ''${target} ''${array[@]}; then + local current="''${PWD%/*}" + result="''${current%\/$target\/*}/''${target}" + else + # Make search case-insensitive. + shopt -s nocasematch - # Find dir name that contains input. - local found=1 - for (( idx=''${#array[@]}-1 ; idx>=0 ; idx-- )); do - dir="''${array[idx]}" - [[ "''${dir}" =~ "''${target}" ]] && found=0 - [[ ''${found} = 0 ]] && result="/''${dir}''${result}" - done + # Find dir name that contains input. + local found=1 + for (( idx=''${#array[@]}-1 ; idx>=0 ; idx-- )); do + dir="''${array[idx]}" + [[ "''${dir}" =~ "''${target}" ]] && found=0 + [[ ''${found} = 0 ]] && result="/''${dir}''${result}" + done - # Clean-up??? - shopt -u nocasematch - fi + # Clean-up??? + shopt -u nocasematch + fi - # Go there! - if [[ "''${result}" != "" ]]; then - echo "''${result}" - cd "''${result}" - else - return 1 - fi - } + # Go there! + if [[ "''${result}" != "" ]]; then + echo "''${result}" + cd "''${result}" + else + return 1 + fi + } - # CLI cd. Opens CLI file manager. - function ccd() { - local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" - yazi "$@" --cwd-file="$tmp" - if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then - cd -- "$cwd" - fi - rm -f -- "$tmp" - } + # CLI cd. Opens CLI file manager. + function ccd() { + local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" + yazi "$@" --cwd-file="$tmp" + if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then + cd -- "$cwd" + fi + rm -f -- "$tmp" + } - # Get list of all parent dirs. - function _cdd_directories() { - local array - IFS='/' read -r -a array <<< "''${PWD}" - array=("''${array[@]:1}") - unset array[-1] - printf "%s\n" "''${array[@]}" - } + # Get list of all parent dirs. + function _cdd_directories() { + local array + IFS='/' read -r -a array <<< "''${PWD}" + array=("''${array[@]:1}") + unset array[-1] + printf "%s\n" "''${array[@]}" + } - function _comp_cdd() { - local IFS=$'\n' - local dirs=($(_cdd_directories)) - _autocomplete ''${dirs[@]} - } + function _comp_cdd() { + local IFS=$'\n' + local dirs=($(_cdd_directories)) + _autocomplete ''${dirs[@]} + } - complete -o nosort -o filenames -F _comp_cdd cdd - ''; + complete -o nosort -o filenames -F _comp_cdd cdd + ''; } diff --git a/home/program/bash/module/Color.nix b/home/program/bash/module/Color.nix index 48b4c2c2..a2afdc2e 100644 --- a/home/program/bash/module/Color.nix +++ b/home/program/bash/module/Color.nix @@ -1,28 +1,29 @@ -{ ... }: { - text = '' - # Collection of available CLI colors. - # They may differ depending on the terminal used. - # Colors with 'b' prefix are bold colors. +{ ... }: +{ + text = '' + # Collection of available CLI colors. + # They may differ depending on the terminal used. + # Colors with 'b' prefix are bold colors. - export color_default="\033[0m" - export color_blue="\033[0;34m" - export color_bblue="\033[1;34m" - export color_cyan="\033[0;36m" - export color_bcyan="\033[1;36m" - export color_green="\033[0;32m" - export color_bgreen="\033[1;32m" - export color_purple="\033[0;35m" - export color_bpurple="\033[1;35m" - export color_red="\033[0;31m" - export color_bred="\033[1;31m" - export color_white="\033[0;37m" - export color_bwhite="\033[1;37m" - export color_yellow="\033[0;33m" - export color_byellow="\033[1;33m" + export color_default="\033[0m" + export color_blue="\033[0;34m" + export color_bblue="\033[1;34m" + export color_cyan="\033[0;36m" + export color_bcyan="\033[1;36m" + export color_green="\033[0;32m" + export color_bgreen="\033[1;32m" + export color_purple="\033[0;35m" + export color_bpurple="\033[1;35m" + export color_red="\033[0;31m" + export color_bred="\033[1;31m" + export color_white="\033[0;37m" + export color_bwhite="\033[1;37m" + export color_yellow="\033[0;33m" + export color_byellow="\033[1;33m" - # Print all available colors with their names colored in corresponding color. - function color_test() { - echo -e "''${color_default}color_default\n''${color_blue}color_blue\n''${color_bblue}color_bblue\n''${color_cyan}color_cyan\n''${color_bcyan}color_bcyan\n''${color_green}color_green\n''${color_bgreen}color_bgreen\n''${color_purple}color_purple\n''${color_bpurple}color_bpurple\n''${color_red}color_red\n''${color_bred}color_bred\n''${color_white}color_white\n''${color_bwhite}color_bwhite\n''${color_yellow}color_yellow\n''${color_byellow}color_byellow" - } - ''; + # Print all available colors with their names colored in corresponding color. + function color_test() { + echo -e "''${color_default}color_default\n''${color_blue}color_blue\n''${color_bblue}color_bblue\n''${color_cyan}color_cyan\n''${color_bcyan}color_bcyan\n''${color_green}color_green\n''${color_bgreen}color_bgreen\n''${color_purple}color_purple\n''${color_bpurple}color_bpurple\n''${color_red}color_red\n''${color_bred}color_bred\n''${color_white}color_white\n''${color_bwhite}color_bwhite\n''${color_yellow}color_yellow\n''${color_byellow}color_byellow" + } + ''; } diff --git a/home/program/bash/module/Copypaste.nix b/home/program/bash/module/Copypaste.nix index 62400e6d..051ef38e 100644 --- a/home/program/bash/module/Copypaste.nix +++ b/home/program/bash/module/Copypaste.nix @@ -1,13 +1,14 @@ -{ ... }: { - text = '' - # Copy stdin to system clipboard. *Example:* `echo hi \| copy`. - function copy() { - wl-copy - } +{ ... }: +{ + text = '' + # Copy stdin to system clipboard. *Example:* `echo hi \| copy`. + function copy() { + wl-copy + } - # Paste system clipboard to stdout. *Example:* `paste > file.txt`. - function paste() { - wl-paste - } - ''; + # Paste system clipboard to stdout. *Example:* `paste > file.txt`. + function paste() { + wl-paste + } + ''; } diff --git a/home/program/bash/module/Cp.nix b/home/program/bash/module/Cp.nix index f047895f..6b648f42 100644 --- a/home/program/bash/module/Cp.nix +++ b/home/program/bash/module/Cp.nix @@ -1,54 +1,55 @@ -{ ... }: { - text = '' - # Replaces default cp with rsync. - # Usage: rcp - function rcp() { - rsync -ahP --chmod=u+w "''${@}" - } +{ ... }: +{ + text = '' + # Replaces default cp with rsync. + # Usage: rcp + function rcp() { + rsync -ahP --chmod=u+w "''${@}" + } - # Replaces default cp with rsync. - # Only compare file size. - # Usage: rcp_fast - function rcp_fast() { - rsync -ahP --chmod=u+w --size-only "''${@}" - } + # Replaces default cp with rsync. + # Only compare file size. + # Usage: rcp_fast + function rcp_fast() { + rsync -ahP --chmod=u+w --size-only "''${@}" + } - # Replaces default cp with rsync. - # Compare file hashes. - # Usage: rcp_hash - function rcp_hash() { - rsync -ahP --chmod=u+w --checksum "''${@}" - } + # Replaces default cp with rsync. + # Compare file hashes. + # Usage: rcp_hash + function rcp_hash() { + rsync -ahP --chmod=u+w --checksum "''${@}" + } - # Copy and also merge all changes (delete dst files that do not exist in src). - # Usage: rcp_merge - function rcp_merge() { - rsync -ahP --chmod=u+w --delete "''${@}" - } + # Copy and also merge all changes (delete dst files that do not exist in src). + # Usage: rcp_merge + function rcp_merge() { + rsync -ahP --chmod=u+w --delete "''${@}" + } - # Copy and also merge all changes FAST (delete dst files that do not exist in src, only compare size). - # Usage: rcp_merge_fast - function rcp_merge_fast() { - rsync -ahP --chmod=u+w --delete --size-only "''${@}" - } + # Copy and also merge all changes FAST (delete dst files that do not exist in src, only compare size). + # Usage: rcp_merge_fast + function rcp_merge_fast() { + rsync -ahP --chmod=u+w --delete --size-only "''${@}" + } - # Copy and also merge all changes BY CHECKSUM (delete dst files that do not exist in src, compare hashes). - # Usage: rcp_merge_hash - function rcp_merge_hash() { - rsync -ahP --chmod=u+w --delete --checksum "''${@}" - } + # Copy and also merge all changes BY CHECKSUM (delete dst files that do not exist in src, compare hashes). + # Usage: rcp_merge_hash + function rcp_merge_hash() { + rsync -ahP --chmod=u+w --delete --checksum "''${@}" + } - # Print output of cp_merge without writing anything. - # Usage: rcp_test - function rcp_test() { - rsync -ahP --chmod=u+w --delete -n "''${@}" - } + # Print output of cp_merge without writing anything. + # Usage: rcp_test + function rcp_test() { + rsync -ahP --chmod=u+w --delete -n "''${@}" + } - # Copy by creating hardlinks. - # Works for directories, too. - # Usage: cp_link - function cp_link() { - /usr/bin/env cp -lr "''${@}" - } - ''; + # Copy by creating hardlinks. + # Works for directories, too. + # Usage: cp_link + function cp_link() { + /usr/bin/env cp -lr "''${@}" + } + ''; } diff --git a/home/program/bash/module/Curl.nix b/home/program/bash/module/Curl.nix index 9780297d..4b5406a5 100644 --- a/home/program/bash/module/Curl.nix +++ b/home/program/bash/module/Curl.nix @@ -1,9 +1,10 @@ -{ ... }: { - text = '' - # Download a file from the web. - # Usaee: dl [FILES...] - function dl() { - wcurl --curl-options='--http2 --continue-at -' -- ''${@} - } - ''; +{ ... }: +{ + text = '' + # Download a file from the web. + # Usaee: dl [FILES...] + function dl() { + wcurl --curl-options='--http2 --continue-at -' -- ''${@} + } + ''; } diff --git a/home/program/bash/module/Date.nix b/home/program/bash/module/Date.nix index 9c208aca..8fdd6813 100644 --- a/home/program/bash/module/Date.nix +++ b/home/program/bash/module/Date.nix @@ -1,13 +1,14 @@ -{ ... }: { - text = '' - # Print today date in yyyyMMdd format. - function today() { - date +%Y%m%d - } +{ ... }: +{ + text = '' + # Print today date in yyyyMMdd format. + function today() { + date +%Y%m%d + } - # Current day of week number. - function dow() { - date +%u - } - ''; + # Current day of week number. + function dow() { + date +%u + } + ''; } diff --git a/home/program/bash/module/Disk.nix b/home/program/bash/module/Disk.nix index ca395fd6..2a7443b0 100644 --- a/home/program/bash/module/Disk.nix +++ b/home/program/bash/module/Disk.nix @@ -1,72 +1,73 @@ -{ ... }: { - text = '' - # Show only physical drives info. - function pdf() { - df --si | sed -e '1p' -e '/^\/dev\//!d' - } +{ ... }: +{ + text = '' + # Show only physical drives info. + function pdf() { + df --si | sed -e '1p' -e '/^\/dev\//!d' + } - # Show total size in SI. - # Current dir by default. - # Usage: tdu [DIRS] - function tdu() { - du -sh --si "''${@}" - } + # Show total size in SI. + # Current dir by default. + # Usage: tdu [DIRS] + function tdu() { + du -sh --si "''${@}" + } - # Unlock encrypted disk file. - # Usage: funlock - function funlock() { - local file="''${1}" + # Unlock encrypted disk file. + # Usage: funlock + function funlock() { + local file="''${1}" - if [[ "''${file}" = "" ]]; then - help funlock - return 2 - fi + if [[ "''${file}" = "" ]]; then + help funlock + return 2 + fi - local name=$(parse_alnum "''${file##*/}") + local name=$(parse_alnum "''${file##*/}") - local loop=$(udisksctl loop-setup --no-user-interaction --file "''${file}") - loop="''${loop##* }"; loop="''${loop%.}" + local loop=$(udisksctl loop-setup --no-user-interaction --file "''${file}") + loop="''${loop##* }"; loop="''${loop%.}" - local decrypted=$(udisksctl unlock --block-device "''${loop}") - decrypted="''${decrypted##* }"; decrypted="''${decrypted%.}" + local decrypted=$(udisksctl unlock --block-device "''${loop}") + decrypted="''${decrypted##* }"; decrypted="''${decrypted%.}" - local mount=$(udisksctl mount --no-user-interaction --block-device "''${decrypted}") - mount="''${mount#* at }" + local mount=$(udisksctl mount --no-user-interaction --block-device "''${decrypted}") + mount="''${mount#* at }" - ya pub dds-cd --str "''${mount}" 2> /dev/null - cd "''${mount}" - } + ya pub dds-cd --str "''${mount}" 2> /dev/null + cd "''${mount}" + } - # Mount file. - # Usage: fmount - function fmount() { - local file="''${1}" - if [[ "''${file}" = "" ]]; then - help fmount - return 2 - fi + # Mount file. + # Usage: fmount + function fmount() { + local file="''${1}" + if [[ "''${file}" = "" ]]; then + help fmount + return 2 + fi - local loop=$(udisksctl loop-setup --no-user-interaction --file "''${file}") - loop="''${loop##* }"; loop="''${loop%.}" + local loop=$(udisksctl loop-setup --no-user-interaction --file "''${file}") + loop="''${loop##* }"; loop="''${loop%.}" - local mount=$(udisksctl mount --no-user-interaction --block-device "''${loop}") - mount="''${mount#* at }" + local mount=$(udisksctl mount --no-user-interaction --block-device "''${loop}") + mount="''${mount#* at }" - ya pub dds-cd --str "''${mount}" 2> /dev/null - cd "''${mount}" - } + ya pub dds-cd --str "''${mount}" 2> /dev/null + cd "''${mount}" + } - # Unmount file. - # Usage: fumount - function fumount() { - local loop="''${1}" - if [[ "''${loop}" = "" ]]; then - help fumount - return 2 - fi + # Unmount file. + # Usage: fumount + function fumount() { + local loop="''${1}" + if [[ "''${loop}" = "" ]]; then + help fumount + return 2 + fi - udisksctl unmount --no-user-interaction --block-device "''${loop}" - udisksctl loop-delete --no-user-interaction --block-device "''${loop}" - } - ''; + udisksctl unmount --no-user-interaction --block-device "''${loop}" + udisksctl loop-delete --no-user-interaction --block-device "''${loop}" + } + ''; } diff --git a/home/program/bash/module/Docker.nix b/home/program/bash/module/Docker.nix index 2febc607..0c3660ed 100644 --- a/home/program/bash/module/Docker.nix +++ b/home/program/bash/module/Docker.nix @@ -1,99 +1,100 @@ -{ ... }: { - text = '' - # Show container's volumes. - # Usage: docker_volumes - function docker_volumes() { - docker inspect -f '{{ .Mounts }}' "''${@}" - } +{ ... }: +{ + text = '' + # Show container's volumes. + # Usage: docker_volumes + function docker_volumes() { + docker inspect -f '{{ .Mounts }}' "''${@}" + } - # Check if any container exited. - function docker_health() { - docker ps -a | grep Exited - } + # Check if any container exited. + function docker_health() { + docker ps -a | grep Exited + } - # Find out container's IP address. - # Usage: docker_ip - function docker_ip() { - docker inspect -f '\'''{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'\' "''${1}" | sed "s/^.//" | sed "s/.$//" - } + # Find out container's IP address. + # Usage: docker_ip + function docker_ip() { + docker inspect -f '\'''{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'\' "''${1}" | sed "s/^.//" | sed "s/.$//" + } - # Update all docker images. - function docker_update() { - docker images --format "{{.Repository}}:{{.Tag}}" | xargs -L1 docker pull - } + # Update all docker images. + function docker_update() { + docker images --format "{{.Repository}}:{{.Tag}}" | xargs -L1 docker pull + } - # Docker compose shortcut. - function dc() { - docker compose "''${@}" - } + # Docker compose shortcut. + function dc() { + docker compose "''${@}" + } - # Docker compose up. - # Usage: dcu [SERVICES] - function dcu() { - docker compose up -d "''${@}" - } + # Docker compose up. + # Usage: dcu [SERVICES] + function dcu() { + docker compose up -d "''${@}" + } - # Docker compose down. - # Usage: dcd [SERVICES] - function dcd() { - docker compose down "''${@}" - } + # Docker compose down. + # Usage: dcd [SERVICES] + function dcd() { + docker compose down "''${@}" + } - # Docker compose pull. - # Usage: dcp [SERVICES] - function dcp() { - docker compose pull "''${@}" - } + # Docker compose pull. + # Usage: dcp [SERVICES] + function dcp() { + docker compose pull "''${@}" + } - # Docker compose logs. - # Usage: dcl [SERVICES] - function dcl() { - docker compose logs -f "''${@}" - } + # Docker compose logs. + # Usage: dcl [SERVICES] + function dcl() { + docker compose logs -f "''${@}" + } - # Docker compose restart. - # Usage: dcr [SERVICES] - function dcr() { - docker compose restart "''${@}" - } + # Docker compose restart. + # Usage: dcr [SERVICES] + function dcr() { + docker compose restart "''${@}" + } - # Docker compose stop. - # Usage: dcs [SERVICES] - function dcs() { - docker compose stop "''${@}" - } + # Docker compose stop. + # Usage: dcs [SERVICES] + function dcs() { + docker compose stop "''${@}" + } - # Docker compose down & up specified services. - # Usage: dcdu [SERVICES] - function dcdu() { - dcd "''${@}" - dcu "''${@}" - } + # Docker compose down & up specified services. + # Usage: dcdu [SERVICES] + function dcdu() { + dcd "''${@}" + dcu "''${@}" + } - # Docker compose pull & up specified services. - # Usage: dcpu [SERVICES] - function dcpu() { - dcp "''${@}" - dcu "''${@}" - } + # Docker compose pull & up specified services. + # Usage: dcpu [SERVICES] + function dcpu() { + dcp "''${@}" + dcu "''${@}" + } - # Docker compose up & attach to logs for specified services. - # Usage: dcul [SERVICES] - function dcul() { - dcu "''${@}" && dcl "''${@}" - } + # Docker compose up & attach to logs for specified services. + # Usage: dcul [SERVICES] + function dcul() { + dcu "''${@}" && dcl "''${@}" + } - # Autocomplete with available services. - function _dc_services() { - _autocomplete "$(docker compose config --services 2> /dev/null)" - } + # Autocomplete with available services. + function _dc_services() { + _autocomplete "$(docker compose config --services 2> /dev/null)" + } - # Autocomplete with available container names. - function _dc_containers() { - _autocomplete "$(docker ps --format "\""{{.Names}}"\"")" - } + # Autocomplete with available container names. + function _dc_containers() { + _autocomplete "$(docker ps --format "\""{{.Names}}"\"")" + } - complete -F _dc_services dcu dcd dcp dcl dcul dcdu dcr dcs dcpu - complete -F _dc_containers docker_volumes docker_ip - ''; + complete -F _dc_services dcu dcd dcp dcl dcul dcdu dcr dcs dcpu + complete -F _dc_containers docker_volumes docker_ip + ''; } diff --git a/home/program/bash/module/Dvd.nix b/home/program/bash/module/Dvd.nix index 3d44cda8..126e4491 100644 --- a/home/program/bash/module/Dvd.nix +++ b/home/program/bash/module/Dvd.nix @@ -1,43 +1,44 @@ -{ ... }: { - text = '' - # Burn specified iso file to DVD. - # Usage: dvd_burn_iso - function dvd_burn_iso() { - local iso="''${1}" - if [[ "''${iso}" = "" ]]; then - help dvd_burn_iso - return 2 - fi +{ ... }: +{ + text = '' + # Burn specified iso file to DVD. + # Usage: dvd_burn_iso + function dvd_burn_iso() { + local iso="''${1}" + if [[ "''${iso}" = "" ]]; then + help dvd_burn_iso + return 2 + fi - growisofs -dvd-compat -speed=8 -use-the-force-luke=tty -Z /dev/sr0="''${iso}" - } + growisofs -dvd-compat -speed=8 -use-the-force-luke=tty -Z /dev/sr0="''${iso}" + } - # Burn specified iso file to CD. - # Usage: cd_burn_iso - function cd_burn_iso() { - local iso="''${1}" - if [[ "''${iso}" = "" ]]; then - help cd_burn_iso - return 2 - fi + # Burn specified iso file to CD. + # Usage: cd_burn_iso + function cd_burn_iso() { + local iso="''${1}" + if [[ "''${iso}" = "" ]]; then + help cd_burn_iso + return 2 + fi - wodim speed=8 -tao dev=/dev/sr0 "''${iso}" - } + wodim speed=8 -tao dev=/dev/sr0 "''${iso}" + } - # Burn specified audio files to CD. - # Usage: cd_burn_audio - function cd_burn_audio() { - if [[ "''${*}" = "" ]]; then - help cd_burn_audio - return 2 - fi + # Burn specified audio files to CD. + # Usage: cd_burn_audio + function cd_burn_audio() { + if [[ "''${*}" = "" ]]; then + help cd_burn_audio + return 2 + fi - cdrecord -v dev=/dev/sr0 speed=8 -audio -pad "''${*}" - } + cdrecord -v dev=/dev/sr0 speed=8 -audio -pad "''${*}" + } - # Spawn Nix shell with required tools. - function dvd_shell() { - SHELL_NAME="dvd" tmpshell dvdplusrwtools cdrkit - } - ''; + # Spawn Nix shell with required tools. + function dvd_shell() { + SHELL_NAME="dvd" tmpshell dvdplusrwtools cdrkit + } + ''; } diff --git a/home/program/bash/module/Ffmpeg.nix b/home/program/bash/module/Ffmpeg.nix index 1f1ab7ad..5b54909c 100644 --- a/home/program/bash/module/Ffmpeg.nix +++ b/home/program/bash/module/Ffmpeg.nix @@ -1,112 +1,113 @@ -{ ... }: { - text = '' - # Mux audio into containers. File names in sound and current dirrectories must match. - # Usage: ffmpeg_mux_audio - function ffmpeg_mux_audio() { - if [[ "''${1}" = "" ]]; then - help ffmpeg_mux_audio - return 2 - fi +{ ... }: +{ + text = '' + # Mux audio into containers. File names in sound and current dirrectories must match. + # Usage: ffmpeg_mux_audio + function ffmpeg_mux_audio() { + if [[ "''${1}" = "" ]]; then + help ffmpeg_mux_audio + return 2 + fi - for file in *; do ffmpeg -i "$file" -i "$1"/"$file" -c copy -map 0:v:0 -map 1:a:0 -shortest "$2"/"$file"; done - } + for file in *; do ffmpeg -i "$file" -i "$1"/"$file" -c copy -map 0:v:0 -map 1:a:0 -shortest "$2"/"$file"; done + } - # Mux cover into music file. - # Usage: ffmpeg_mux_cover - function ffmpeg_mux_cover() { - if [[ "''${1}" = "" ]]; then - help ffmpeg_mux_cover - return 2 - fi + # Mux cover into music file. + # Usage: ffmpeg_mux_cover + function ffmpeg_mux_cover() { + if [[ "''${1}" = "" ]]; then + help ffmpeg_mux_cover + return 2 + fi - local format="''${1}" - local cover="''${2}" + local format="''${1}" + local cover="''${2}" - mkdir out + mkdir out - case "''${format}" in - # "mka"|"mkv") - # for file in *.''${format}; do - # ffmpeg -i "''${file}" -attach "''${cover}" -map 0 -c copy -metadata:s:t mimetype="image/''${cover##*.}" -metadata:s:t:0 filename="cover.''${cover##*.}" "./out/''${file}" || return 1 - # done - # ;; - *) - for file in *.''${format}; do - # ffmpeg -i "''${file}" -i "''${cover}" -map 0 -map 0:-v? -map 1 -codec copy -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" -disposition:v attached_pic ./out/"''${file}" || return 1 - ffmpeg -i "''${file}" -i "''${cover}" -map 0 -map 1 -codec copy -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" -disposition:v attached_pic ./out/"''${file}" || return 1 - done - ;; - esac + case "''${format}" in + # "mka"|"mkv") + # for file in *.''${format}; do + # ffmpeg -i "''${file}" -attach "''${cover}" -map 0 -c copy -metadata:s:t mimetype="image/''${cover##*.}" -metadata:s:t:0 filename="cover.''${cover##*.}" "./out/''${file}" || return 1 + # done + # ;; + *) + for file in *.''${format}; do + # ffmpeg -i "''${file}" -i "''${cover}" -map 0 -map 0:-v? -map 1 -codec copy -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" -disposition:v attached_pic ./out/"''${file}" || return 1 + ffmpeg -i "''${file}" -i "''${cover}" -map 0 -map 1 -codec copy -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" -disposition:v attached_pic ./out/"''${file}" || return 1 + done + ;; + esac - mv out/* . - rm -d out/ && rm "''${2}" - } + mv out/* . + rm -d out/ && rm "''${2}" + } - # Generate music metadata from directory structure. - # Top dir is the Artist name like this: `The_Beatles`. - # Next are albums like this: `2010_My_love`. - # Inside are songs like this: `01_sample.flac`. - # Usage: ffmpeg_music_meta - function ffmpeg_music_meta() { - if [[ "''${1}" = "" ]]; then - help ffmpeg_music_meta - return 2 - fi + # Generate music metadata from directory structure. + # Top dir is the Artist name like this: `The_Beatles`. + # Next are albums like this: `2010_My_love`. + # Inside are songs like this: `01_sample.flac`. + # Usage: ffmpeg_music_meta + function ffmpeg_music_meta() { + if [[ "''${1}" = "" ]]; then + help ffmpeg_music_meta + return 2 + fi - local format="''${1}" + local format="''${1}" - ls *.''${format} &> /dev/null || return 1 + ls *.''${format} &> /dev/null || return 1 - local artist="''${PWD%/*}"; artist="''${artist##*/}"; artist="''${artist//_/ }" - local album="''${PWD##*/}"; album="''${album#*_}"; album="''${album//_/ }" - local year="''${PWD##*/}"; year="''${year%%_*}" - # local total=$(ls *.''${format} | wc -l) + local artist="''${PWD%/*}"; artist="''${artist##*/}"; artist="''${artist//_/ }" + local album="''${PWD##*/}"; album="''${album#*_}"; album="''${album//_/ }" + local year="''${PWD##*/}"; year="''${year%%_*}" + # local total=$(ls *.''${format} | wc -l) - mkdir out + mkdir out - for file in *.''${format}; do - local track="''${file%%_*}"; track=$((10#''${track})); [[ "''${track}" = "" ]] && track=0 - local title="''${file#*_}"; title="''${title%.*}"; title="''${title//_/ }" + for file in *.''${format}; do + local track="''${file%%_*}"; track=$((10#''${track})); [[ "''${track}" = "" ]] && track=0 + local title="''${file#*_}"; title="''${title%.*}"; title="''${title//_/ }" - # echo "''${artist}; ''${album}; ''${year}; ''${track}; ''${title}" - # TODO: make it format-specific. - ffmpeg -i "''${file}" -map 0 -c copy -metadata "artists=" -metadata "artist=''${artist}" -metadata "album_artist=''${artist}" -metadata "album=''${album}" -metadata "date=''${year}" -metadata "year=''${year}" -metadata "date_released=''${year}" -metadata "track=''${track}" -metadata "part_number=''${track}" -metadata "title=''${title}" ./out/"''${file}" || return 1 - done + # echo "''${artist}; ''${album}; ''${year}; ''${track}; ''${title}" + # TODO: make it format-specific. + ffmpeg -i "''${file}" -map 0 -c copy -metadata "artists=" -metadata "artist=''${artist}" -metadata "album_artist=''${artist}" -metadata "album=''${album}" -metadata "date=''${year}" -metadata "year=''${year}" -metadata "date_released=''${year}" -metadata "track=''${track}" -metadata "part_number=''${track}" -metadata "title=''${title}" ./out/"''${file}" || return 1 + done - mv out/* . - rm -d out/ - } + mv out/* . + rm -d out/ + } - # Rotate the video clock-wise. - # Usage: ffmpeg_rotate - function ffmpeg_rotate() { - if [[ "''${2}" = "" ]]; then - help ffmpeg_rotate - fi + # Rotate the video clock-wise. + # Usage: ffmpeg_rotate + function ffmpeg_rotate() { + if [[ "''${2}" = "" ]]; then + help ffmpeg_rotate + fi - local angle="''${1}" - local target="''${2}" + local angle="''${1}" + local target="''${2}" - ffmpeg -display_rotation ''${angle} -i ''${target} -c copy _''${target} && mv _''${target} ''${target} || rm _''${target} - } + ffmpeg -display_rotation ''${angle} -i ''${target} -c copy _''${target} && mv _''${target} ''${target} || rm _''${target} + } - # Get video FPS. - function _ffprobe_fps() { - local fps=$(ffprobe -v 0 -of csv=p=0 -select_streams v:0 -show_entries stream=r_frame_rate "''${1}") - [[ "''${fps}" = "" ]] && fps=30 || fps=$((fps)) - echo "''${fps}" - } + # Get video FPS. + function _ffprobe_fps() { + local fps=$(ffprobe -v 0 -of csv=p=0 -select_streams v:0 -show_entries stream=r_frame_rate "''${1}") + [[ "''${fps}" = "" ]] && fps=30 || fps=$((fps)) + echo "''${fps}" + } - # Get recommended keyframe interval for a file. - function _ffprobe_keyint() { - local fps=$(_ffprobe_fps "''${1}") - echo $((fps*5)) - } + # Get recommended keyframe interval for a file. + function _ffprobe_keyint() { + local fps=$(_ffprobe_fps "''${1}") + echo $((fps*5)) + } - # Get audio bitrage. 128 by default. - function _ffprobe_ba() { - local ba=$(ffprobe -v error -select_streams a:0 -show_entries stream=bit_rate -of default=noprint_wrappers=1:nokey=1 "''${1}") - [[ "''${ba}" != "N/A" ]] && echo $((ba/1024)) || echo 128 - } - ''; + # Get audio bitrage. 128 by default. + function _ffprobe_ba() { + local ba=$(ffprobe -v error -select_streams a:0 -show_entries stream=bit_rate -of default=noprint_wrappers=1:nokey=1 "''${1}") + [[ "''${ba}" != "N/A" ]] && echo $((ba/1024)) || echo 128 + } + ''; } diff --git a/home/program/bash/module/File.nix b/home/program/bash/module/File.nix index a0adc8cd..82023d4f 100644 --- a/home/program/bash/module/File.nix +++ b/home/program/bash/module/File.nix @@ -1,9 +1,10 @@ -{ ... }: { - text = '' - # Open file/dir in GUI. - # Usage: o - function o() { - xdg-open "''${@}" - } - ''; +{ ... }: +{ + text = '' + # Open file/dir in GUI. + # Usage: o + function o() { + xdg-open "''${@}" + } + ''; } diff --git a/home/program/bash/module/Find.nix b/home/program/bash/module/Find.nix index ef94b59d..9224ae1f 100644 --- a/home/program/bash/module/Find.nix +++ b/home/program/bash/module/Find.nix @@ -1,9 +1,10 @@ -{ ... }: { - text = '' - # Find all file extensions. - function find_ext() { - local types=($(find -type f | sed -e "s/.*\///" -e "s/^\.//" -e "/\./!d" -e "s/.*\.//")) - echo "''${types[@]}" | tr ' ' '\n' | sort -u - } - ''; +{ ... }: +{ + text = '' + # Find all file extensions. + function find_ext() { + local types=($(find -type f | sed -e "s/.*\///" -e "s/^\.//" -e "/\./!d" -e "s/.*\.//")) + echo "''${types[@]}" | tr ' ' '\n' | sort -u + } + ''; } diff --git a/home/program/bash/module/Fix.nix b/home/program/bash/module/Fix.nix index 84e81f0c..b2ded6bc 100644 --- a/home/program/bash/module/Fix.nix +++ b/home/program/bash/module/Fix.nix @@ -1,24 +1,25 @@ -{ ... }: { - text = '' - # Fix when ethernet mistakenly detects 100 Mb instead of 1000 Mb. - # SPEED is one of 10/100/1000 etc. - # Usage: fix_ethernet_speed - function fix_ethernet_speed() { - local device="''${1}" - local speed="''${2}" +{ ... }: +{ + text = '' + # Fix when ethernet mistakenly detects 100 Mb instead of 1000 Mb. + # SPEED is one of 10/100/1000 etc. + # Usage: fix_ethernet_speed + function fix_ethernet_speed() { + local device="''${1}" + local speed="''${2}" - if [[ "''${device}" = "" || "''${speed}" = "" ]]; then - help fix_ethernet_speed - return 2 - fi + if [[ "''${device}" = "" || "''${speed}" = "" ]]; then + help fix_ethernet_speed + return 2 + fi - ethtool -s "''${device}" speed "''${speed}" - } + ethtool -s "''${device}" speed "''${speed}" + } - # Delete lost Gradle lock files. - function fix_gradle_lock() { - cd "''${HOME}/.gradle" && find -type f | grep \\.lock$ | xargs -- rm - cd - - } - ''; + # Delete lost Gradle lock files. + function fix_gradle_lock() { + cd "''${HOME}/.gradle" && find -type f | grep \\.lock$ | xargs -- rm + cd - + } + ''; } diff --git a/home/program/bash/module/Git.nix b/home/program/bash/module/Git.nix index 903c3475..5250c2ec 100644 --- a/home/program/bash/module/Git.nix +++ b/home/program/bash/module/Git.nix @@ -1,337 +1,338 @@ -{ ... }: { - text = '' - # Git push. - function gps() { - git push "''${@}" - } +{ ... }: +{ + text = '' + # Git push. + function gps() { + git push "''${@}" + } - # Git push all (branches). Useful for pushing all stuff to a new remote. - function gpsa() { - local remotes=($(git remote)) - for remote in ''${remotes[@]}; do - echo -n "''${remote}: " - git push "''${remote}" --tags "refs/remotes/origin/*:refs/heads/*" - done - } + # Git push all (branches). Useful for pushing all stuff to a new remote. + function gpsa() { + local remotes=($(git remote)) + for remote in ''${remotes[@]}; do + echo -n "''${remote}: " + git push "''${remote}" --tags "refs/remotes/origin/*:refs/heads/*" + done + } - # Git force push. - function gpsf() { - git push --force "''${@}" - } + # Git force push. + function gpsf() { + git push --force "''${@}" + } - # Git pull. - function gpl() { - git pull "''${@}" - } + # Git pull. + function gpl() { + git pull "''${@}" + } - # Git log. - function gl() { - git log --show-signature "''${@}" - } + # Git log. + function gl() { + git log --show-signature "''${@}" + } - # Git status. - function gs() { - git status "''${@}" - } + # Git status. + function gs() { + git status "''${@}" + } - # Git stash. - function gst() { - git stash "''${@}" - } + # Git stash. + function gst() { + git stash "''${@}" + } - # Cd to git's root dir. - function gcd() { - local path=$(git rev-parse --show-toplevel) - [[ "''${path}" = "" ]] && return 1 - cd "''${path}" - } + # Cd to git's root dir. + function gcd() { + local path=$(git rev-parse --show-toplevel) + [[ "''${path}" = "" ]] && return 1 + cd "''${path}" + } - # Git diff. - function gd() { - git diff --patience "''${@}" - } + # Git diff. + function gd() { + git diff --patience "''${@}" + } - # Git diff added. - function gda() { - git diff --cached --patience "''${@}" - } + # Git diff added. + function gda() { + git diff --cached --patience "''${@}" + } - # Git commit. - function gc() { - git commit -m "''${@}" - } + # Git commit. + function gc() { + git commit -m "''${@}" + } - # Git clone with tree filter. - function gct() { - git clone --filter tree:0 ''${@} - } + # Git clone with tree filter. + function gct() { + git clone --filter tree:0 ''${@} + } - # Git clone full repo. - function gcf() { - git clone ''${@} - } + # Git clone full repo. + function gcf() { + git clone ''${@} + } - # Git clone latest commit only. - function gcl() { - git clone --depth=1 --single-branch ''${@} - } + # Git clone latest commit only. + function gcl() { + git clone --depth=1 --single-branch ''${@} + } - # Git signed commit. - function gcs() { - git commit -S -m "''${@}" - } + # Git signed commit. + function gcs() { + git commit -S -m "''${@}" + } - # Git checkout. - function gch() { - git checkout "''${@}" - } + # Git checkout. + function gch() { + git checkout "''${@}" + } - # Git checkout branch. - # Usage: gchb - function gchb() { - git checkout -b "''${@}" - } + # Git checkout branch. + # Usage: gchb + function gchb() { + git checkout -b "''${@}" + } - # Git branch. - function gb() { - git branch --all "''${@}" - } + # Git branch. + function gb() { + git branch --all "''${@}" + } - # Git branch delete. - # Usage: gbd - function gbd() { - git branch -D "''${@}" - } + # Git branch delete. + # Usage: gbd + function gbd() { + git branch -D "''${@}" + } - # Git branch delete all except current. - function gbda() { - git branch | grep -v ^* | xargs git branch -D - } + # Git branch delete all except current. + function gbda() { + git branch | grep -v ^* | xargs git branch -D + } - # Git fetch all. - function gf() { - git fetch --all -v -p - } + # Git fetch all. + function gf() { + git fetch --all -v -p + } - # Git tag. - function gt() { - git tag "''${@}" - } + # Git tag. + function gt() { + git tag "''${@}" + } - # Git ignore files. - function gi() { - git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached - } + # Git ignore files. + function gi() { + git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached + } - # Git patch from staged diff. - # Usage: gpd - function gpd() { - git diff --staged --patch --binary --minimal - } + # Git patch from staged diff. + # Usage: gpd + function gpd() { + git diff --staged --patch --binary --minimal + } - # Git patch from commit. - # Usage: gpc [REF] [COUNT] - function gpc() { - local ref="''${1}" - local count="''${2}" - [[ "''${ref}" = "" ]] && ref="HEAD" - [[ "''${count}" = "" ]] && count=1 - git format-patch --stdout --minimal --patch --binary -''${count} "''${ref}" - } + # Git patch from commit. + # Usage: gpc [REF] [COUNT] + function gpc() { + local ref="''${1}" + local count="''${2}" + [[ "''${ref}" = "" ]] && ref="HEAD" + [[ "''${count}" = "" ]] && count=1 + git format-patch --stdout --minimal --patch --binary -''${count} "''${ref}" + } - # Git patch apply. - # Usage: gpa - function gpa() { - git apply --index "''${@}" - } + # Git patch apply. + # Usage: gpa + function gpa() { + git apply --index "''${@}" + } - # Unstage changes. - # Usage: grs [FILES] - function grs() { - local target=''${@} - [[ "''${target}" = "" ]] && target="." - git restore --staged "''${target}" - } + # Unstage changes. + # Usage: grs [FILES] + function grs() { + local target=''${@} + [[ "''${target}" = "" ]] && target="." + git restore --staged "''${target}" + } - # Run git garbage collection. - function ggc() { - git gc --aggressive --no-cruft --prune=now - } + # Run git garbage collection. + function ggc() { + git gc --aggressive --no-cruft --prune=now + } - # Check git file integrity. - function gfsck() { - git fsck - } + # Check git file integrity. + function gfsck() { + git fsck + } - # Preview diff while adding. Adds current dir by default. - # Usage: ga [FILES] - function ga() { - local target=''${@} - [[ "''${target}" = "" ]] && target="." + # Preview diff while adding. Adds current dir by default. + # Usage: ga [FILES] + function ga() { + local target=''${@} + [[ "''${target}" = "" ]] && target="." - git diff ''${target} - git add ''${target} - } + git diff ''${target} + git add ''${target} + } - # Rebase by X commits or from root. When COUNT is 0 - rebase from root. Default is 2. - # Usage: gr [COMMIT COUNT] - function gr() { - local base="''${1}" + # Rebase by X commits or from root. When COUNT is 0 - rebase from root. Default is 2. + # Usage: gr [COMMIT COUNT] + function gr() { + local base="''${1}" - # Rebase last 2 commits by default. - if [[ "''${base}" = "" ]]; then - base="2" - fi + # Rebase last 2 commits by default. + if [[ "''${base}" = "" ]]; then + base="2" + fi - # If 0, rebase from root. else from specified base. - if [[ "''${base}" = "0" ]]; then - git rebase -i --root - else - git rebase -i HEAD~''${base} - fi - } + # If 0, rebase from root. else from specified base. + if [[ "''${base}" = "0" ]]; then + git rebase -i --root + else + git rebase -i HEAD~''${base} + fi + } - # Specify git user as Dmitry Voronin with provided email. - # Usage: gu [EMAIL] - function gu() { - local name="Dmitry Voronin" - local email="''${1}" + # Specify git user as Dmitry Voronin with provided email. + # Usage: gu [EMAIL] + function gu() { + local name="Dmitry Voronin" + local email="''${1}" - if [[ "''${name}" = "" || "''${email}" = "" ]]; then - echo "usage: gu [EMAIL]" - return 2 - fi + if [[ "''${name}" = "" || "''${email}" = "" ]]; then + echo "usage: gu [EMAIL]" + return 2 + fi - git config user.name "''${name}" - git config user.email "''${email}" - } + git config user.name "''${name}" + git config user.email "''${email}" + } - # Get my git repo. - # Usage: gg - function gg() { - local repo="''${1}" + # Get my git repo. + # Usage: gg + function gg() { + local repo="''${1}" - if [[ "''${repo}" = "" ]]; then - help gg - return 2 - fi + if [[ "''${repo}" = "" ]]; then + help gg + return 2 + fi - git clone ssh://git@git.voronind.com:22144/voronind/"''${repo}" - } + git clone ssh://git@git.voronind.com:22144/voronind/"''${repo}" + } - # See diff for a specific commit. Last commit by default. - # Usage: gdc [COMMITHASH] - function gdc() { - local hash="''${1}" - [[ "''${hash}" = "" ]] && hash="HEAD" - git diff "''${hash}^!" - } + # See diff for a specific commit. Last commit by default. + # Usage: gdc [COMMITHASH] + function gdc() { + local hash="''${1}" + [[ "''${hash}" = "" ]] && hash="HEAD" + git diff "''${hash}^!" + } - # Get version number based on commit count. - function gv() { - git rev-list HEAD --count - } + # Get version number based on commit count. + function gv() { + git rev-list HEAD --count + } - # Open the remote web url in default browser. - # Usage: gw [REMOTE] - function gw() { - local remote="''${1}" - [[ "''${remote}" = "" ]] && remote="$(git remote | head -n1)" + # Open the remote web url in default browser. + # Usage: gw [REMOTE] + function gw() { + local remote="''${1}" + [[ "''${remote}" = "" ]] && remote="$(git remote | head -n1)" - local url="$(git remote get-url ''${remote})" - open "''${url}" - } + local url="$(git remote get-url ''${remote})" + open "''${url}" + } - # Search for string in whole git history. - # Usage: gsearch - function gsearch() { - local target="''${*}" + # Search for string in whole git history. + # Usage: gsearch + function gsearch() { + local target="''${*}" - if [[ "''${target}" = "" ]]; then - help gsearch - return 2 - fi + if [[ "''${target}" = "" ]]; then + help gsearch + return 2 + fi - git log -p -G "''${target}" - } + git log -p -G "''${target}" + } - # Sign the old commits. 0 to resign from root. - # Usage: gsign [COMMIT_COUNT] - function gsign() { - local base="''${1}" + # Sign the old commits. 0 to resign from root. + # Usage: gsign [COMMIT_COUNT] + function gsign() { + local base="''${1}" - # Resign last commit by default. - if [[ "''${base}" = "" ]]; then - base="1" - fi + # Resign last commit by default. + if [[ "''${base}" = "" ]]; then + base="1" + fi - # If 0, rebase from root. else from specified base. - if [[ "''${base}" = "0" ]]; then - git rebase --exec 'git commit --amend --no-edit -n -S' -i --root - else - git rebase --exec 'git commit --amend --no-edit -n -S' -i HEAD~''${base} - fi - } + # If 0, rebase from root. else from specified base. + if [[ "''${base}" = "0" ]]; then + git rebase --exec 'git commit --amend --no-edit -n -S' -i --root + else + git rebase --exec 'git commit --amend --no-edit -n -S' -i HEAD~''${base} + fi + } - # Show current branch. - function _git_current_branch() { - git branch --show-current 2> /dev/null - } + # Show current branch. + function _git_current_branch() { + git branch --show-current 2> /dev/null + } - # Show origin's url. - function _git_origin_url() { - git remote get-url origin - } + # Show origin's url. + function _git_origin_url() { + git remote get-url origin + } - # Get this dotfiles url. - function _git_dotfiles_url() { - echo 'https://git.voronind.com/voronind/linux.git' - } + # Get this dotfiles url. + function _git_dotfiles_url() { + echo 'https://git.voronind.com/voronind/linux.git' + } - # Check if current git repo is this dotfiles. - function _git_is_dotfiles() { - # [[ "$(_git_origin_url)" = "$(_git_dotfiles_url)" ]] - local dir="''${PWD}" + # Check if current git repo is this dotfiles. + function _git_is_dotfiles() { + # [[ "$(_git_origin_url)" = "$(_git_dotfiles_url)" ]] + local dir="''${PWD}" - while [[ "''${dir}" != "" ]]; do - if [[ -d "''${dir}/.git" ]]; then - if [[ "''${dir}" = "''${HOME}" ]] || [[ "''${dir}" = "$(realpath ''${HOME})" ]]; then - return 0 - else - return 1 - fi - fi + while [[ "''${dir}" != "" ]]; do + if [[ -d "''${dir}/.git" ]]; then + if [[ "''${dir}" = "''${HOME}" ]] || [[ "''${dir}" = "$(realpath ''${HOME})" ]]; then + return 0 + else + return 1 + fi + fi - dir="''${dir%/*}" - done - } + dir="''${dir%/*}" + done + } - # Autocomplete. - _completion_loader git &> /dev/null - __git_complete gps _git_push &> /dev/null - __git_complete gpsf _git_push &> /dev/null - __git_complete gpl _git_pull &> /dev/null - __git_complete gl _git_log &> /dev/null - __git_complete gs _git_status &> /dev/null - __git_complete gst _git_stash &> /dev/null - __git_complete gd _git_diff &> /dev/null - __git_complete gdc _git_diff &> /dev/null - __git_complete gc _git_commit &> /dev/null - __git_complete gch _git_checkout &> /dev/null - __git_complete gchb _git_checkout &> /dev/null - __git_complete gb _git_branch &> /dev/null - __git_complete gbd _git_branch &> /dev/null - __git_complete gf _git_fetch &> /dev/null - __git_complete gt _git_tag &> /dev/null - __git_complete gp _git_apply &> /dev/null - __git_complete ga _git_add &> /dev/null - __git_complete gw _git_pull &> /dev/null + # Autocomplete. + _completion_loader git &> /dev/null + __git_complete gps _git_push &> /dev/null + __git_complete gpsf _git_push &> /dev/null + __git_complete gpl _git_pull &> /dev/null + __git_complete gl _git_log &> /dev/null + __git_complete gs _git_status &> /dev/null + __git_complete gst _git_stash &> /dev/null + __git_complete gd _git_diff &> /dev/null + __git_complete gdc _git_diff &> /dev/null + __git_complete gc _git_commit &> /dev/null + __git_complete gch _git_checkout &> /dev/null + __git_complete gchb _git_checkout &> /dev/null + __git_complete gb _git_branch &> /dev/null + __git_complete gbd _git_branch &> /dev/null + __git_complete gf _git_fetch &> /dev/null + __git_complete gt _git_tag &> /dev/null + __git_complete gp _git_apply &> /dev/null + __git_complete ga _git_add &> /dev/null + __git_complete gw _git_pull &> /dev/null - # Autocomplete with my git emails. - function _gu() { - _autocomplete hi@voronind.com dd.voronin@fsight.ru - } + # Autocomplete with my git emails. + function _gu() { + _autocomplete hi@voronind.com dd.voronin@fsight.ru + } - complete -F _gu gu - ''; + complete -F _gu gu + ''; } diff --git a/home/program/bash/module/Gpg.nix b/home/program/bash/module/Gpg.nix index 4c5ea4bd..36366ed3 100644 --- a/home/program/bash/module/Gpg.nix +++ b/home/program/bash/module/Gpg.nix @@ -1,95 +1,96 @@ -{ ... }: { - text = '' - # Check smartcard pin. - function scunlock() { - pkill keyboxd &> /dev/null - # pkill gpg-agent &> /dev/null - echo verify | gpg --card-edit --no-tty --command-fd=0 - } +{ ... }: +{ + text = '' + # Check smartcard pin. + function scunlock() { + pkill keyboxd &> /dev/null + # pkill gpg-agent &> /dev/null + echo verify | gpg --card-edit --no-tty --command-fd=0 + } - # Encrypt files to myself. - # Usage: encrypt - function encrypt() { - local IFS=$'\n' - local targets=(''${@}) + # Encrypt files to myself. + # Usage: encrypt + function encrypt() { + local IFS=$'\n' + local targets=(''${@}) - if [[ "''${targets}" = "" ]]; then - help encrypt - return 2 - fi + if [[ "''${targets}" = "" ]]; then + help encrypt + return 2 + fi - process() { - gpg --encrypt --armor --recipient hi@voronind.com --output "''${target}.gpg" "''${target}" - } + process() { + gpg --encrypt --armor --recipient hi@voronind.com --output "''${target}.gpg" "''${target}" + } - _iterate_targets process ''${targets[@]} - } + _iterate_targets process ''${targets[@]} + } - # Decrypt files to myself. - # Usage: decrypt [FILES] - function decrypt() { - local IFS=$'\n' - local targets=(''${@}) + # Decrypt files to myself. + # Usage: decrypt [FILES] + function decrypt() { + local IFS=$'\n' + local targets=(''${@}) - [[ "''${targets}" = "" ]] && targets=(*.gpg) + [[ "''${targets}" = "" ]] && targets=(*.gpg) - process() { - gpg --decrypt --output "''${target%.gpg}" "''${target}" - } + process() { + gpg --decrypt --output "''${target%.gpg}" "''${target}" + } - _iterate_targets process ''${targets[@]} - } + _iterate_targets process ''${targets[@]} + } - # Sign a file. - # Usage: sign - function sign() { - local IFS=$'\n' - local targets=(''${@}) + # Sign a file. + # Usage: sign + function sign() { + local IFS=$'\n' + local targets=(''${@}) - if [[ "''${targets}" = "" ]]; then - help sign - return 2 - fi + if [[ "''${targets}" = "" ]]; then + help sign + return 2 + fi - process() { - gpg --detach-sig --armor --output "''${target}.sig" "''${target}" - } + process() { + gpg --detach-sig --armor --output "''${target}.sig" "''${target}" + } - _iterate_targets process ''${targets[@]} - } + _iterate_targets process ''${targets[@]} + } - # Verify a signature. All .sig files by default. - # Usage: verify [FILES] - function verify() { - local IFS=$'\n' - local targets=(''${@}) + # Verify a signature. All .sig files by default. + # Usage: verify [FILES] + function verify() { + local IFS=$'\n' + local targets=(''${@}) - [[ "''${targets}" = "" ]] && targets=(*.sig) + [[ "''${targets}" = "" ]] && targets=(*.sig) - process() { - gpg --verify "''${target}" - } + process() { + gpg --verify "''${target}" + } - _iterate_targets process ''${targets[@]} - } + _iterate_targets process ''${targets[@]} + } - # Find user keys using keyservers. - # Usage: gpg_find - function gpg_find() { - local email="''${1}" + # Find user keys using keyservers. + # Usage: gpg_find + function gpg_find() { + local email="''${1}" - if [[ "''${email}" = "" ]]; then - help gpg_find - return 2 - fi + if [[ "''${email}" = "" ]]; then + help gpg_find + return 2 + fi - gpg --locate-keys "''${email}" \ - || gpg --locate-keys --auto-key-locate hkps://keys.openpgp.org "''${email}" - } + gpg --locate-keys "''${email}" \ + || gpg --locate-keys --auto-key-locate hkps://keys.openpgp.org "''${email}" + } - # Update keys. - function gpg_refresh() { - gpg --refresh-keys - } - ''; + # Update keys. + function gpg_refresh() { + gpg --refresh-keys + } + ''; } diff --git a/home/program/bash/module/Group.nix b/home/program/bash/module/Group.nix index a99809db..a19ae26f 100644 --- a/home/program/bash/module/Group.nix +++ b/home/program/bash/module/Group.nix @@ -1,73 +1,74 @@ -{ ... }: { - text = '' - # Group files by extension. - # Usage: group_ext [FILES] - function group_ext() { - local IFS=$'\n' - local targets=(''${@}) - [[ "''${targets}" = "" ]] && targets=($(_ls_file)) +{ ... }: +{ + text = '' + # Group files by extension. + # Usage: group_ext [FILES] + function group_ext() { + local IFS=$'\n' + local targets=(''${@}) + [[ "''${targets}" = "" ]] && targets=($(_ls_file)) - process() { - local ext=''${target##*.} - [[ -d "''${target}" ]] && { _iterate_skip "Is a directory."; return 0; } - [[ "''${ext}" = "''${target}" ]] && { _iterate_skip "No extension."; return 0; } + process() { + local ext=''${target##*.} + [[ -d "''${target}" ]] && { _iterate_skip "Is a directory."; return 0; } + [[ "''${ext}" = "''${target}" ]] && { _iterate_skip "No extension."; return 0; } - mkdir ''${ext} 2> /dev/null + mkdir ''${ext} 2> /dev/null - mv -- ''${target} ./''${ext}/''${target} - } + mv -- ''${target} ./''${ext}/''${target} + } - _iterate_targets process ''${targets[@]} - } + _iterate_targets process ''${targets[@]} + } - # Group files and dirs by year. - # Usage: group_year [FILES] - function group_year() { - local IFS=$'\n' - local targets=(''${@}) - [[ "''${targets}" = "" ]] && targets=($(ls)) + # Group files and dirs by year. + # Usage: group_year [FILES] + function group_year() { + local IFS=$'\n' + local targets=(''${@}) + [[ "''${targets}" = "" ]] && targets=($(ls)) - process() { - local year=$(stat --format=%y ''${target}) - year=''${year%%-*} + process() { + local year=$(stat --format=%y ''${target}) + year=''${year%%-*} - mkdir ''${year} 2> /dev/null + mkdir ''${year} 2> /dev/null - mv -- ''${target} ./''${year}/''${target} - } + mv -- ''${target} ./''${year}/''${target} + } - _iterate_targets process ''${targets[@]} - } + _iterate_targets process ''${targets[@]} + } - # Copy files from current year to the named dir. - # Usage: group_year_copy [FILES] - function group_year_copy() { - local IFS=$'\n' - local selected_year="''${1}" - local targets=(''${@:2}) + # Copy files from current year to the named dir. + # Usage: group_year_copy [FILES] + function group_year_copy() { + local IFS=$'\n' + local selected_year="''${1}" + local targets=(''${@:2}) - if [[ "''${selected_year}" = "" ]]; then - help group_year_copy - return 2 - fi + if [[ "''${selected_year}" = "" ]]; then + help group_year_copy + return 2 + fi - # All files by default. - [[ "''${targets}" = "" ]] && targets=($(ls)) + # All files by default. + [[ "''${targets}" = "" ]] && targets=($(ls)) - mkdir ''${selected_year} 2> /dev/null + mkdir ''${selected_year} 2> /dev/null - process() { - local year=$(stat --format=%y ''${target}) - year=''${year%%-*} + process() { + local year=$(stat --format=%y ''${target}) + year=''${year%%-*} - if [[ "''${year}" = "''${selected_year}" ]]; then - rcp -- ''${target} ./''${selected_year}/ - else - _iterate_skip "Skip: ''${year}" - fi - } + if [[ "''${year}" = "''${selected_year}" ]]; then + rcp -- ''${target} ./''${selected_year}/ + else + _iterate_skip "Skip: ''${year}" + fi + } - _iterate_targets process ''${targets[@]} - } - ''; + _iterate_targets process ''${targets[@]} + } + ''; } diff --git a/home/program/bash/module/Help.nix b/home/program/bash/module/Help.nix index c11dfcda..c08172e1 100644 --- a/home/program/bash/module/Help.nix +++ b/home/program/bash/module/Help.nix @@ -1,29 +1,30 @@ -{ ... }: { - text = '' - # Get help about dotfiles bash function. - # Usage: help - function help() { - local fun="''${1}" +{ ... }: +{ + text = '' + # Get help about dotfiles bash function. + # Usage: help + function help() { + local fun="''${1}" - if [[ "''${fun}" = "" ]] || [[ "$(find_function | grep ''${fun})" = "" ]]; then - help help - return 2 - fi + if [[ "''${fun}" = "" ]] || [[ "$(find_function | grep ''${fun})" = "" ]]; then + help help + return 2 + fi - cat ~/.bashrc | sed -n -e "/^function ''${fun}()/q;p" | tac | sed -n -e "/^[^#]/q;p" | tac | sed -e "s/^# \+//" -e "\$i \ " | sed "1{/^$/d}" | sed "1{/^ *$/d}" - } + cat ~/.bashrc | sed -n -e "/^function ''${fun}()/q;p" | tac | sed -n -e "/^[^#]/q;p" | tac | sed -e "s/^# \+//" -e "\$i \ " | sed "1{/^$/d}" | sed "1{/^ *$/d}" + } - # Short for help. - # Usage: h - function h() { - help "''${@}" - } + # Short for help. + # Usage: h + function h() { + help "''${@}" + } - # Autocomplete with available functions. - function _help_functions() { - _autocomplete $(find_function) - } + # Autocomplete with available functions. + function _help_functions() { + _autocomplete $(find_function) + } - complete -F _help_functions help h - ''; + complete -F _help_functions help h + ''; } diff --git a/home/program/bash/module/Ls.nix b/home/program/bash/module/Ls.nix index e4cbd067..ca001d75 100644 --- a/home/program/bash/module/Ls.nix +++ b/home/program/bash/module/Ls.nix @@ -1,70 +1,71 @@ -{ ... }: { - text = '' - # Unset possible system-defined aliases. - unalias l ll lll llll la lla &> /dev/null - unset l ll lll llll la lla &> /dev/null +{ ... }: +{ + text = '' + # Unset possible system-defined aliases. + unalias l ll lll llll la lla &> /dev/null + unset l ll lll llll la lla &> /dev/null - # List files in dirs. - # Current dir by default. - # Usage: l [DIRS] - function l() { - # ls -lhv --si --group-directories-first --color=auto -- "$@" - ccd "$@" - } + # List files in dirs. + # Current dir by default. + # Usage: l [DIRS] + function l() { + # ls -lhv --si --group-directories-first --color=auto -- "$@" + ccd "$@" + } - # List last modified files first. - # Current dir by default. - # Usage: ll [DIRS] - function ll() { - ls -lhv --si --group-directories-first --color=auto -- "$@" - # ls -lhvtr --si --color=auto -- "$@" - } + # List last modified files first. + # Current dir by default. + # Usage: ll [DIRS] + function ll() { + ls -lhv --si --group-directories-first --color=auto -- "$@" + # ls -lhvtr --si --color=auto -- "$@" + } - # List files in tree structure. - # Current dir by default. - # Depth can be omitted by passing `-` (dash). - # Usage: lll [DEPTH] [DIRS] - function lll() { - local IFS=$'\n' - local depth="''${1}" - local target=("''${@:2}") + # List files in tree structure. + # Current dir by default. + # Depth can be omitted by passing `-` (dash). + # Usage: lll [DEPTH] [DIRS] + function lll() { + local IFS=$'\n' + local depth="''${1}" + local target=("''${@:2}") - [[ "''${target}" = "" ]] && target="." - [[ "''${depth}" = "" ]] && depth=666 - [[ "''${depth}" = "-" ]] && depth=666 + [[ "''${target}" = "" ]] && target="." + [[ "''${depth}" = "" ]] && depth=666 + [[ "''${depth}" = "-" ]] && depth=666 - tree -a -L "''${depth}" -- "''${target[@]}" - } + tree -a -L "''${depth}" -- "''${target[@]}" + } - # List files recursively. - # Current dir by default. - # Usage: llll [DIRS] - function llll() { - ls -RlAhv --si --group-directories-first --color=auto -- "$@" - } + # List files recursively. + # Current dir by default. + # Usage: llll [DIRS] + function llll() { + ls -RlAhv --si --group-directories-first --color=auto -- "$@" + } - # List all files in dirs, incl. hidden files. - # Current dir by default. - # Usage: la [DIRS] - function la() { - ls -lAh --si --group-directories-first --color=auto -- "$@" - } + # List all files in dirs, incl. hidden files. + # Current dir by default. + # Usage: la [DIRS] + function la() { + ls -lAh --si --group-directories-first --color=auto -- "$@" + } - # List all files in dirs, incl. hidden files, sorted by mtime. - # Current dir by default. - # Usage: lla [DIRS] - function lla() { - ls -lAhtr --si --color=auto -- "$@" - } + # List all files in dirs, incl. hidden files, sorted by mtime. + # Current dir by default. + # Usage: lla [DIRS] + function lla() { + ls -lAhtr --si --color=auto -- "$@" + } - # List only files. - function _ls_file() { - ls --classify | grep -v \/$ - } + # List only files. + function _ls_file() { + ls --classify | grep -v \/$ + } - # List only dirs. - function _ls_dir() { - ls --classify | grep \/$ | sed -e "s/\/$//" - } - ''; + # List only dirs. + function _ls_dir() { + ls --classify | grep \/$ | sed -e "s/\/$//" + } + ''; } diff --git a/home/program/bash/module/Name.nix b/home/program/bash/module/Name.nix index 749caaf8..3278b085 100644 --- a/home/program/bash/module/Name.nix +++ b/home/program/bash/module/Name.nix @@ -1,399 +1,400 @@ -{ ... }: { - text = '' - # Rename dirs to `snake_case` and files to `PascalCase`. Careful with structured file names like archives! - # Usage: name [FILES] - function name() { - local IFS=$'\n' - local targets=(''${@}) - [[ "''${targets}" = "" ]] && targets=($(ls)) - - process() { - # Skip archive. - if $(_is_archive "''${target}"); then - _iterate_skip "File is an archive, skip." - return 0 - fi - - if [[ -d "''${target}" ]]; then - local new_name=$(parse_snake ''${target}) - [[ -e "''${new_name}" ]] && return 0 - - mv -- ''${target} ''${new_name} && echo ''${new_name} - else - local ext=".''${target##*.}" - local name=''${target%.*} - [[ "''${ext}" = ".''${target}" ]] && ext="" - - local new_name="$(parse_pascal ''${name})''${ext}" - [[ -e "''${new_name}" ]] && return 0 - - mv -- ''${target} ''${new_name} && echo ''${new_name} - fi - } - - _iterate_targets process ''${targets[@]} - } - - # Rename files with provided parser, i.e. `parse_simple`. - # All files by default. - # Usage: name_parse [FILES] - function name_parse() { - local IFS=$'\n' - local parser=''${1} - local targets=(''${@:2}) - [[ "''${targets}" = "" ]] && targets=([^.]*) - - if [[ "''${parser}" = "" ]]; then - help name_parse - return 2 - fi - - process() { - # Skip archive. - if $(_is_archive "''${target}"); then - _iterate_skip "File is an archive, skip." - return 0 - fi - - # parse new name. - local ext="" - local name="''${target}" - - # ext only for files. - if [[ -f "''${target}" ]]; then - ext=".''${target##*.}" - name="''${target%.*}" - fi - - # Files w/o extension support. - [[ "''${ext#.}" = "''${name}" ]] && ext="" - - # Get new name. - local new_name=$(''${parser} "''${name}")''${ext,,} - - # check if same name. - [[ "''${target}" = "''${new_name}" ]] && return 0 - - # check if target name already exists. - if [[ -f "''${new_name}" ]]; then - _error "''${new_name}: Already exists!" - return 1 - fi - - # rename target. - mv -- "''${target}" "''${new_name}" && echo "''${new_name}" - } - - _iterate_targets process ''${targets[@]} - } - - # Rename all files to their hashes while keeping extensions. - # All files by default. - # Usage: name_hash [FILES] - function name_hash() { - local IFS=$'\n' - local targets=(''${@}) - [[ "''${targets}" = "" ]] && targets=($(_ls_file)) - - process() { - # extract extension. - local extension="''${target##*.}" - if [[ "''${extension}" = "''${target}" ]]; then - extension="" - else - extension=".''${extension}" - fi - - # hash the new name. - local hash=$(pv "''${target}" | sha1sum | cut -d\ -f1) - new_name="''${hash,,}''${extension,,}" - - # check if same name. - [[ "''${target}" = "''${new_name}" ]] && return 0 - - # rename target. - mv -- ''${target} ''${new_name} && echo ''${new_name} - } - - _iterate_targets process ''${targets[@]} - } - - # Check hashes for previously renamed files. - # All files by default. - # Usage: name_hash_check [FILES] - function name_hash_check() { - local IFS=$'\n' - local targets=(''${@}) - [[ "''${targets}" = "" ]] && targets=([^.]*) - - process() { - # extract hashes. - local stored="''${target%%.*}" - local actual=$(pv "''${target}" | sha1sum | cut -d\ -f1) - - # compare hashes. - if [[ "''${stored}" != "''${actual}" ]]; then - _error "Failed." - return 1 - fi - } - - _iterate_targets process ''${targets[@]} - } - - # Rename files for Jellyfin shows, i.e. `Episode S01E01.mkv` - # All files by default. - # Usage: name_show [FILES] - function name_show() { - local IFS=$'\n' - local season="$(realpath .)"; season="''${season##*\ }" - local episode=0 - local targets=(''${@}) - [[ "''${targets}" = "" ]] && targets=($(_ls_file)) - - # Error when no season number specified. - if [[ "''${season}" = "" ]]; then - _error "Could not determine season number." - return 2 - fi - - process() { - ((episode++)) - - # extract new name. - local new_name="Episode S''${season}E$(printf %02d ''${episode}).''${target##*.}" - - # Skip on no change. - [[ "''${target}" = "''${new_name}" ]] && return 0 - - # rename target. - mv -- ''${target} ''${new_name} && echo ''${new_name} - } - - _iterate_targets process ''${targets[@]} - } - - # Rename files for Kavita manga format. - # All files by default. - # Usage: name_manga [FILES] - function name_manga() { - local IFS=$'\n' - local manga=''${PWD##*/} - local season=''${1} - local episode=0 - local targets=(''${@:2}) - [[ "''${targets}" = "" ]] && targets=($(_ls_file)) - - # Error when no season number specified. - if [[ "''${season}" = "" ]]; then - help name_manga - return 2 - fi - - process() { - ((episode++)) - - # Extract new name. - local new_name="''${manga} Vol.''${season} Ch.''${episode}.''${target##*.}" - - # Skip on no change. - [[ "''${target}" = "''${new_name}" ]] && return 0 - - # Rename target. - mv -- ''${target} ''${new_name} && echo ''${new_name} - } - - _iterate_targets process ''${targets[@]} - } - - # Rename files for ffmpeg_music_meta format. - # All files by default. - # Usage: name_music [FILES] - function name_music() { - local IFS=$'\n' - local targets=(''${@}) - [[ "''${targets}" = "" ]] && targets=($(ls)) - - process() { - # Extract new name. - local ext=''${target##*.} - - if [[ -d "''${target}" ]]; then - local new_name="$(parse_startcase $(parse_simple ''${target%.*}))" - else - local new_name="$(parse_startcase $(parse_simple ''${target%.*})).''${ext}" - fi - - # Skip on no change. - [[ "''${target%/}" = "''${new_name}" ]] && return 0 - - # Rename target. - mv -- ''${target} ''${new_name} && echo ''${new_name} - } - - _iterate_targets process ''${targets[@]} - } - - # Rename files with new extension. - # All files by default. - # Usage: name_ext [FILES] - function name_ext() { - local IFS=$'\n' - local extension=''${1} - local targets=(''${@:2}) - [[ "''${targets}" = "" ]] && targets=($(_ls_file)) - - # Error when no new extension specified. - if [[ "''${extension}" = "" ]]; then - help name_ext - return 2 - fi - - process() { - # Extract new name. - local new_name="''${target%.*}"."''${extension}" - - # Skip on no change. - [[ "''${target}" = "''${new_name}" ]] && return 0 - - # Rename target. - mv -- ''${target} ''${new_name} && echo ''${new_name} - } - - _iterate_targets process ''${targets[@]} - } - - # Change file name prefix. - # All matching files by default. - # Usage: name_prefix [FILES] - function name_prefix() { - local IFS=$'\n' - local old=''${1} - local new=''${2} - local targets=(''${@:3}) - [[ "''${targets}" = "" ]] && targets=(''${old}*) - - process() { - # Create new name. - local new_name="''${new}''${target#$old}" - - # Skip on no change. - [[ "''${target}" = "''${new_name}" ]] && return 0 - - # Rename. - mv -- ''${target} ''${new_name} && echo ''${new_name} - } - - _iterate_targets process ''${targets[@]} - } - - # Change file name postfix. - # All matching files by default. - # Usage: name_postfix [FILES] - function name_postfix() { - local IFS=$'\n' - local old=''${1} - local new=''${2} - local targets=(''${@:3}) - [[ "''${targets}" = "" ]] && targets=(*''${old}) - - process() { - # Create new name. - local new_name="''${target%$old}''${new}" - - # Skip on no change. - [[ "''${target}" = "''${new_name}" ]] && return 0 - - # Rename. - mv -- ''${target} ''${new_name} && echo ''${new_name} - } - - _iterate_targets process ''${targets[@]} - } - - # Replace part of the name. - # All matching files by default. - # Usage: name_replace [FILES] - function name_replace() { - local IFS=$'\n' - local old=''${1} - local new=''${2} - local targets=(''${@:3}) - [[ "''${targets}" = "" ]] && targets=(*''${old}*) - - process() { - # Create new name. - local new_name="''${target//$old/$new}" - - # Skip on no change. - [[ "''${target}" = "''${new_name}" ]] && return 0 - - # Rename. - mv -- ''${target} ''${new_name} && echo ''${new_name} - } - - _iterate_targets process ''${targets[@]} - } - - # Fix numbering for numbered files. I.e if there are 10 items and some of them start without zero, then append zero to it. 1..10 -> 01..10. - # Usage: name_fix_numbering [FILES] - function name_fix_numbering() { - local IFS=$'\n' - local highest=0 - local power=0 - local targets=(''${@}) - [[ "''${targets}" = "" ]] && targets=($(ls | grep "^[0-9]")) - - # Count leading zeroes. - for target in "''${targets[@]}"; do - # Check that starts with a digit. - [[ "''${target}" =~ ^[0-9] ]] || continue - - local digits=($(parse_ints "''${target}")) - local digit="''${digits[0]}" - digit=$((10#''${digit})) - - [[ "''${digit}" -gt "''${highest}" ]] && highest="''${digit}" - done - - local i=''${highest} - while [[ i -gt 0 ]]; do - ((power++)) - i=$((''${i}/10)) - done - - process() { - # Check that starts with a digit. - if [[ ! "''${target}" =~ ^[0-9] ]]; then - _error "Does not start with a digit!" - return 1 - fi - - # Prepare new name. - local digits=($(parse_ints "''${target}")) - local digit="''${digits[0]}" - digit=$((10#''${digit})) - local new_name=$(printf "%0''${power}d" "''${digit}")"''${target#''${digits[0]}}" - - # Skip if the same name. - [[ "''${target}" = "''${new_name}" ]] && return 0 - - # Check that file does not exist. - if [[ -e "''${new_name}" ]]; then - _error "''${new_name}: File exists!" - return 1 - fi - - mv -- ''${target} ''${new_name} && echo ''${new_name} - } - - _iterate_targets process ''${targets[@]} - } - - function _comp_name_parse() { - _autocomplete $(find_function | grep ^parse) - } - - complete -o filenames -F _comp_name_parse name_parse - ''; +{ ... }: +{ + text = '' + # Rename dirs to `snake_case` and files to `PascalCase`. Careful with structured file names like archives! + # Usage: name [FILES] + function name() { + local IFS=$'\n' + local targets=(''${@}) + [[ "''${targets}" = "" ]] && targets=($(ls)) + + process() { + # Skip archive. + if $(_is_archive "''${target}"); then + _iterate_skip "File is an archive, skip." + return 0 + fi + + if [[ -d "''${target}" ]]; then + local new_name=$(parse_snake ''${target}) + [[ -e "''${new_name}" ]] && return 0 + + mv -- ''${target} ''${new_name} && echo ''${new_name} + else + local ext=".''${target##*.}" + local name=''${target%.*} + [[ "''${ext}" = ".''${target}" ]] && ext="" + + local new_name="$(parse_pascal ''${name})''${ext}" + [[ -e "''${new_name}" ]] && return 0 + + mv -- ''${target} ''${new_name} && echo ''${new_name} + fi + } + + _iterate_targets process ''${targets[@]} + } + + # Rename files with provided parser, i.e. `parse_simple`. + # All files by default. + # Usage: name_parse [FILES] + function name_parse() { + local IFS=$'\n' + local parser=''${1} + local targets=(''${@:2}) + [[ "''${targets}" = "" ]] && targets=([^.]*) + + if [[ "''${parser}" = "" ]]; then + help name_parse + return 2 + fi + + process() { + # Skip archive. + if $(_is_archive "''${target}"); then + _iterate_skip "File is an archive, skip." + return 0 + fi + + # parse new name. + local ext="" + local name="''${target}" + + # ext only for files. + if [[ -f "''${target}" ]]; then + ext=".''${target##*.}" + name="''${target%.*}" + fi + + # Files w/o extension support. + [[ "''${ext#.}" = "''${name}" ]] && ext="" + + # Get new name. + local new_name=$(''${parser} "''${name}")''${ext,,} + + # check if same name. + [[ "''${target}" = "''${new_name}" ]] && return 0 + + # check if target name already exists. + if [[ -f "''${new_name}" ]]; then + _error "''${new_name}: Already exists!" + return 1 + fi + + # rename target. + mv -- "''${target}" "''${new_name}" && echo "''${new_name}" + } + + _iterate_targets process ''${targets[@]} + } + + # Rename all files to their hashes while keeping extensions. + # All files by default. + # Usage: name_hash [FILES] + function name_hash() { + local IFS=$'\n' + local targets=(''${@}) + [[ "''${targets}" = "" ]] && targets=($(_ls_file)) + + process() { + # extract extension. + local extension="''${target##*.}" + if [[ "''${extension}" = "''${target}" ]]; then + extension="" + else + extension=".''${extension}" + fi + + # hash the new name. + local hash=$(pv "''${target}" | sha1sum | cut -d\ -f1) + new_name="''${hash,,}''${extension,,}" + + # check if same name. + [[ "''${target}" = "''${new_name}" ]] && return 0 + + # rename target. + mv -- ''${target} ''${new_name} && echo ''${new_name} + } + + _iterate_targets process ''${targets[@]} + } + + # Check hashes for previously renamed files. + # All files by default. + # Usage: name_hash_check [FILES] + function name_hash_check() { + local IFS=$'\n' + local targets=(''${@}) + [[ "''${targets}" = "" ]] && targets=([^.]*) + + process() { + # extract hashes. + local stored="''${target%%.*}" + local actual=$(pv "''${target}" | sha1sum | cut -d\ -f1) + + # compare hashes. + if [[ "''${stored}" != "''${actual}" ]]; then + _error "Failed." + return 1 + fi + } + + _iterate_targets process ''${targets[@]} + } + + # Rename files for Jellyfin shows, i.e. `Episode S01E01.mkv` + # All files by default. + # Usage: name_show [FILES] + function name_show() { + local IFS=$'\n' + local season="$(realpath .)"; season="''${season##*\ }" + local episode=0 + local targets=(''${@}) + [[ "''${targets}" = "" ]] && targets=($(_ls_file)) + + # Error when no season number specified. + if [[ "''${season}" = "" ]]; then + _error "Could not determine season number." + return 2 + fi + + process() { + ((episode++)) + + # extract new name. + local new_name="Episode S''${season}E$(printf %02d ''${episode}).''${target##*.}" + + # Skip on no change. + [[ "''${target}" = "''${new_name}" ]] && return 0 + + # rename target. + mv -- ''${target} ''${new_name} && echo ''${new_name} + } + + _iterate_targets process ''${targets[@]} + } + + # Rename files for Kavita manga format. + # All files by default. + # Usage: name_manga [FILES] + function name_manga() { + local IFS=$'\n' + local manga=''${PWD##*/} + local season=''${1} + local episode=0 + local targets=(''${@:2}) + [[ "''${targets}" = "" ]] && targets=($(_ls_file)) + + # Error when no season number specified. + if [[ "''${season}" = "" ]]; then + help name_manga + return 2 + fi + + process() { + ((episode++)) + + # Extract new name. + local new_name="''${manga} Vol.''${season} Ch.''${episode}.''${target##*.}" + + # Skip on no change. + [[ "''${target}" = "''${new_name}" ]] && return 0 + + # Rename target. + mv -- ''${target} ''${new_name} && echo ''${new_name} + } + + _iterate_targets process ''${targets[@]} + } + + # Rename files for ffmpeg_music_meta format. + # All files by default. + # Usage: name_music [FILES] + function name_music() { + local IFS=$'\n' + local targets=(''${@}) + [[ "''${targets}" = "" ]] && targets=($(ls)) + + process() { + # Extract new name. + local ext=''${target##*.} + + if [[ -d "''${target}" ]]; then + local new_name="$(parse_startcase $(parse_simple ''${target%.*}))" + else + local new_name="$(parse_startcase $(parse_simple ''${target%.*})).''${ext}" + fi + + # Skip on no change. + [[ "''${target%/}" = "''${new_name}" ]] && return 0 + + # Rename target. + mv -- ''${target} ''${new_name} && echo ''${new_name} + } + + _iterate_targets process ''${targets[@]} + } + + # Rename files with new extension. + # All files by default. + # Usage: name_ext [FILES] + function name_ext() { + local IFS=$'\n' + local extension=''${1} + local targets=(''${@:2}) + [[ "''${targets}" = "" ]] && targets=($(_ls_file)) + + # Error when no new extension specified. + if [[ "''${extension}" = "" ]]; then + help name_ext + return 2 + fi + + process() { + # Extract new name. + local new_name="''${target%.*}"."''${extension}" + + # Skip on no change. + [[ "''${target}" = "''${new_name}" ]] && return 0 + + # Rename target. + mv -- ''${target} ''${new_name} && echo ''${new_name} + } + + _iterate_targets process ''${targets[@]} + } + + # Change file name prefix. + # All matching files by default. + # Usage: name_prefix [FILES] + function name_prefix() { + local IFS=$'\n' + local old=''${1} + local new=''${2} + local targets=(''${@:3}) + [[ "''${targets}" = "" ]] && targets=(''${old}*) + + process() { + # Create new name. + local new_name="''${new}''${target#$old}" + + # Skip on no change. + [[ "''${target}" = "''${new_name}" ]] && return 0 + + # Rename. + mv -- ''${target} ''${new_name} && echo ''${new_name} + } + + _iterate_targets process ''${targets[@]} + } + + # Change file name postfix. + # All matching files by default. + # Usage: name_postfix [FILES] + function name_postfix() { + local IFS=$'\n' + local old=''${1} + local new=''${2} + local targets=(''${@:3}) + [[ "''${targets}" = "" ]] && targets=(*''${old}) + + process() { + # Create new name. + local new_name="''${target%$old}''${new}" + + # Skip on no change. + [[ "''${target}" = "''${new_name}" ]] && return 0 + + # Rename. + mv -- ''${target} ''${new_name} && echo ''${new_name} + } + + _iterate_targets process ''${targets[@]} + } + + # Replace part of the name. + # All matching files by default. + # Usage: name_replace [FILES] + function name_replace() { + local IFS=$'\n' + local old=''${1} + local new=''${2} + local targets=(''${@:3}) + [[ "''${targets}" = "" ]] && targets=(*''${old}*) + + process() { + # Create new name. + local new_name="''${target//$old/$new}" + + # Skip on no change. + [[ "''${target}" = "''${new_name}" ]] && return 0 + + # Rename. + mv -- ''${target} ''${new_name} && echo ''${new_name} + } + + _iterate_targets process ''${targets[@]} + } + + # Fix numbering for numbered files. I.e if there are 10 items and some of them start without zero, then append zero to it. 1..10 -> 01..10. + # Usage: name_fix_numbering [FILES] + function name_fix_numbering() { + local IFS=$'\n' + local highest=0 + local power=0 + local targets=(''${@}) + [[ "''${targets}" = "" ]] && targets=($(ls | grep "^[0-9]")) + + # Count leading zeroes. + for target in "''${targets[@]}"; do + # Check that starts with a digit. + [[ "''${target}" =~ ^[0-9] ]] || continue + + local digits=($(parse_ints "''${target}")) + local digit="''${digits[0]}" + digit=$((10#''${digit})) + + [[ "''${digit}" -gt "''${highest}" ]] && highest="''${digit}" + done + + local i=''${highest} + while [[ i -gt 0 ]]; do + ((power++)) + i=$((''${i}/10)) + done + + process() { + # Check that starts with a digit. + if [[ ! "''${target}" =~ ^[0-9] ]]; then + _error "Does not start with a digit!" + return 1 + fi + + # Prepare new name. + local digits=($(parse_ints "''${target}")) + local digit="''${digits[0]}" + digit=$((10#''${digit})) + local new_name=$(printf "%0''${power}d" "''${digit}")"''${target#''${digits[0]}}" + + # Skip if the same name. + [[ "''${target}" = "''${new_name}" ]] && return 0 + + # Check that file does not exist. + if [[ -e "''${new_name}" ]]; then + _error "''${new_name}: File exists!" + return 1 + fi + + mv -- ''${target} ''${new_name} && echo ''${new_name} + } + + _iterate_targets process ''${targets[@]} + } + + function _comp_name_parse() { + _autocomplete $(find_function | grep ^parse) + } + + complete -o filenames -F _comp_name_parse name_parse + ''; } diff --git a/home/program/bash/module/Nix.nix b/home/program/bash/module/Nix.nix index 54557bf9..32b306e2 100644 --- a/home/program/bash/module/Nix.nix +++ b/home/program/bash/module/Nix.nix @@ -1,89 +1,90 @@ -{ ... }: { - text = '' - # Spawn shell with specified nix environment. - # Uses flake.nix in current dir by default. - # Usage: shell [NAME] - function shell() { - local target="''${1}" - [[ "''${target}" = "" ]] && target="default" +{ ... }: +{ + text = '' + # Spawn shell with specified nix environment. + # Uses flake.nix in current dir by default. + # Usage: shell [NAME] + function shell() { + local target="''${1}" + [[ "''${target}" = "" ]] && target="default" - SHELL_NAME="''${target}" nix develop ".#''${target}" - } + SHELL_NAME="''${target}" nix develop ".#''${target}" + } - # Spawn temporary nix-shell with specified packages. - # Usage: tmpshell - function tmpshell() { - local IFS=$'\n' - local input=("''${@}") - local pkgs=() - local tag="''${1}" + # Spawn temporary nix-shell with specified packages. + # Usage: tmpshell + function tmpshell() { + local IFS=$'\n' + local input=("''${@}") + local pkgs=() + local tag="''${1}" - if [[ "''${input}" = "" ]]; then - help tmpshell - return 2 - fi + if [[ "''${input}" = "" ]]; then + help tmpshell + return 2 + fi - for pkg in ''${input[@]}; do - pkgs+=("nixpkgs#''${pkg}") - done + for pkg in ''${input[@]}; do + pkgs+=("nixpkgs#''${pkg}") + done - SHELL_NAME="''${tag}" NIXPKGS_ALLOW_INSECURE=1 NIXPKGS_ALLOW_UNFREE=1 nix shell --impure ''${pkgs[@]} - } + SHELL_NAME="''${tag}" NIXPKGS_ALLOW_INSECURE=1 NIXPKGS_ALLOW_UNFREE=1 nix shell --impure ''${pkgs[@]} + } - function nix_depends() { - nix why-depends /run/current-system nixpkgs#''${1} - } + function nix_depends() { + nix why-depends /run/current-system nixpkgs#''${1} + } - # Run stuff directrly from Nixpks. - # Usage: nixpkgs_run [COMMAND] - function nixpkgs_run() { - local rev="''${1}" - local pkg="''${2}" - local cmd="''${@:3}" + # Run stuff directrly from Nixpks. + # Usage: nixpkgs_run [COMMAND] + function nixpkgs_run() { + local rev="''${1}" + local pkg="''${2}" + local cmd="''${@:3}" - if [[ "''${pkg}" = "" ]]; then - help nixpkgs_run - return 2 - fi + if [[ "''${pkg}" = "" ]]; then + help nixpkgs_run + return 2 + fi - [[ "''${cmd}" = "" ]] && cmd="''${pkg}" + [[ "''${cmd}" = "" ]] && cmd="''${pkg}" - SHELL_NAME="''${pkg}" NIXPKGS_ALLOW_INSECURE=1 NIXPKGS_ALLOW_UNFREE=1 nix shell --impure github:NixOS/nixpkgs/''${rev}#''${pkg} -c ''${cmd} - } + SHELL_NAME="''${pkg}" NIXPKGS_ALLOW_INSECURE=1 NIXPKGS_ALLOW_UNFREE=1 nix shell --impure github:NixOS/nixpkgs/''${rev}#''${pkg} -c ''${cmd} + } - # Prefetch to nix store. - # Usage: prefetch - function prefetch() { - local url="''${1}" - local name="''${1##*/}" - name=$(parse_alnum "''${name%%\?*}") + # Prefetch to nix store. + # Usage: prefetch + function prefetch() { + local url="''${1}" + local name="''${1##*/}" + name=$(parse_alnum "''${name%%\?*}") - if [[ "''${url}" = "" ]]; then - help prefetch - return 2 - fi + if [[ "''${url}" = "" ]]; then + help prefetch + return 2 + fi - local result=$(nix hash convert --to sri --hash-algo sha256 $(nix-prefetch-url --name "''${name}" "''${url}")) - printf "%s" ''${result} | copy - printf "%s\n" ''${result} - } + local result=$(nix hash convert --to sri --hash-algo sha256 $(nix-prefetch-url --name "''${name}" "''${url}")) + printf "%s" ''${result} | copy + printf "%s\n" ''${result} + } - # Run nix locally with no builders. - # Usage: nix_local - function nix_local() { - nix --option max-jobs $(_core_count) --builders "" --substituters https://cache.nixos.org ''${@} - } + # Run nix locally with no builders. + # Usage: nix_local + function nix_local() { + nix --option max-jobs $(_core_count) --builders "" --substituters https://cache.nixos.org ''${@} + } - # Run test app from other people PRs. - # Usage: nix_test github:user/nixpkgs/# - function nix_test() { - if [[ "''${@}" = "" ]]; then - help nix_test - return 2 - fi + # Run test app from other people PRs. + # Usage: nix_test github:user/nixpkgs/# + function nix_test() { + if [[ "''${@}" = "" ]]; then + help nix_test + return 2 + fi - local name=''${*##*#} - SHELL_NAME="''${name}" NIXPKGS_ALLOW_INSECURE=1 NIXPKGS_ALLOW_UNFREE=1 nix --option max-jobs $(_core_count) --builders "" --substituters https://cache.nixos.org shell --impure ''${@} - } - ''; + local name=''${*##*#} + SHELL_NAME="''${name}" NIXPKGS_ALLOW_INSECURE=1 NIXPKGS_ALLOW_UNFREE=1 nix --option max-jobs $(_core_count) --builders "" --substituters https://cache.nixos.org shell --impure ''${@} + } + ''; } diff --git a/home/program/bash/module/Notify.nix b/home/program/bash/module/Notify.nix index 261322e6..87065baf 100644 --- a/home/program/bash/module/Notify.nix +++ b/home/program/bash/module/Notify.nix @@ -1,15 +1,16 @@ -{ secret, ... }: { - text = '' - # Send Telegram notification. - # Usage: notify - function notify() { - curl -X POST -H 'Content-Type: Application/json' -d "${secret.tg.dt "false"}" ${secret.tg.bt} &> /dev/null - } +{ secret, ... }: +{ + text = '' + # Send Telegram notification. + # Usage: notify + function notify() { + curl -X POST -H 'Content-Type: Application/json' -d "${secret.tg.dt "false"}" ${secret.tg.bt} &> /dev/null + } - # Send silent Telegram notification. - # Usage: notify_silent - function notify_silent() { - curl -X POST -H 'Content-Type: Application/json' -d "${secret.tg.dt "true"}" ${secret.tg.bt} &> /dev/null - } - ''; + # Send silent Telegram notification. + # Usage: notify_silent + function notify_silent() { + curl -X POST -H 'Content-Type: Application/json' -d "${secret.tg.dt "true"}" ${secret.tg.bt} &> /dev/null + } + ''; } diff --git a/home/program/bash/module/Own.nix b/home/program/bash/module/Own.nix index 3be790ff..c1c69745 100644 --- a/home/program/bash/module/Own.nix +++ b/home/program/bash/module/Own.nix @@ -1,40 +1,41 @@ -{ ... }: { - text = '' - # Change file ownership to specified user id and restrict access to him. - # Root user by default. This directory recursively by default. - # Usage: own [USER] [FILES] - function own() { - local IFS=$'\n' - local files=("''${@:2}") - local user="''${1}" - local group="''${1}" +{ ... }: +{ + text = '' + # Change file ownership to specified user id and restrict access to him. + # Root user by default. This directory recursively by default. + # Usage: own [USER] [FILES] + function own() { + local IFS=$'\n' + local files=("''${@:2}") + local user="''${1}" + local group="''${1}" - # default to current dir. - if [ "''${files[*]}" = "" ]; then - files=(".") - fi + # default to current dir. + if [ "''${files[*]}" = "" ]; then + files=(".") + fi - # default to current user. - if [ "''${user}" = "" ]; then - user="''${UID}" - fi + # default to current user. + if [ "''${user}" = "" ]; then + user="''${UID}" + fi - # If not root, default to users group. - [[ "''${user}" = 0 ]] && group="0" || group="100" + # If not root, default to users group. + [[ "''${user}" = 0 ]] && group="0" || group="100" - for file in "''${files[@]}"; do - # set ownership. - chown "''${user}":"''${group}" -R "''${file}" &> /dev/null + for file in "''${files[@]}"; do + # set ownership. + chown "''${user}":"''${group}" -R "''${file}" &> /dev/null - # remove access from group and others. - chmod -077 -R "''${file}" - done - } + # remove access from group and others. + chmod -077 -R "''${file}" + done + } - function _complete_own() { - _autocomplete $(_get_users) - } + function _complete_own() { + _autocomplete $(_get_users) + } - complete -F _complete_own own - ''; + complete -F _complete_own own + ''; } diff --git a/home/program/bash/module/Pack.nix b/home/program/bash/module/Pack.nix index 37eb1cb5..eaff2720 100644 --- a/home/program/bash/module/Pack.nix +++ b/home/program/bash/module/Pack.nix @@ -1,208 +1,209 @@ -{ ... }: { - text = '' - export _unpack_supported=".tar$|.tgz$|.txz$|.tar.gz$|.tar.xz$|.zip$|.iso$|.rar$" +{ ... }: +{ + text = '' + export _unpack_supported=".tar$|.tgz$|.txz$|.tar.gz$|.tar.xz$|.zip$|.iso$|.rar$" - # Pack files into desired format. - # All files and directories by default. - # Usage: pack [FILES] - function pack() { - local IFS=$'\n' - local output="''${1}" - local targets=("''${@:2}") - local format="''${output##*.}" - local name="''${output%.*}" + # Pack files into desired format. + # All files and directories by default. + # Usage: pack [FILES] + function pack() { + local IFS=$'\n' + local output="''${1}" + local targets=("''${@:2}") + local format="''${output##*.}" + local name="''${output%.*}" - # report no output. - if [[ "''${output}" = "" ]]; then - help pack - return 2 - fi + # report no output. + if [[ "''${output}" = "" ]]; then + help pack + return 2 + fi - # report no format. - if [[ "''${format}" = "" ]]; then - _error "Could not determine output format." - help pack - return 2 - fi + # report no format. + if [[ "''${format}" = "" ]]; then + _error "Could not determine output format." + help pack + return 2 + fi - # All targets by default. - [[ "''${targets}" = "" ]] && targets=(*) + # All targets by default. + [[ "''${targets}" = "" ]] && targets=(*) - case "''${format}" in - "tgz") - _pack_tgz "''${output}" "''${targets[@]}" - ;; - "txz") - _pack_txz "''${output}" "''${targets[@]}" - ;; - "tar") - _pack_tar "''${output}" "''${targets[@]}" - ;; - "zip") - _pack_zip "''${output}" "''${targets[@]}" - ;; - "gz") - _pack_gz "''${output}" "''${targets[@]}" - ;; - "xz") - _pack_xz "''${output}" "''${targets[@]}" - ;; - "iso") - _pack_iso "''${output}" "''${targets[@]}" - ;; - *) - _error "''${target}: Format not supported." - return 2 - ;; - esac - } + case "''${format}" in + "tgz") + _pack_tgz "''${output}" "''${targets[@]}" + ;; + "txz") + _pack_txz "''${output}" "''${targets[@]}" + ;; + "tar") + _pack_tar "''${output}" "''${targets[@]}" + ;; + "zip") + _pack_zip "''${output}" "''${targets[@]}" + ;; + "gz") + _pack_gz "''${output}" "''${targets[@]}" + ;; + "xz") + _pack_xz "''${output}" "''${targets[@]}" + ;; + "iso") + _pack_iso "''${output}" "''${targets[@]}" + ;; + *) + _error "''${target}: Format not supported." + return 2 + ;; + esac + } - # Attempt to unpack. - # All supported formats by default. - # Usage: unpack [FILES] - function unpack() { - local IFS=$'\n' - local targets=(''${@}) - [[ "''${targets}" = "" ]] && targets=($(_ls_files | grep -E ''${_unpack_supported})) + # Attempt to unpack. + # All supported formats by default. + # Usage: unpack [FILES] + function unpack() { + local IFS=$'\n' + local targets=(''${@}) + [[ "''${targets}" = "" ]] && targets=($(_ls_files | grep -E ''${_unpack_supported})) - process() { - # Use full path to file. - target=''$(realpath "''${target}") + process() { + # Use full path to file. + target=''$(realpath "''${target}") - # Check for archive. - if $(_is_archive "''${target}"); then - unarchive "''${target}" - return 0 - fi + # Check for archive. + if $(_is_archive "''${target}"); then + unarchive "''${target}" + return 0 + fi - # Unpack file type. - local type="''${target##*.}" + # Unpack file type. + local type="''${target##*.}" - [[ "''${target}" =~ .tar.gz$ ]] && type="tar.gz" - [[ "''${target}" =~ .tar.xz$ ]] && type="tar.xz" + [[ "''${target}" =~ .tar.gz$ ]] && type="tar.gz" + [[ "''${target}" =~ .tar.xz$ ]] && type="tar.xz" - # Make a dir for files. - local dir="''${target%.$type}"; dir="''${dir##*/}" - mkdir "''${dir}" > /dev/null - pushd "''${dir}" > /dev/null + # Make a dir for files. + local dir="''${target%.$type}"; dir="''${dir##*/}" + mkdir "''${dir}" > /dev/null + pushd "''${dir}" > /dev/null - # Unpack content. - case "''${type,,}" in - "zip") - _unpack_zip "''${target}" - ;; - "7z") - _unpack_7z "''${target}" - ;; - "tgz"|"tar.gz") - _unpack_tgz "''${target}" - ;; - "txz"|"tar.xz") - _unpack_txz "''${target}" - ;; - "tar") - _unpack_tar "''${target}" - ;; - "iso") - _unpack_iso "''${target}" - ;; - "rar") - _unpack_rar "''${target}" - ;; - "xz") - _unpack_xz "''${target}" - ;; - "gz") - _unpack_gz "''${target}" - ;; - *) - _error "''${target}: Format not supported." - return 2 - ;; - esac + # Unpack content. + case "''${type,,}" in + "zip") + _unpack_zip "''${target}" + ;; + "7z") + _unpack_7z "''${target}" + ;; + "tgz"|"tar.gz") + _unpack_tgz "''${target}" + ;; + "txz"|"tar.xz") + _unpack_txz "''${target}" + ;; + "tar") + _unpack_tar "''${target}" + ;; + "iso") + _unpack_iso "''${target}" + ;; + "rar") + _unpack_rar "''${target}" + ;; + "xz") + _unpack_xz "''${target}" + ;; + "gz") + _unpack_gz "''${target}" + ;; + *) + _error "''${target}: Format not supported." + return 2 + ;; + esac - # Cd back. - popd > /dev/null - } + # Cd back. + popd > /dev/null + } - _iterate_targets process ''${targets[@]} - } + _iterate_targets process ''${targets[@]} + } - function _pack_zip() { - zip -9 -r "''${@}" - } + function _pack_zip() { + zip -9 -r "''${@}" + } - function _pack_tgz() { - tar -c "''${@:2}" | pv -s $(/usr/bin/env du -csb "''${@:2}" | sed -n -e '$p' | awk '{print $1}') | gzip -1 > "''${1}" - } + function _pack_tgz() { + tar -c "''${@:2}" | pv -s $(/usr/bin/env du -csb "''${@:2}" | sed -n -e '$p' | awk '{print $1}') | gzip -1 > "''${1}" + } - function _pack_txz() { - tar -c "''${@:2}" | pv -s $(/usr/bin/env du -csb "''${@:2}" | sed -n -e '$p' | awk '{print $1}') | xz -9e > "''${1}" - } + function _pack_txz() { + tar -c "''${@:2}" | pv -s $(/usr/bin/env du -csb "''${@:2}" | sed -n -e '$p' | awk '{print $1}') | xz -9e > "''${1}" + } - function _pack_tar() { - tar -c "''${@:2}" | pv -s $(/usr/bin/env du -csb "''${@:2}" | sed -n -e '$p' | awk '{print $1}') > "''${1}" - } + function _pack_tar() { + tar -c "''${@:2}" | pv -s $(/usr/bin/env du -csb "''${@:2}" | sed -n -e '$p' | awk '{print $1}') > "''${1}" + } - function _pack_gz() { - pv "''${2}" | gzip -1 > "''${1}" - } + function _pack_gz() { + pv "''${2}" | gzip -1 > "''${1}" + } - function _pack_xz() { - pv "''${2}" | xz -9e > "''${1}" - } + function _pack_xz() { + pv "''${2}" | xz -9e > "''${1}" + } - function _pack_iso() { - local input=("''${@:2}") - local output="''${1}" - local args=() + function _pack_iso() { + local input=("''${@:2}") + local output="''${1}" + local args=() - for arg in ''${input[@]}; do - [[ -d "''${arg}" ]] || { - _error "''${arg} is not a directory." - return 1 - }; + for arg in ''${input[@]}; do + [[ -d "''${arg}" ]] || { + _error "''${arg} is not a directory." + return 1 + }; - args+=("''${arg}=''${arg}") - done + args+=("''${arg}=''${arg}") + done - genisoimage -J -r -pad -o "''${output}" -graft-points "''${args[@]}" - } + genisoimage -J -r -pad -o "''${output}" -graft-points "''${args[@]}" + } - function _unpack_zip() { - unzip "''${1}" - } + function _unpack_zip() { + unzip "''${1}" + } - function _unpack_7z() { - 7za x "''${1}" - } + function _unpack_7z() { + 7za x "''${1}" + } - function _unpack_tgz() { - pv "''${1}" | gzip -d | tar -xf - - } + function _unpack_tgz() { + pv "''${1}" | gzip -d | tar -xf - + } - function _unpack_txz() { - pv "''${1}" | xz -d | tar -xf - - } + function _unpack_txz() { + pv "''${1}" | xz -d | tar -xf - + } - function _unpack_tar() { - pv "''${1}" | tar -xf - - } + function _unpack_tar() { + pv "''${1}" | tar -xf - + } - function _unpack_iso() { - 7za x "''${1}" - } + function _unpack_iso() { + 7za x "''${1}" + } - function _unpack_rar() { - unrar x "''${1}" - } + function _unpack_rar() { + unrar x "''${1}" + } - function _unpack_gz() { - pv "''${1}" | gzip -d > "''${1%.gz}" - } + function _unpack_gz() { + pv "''${1}" | gzip -d > "''${1%.gz}" + } - function _unpack_xz() { - pv "''${1}" | xz -d > "''${1%.xz}" - } - ''; + function _unpack_xz() { + pv "''${1}" | xz -d > "''${1%.xz}" + } + ''; } diff --git a/home/program/bash/module/Parse.nix b/home/program/bash/module/Parse.nix index dac76e09..d5ae89a6 100644 --- a/home/program/bash/module/Parse.nix +++ b/home/program/bash/module/Parse.nix @@ -1,172 +1,173 @@ -{ ... }: { - text = '' - export _PARSE_ALLOWED_CHARS="_-" - export _PARSE_SPLIT_CHARS="\.\ _-" +{ ... }: +{ + text = '' + export _PARSE_ALLOWED_CHARS="_-" + export _PARSE_SPLIT_CHARS="\.\ _-" - # Parse data and output simplified format. - # Usage: parse_simple - function parse_simple() { - echo "''${*}" | sed \ - -e "s/[''${_PARSE_SPLIT_CHARS}]/_/g" \ - -e "s/[^[:alnum:]''${_PARSE_ALLOWED_CHARS}]//g" \ - -e "s/_\+/_/g" -e "s/-\+/-/g" \ - -e "s/_-/_/g" -e "s/-_/_/g" \ - -e "s/_\+/_/g" \ - -e "s/^_//" -e "s/_$//" - } + # Parse data and output simplified format. + # Usage: parse_simple + function parse_simple() { + echo "''${*}" | sed \ + -e "s/[''${_PARSE_SPLIT_CHARS}]/_/g" \ + -e "s/[^[:alnum:]''${_PARSE_ALLOWED_CHARS}]//g" \ + -e "s/_\+/_/g" -e "s/-\+/-/g" \ + -e "s/_-/_/g" -e "s/-_/_/g" \ + -e "s/_\+/_/g" \ + -e "s/^_//" -e "s/_$//" + } - # Parse to PascalCase. - # Usage: parse_pascal - function parse_pascal() { - local parts=($(_get_parts $(parse_simple "''${*}"))) - local result + # Parse to PascalCase. + # Usage: parse_pascal + function parse_pascal() { + local parts=($(_get_parts $(parse_simple "''${*}"))) + local result - for part in "''${parts[@]}"; do - local word="''${part,,}" - word="''${word^}" - result="''${result}''${word}" - done + for part in "''${parts[@]}"; do + local word="''${part,,}" + word="''${word^}" + result="''${result}''${word}" + done - echo "''${result}" - } + echo "''${result}" + } - # Parse to snake_case. - # Usage: parse_snake - function parse_snake() { - local parts=($(_get_parts $(parse_simple "''${*}"))) - local result + # Parse to snake_case. + # Usage: parse_snake + function parse_snake() { + local parts=($(_get_parts $(parse_simple "''${*}"))) + local result - for part in "''${parts[@]}"; do - local word="''${part,,}" - result="''${result}_''${word}" - done + for part in "''${parts[@]}"; do + local word="''${part,,}" + result="''${result}_''${word}" + done - echo "''${result#_}" - } + echo "''${result#_}" + } - # Parse to kebab-case. - # Usage: parse_kebab - function parse_kebab() { - local parts=($(_get_parts $(parse_simple "''${*}"))) - local result + # Parse to kebab-case. + # Usage: parse_kebab + function parse_kebab() { + local parts=($(_get_parts $(parse_simple "''${*}"))) + local result - for part in "''${parts[@]}"; do - local word="''${part,,}" - result="''${result}-''${word}" - done + for part in "''${parts[@]}"; do + local word="''${part,,}" + result="''${result}-''${word}" + done - echo "''${result#-}" - } + echo "''${result#-}" + } - # Parse to camelCase. - # Usage: parse_camel - function parse_camel() { - local parts=($(_get_parts $(parse_simple "''${*}"))) - local result + # Parse to camelCase. + # Usage: parse_camel + function parse_camel() { + local parts=($(_get_parts $(parse_simple "''${*}"))) + local result - for part in "''${parts[@]}"; do - local word="''${part,,}" - word="''${word^}" - result="''${result}''${word}" - done + for part in "''${parts[@]}"; do + local word="''${part,,}" + word="''${word^}" + result="''${result}''${word}" + done - echo "''${result,}" - } + echo "''${result,}" + } - # Parse to SNAKE_CASE_UPPERCASE. **NOT STABLE! Repeating results in different output.** - # Usage: parse_snake_uppercase - function parse_snake_uppercase() { - local parts=($(_get_parts $(parse_simple "''${*}"))) - local result + # Parse to SNAKE_CASE_UPPERCASE. **NOT STABLE! Repeating results in different output.** + # Usage: parse_snake_uppercase + function parse_snake_uppercase() { + local parts=($(_get_parts $(parse_simple "''${*}"))) + local result - for part in "''${parts[@]}"; do - local word="''${part^^}" - result="''${result}_''${word}" - done + for part in "''${parts[@]}"; do + local word="''${part^^}" + result="''${result}_''${word}" + done - echo "''${result#_}" - } + echo "''${result#_}" + } - # Parse data keeping only alphanumeric characters. - # Usage: parse_alnum - function parse_alnum() { - echo "''${*}" | sed -e "s/[^[:alnum:]]//g" - } + # Parse data keeping only alphanumeric characters. + # Usage: parse_alnum + function parse_alnum() { + echo "''${*}" | sed -e "s/[^[:alnum:]]//g" + } - # Parse integers from mixed string. - # Usage: parse_ints - function parse_ints() { - echo "''${*}" | tr '\n' ' ' | sed -e 's/[^0-9]/ /g' -e 's/^ *//g' -e 's/ *$//g' | tr -s ' ' | sed 's/ /\n/g' - } + # Parse integers from mixed string. + # Usage: parse_ints + function parse_ints() { + echo "''${*}" | tr '\n' ' ' | sed -e 's/[^0-9]/ /g' -e 's/^ *//g' -e 's/ *$//g' | tr -s ' ' | sed 's/ /\n/g' + } - # Parse string to lowercase. - # Usage: parse_lowercase - function parse_lowercase() { - echo "''${*,,}" - } + # Parse string to lowercase. + # Usage: parse_lowercase + function parse_lowercase() { + echo "''${*,,}" + } - # Parse string to uppercase. - # Usage: parse_uppercase - function parse_uppercase() { - echo "''${*^^}" - } + # Parse string to uppercase. + # Usage: parse_uppercase + function parse_uppercase() { + echo "''${*^^}" + } - # Parse string to title case. - # Usage: parse_titlecase - function parse_titlecase() { - local IFS=$'\n' - local parts=($(_parse_split ''${@})) - local minors=("is" "at" "of" "to" "in" "for" "the" "a" "an" "and" "but" "or" "on" "was" "were" "been" "be" "do" "did" "does") + # Parse string to title case. + # Usage: parse_titlecase + function parse_titlecase() { + local IFS=$'\n' + local parts=($(_parse_split ''${@})) + local minors=("is" "at" "of" "to" "in" "for" "the" "a" "an" "and" "but" "or" "on" "was" "were" "been" "be" "do" "did" "does") - echo -n "$(parse_sentencecase ''${parts[0]})" - for part in ''${parts[@]:1}; do - if _contains $(echo ''${part,,} | sed -e "s/[''${_PARSE_SPLIT_CHARS}]//g") ''${minors[@]}; then - echo -n "''${part,,}" - else - echo -n "$(parse_sentencecase ''${part})" - fi - done + echo -n "$(parse_sentencecase ''${parts[0]})" + for part in ''${parts[@]:1}; do + if _contains $(echo ''${part,,} | sed -e "s/[''${_PARSE_SPLIT_CHARS}]//g") ''${minors[@]}; then + echo -n "''${part,,}" + else + echo -n "$(parse_sentencecase ''${part})" + fi + done - echo - } + echo + } - # Parse string to sentence case. - # Usage: parse_sentencecase - function parse_sentencecase() { - local lower="''${*,,}" - echo "''${lower^}" - } + # Parse string to sentence case. + # Usage: parse_sentencecase + function parse_sentencecase() { + local lower="''${*,,}" + echo "''${lower^}" + } - # Parse string to start case. - # Usage: parse_startcase - function parse_startcase() { - local IFS=$'\n' - local lower="''${*,,}" - local parts=($(_parse_split ''${lower})) + # Parse string to start case. + # Usage: parse_startcase + function parse_startcase() { + local IFS=$'\n' + local lower="''${*,,}" + local parts=($(_parse_split ''${lower})) - for part in ''${parts[@]}; do - echo -n "''${part^}" - done + for part in ''${parts[@]}; do + echo -n "''${part^}" + done - echo - } + echo + } - # Parse string to pretty Json. - # Usage: parse_json - function parse_json() { - echo "''${*}" | jq - } + # Parse string to pretty Json. + # Usage: parse_json + function parse_json() { + echo "''${*}" | jq + } - # Split string by separators. - # Usage: _parse_split - function _parse_split() { - echo "''${*}" | sed -e "s/[A-Z]\+/\n&/g" -e "s/[0-9]\+/\n&\n/g" -e "s/[''${_PARSE_SPLIT_CHARS}]/&\n/g" | sed -e "/^$/d" - } + # Split string by separators. + # Usage: _parse_split + function _parse_split() { + echo "''${*}" | sed -e "s/[A-Z]\+/\n&/g" -e "s/[0-9]\+/\n&\n/g" -e "s/[''${_PARSE_SPLIT_CHARS}]/&\n/g" | sed -e "/^$/d" + } - # Get name parts. - # Usage: _get_parts - function _get_parts() { - _parse_split "''${*}" | sed -e "s/[''${_PARSE_SPLIT_CHARS}]//g" | sed -e "/^$/d" - } - ''; + # Get name parts. + # Usage: _get_parts + function _get_parts() { + _parse_split "''${*}" | sed -e "s/[''${_PARSE_SPLIT_CHARS}]//g" | sed -e "/^$/d" + } + ''; } diff --git a/home/program/bash/module/Permission.nix b/home/program/bash/module/Permission.nix index 3b785c15..f861cc14 100644 --- a/home/program/bash/module/Permission.nix +++ b/home/program/bash/module/Permission.nix @@ -1,13 +1,14 @@ -{ ... }: { - text = '' - # Recursively change permissions to allow read sharing with group and others. - function perm_share() { - find . -type d -exec chmod 755 {} \;; find . -type f -exec chmod 644 {} \; - } +{ ... }: +{ + text = '' + # Recursively change permissions to allow read sharing with group and others. + function perm_share() { + find . -type d -exec chmod 755 {} \;; find . -type f -exec chmod 644 {} \; + } - # Recursively change permissions to restrict access for group and others. - function perm() { - find . -type d -exec chmod 700 {} \;; find . -type f -exec chmod 600 {} \; - } - ''; + # Recursively change permissions to restrict access for group and others. + function perm() { + find . -type d -exec chmod 700 {} \;; find . -type f -exec chmod 600 {} \; + } + ''; } diff --git a/home/program/bash/module/Picture.nix b/home/program/bash/module/Picture.nix index 2f4b6bc3..41b0412a 100644 --- a/home/program/bash/module/Picture.nix +++ b/home/program/bash/module/Picture.nix @@ -1,18 +1,19 @@ -{ ... }: { - text = '' - # Quick edit a picture and copy to clipboard. - # Usage: pic_copy - function pic_copy() { - swappy -f "''${1}" -o - | copy - } +{ ... }: +{ + text = '' + # Quick edit a picture and copy to clipboard. + # Usage: pic_copy + function pic_copy() { + swappy -f "''${1}" -o - | copy + } - # Quick edit a pictures inplace. - # Usage: pic_edit - function pic_edit() { - local IFS=$'\n' - for file in "''${@}"; do - swappy -f "''${file}" -o "''${file}" - done - } - ''; + # Quick edit a pictures inplace. + # Usage: pic_edit + function pic_edit() { + local IFS=$'\n' + for file in "''${@}"; do + swappy -f "''${file}" -o "''${file}" + done + } + ''; } diff --git a/home/program/bash/module/Print.nix b/home/program/bash/module/Print.nix index 7699ab7b..cd09d4a0 100644 --- a/home/program/bash/module/Print.nix +++ b/home/program/bash/module/Print.nix @@ -1,9 +1,10 @@ -{ ... }: { - text = '' - # Printf shortcut. - # Usage: print [TEXT] - function print() { - printf "%s" "''${*}" - } - ''; +{ ... }: +{ + text = '' + # Printf shortcut. + # Usage: print [TEXT] + function print() { + printf "%s" "''${*}" + } + ''; } diff --git a/home/program/bash/module/Ps.nix b/home/program/bash/module/Ps.nix index bc4fa8b2..0a9afe10 100644 --- a/home/program/bash/module/Ps.nix +++ b/home/program/bash/module/Ps.nix @@ -1,15 +1,16 @@ -{ ... }: { - text = '' - # Find process and filter. - # Usage: fps [PROCESS] - function fps() { - local process="''${1}" +{ ... }: +{ + text = '' + # Find process and filter. + # Usage: fps [PROCESS] + function fps() { + local process="''${1}" - if [[ "''${process}" = "" ]]; then - ps aux - else - ps aux | sed -n -e "1p" -e "/''${process}/Ip" | sed -e "/sed -n -e 1p -e/d" - fi - } - ''; + if [[ "''${process}" = "" ]]; then + ps aux + else + ps aux | sed -n -e "1p" -e "/''${process}/Ip" | sed -e "/sed -n -e 1p -e/d" + fi + } + ''; } diff --git a/home/program/bash/module/Ps1.nix b/home/program/bash/module/Ps1.nix index ffb731e8..436b98a1 100644 --- a/home/program/bash/module/Ps1.nix +++ b/home/program/bash/module/Ps1.nix @@ -1,160 +1,159 @@ +{ config, ... }: +let + accent = "${config.module.style.color.accentR};${config.module.style.color.accentG};${config.module.style.color.accentB}"; + negative = "${config.module.style.color.negativeR};${config.module.style.color.negativeG};${config.module.style.color.negativeB}"; + neutral = "${config.module.style.color.neutralR};${config.module.style.color.neutralG};${config.module.style.color.neutralB}"; + positive = "${config.module.style.color.positiveR};${config.module.style.color.positiveG};${config.module.style.color.positiveB}"; +in { - config, - ... -}: let - accent = "${config.module.style.color.accentR};${config.module.style.color.accentG};${config.module.style.color.accentB}"; - negative = "${config.module.style.color.negativeR};${config.module.style.color.negativeG};${config.module.style.color.negativeB}"; - neutral = "${config.module.style.color.neutralR};${config.module.style.color.neutralG};${config.module.style.color.neutralB}"; - positive = "${config.module.style.color.positiveR};${config.module.style.color.positiveG};${config.module.style.color.positiveB}"; -in { - text = '' - export PROMPT_COMMAND=(__prompt_command "''${PROMPT_COMMAND[@]}") + text = '' + export PROMPT_COMMAND=(__prompt_command "''${PROMPT_COMMAND[@]}") - function __prompt_color() { - local color="''${1}" - if [[ "''${color}" = "" ]]; then - printf "\[\x1b[0m\]" - else - printf "\[\x1b[38;2;''${color}m\]" - fi - } + function __prompt_color() { + local color="''${1}" + if [[ "''${color}" = "" ]]; then + printf "\[\x1b[0m\]" + else + printf "\[\x1b[38;2;''${color}m\]" + fi + } - # Custom terminal prompt format. - function __prompt_command() { - local last_status="''${?}" - local is_error=false - local is_root=false + # Custom terminal prompt format. + function __prompt_command() { + local last_status="''${?}" + local is_error=false + local is_root=false - if [[ ''${last_status} != 0 && ''${last_status} != 130 ]]; then - is_error=true - fi - if [[ "''${UID}" -eq 0 ]]; then - is_root=true - fi + if [[ ''${last_status} != 0 && ''${last_status} != 130 ]]; then + is_error=true + fi + if [[ "''${UID}" -eq 0 ]]; then + is_root=true + fi - # Add newline. - PS1="\n" + # Add newline. + PS1="\n" - # Set error red. - if ''${is_error}; then - PS1+="$(__prompt_color '${negative}')" - PS1+="[" - else - PS1+="$(__prompt_color)" - PS1+="[" - fi + # Set error red. + if ''${is_error}; then + PS1+="$(__prompt_color '${negative}')" + PS1+="[" + else + PS1+="$(__prompt_color)" + PS1+="[" + fi - # Add time. - # PS1+="$(__prompt_color '${accent}')" - # PS1+="$(date +%H:%M) " + # Add time. + # PS1+="$(__prompt_color '${accent}')" + # PS1+="$(date +%H:%M) " - # Set root red. - if ''${is_root}; then - PS1+="$(__prompt_color '${negative}')" - else - PS1+="$(__prompt_color '${neutral}')" - fi + # Set root red. + if ''${is_root}; then + PS1+="$(__prompt_color '${negative}')" + else + PS1+="$(__prompt_color '${neutral}')" + fi - # Add user, host and working dir. - PS1+="\u@\h " - PS1+="$(__prompt_color '${positive}')" - PS1+="\w" - # PS1+="\''${PWD}" + # Add user, host and working dir. + PS1+="\u@\h " + PS1+="$(__prompt_color '${positive}')" + PS1+="\w" + # PS1+="\''${PWD}" - # Add git branch if available. - local git_branch="$(_git_current_branch)" - if [[ "''${git_branch}" != "" ]]; then - PS1+=" $(__prompt_color '${accent}')@''${git_branch}" - fi + # Add git branch if available. + local git_branch="$(_git_current_branch)" + if [[ "''${git_branch}" != "" ]]; then + PS1+=" $(__prompt_color '${accent}')@''${git_branch}" + fi - # Set error red. - if ''${is_error}; then - PS1+="$(__prompt_color '${negative}')" - PS1+="] " - else - PS1+="$(__prompt_color)" - PS1+="] " - fi + # Set error red. + if ''${is_error}; then + PS1+="$(__prompt_color '${negative}')" + PS1+="] " + else + PS1+="$(__prompt_color)" + PS1+="] " + fi - # If error, show code. - if ''${is_error}; then - PS1+="$(__prompt_color '${negative}')(" - PS1+="''${last_status}" - local error_type="$(_ps1error ''${last_status})" - [[ "''${error_type}" != "" ]] && PS1+=" ''${error_type}" - PS1+=")$(__prompt_color) " - fi + # If error, show code. + if ''${is_error}; then + PS1+="$(__prompt_color '${negative}')(" + PS1+="''${last_status}" + local error_type="$(_ps1error ''${last_status})" + [[ "''${error_type}" != "" ]] && PS1+=" ''${error_type}" + PS1+=")$(__prompt_color) " + fi - # Command on new line. - PS1+="\n" + # Command on new line. + PS1+="\n" - # Show nix shell name or shell depth. - if [ -n "''${SHELL_NAME}" ]; then - PS1+="''${SHELL_NAME} " - fi + # Show nix shell name or shell depth. + if [ -n "''${SHELL_NAME}" ]; then + PS1+="''${SHELL_NAME} " + fi - # Show remote connections. - if [ -n "''${SSH_TTY}" ]; then - PS1+=">" - fi + # Show remote connections. + if [ -n "''${SSH_TTY}" ]; then + PS1+=">" + fi - PS1+="$(__prompt_color)" + PS1+="$(__prompt_color)" - # Set user tag. - if ''${is_root}; then - PS1+="# " - else - PS1+="$ " - fi + # Set user tag. + if ''${is_root}; then + PS1+="# " + else + PS1+="$ " + fi - # Reset color. - PS1+="\[\033[0m\]" - } + # Reset color. + PS1+="\[\033[0m\]" + } - # Convert error code into short description. - # Usage: _ps1error - function _ps1error() { - local type - case ''${1} in - 1) type="GENERAL" ;; - 2) type="MISUSE" ;; - 126) type="CANTEXEC" ;; - 127) type="CMDNF" ;; - 129) type="SIGHUP" ;; - 130) type="SIGINT" ;; - 131) type="SIGQUIT" ;; - 132) type="SIGILL" ;; - 133) type="SIGTRAP" ;; - 134) type="SIGABRT" ;; - 135) type="SIGBUS" ;; - 136) type="SIGFPE" ;; - 137) type="SIGKILL" ;; - 138) type="SIGUSR1" ;; - 139) type="SIGSEGV" ;; - 140) type="SIGUSR2" ;; - 141) type="SIGPIPE" ;; - 142) type="SIGALRM" ;; - 143) type="SIGTERM" ;; - 144) type="" ;; - 145) type="SIGCHLD" ;; - 146) type="SIGCONT" ;; - 147) type="SIGSTOP" ;; - 148) type="SIGTSTP" ;; - 149) type="SIGTTIN" ;; - 150) type="SIGTTOU" ;; - 151) type="SIGURG" ;; - 152) type="SIGXCPU" ;; - 153) type="SIGXFSZ" ;; - 154) type="SIGVTALRM" ;; - 155) type="SIGPROF" ;; - 156) type="SIGWINCH" ;; - 157) type="SIGIO" ;; - 158) type="SIGPWR" ;; - 159) type="SIGSYS" ;; - *) type="" ;; - esac + # Convert error code into short description. + # Usage: _ps1error + function _ps1error() { + local type + case ''${1} in + 1) type="GENERAL" ;; + 2) type="MISUSE" ;; + 126) type="CANTEXEC" ;; + 127) type="CMDNF" ;; + 129) type="SIGHUP" ;; + 130) type="SIGINT" ;; + 131) type="SIGQUIT" ;; + 132) type="SIGILL" ;; + 133) type="SIGTRAP" ;; + 134) type="SIGABRT" ;; + 135) type="SIGBUS" ;; + 136) type="SIGFPE" ;; + 137) type="SIGKILL" ;; + 138) type="SIGUSR1" ;; + 139) type="SIGSEGV" ;; + 140) type="SIGUSR2" ;; + 141) type="SIGPIPE" ;; + 142) type="SIGALRM" ;; + 143) type="SIGTERM" ;; + 144) type="" ;; + 145) type="SIGCHLD" ;; + 146) type="SIGCONT" ;; + 147) type="SIGSTOP" ;; + 148) type="SIGTSTP" ;; + 149) type="SIGTTIN" ;; + 150) type="SIGTTOU" ;; + 151) type="SIGURG" ;; + 152) type="SIGXCPU" ;; + 153) type="SIGXFSZ" ;; + 154) type="SIGVTALRM" ;; + 155) type="SIGPROF" ;; + 156) type="SIGWINCH" ;; + 157) type="SIGIO" ;; + 158) type="SIGPWR" ;; + 159) type="SIGSYS" ;; + *) type="" ;; + esac - echo -n "''${type}" - } - ''; + echo -n "''${type}" + } + ''; } diff --git a/home/program/bash/module/Qr.nix b/home/program/bash/module/Qr.nix index 345c35cd..083da59d 100644 --- a/home/program/bash/module/Qr.nix +++ b/home/program/bash/module/Qr.nix @@ -1,7 +1,8 @@ -{ ... }: { - text = '' - function qr() { - qrencode -t ansiutf8 - } - ''; +{ ... }: +{ + text = '' + function qr() { + qrencode -t ansiutf8 + } + ''; } diff --git a/home/program/bash/module/Radj.nix b/home/program/bash/module/Radj.nix index 8e8dc752..9b1ee35f 100644 --- a/home/program/bash/module/Radj.nix +++ b/home/program/bash/module/Radj.nix @@ -1,15 +1,16 @@ -{ ... }: { - text = '' - # Adjust ryzen temp limit. - # Usage: radj [TEMP] - function radj() { - local limit="''${1}" - if [[ "''${limit}" = "" ]]; then - systemctl start radj.service - else - systemctl stop radj.service - ryzenadj --tctl-temp=''${limit} - fi - } - ''; +{ ... }: +{ + text = '' + # Adjust ryzen temp limit. + # Usage: radj [TEMP] + function radj() { + local limit="''${1}" + if [[ "''${limit}" = "" ]]; then + systemctl start radj.service + else + systemctl stop radj.service + ryzenadj --tctl-temp=''${limit} + fi + } + ''; } diff --git a/home/program/bash/module/Random.nix b/home/program/bash/module/Random.nix index b60b923c..e32160cc 100644 --- a/home/program/bash/module/Random.nix +++ b/home/program/bash/module/Random.nix @@ -1,25 +1,26 @@ -{ ... }: { - text = '' - # Generate random string. - # Usage: random - function random() { - local length="''${1}" - if [[ "''${length}" = "" ]]; then - help random - return 2 - fi - head /dev/urandom | tr -dc A-Za-z0-9 | head -c''${length} - } +{ ... }: +{ + text = '' + # Generate random string. + # Usage: random + function random() { + local length="''${1}" + if [[ "''${length}" = "" ]]; then + help random + return 2 + fi + head /dev/urandom | tr -dc A-Za-z0-9 | head -c''${length} + } - # Picks a random file or directory. - function random_file() { - local IFS=$'\n' - local dirs=($(ls)) - local total=''${#dirs[@]} - ((total--)) - local index=$(shuf -i 0-''${total} -n 1) + # Picks a random file or directory. + function random_file() { + local IFS=$'\n' + local dirs=($(ls)) + local total=''${#dirs[@]} + ((total--)) + local index=$(shuf -i 0-''${total} -n 1) - printf "%s" ''${dirs[$index]} - } - ''; + printf "%s" ''${dirs[$index]} + } + ''; } diff --git a/home/program/bash/module/Recursive.nix b/home/program/bash/module/Recursive.nix index a53087cb..07e836fc 100644 --- a/home/program/bash/module/Recursive.nix +++ b/home/program/bash/module/Recursive.nix @@ -1,84 +1,85 @@ -{ ... }: { - text = '' - # Run something recursively over all directories. - # Usage: recursive - function recursive() { - if [[ "''${*}" = "" ]]; then - help recursive - return 2 - fi +{ ... }: +{ + text = '' + # Run something recursively over all directories. + # Usage: recursive + function recursive() { + if [[ "''${*}" = "" ]]; then + help recursive + return 2 + fi - local IFS=$'\n' - local current="''${PWD}" - local dirs=$(find -type d) - local total=$(find -type d | wc -l) # TODO: don't call find twice. won't work with "echo ''${dirs}". - local count=0 - local failed=0 + local IFS=$'\n' + local current="''${PWD}" + local dirs=$(find -type d) + local total=$(find -type d | wc -l) # TODO: don't call find twice. won't work with "echo ''${dirs}". + local count=0 + local failed=0 - for dir in ''${dirs}; do - # increment counter. - ((count++)) + for dir in ''${dirs}; do + # increment counter. + ((count++)) - # cd into the next dir. - cd "''${current}" || failed=''${?} - cd "''${dir}" || failed=''${?} + # cd into the next dir. + cd "''${current}" || failed=''${?} + cd "''${dir}" || failed=''${?} - # echo status. - echo -e "''${color_bblue}[''${count}/''${total}] ''${dir}''${color_default}" + # echo status. + echo -e "''${color_bblue}[''${count}/''${total}] ''${dir}''${color_default}" - # run command. - ''${*} || failed=''${?} + # run command. + ''${*} || failed=''${?} - # Add newline if not the last one. - [[ "''${count}" = "''${total}" ]] || echo - done + # Add newline if not the last one. + [[ "''${count}" = "''${total}" ]] || echo + done - # return back on complete. - cd "''${current}" || failed=''${?} + # return back on complete. + cd "''${current}" || failed=''${?} - return ''${failed} - } + return ''${failed} + } - # Run something recursively over directories of 1 depth (excluding current dir). - # Usage: recursive1 - function recursive1() { - if [[ "''${*}" = "" ]]; then - help recursive1 - return 2 - fi + # Run something recursively over directories of 1 depth (excluding current dir). + # Usage: recursive1 + function recursive1() { + if [[ "''${*}" = "" ]]; then + help recursive1 + return 2 + fi - local IFS=$'\n' - local current="''${PWD}" - local dirs=$(find -mindepth 1 -maxdepth 1 -type d) - local total=$(find -mindepth 1 -maxdepth 1 -type d | wc -l) # TODO: don't call find twice. won't work with "echo ''${dirs}". - local count=0 - local failed=0 + local IFS=$'\n' + local current="''${PWD}" + local dirs=$(find -mindepth 1 -maxdepth 1 -type d) + local total=$(find -mindepth 1 -maxdepth 1 -type d | wc -l) # TODO: don't call find twice. won't work with "echo ''${dirs}". + local count=0 + local failed=0 - for dir in ''${dirs}; do - # increment counter. - ((count++)) + for dir in ''${dirs}; do + # increment counter. + ((count++)) - # cd into the next dir. - cd "''${current}" - cd "''${dir}" + # cd into the next dir. + cd "''${current}" + cd "''${dir}" - # echo status. - echo -e "''${color_bblue}[''${count}/''${total}] ''${dir}''${color_default}" + # echo status. + echo -e "''${color_bblue}[''${count}/''${total}] ''${dir}''${color_default}" - # run command. - ''${*} || failed=''${?} + # run command. + ''${*} || failed=''${?} - # Add newline if not the last one. - [[ "''${count}" = "''${total}" ]] || echo - done + # Add newline if not the last one. + [[ "''${count}" = "''${total}" ]] || echo + done - # return back on complete. - cd "''${current}" + # return back on complete. + cd "''${current}" - return ''${failed} - } + return ''${failed} + } - # autocomplete. - complete -F _autocomplete_nested recursive recursive1 - ''; + # autocomplete. + complete -F _autocomplete_nested recursive recursive1 + ''; } diff --git a/home/program/bash/module/Reload.nix b/home/program/bash/module/Reload.nix index 9d435cce..04555f5b 100644 --- a/home/program/bash/module/Reload.nix +++ b/home/program/bash/module/Reload.nix @@ -1,8 +1,9 @@ -{ ... }: { - text = '' - function reload() { - source ~/.bashrc - } - trap reload USR1 - ''; +{ ... }: +{ + text = '' + function reload() { + source ~/.bashrc + } + trap reload USR1 + ''; } diff --git a/home/program/bash/module/Shopt.nix b/home/program/bash/module/Shopt.nix index 47602804..85d49c0c 100644 --- a/home/program/bash/module/Shopt.nix +++ b/home/program/bash/module/Shopt.nix @@ -1,27 +1,28 @@ -{ ... }: { - text = '' - shopt -s dotglob - shopt -s globstar - shopt -s autocd - shopt -s extglob +{ ... }: +{ + text = '' + shopt -s dotglob + shopt -s globstar + shopt -s autocd + shopt -s extglob - # Enable vim mode. - bind 'set editing-mode vi' - bind 'set show-mode-in-prompt on' - bind 'set keyseq-timeout 0' + # Enable vim mode. + bind 'set editing-mode vi' + bind 'set show-mode-in-prompt on' + bind 'set keyseq-timeout 0' - # Set the mode string and cursor to indicate the vim mode - # For the number after `\e[`: - # 0: blinking block - # 1: blinking block (default) - # 2: steady block - # 3: blinking underline - # 4: steady underline - # 5: blinking bar (xterm) - # 6: steady bar (xterm) - bind 'set vi-ins-mode-string \1\e[6 q\2' - bind 'set vi-cmd-mode-string \1\e[2 q\2' + # Set the mode string and cursor to indicate the vim mode + # For the number after `\e[`: + # 0: blinking block + # 1: blinking block (default) + # 2: steady block + # 3: blinking underline + # 4: steady underline + # 5: blinking bar (xterm) + # 6: steady bar (xterm) + bind 'set vi-ins-mode-string \1\e[6 q\2' + bind 'set vi-cmd-mode-string \1\e[2 q\2' - exec {BASH_XTRACEFD}>/dev/null - ''; + exec {BASH_XTRACEFD}>/dev/null + ''; } diff --git a/home/program/bash/module/Ssh.nix b/home/program/bash/module/Ssh.nix index 7b8a75cb..01e61952 100644 --- a/home/program/bash/module/Ssh.nix +++ b/home/program/bash/module/Ssh.nix @@ -1,8 +1,9 @@ -{ ... }: { - text = '' - # Kill all ssh sockets. - function sshka() { - rm ~/.ssh/*.socket - } - ''; +{ ... }: +{ + text = '' + # Kill all ssh sockets. + function sshka() { + rm ~/.ssh/*.socket + } + ''; } diff --git a/home/program/bash/module/Su.nix b/home/program/bash/module/Su.nix index c4f1193e..0ba3c542 100644 --- a/home/program/bash/module/Su.nix +++ b/home/program/bash/module/Su.nix @@ -1,34 +1,35 @@ -{ ... }: { - text = '' - # Su shortcut for lazy me. - # Root by default. - # Usage: s [USER] - function s() { - su - ''${1} - } - alias su="SHELL_NAME=su su" +{ ... }: +{ + text = '' + # Su shortcut for lazy me. + # Root by default. + # Usage: s [USER] + function s() { + su - ''${1} + } + alias su="SHELL_NAME=su su" - # Run something as root. Runs command as a current user if su is not available. - # Usage: sudo - function sudo() { - if command -v su &> /dev/null; then - su -c "$(echo ''${*} | tr '\n' ' ')" - else - ''${*} - fi - } + # Run something as root. Runs command as a current user if su is not available. + # Usage: sudo + function sudo() { + if command -v su &> /dev/null; then + su -c "$(echo ''${*} | tr '\n' ' ')" + else + ''${*} + fi + } - # Run something as current user. If fails, try to run with sudo. - # Usage: trysudo - function trysudo() { - ''${*} || sudo ''${*} - } + # Run something as current user. If fails, try to run with sudo. + # Usage: trysudo + function trysudo() { + ''${*} || sudo ''${*} + } - function _complete_s() { - _autocomplete $(_get_users) - } + function _complete_s() { + _autocomplete $(_get_users) + } - complete -F _complete_s s - complete -F _autocomplete_nested sudo trysudo - ''; + complete -F _complete_s s + complete -F _autocomplete_nested sudo trysudo + ''; } diff --git a/home/program/bash/module/Switch.nix b/home/program/bash/module/Switch.nix index a1dc41ce..221efad1 100644 --- a/home/program/bash/module/Switch.nix +++ b/home/program/bash/module/Switch.nix @@ -1,45 +1,46 @@ -{ ... }: { - text = '' - # Install on a Nintendo Switch. - # Usage: switch_install - function switch_install() { - local IFS=$'\n' - local targets=(''${@}) - [[ "''${targets}" = "" ]] && targets=(*.ns[pz]) +{ ... }: +{ + text = '' + # Install on a Nintendo Switch. + # Usage: switch_install + function switch_install() { + local IFS=$'\n' + local targets=(''${@}) + [[ "''${targets}" = "" ]] && targets=(*.ns[pz]) - local id=$(_switch_id) - _switch_mount + local id=$(_switch_id) + _switch_mount - install() { - gio copy -p "''${target}" ''${id}5:\ SD\ Card\ install/ - } + install() { + gio copy -p "''${target}" ''${id}5:\ SD\ Card\ install/ + } - _iterate_targets install ''${targets[@]} - } + _iterate_targets install ''${targets[@]} + } - # Backup a Nintendo Switch saves and album. - function switch_backup() { - local id=$(_switch_id) - _switch_mount - mkdir switch_backup || rm -r switch_backup/* - mkdir switch_backup/{save,album} - pushd switch_backup/save - cp -r /run/user/''${UID}/gvfs/mtp\:host\=-_DBI_*/7\:\ Saves/* . - popd - pushd switch_backup/album - cp -r /run/user/''${UID}/gvfs/mtp\:host\=-_DBI_*/8\:\ Album/* . - popd - pushd switch_backup - archive_fast album - archive save - } + # Backup a Nintendo Switch saves and album. + function switch_backup() { + local id=$(_switch_id) + _switch_mount + mkdir switch_backup || rm -r switch_backup/* + mkdir switch_backup/{save,album} + pushd switch_backup/save + cp -r /run/user/''${UID}/gvfs/mtp\:host\=-_DBI_*/7\:\ Saves/* . + popd + pushd switch_backup/album + cp -r /run/user/''${UID}/gvfs/mtp\:host\=-_DBI_*/8\:\ Album/* . + popd + pushd switch_backup + archive_fast album + archive save + } - function _switch_id() { - gio mount -l -i | rg 'mtp://-_DBI_' | sed "s/^.*=//" | head -1 - } + function _switch_id() { + gio mount -l -i | rg 'mtp://-_DBI_' | sed "s/^.*=//" | head -1 + } - function _switch_mount() { - test -d /run/user/''${UID}/gvfs/mtp\:host\=-_DBI_* || gio mount "$(_switch_id)" - } - ''; + function _switch_mount() { + test -d /run/user/''${UID}/gvfs/mtp\:host\=-_DBI_* || gio mount "$(_switch_id)" + } + ''; } diff --git a/home/program/bash/module/Tmux.nix b/home/program/bash/module/Tmux.nix index a84cae11..880124c2 100644 --- a/home/program/bash/module/Tmux.nix +++ b/home/program/bash/module/Tmux.nix @@ -1,98 +1,99 @@ -{ ... }: { - text = '' - # Create/attach to named session. - # By default uses current dir name. - # Usage: ta [NAME] - function ta() { - local name="''${1}" +{ ... }: +{ + text = '' + # Create/attach to named session. + # By default uses current dir name. + # Usage: ta [NAME] + function ta() { + local name="''${1}" - # Set default name. - # [[ "''${name}" = "" ]] && name="main" - [[ "''${name}" = "" ]] && name=$(parse_alnum "''${PWD##*/}") + # Set default name. + # [[ "''${name}" = "" ]] && name="main" + [[ "''${name}" = "" ]] && name=$(parse_alnum "''${PWD##*/}") - # Create session. - tmux new-session -s "''${name}" -d &> /dev/null + # Create session. + tmux new-session -s "''${name}" -d &> /dev/null - # Attach to session. - if _is_tmux; then - tmux switch-client -t "''${name}" - else - tmux attach-session -t "''${name}" - fi - } + # Attach to session. + if _is_tmux; then + tmux switch-client -t "''${name}" + else + tmux attach-session -t "''${name}" + fi + } - # Detach from running session. - function td() { - tmux detach-client - } + # Detach from running session. + function td() { + tmux detach-client + } - # Detach all other tmux clients. - function tda() { - tmux detach-client -s $(tmux display-message -p '#S') - } + # Detach all other tmux clients. + function tda() { + tmux detach-client -s $(tmux display-message -p '#S') + } - # List running sessions. - function tl() { - tmux list-sessions - } + # List running sessions. + function tl() { + tmux list-sessions + } - # Assign name to session. Uses current dir name by default. - # Usage: tns [NAME] - function tns() { - local name="''${1}" + # Assign name to session. Uses current dir name by default. + # Usage: tns [NAME] + function tns() { + local name="''${1}" - [[ "''${name}" = "" ]] && name=$(parse_alnum "''${PWD##*/}") + [[ "''${name}" = "" ]] && name=$(parse_alnum "''${PWD##*/}") - tmux rename-session "''${name}" - } + tmux rename-session "''${name}" + } - # Assign name to window. Uses current dir name by default. - # Usage: tnw [NAME] - function tnw() { - local name="''${1}" + # Assign name to window. Uses current dir name by default. + # Usage: tnw [NAME] + function tnw() { + local name="''${1}" - [[ "''${name}" = "" ]] && name=$(parse_alnum "''${PWD##*/}") + [[ "''${name}" = "" ]] && name=$(parse_alnum "''${PWD##*/}") - tmux rename-window "''${name}" - } + tmux rename-window "''${name}" + } - # Kill specified session. - # By default uses current dir name. - # Usage: tk [NAME] - function tk() { - local name="''${1}" + # Kill specified session. + # By default uses current dir name. + # Usage: tk [NAME] + function tk() { + local name="''${1}" - [[ "''${name}" = "" ]] && name=$(parse_alnum "''${PWD##*/}") + [[ "''${name}" = "" ]] && name=$(parse_alnum "''${PWD##*/}") - tmux kill-session -t "''${name}" - } + tmux kill-session -t "''${name}" + } - # Kill all sessions. - function tka() { - local sessions=$(tmux list-sessions | sed -e 's/:.*//') + # Kill all sessions. + function tka() { + local sessions=$(tmux list-sessions | sed -e 's/:.*//') - for session in $sessions; do - tmux kill-session -t "$session" - done - } + for session in $sessions; do + tmux kill-session -t "$session" + done + } - # Autocomplete with running sessions once. - function _complete_tmux_session() { - _autocomplete "$(tmux list-sessions 2> /dev/null | sed -e 's/:.*//')" - } + # Autocomplete with running sessions once. + function _complete_tmux_session() { + _autocomplete "$(tmux list-sessions 2> /dev/null | sed -e 's/:.*//')" + } - # Autocomplete with running sessions. - function _complete_tmux_sessions() { - _autocomplete "$(tmux list-sessions 2> /dev/null | sed -e 's/:.*//')" - } + # Autocomplete with running sessions. + function _complete_tmux_sessions() { + _autocomplete "$(tmux list-sessions 2> /dev/null | sed -e 's/:.*//')" + } - # Autocomplete with current dir name and dirs inside this one. - function _complete_tmux_name() { - _autocomplete "''${PWD##*/}"$'\n'$(ls --classify | grep /$ | sed -e 's/\/$//') - } + # Autocomplete with current dir name and dirs inside this one. + function _complete_tmux_name() { + _autocomplete "''${PWD##*/}"$'\n'$(ls --classify | grep /$ | sed -e 's/\/$//') + } - complete -F _complete_tmux_session ta - complete -F _complete_tmux_sessions tk - complete -o nosort -F _complete_tmux_name tns tnw - ''; + complete -F _complete_tmux_session ta + complete -F _complete_tmux_sessions tk + complete -o nosort -F _complete_tmux_name tns tnw + ''; } diff --git a/home/program/bash/module/Transcode.nix b/home/program/bash/module/Transcode.nix index 730d8834..512e53e4 100644 --- a/home/program/bash/module/Transcode.nix +++ b/home/program/bash/module/Transcode.nix @@ -1,108 +1,109 @@ -{ ... }: { - text = '' - # Convert between different formats. - # By default tries to convert all files. - # Usage: transcode [FILES] - function transcode() { local IFS=$'\n' - local format=''${1} - local targets=(''${@:2}) - [[ "''${targets}" = "" ]] && targets=($(_ls_file)) +{ ... }: +{ + text = '' + # Convert between different formats. + # By default tries to convert all files. + # Usage: transcode [FILES] + function transcode() { local IFS=$'\n' + local format=''${1} + local targets=(''${@:2}) + [[ "''${targets}" = "" ]] && targets=($(_ls_file)) - # Report no format. - if [[ "''${format}" = "" ]] || [[ "''${format}" =~ "." ]]; then - _error "No format specified." - help transcode - return 2 - fi + # Report no format. + if [[ "''${format}" = "" ]] || [[ "''${format}" =~ "." ]]; then + _error "No format specified." + help transcode + return 2 + fi - process() { - # Define context names and status. - local from="''${target##*.}" - local to="''${format}" - local output="''${target##*/}" - output="''${output%.*}.''${to}" + process() { + # Define context names and status. + local from="''${target##*.}" + local to="''${format}" + local output="''${target##*/}" + output="''${output%.*}.''${to}" - # Skip if file exists. - [[ -f "''${output}" ]] && { _iterate_skip "Already exists."; return 0; } + # Skip if file exists. + [[ -f "''${output}" ]] && { _iterate_skip "Already exists."; return 0; } - # Support multiple inputs. - [[ "''${to}" = "flac" ]] && from="" - [[ "''${to}" = "jxl" ]] && from="" - [[ "''${to}" = "mka" ]] && from="" - [[ "''${to}" = "mkv" ]] && from="" - [[ "''${to}" = "mp3" ]] && from="" + # Support multiple inputs. + [[ "''${to}" = "flac" ]] && from="" + [[ "''${to}" = "jxl" ]] && from="" + [[ "''${to}" = "mka" ]] && from="" + [[ "''${to}" = "mkv" ]] && from="" + [[ "''${to}" = "mp3" ]] && from="" - # Send convert. - case "''${from}-''${to}" in - "gz-xz"|"tgz-txz") - _transcode_gz-xz "''${target}" "''${output}" - ;; - "xz-gz"|"txz-tgz") - _transcode_xz-gz "''${target}" "''${output}" - ;; - "-mp3") - _transcode_mp3 "''${target}" "''${output}" - ;; - "-flac") - _transcode_flac "''${target}" "''${output}" - ;; - "-mka") - _transcode_mka "''${target}" "''${output}" - ;; - "-mkv") - _transcode_mkv "''${target}" "''${output}" - ;; - "-jxl") - _transcode_jxl "''${target}" "''${output}" - ;; - *) - _error "Conversion ''${target##*.}-''${to} not supported." - return 1 - ;; - esac - } + # Send convert. + case "''${from}-''${to}" in + "gz-xz"|"tgz-txz") + _transcode_gz-xz "''${target}" "''${output}" + ;; + "xz-gz"|"txz-tgz") + _transcode_xz-gz "''${target}" "''${output}" + ;; + "-mp3") + _transcode_mp3 "''${target}" "''${output}" + ;; + "-flac") + _transcode_flac "''${target}" "''${output}" + ;; + "-mka") + _transcode_mka "''${target}" "''${output}" + ;; + "-mkv") + _transcode_mkv "''${target}" "''${output}" + ;; + "-jxl") + _transcode_jxl "''${target}" "''${output}" + ;; + *) + _error "Conversion ''${target##*.}-''${to} not supported." + return 1 + ;; + esac + } - _iterate_targets process ''${targets[@]} - } + _iterate_targets process ''${targets[@]} + } - function _transcode_gz-xz() { - [[ -f "''${2}" ]] && return 1 - pv "''${1}" | gzip -d | xz -9e > "''${2}" - } + function _transcode_gz-xz() { + [[ -f "''${2}" ]] && return 1 + pv "''${1}" | gzip -d | xz -9e > "''${2}" + } - function _transcode_xz-gz() { - [[ -f "''${2}" ]] && return 1 - pv "''${1}" | xz -d | gzip -1 > "''${2}" - } + function _transcode_xz-gz() { + [[ -f "''${2}" ]] && return 1 + pv "''${1}" | xz -d | gzip -1 > "''${2}" + } - function _transcode_mp3() { - ffmpeg -n -i "''${1}" -c:a libmp3lame -b:a 320k -f mp3 "''${2}" - } + function _transcode_mp3() { + ffmpeg -n -i "''${1}" -c:a libmp3lame -b:a 320k -f mp3 "''${2}" + } - function _transcode_flac() { - ffmpeg -n -i "''${1}" -c:a flac -f flac "''${2}" - } + function _transcode_flac() { + ffmpeg -n -i "''${1}" -c:a flac -f flac "''${2}" + } - function _transcode_mka() { - local braudio=$(_ffprobe_ba "''${1}") - [[ ''${braudio} -gt 128 ]] && braudio=128 + function _transcode_mka() { + local braudio=$(_ffprobe_ba "''${1}") + [[ ''${braudio} -gt 128 ]] && braudio=128 - ffmpeg -n -i "''${1}" -ac 2 -c:a libopus -b:a ''${braudio}k -vn "''${2}" - } + ffmpeg -n -i "''${1}" -ac 2 -c:a libopus -b:a ''${braudio}k -vn "''${2}" + } - function _transcode_mkv() { - local keyint=$(_ffprobe_keyint "''${1}") - local braudio=$(_ffprobe_ba "''${1}") - local fps=$(_ffprobe_fps "''${1}") - [[ ''${braudio} -gt 128 ]] && braudio=128 - [[ ''${fps} -gt 30 ]] && fps=30 + function _transcode_mkv() { + local keyint=$(_ffprobe_keyint "''${1}") + local braudio=$(_ffprobe_ba "''${1}") + local fps=$(_ffprobe_fps "''${1}") + [[ ''${braudio} -gt 128 ]] && braudio=128 + [[ ''${fps} -gt 30 ]] && fps=30 - # ffmpeg -n -i "''${1}" -c:a libopus -b:a ''${braudio}k -c:v libsvtav1 -crf 30 -svtav1-params "fast-decode=1:tune=0" -preset 8 -pix_fmt yuv420p10le -g ''${keyint} -vf "scale=-2:min'(1080,ih)'" "''${2}" - ffmpeg -n -i "''${1}" -map 0 -map -v -map V -map -t -dn -c:s srt -ac 2 -c:a libopus -b:a ''${braudio}k -c:v libsvtav1 -crf 30 -svtav1-params "tune=0" -pix_fmt yuv420p10le -g ''${keyint} -vf "scale=-2:min'(1080,ih)' , fps=''${fps}" "''${2}" - } + # ffmpeg -n -i "''${1}" -c:a libopus -b:a ''${braudio}k -c:v libsvtav1 -crf 30 -svtav1-params "fast-decode=1:tune=0" -preset 8 -pix_fmt yuv420p10le -g ''${keyint} -vf "scale=-2:min'(1080,ih)'" "''${2}" + ffmpeg -n -i "''${1}" -map 0 -map -v -map V -map -t -dn -c:s srt -ac 2 -c:a libopus -b:a ''${braudio}k -c:v libsvtav1 -crf 30 -svtav1-params "tune=0" -pix_fmt yuv420p10le -g ''${keyint} -vf "scale=-2:min'(1080,ih)' , fps=''${fps}" "''${2}" + } - function _transcode_jxl() { - cjxl -e 10 --lossless_jpeg=1 -- "''${1}" "''${2}" - } - ''; + function _transcode_jxl() { + cjxl -e 10 --lossless_jpeg=1 -- "''${1}" "''${2}" + } + ''; } diff --git a/home/program/bash/module/Try.nix b/home/program/bash/module/Try.nix index 22a790a3..d33ce474 100644 --- a/home/program/bash/module/Try.nix +++ b/home/program/bash/module/Try.nix @@ -1,25 +1,26 @@ -{ ... }: { - text = '' - # Retry command every 2 sec until it completes successfully. - # Usage: try - function try() { - if [[ "''${*}" = "" ]]; then - help try - return 2 - fi +{ ... }: +{ + text = '' + # Retry command every 2 sec until it completes successfully. + # Usage: try + function try() { + if [[ "''${*}" = "" ]]; then + help try + return 2 + fi - local result=-1 + local result=-1 - while [ "$result" != 0 ]; do - ''${*} - result=$? - if [ "$result" != 0 ]; then - sleep 2 - fi - done - } + while [ "$result" != 0 ]; do + ''${*} + result=$? + if [ "$result" != 0 ]; then + sleep 2 + fi + done + } - # autocomplete. - complete -F _autocomplete_nested try - ''; + # autocomplete. + complete -F _autocomplete_nested try + ''; } diff --git a/home/program/bash/module/Util.nix b/home/program/bash/module/Util.nix index dfdf3b7b..97688a3c 100644 --- a/home/program/bash/module/Util.nix +++ b/home/program/bash/module/Util.nix @@ -1,158 +1,159 @@ -{ ... }: { - text = '' - # Get the number of avaialble cores (threads). - function _core_count() { - cat /proc/cpuinfo | grep ^processor | wc -l - } +{ ... }: +{ + text = '' + # Get the number of avaialble cores (threads). + function _core_count() { + cat /proc/cpuinfo | grep ^processor | wc -l + } - # Get the number of available memory (in mebibytes). - function _mem_free() { - free -m | sed -n -e '2p' | awk '{print $7}' - } + # Get the number of available memory (in mebibytes). + function _mem_free() { + free -m | sed -n -e '2p' | awk '{print $7}' + } - # Function-wrapper to iterate with specified function with provided files. - # By default Iterates on all non-hidden files and directories. - # List of variables available to FUNCTION: target - current file, count - current item index, total - sum of targets, failed - count of previously failed items, skipped - count of skipped files, status - status line (not recommended to use). - # Usage: _iterate_targets [FILES] - function _iterate_targets() { - local IFS=$'\n' - local foo="''${1}" - local targets=("''${@:2}") - local total=''${#targets[@]} - local count=0 - local failed=0 - local skipped=0 - local code=0 + # Function-wrapper to iterate with specified function with provided files. + # By default Iterates on all non-hidden files and directories. + # List of variables available to FUNCTION: target - current file, count - current item index, total - sum of targets, failed - count of previously failed items, skipped - count of skipped files, status - status line (not recommended to use). + # Usage: _iterate_targets [FILES] + function _iterate_targets() { + local IFS=$'\n' + local foo="''${1}" + local targets=("''${@:2}") + local total=''${#targets[@]} + local count=0 + local failed=0 + local skipped=0 + local code=0 - # set dafult value to target all supported archives. - if [[ "''${targets}" = "" ]]; then - _error "No targets provided." - return 1 - fi + # set dafult value to target all supported archives. + if [[ "''${targets}" = "" ]]; then + _error "No targets provided." + return 1 + fi - # iterate each target. - for target in "''${targets[@]}"; do - # increment counter. - ((count++)) + # iterate each target. + for target in "''${targets[@]}"; do + # increment counter. + ((count++)) - # status info. - local status="[''${count}/''${total}] ''${target}" - _info "''${status}" + # status info. + local status="[''${count}/''${total}] ''${target}" + _info "''${status}" - # Call function. - ''${foo} "''${target}" + # Call function. + ''${foo} "''${target}" - # Show error. - if [[ ''${?} != 0 ]]; then - ((failed++)) - _error "''${status}: Failed." - fi + # Show error. + if [[ ''${?} != 0 ]]; then + ((failed++)) + _error "''${status}: Failed." + fi - # Add newline if not the last one. - [[ "''${count}" = "''${total}" ]] || _info - done + # Add newline if not the last one. + [[ "''${count}" = "''${total}" ]] || _info + done - # Show skipped. - if [[ ''${skipped} != 0 ]]; then - _warn - _warn "''${color_byellow}Skipped: ''${skipped}.''${color_default}" - fi + # Show skipped. + if [[ ''${skipped} != 0 ]]; then + _warn + _warn "''${color_byellow}Skipped: ''${skipped}.''${color_default}" + fi - # Show error. - if [[ ''${failed} != 0 ]]; then - [[ "''${skipped}" = 0 ]] && _error - _error "''${color_bred}Failed: ''${failed}.''${color_default}" - false - fi - } + # Show error. + if [[ ''${failed} != 0 ]]; then + [[ "''${skipped}" = 0 ]] && _error + _error "''${color_bred}Failed: ''${failed}.''${color_default}" + false + fi + } - # Skip current iteration. - # Usage: _iterate_skip [MESSAGE] - function _iterate_skip() { - ((skipped++)) + # Skip current iteration. + # Usage: _iterate_skip [MESSAGE] + function _iterate_skip() { + ((skipped++)) - [[ "''${*}" != "" ]] && _warn "''${color_byellow}''${*}''${color_default}" - } + [[ "''${*}" != "" ]] && _warn "''${color_byellow}''${*}''${color_default}" + } - # Report an error. - # Always returns code 1. - # Usage: _error - function _error() { - >&2 echo -e "''${color_bred}''${*}''${color_default}" - return 1 - } + # Report an error. + # Always returns code 1. + # Usage: _error + function _error() { + >&2 echo -e "''${color_bred}''${*}''${color_default}" + return 1 + } - # Report a warning. - # Usage: _warn - function _warn() { - >&2 echo -e "''${color_byellow}''${*}''${color_default}" - } + # Report a warning. + # Usage: _warn + function _warn() { + >&2 echo -e "''${color_byellow}''${*}''${color_default}" + } - # Report a debug. - # Usage: _debug - function _debug() { - >&2 echo -e "''${color_bwhite}''${*}''${color_default}" - } + # Report a debug. + # Usage: _debug + function _debug() { + >&2 echo -e "''${color_bwhite}''${*}''${color_default}" + } - # Report an info. - # Usage: _info - function _info() { - >&2 echo -e "''${color_bwhite}''${*}''${color_default}" - } + # Report an info. + # Usage: _info + function _info() { + >&2 echo -e "''${color_bwhite}''${*}''${color_default}" + } - # Check if array contains an element (strict). - # Usage: _contains - function _contains() { - local IFS=$'\n' - local target="''${1}" - local array="''${@:2}" + # Check if array contains an element (strict). + # Usage: _contains + function _contains() { + local IFS=$'\n' + local target="''${1}" + local array="''${@:2}" - if [[ "''${target}" = "" ]] || [[ "''${array}" = "" ]]; then - help _contains - return 2 - fi + if [[ "''${target}" = "" ]] || [[ "''${array}" = "" ]]; then + help _contains + return 2 + fi - for item in ''${array[@]}; do - [[ "''${item}" = "''${target}" ]] && return 0 - done + for item in ''${array[@]}; do + [[ "''${item}" = "''${target}" ]] && return 0 + done - return 1 - } + return 1 + } - # Find an index of an element in array. - # Usage: _index_of - function _index_of() { - local element="''${1}" - local array="''${@:2}" - local index=0 + # Find an index of an element in array. + # Usage: _index_of + function _index_of() { + local element="''${1}" + local array="''${@:2}" + local index=0 - for item in ''${array[@]}; do - [[ "''${item}" = "''${element}" ]] && break - ((index++)) - done + for item in ''${array[@]}; do + [[ "''${item}" = "''${element}" ]] && break + ((index++)) + done - echo "''${index}" - } + echo "''${index}" + } - # Check if inside Tmux. - function _is_tmux() { - [[ "''${TERM_PROGRAM}" = "tmux" ]] - } + # Check if inside Tmux. + function _is_tmux() { + [[ "''${TERM_PROGRAM}" = "tmux" ]] + } - # Check if root. - function _is_root() { - [[ "''${UID}" = 0 ]] - } + # Check if root. + function _is_root() { + [[ "''${UID}" = 0 ]] + } - # Ring a bell. - function _bell() { - echo -e '\a' - } + # Ring a bell. + function _bell() { + echo -e '\a' + } - # Get users. - function _get_users() { - local users=("voronind" "dasha") - echo ''${users[@]} - } - ''; + # Get users. + function _get_users() { + local users=("voronind" "dasha") + echo ''${users[@]} + } + ''; } diff --git a/home/program/bash/module/Vdl.nix b/home/program/bash/module/Vdl.nix index cfe60229..87cdd8c2 100644 --- a/home/program/bash/module/Vdl.nix +++ b/home/program/bash/module/Vdl.nix @@ -1,43 +1,44 @@ -{ ... }: { - text = '' - # Download video from URL. When no `[LINK]` specified, it tries to update previously downloaded link. - # Usage: vdl [LINK] - function vdl() { - # Check that ffmpeg and ffprobe are available. - if [[ "$(ffmpeg -version)" = "" ]] || [[ "$(ffprobe -version)" = "" ]]; then - _error "ffmpeg and ffprobe are required." - return 1 - fi +{ ... }: +{ + text = '' + # Download video from URL. When no `[LINK]` specified, it tries to update previously downloaded link. + # Usage: vdl [LINK] + function vdl() { + # Check that ffmpeg and ffprobe are available. + if [[ "$(ffmpeg -version)" = "" ]] || [[ "$(ffprobe -version)" = "" ]]; then + _error "ffmpeg and ffprobe are required." + return 1 + fi - local target="''${@}" # What to download/update. + local target="''${@}" # What to download/update. - # If no [LINK] provided, try to read from `Src.txt`. - [[ "''${target}" = "" ]] && target="$(cat Src.txt)" + # If no [LINK] provided, try to read from `Src.txt`. + [[ "''${target}" = "" ]] && target="$(cat Src.txt)" - # If could not get [LINK] eventually, show an error and exit. - if [[ "''${target}" = "" ]]; then - _error "Could not determine [LINK] to download." - help vdl - return 2 - fi + # If could not get [LINK] eventually, show an error and exit. + if [[ "''${target}" = "" ]]; then + _error "Could not determine [LINK] to download." + help vdl + return 2 + fi - # Save [LINK] for later use. - [[ -f "Src.txt" ]] || echo "''${target}" > Src.txt + # Save [LINK] for later use. + [[ -f "Src.txt" ]] || echo "''${target}" > Src.txt - # Download [LINK] content. - yt-dlp -4 -S 'res:1080,codec:av1,codec:vp9,codec:h264' --download-archive Index.txt --embed-thumbnail --embed-subs --write-auto-subs --embed-metadata --merge-output-format mkv -cio '%(playlist_index)000006d_%(id)s.%(ext)s' ''${target} # || _vdl_retry - } + # Download [LINK] content. + yt-dlp -4 -S 'res:1080,codec:av1,codec:vp9,codec:h264' --download-archive Index.txt --embed-thumbnail --embed-subs --write-auto-subs --embed-metadata --merge-output-format mkv -cio '%(playlist_index)000006d_%(id)s.%(ext)s' ''${target} # || _vdl_retry + } - # Temporary fix for vk downloads. - # Usage: vdl_vk - function vdl_vk() { - vdl --format mp4 "''${@}" - } + # Temporary fix for vk downloads. + # Usage: vdl_vk + function vdl_vk() { + vdl --format mp4 "''${@}" + } - # Download all videos from file with links. - # Usage: vdl_file - function vdl_file() { - vdl -a "''${@}" - } - ''; + # Download all videos from file with links. + # Usage: vdl_file + function vdl_file() { + vdl -a "''${@}" + } + ''; } diff --git a/home/program/bash/module/Vi.nix b/home/program/bash/module/Vi.nix index d813bfee..960b7eae 100644 --- a/home/program/bash/module/Vi.nix +++ b/home/program/bash/module/Vi.nix @@ -1,8 +1,9 @@ -{ ... }: { - text = '' - # Neovim shortcut. - function v() { - nvim -- "''${@}" - } - ''; +{ ... }: +{ + text = '' + # Neovim shortcut. + function v() { + nvim -- "''${@}" + } + ''; } diff --git a/home/program/bash/module/Watch.nix b/home/program/bash/module/Watch.nix index 167f990e..6a951a00 100644 --- a/home/program/bash/module/Watch.nix +++ b/home/program/bash/module/Watch.nix @@ -1,28 +1,29 @@ -{ ... }: { - text = '' - # Watch command output with 2 seconds interval. - # Usage: w - function w() { - if [[ "''${*}" = "" ]]; then - help w - return 2 - fi +{ ... }: +{ + text = '' + # Watch command output with 2 seconds interval. + # Usage: w + function w() { + if [[ "''${*}" = "" ]]; then + help w + return 2 + fi - watch -n 2 "''${@}" - } + watch -n 2 "''${@}" + } - # Watch command output with minimal interval. - # Usage: ww - function ww() { - if [[ "''${*}" = "" ]]; then - help ww - return 2 - fi + # Watch command output with minimal interval. + # Usage: ww + function ww() { + if [[ "''${*}" = "" ]]; then + help ww + return 2 + fi - watch -n 0 "''${@}" - } + watch -n 0 "''${@}" + } - # Autocomplete. - complete -F _autocomplete_nested w ww - ''; + # Autocomplete. + complete -F _autocomplete_nested w ww + ''; } diff --git a/home/program/bash/module/Zapret.nix b/home/program/bash/module/Zapret.nix index 0ca5b10f..5b3fd733 100644 --- a/home/program/bash/module/Zapret.nix +++ b/home/program/bash/module/Zapret.nix @@ -1,10 +1,11 @@ -{ ... }: { - text = '' - # FRKN. - # SOURCE: https://github.com/bol-van/zapret - function zapret() { - iptables -t mangle -I POSTROUTING -p tcp -m multiport --dports 80,443 -m connbytes --connbytes-dir=original --connbytes-mode=packets --connbytes 1:6 -m mark ! --mark 0x40000000/0x40000000 -j NFQUEUE --queue-num 201 --queue-bypass - nfqws --pidfile=/run/nfqws.pid --qnum=201 ''${@} - } - ''; +{ ... }: +{ + text = '' + # FRKN. + # SOURCE: https://github.com/bol-van/zapret + function zapret() { + iptables -t mangle -I POSTROUTING -p tcp -m multiport --dports 80,443 -m connbytes --connbytes-dir=original --connbytes-mode=packets --connbytes 1:6 -m mark ! --mark 0x40000000/0x40000000 -j NFQUEUE --queue-num 201 --queue-bypass + nfqws --pidfile=/run/nfqws.pid --qnum=201 ''${@} + } + ''; } diff --git a/home/program/chromium/default.nix b/home/program/chromium/default.nix index 830dfc45..4f2ad177 100644 --- a/home/program/chromium/default.nix +++ b/home/program/chromium/default.nix @@ -1,69 +1,84 @@ { - pkgs, - pkgsUnstable, - lib, - ... -}: let - package = pkgsUnstable.ungoogled-chromium; - browserVersion = lib.versions.major package.version; - extensions = let - fetchFromStore = { id, sha256, version, }: { - inherit id version; - crxPath = pkgs.fetchurl { - inherit sha256; - name = "${id}.crx"; - url = "https://clients2.google.com/service/update2/crx?response=redirect&acceptformat=crx2,crx3&prodversion=${browserVersion}&x=id%3D${id}%26installsource%3Dondemand%26uc"; - }; - }; - fetchFromUrl = { id, url, sha256, version, }: { - inherit id version; - crxPath = pkgs.fetchurl { - inherit sha256 url; - name = "${id}.crx"; - }; - }; - in [ - (fetchFromStore { - # uBlock Origin dev. - id = "cgbcahbpdhpcegmbfconppldiemgcoii"; - sha256 = "sha256-sTE96l7/B3n4rJHYC0p4hCVmXUMYj/6O6+596DFIK58="; - version = "1.60.1.16"; - }) - (fetchFromStore { - # Dark reader. - id = "eimadpbcbfnmbkopoojfekhnkhdbieeh"; - sha256 = "sha256-98sGCo2dG+XYMzBeLR+10Ic5DLjDXhSh1DzatLOCyQQ="; - version = "4.9.95"; - }) - (fetchFromStore { - # Foxy Proxy. - id = "gcknhkkoolaabfmlnjonogaaifnjlfnp"; - sha256 = "sha256-Zm7x/467CaGcEN+cYwf8XowpaZRJQIzIEY/F6NhJ3pA="; - version = "8.9"; - }) - (fetchFromStore { - # Vimium. - id = "dbepggeogbaibhgnhhndojpepiihcmeb"; - sha256 = "sha256-DaEM1NyMX8RMBvWoIVOhmfY/ae66HCNfRFnwAuLUHVU="; - version = "2.1.2"; - }) - # (fetchFromUrl rec { - # # Ext updater. - # id = "ocaahdebbfolfmndjeplogmgcagdmblk"; - # url = "https://github.com/NeverDecaf/chromium-web-store/releases/download/v${version}/Chromium.Web.Store.crx"; - # sha256 = "sha256-gKAcrvnxLh9gMraTFX4zRsUua4OI+lak51gpII29d8g="; - # version = "1.5.4.3"; - # }) - ]; -in { - inherit extensions package; - enable = true; - dictionaries = with pkgsUnstable.hunspellDictsChromium; [ - en_US - ]; - commandLineArgs = [ - # Disable animations. - "--wm-window-animations-disabled" - "--animation-duration-scale=0" - ]; + pkgs, + pkgsUnstable, + lib, + ... +}: +let + package = pkgsUnstable.ungoogled-chromium; + browserVersion = lib.versions.major package.version; + extensions = + let + fetchFromStore = + { + id, + sha256, + version, + }: + { + inherit id version; + crxPath = pkgs.fetchurl { + inherit sha256; + name = "${id}.crx"; + url = "https://clients2.google.com/service/update2/crx?response=redirect&acceptformat=crx2,crx3&prodversion=${browserVersion}&x=id%3D${id}%26installsource%3Dondemand%26uc"; + }; + }; + fetchFromUrl = + { + id, + url, + sha256, + version, + }: + { + inherit id version; + crxPath = pkgs.fetchurl { + inherit sha256 url; + name = "${id}.crx"; + }; + }; + in + [ + (fetchFromStore { + # uBlock Origin dev. + id = "cgbcahbpdhpcegmbfconppldiemgcoii"; + sha256 = "sha256-sTE96l7/B3n4rJHYC0p4hCVmXUMYj/6O6+596DFIK58="; + version = "1.60.1.16"; + }) + (fetchFromStore { + # Dark reader. + id = "eimadpbcbfnmbkopoojfekhnkhdbieeh"; + sha256 = "sha256-98sGCo2dG+XYMzBeLR+10Ic5DLjDXhSh1DzatLOCyQQ="; + version = "4.9.95"; + }) + (fetchFromStore { + # Foxy Proxy. + id = "gcknhkkoolaabfmlnjonogaaifnjlfnp"; + sha256 = "sha256-Zm7x/467CaGcEN+cYwf8XowpaZRJQIzIEY/F6NhJ3pA="; + version = "8.9"; + }) + (fetchFromStore { + # Vimium. + id = "dbepggeogbaibhgnhhndojpepiihcmeb"; + sha256 = "sha256-DaEM1NyMX8RMBvWoIVOhmfY/ae66HCNfRFnwAuLUHVU="; + version = "2.1.2"; + }) + # (fetchFromUrl rec { + # # Ext updater. + # id = "ocaahdebbfolfmndjeplogmgcagdmblk"; + # url = "https://github.com/NeverDecaf/chromium-web-store/releases/download/v${version}/Chromium.Web.Store.crx"; + # sha256 = "sha256-gKAcrvnxLh9gMraTFX4zRsUua4OI+lak51gpII29d8g="; + # version = "1.5.4.3"; + # }) + ]; +in +{ + inherit extensions package; + enable = true; + dictionaries = with pkgsUnstable.hunspellDictsChromium; [ en_US ]; + commandLineArgs = [ + # Disable animations. + "--wm-window-animations-disabled" + "--animation-duration-scale=0" + ]; } diff --git a/home/program/default.nix b/home/program/default.nix index bb185cf3..0c81a7b2 100644 --- a/home/program/default.nix +++ b/home/program/default.nix @@ -1,32 +1,34 @@ { - config, - lib, - secret, - ... -} @args: let - bash = import ./bash args; -in { - core = { - home-manager.enable = true; + config, + lib, + secret, + ... +}@args: +let + bash = import ./bash args; +in +{ + core = { + home-manager.enable = true; - gpg = { - inherit (secret.crypto) publicKeys; - enable = true; - mutableKeys = true; - mutableTrust = true; - settings = { - keyserver = "hkps://keys.openpgp.org"; - }; - }; + gpg = { + inherit (secret.crypto) publicKeys; + enable = true; + mutableKeys = true; + mutableTrust = true; + settings = { + keyserver = "hkps://keys.openpgp.org"; + }; + }; - bash = { - enable = true; - initExtra = bash.bashrc; - }; - }; + bash = { + enable = true; + initExtra = bash.bashrc; + }; + }; - desktop = { - chromium = import ./chromium args; - firefox = import ./firefox args; - }; + desktop = { + chromium = import ./chromium args; + firefox = import ./firefox args; + }; } diff --git a/home/program/firefox/default.nix b/home/program/firefox/default.nix index 9e978517..79aeb24d 100644 --- a/home/program/firefox/default.nix +++ b/home/program/firefox/default.nix @@ -1,489 +1,487 @@ { - __findFile, - config, - pkgs, - pkgsUnstable, - ... -} @args: let - bookmarks = [ - (mkBookmark "Dashboard" "https://home.voronind.com") - (mkBookmark "Watch" "https://watch.voronind.com") - (mkBookmark "Telegram" "https://web.telegram.org/a") - (mkBookmark "WorkChat" "https://fsmm.fsight.ru/fmp") - (mkBookmark "Mail" "https://mail.voronind.com") - (mkBookmark "WorkMail" "https://mail.fsight.ru") - (mkBookmark "Git" "https://git.voronind.com") - (mkBookmark "WorkGit" "https://git.fmp.fsight.world") - (mkBookmark "WorkBoard" "https://support.fsight.ru") - (mkBookmark "Hass" "https://iot.voronind.com") - (mkBookmark "Cloud" "https://cloud.voronind.com") - (mkBookmark "GitHub" "https://github.com/notifications") - ]; + __findFile, + config, + pkgs, + pkgsUnstable, + ... +}@args: +let + bookmarks = [ + (mkBookmark "Dashboard" "https://home.voronind.com") + (mkBookmark "Watch" "https://watch.voronind.com") + (mkBookmark "Telegram" "https://web.telegram.org/a") + (mkBookmark "WorkChat" "https://fsmm.fsight.ru/fmp") + (mkBookmark "Mail" "https://mail.voronind.com") + (mkBookmark "WorkMail" "https://mail.fsight.ru") + (mkBookmark "Git" "https://git.voronind.com") + (mkBookmark "WorkGit" "https://git.fmp.fsight.world") + (mkBookmark "WorkBoard" "https://support.fsight.ru") + (mkBookmark "Hass" "https://iot.voronind.com") + (mkBookmark "Cloud" "https://cloud.voronind.com") + (mkBookmark "GitHub" "https://github.com/notifications") + ]; - searchEngines = [ - (mkSearchEngine "4p" "4pda" "https://4pda.to/forum/index.php?act=search&forums[]=all&source=all&query={searchTerms}") - (mkSearchEngine "aw" "Arch Wiki" "https://wiki.archlinux.org/index.php?search={searchTerms}") - (mkSearchEngine "fa" "Font Awesome" "https://fontawesome.com/search?q={searchTerms}&o=r&m=free") - (mkSearchEngine "fb" "Flibusta" "https://flibusta.is/booksearch?ask={searchTerms}") - (mkSearchEngine "gh" "GitHub" "https://github.com/search?q={searchTerms}") - (mkSearchEngine "gc" "GitHub Code" "https://github.com/search?q={searchTerms}&type=code") - (mkSearchEngine "gn" "GitHub Notif" "https://github.com/notifications?query={searchTerms}") - (mkSearchEngine "hm" "Home Manager" "https://home-manager-options.extranix.com/?query={searchTerms}") - (mkSearchEngine "nf" "Nerd Fonts" "https://www.nerdfonts.com/cheat-sheet?q={searchTerms}") - (mkSearchEngine "no" "NixOS Options" "https://search.nixos.org/options?query={searchTerms}") - (mkSearchEngine "np" "NixOS Packages" "https://search.nixos.org/packages?query={searchTerms}") - (mkSearchEngine "oz" "Ozon" "https://www.ozon.ru/search?text={searchTerms}") - (mkSearchEngine "re" "Reddit" "https://www.reddit.com/search/?q={searchTerms}") - (mkSearchEngine "rt" "RuTracker" "https://rutracker.org/forum/tracker.php?nm={searchTerms}") - (mkSearchEngine "so" "Stack Overflow" "https://stackoverflow.com/search?tab=votes&q={searchTerms}") - (mkSearchEngine "st" "Steam" "https://store.steampowered.com/search/?term={searchTerms}") - (mkSearchEngine "sx" "SearX" "https://search.voronind.com/search?q={searchTerms}") - (mkSearchEngine "wp" "Wallpaper" "https://unsplash.com/s/photos/{searchTerms}?license=free&orientation=landscape") - (mkSearchEngine "yt" "YouTube" "https://yt.voronind.com/search?q={searchTerms}") - ]; + searchEngines = [ + (mkSearchEngine "4p" "4pda" + "https://4pda.to/forum/index.php?act=search&forums[]=all&source=all&query={searchTerms}" + ) + (mkSearchEngine "aw" "Arch Wiki" "https://wiki.archlinux.org/index.php?search={searchTerms}") + (mkSearchEngine "fa" "Font Awesome" "https://fontawesome.com/search?q={searchTerms}&o=r&m=free") + (mkSearchEngine "fb" "Flibusta" "https://flibusta.is/booksearch?ask={searchTerms}") + (mkSearchEngine "gh" "GitHub" "https://github.com/search?q={searchTerms}") + (mkSearchEngine "gc" "GitHub Code" "https://github.com/search?q={searchTerms}&type=code") + (mkSearchEngine "gn" "GitHub Notif" "https://github.com/notifications?query={searchTerms}") + (mkSearchEngine "hm" "Home Manager" + "https://home-manager-options.extranix.com/?query={searchTerms}" + ) + (mkSearchEngine "nf" "Nerd Fonts" "https://www.nerdfonts.com/cheat-sheet?q={searchTerms}") + (mkSearchEngine "no" "NixOS Options" "https://search.nixos.org/options?query={searchTerms}") + (mkSearchEngine "np" "NixOS Packages" "https://search.nixos.org/packages?query={searchTerms}") + (mkSearchEngine "oz" "Ozon" "https://www.ozon.ru/search?text={searchTerms}") + (mkSearchEngine "re" "Reddit" "https://www.reddit.com/search/?q={searchTerms}") + (mkSearchEngine "rt" "RuTracker" "https://rutracker.org/forum/tracker.php?nm={searchTerms}") + (mkSearchEngine "so" "Stack Overflow" "https://stackoverflow.com/search?tab=votes&q={searchTerms}") + (mkSearchEngine "st" "Steam" "https://store.steampowered.com/search/?term={searchTerms}") + (mkSearchEngine "sx" "SearX" "https://search.voronind.com/search?q={searchTerms}") + (mkSearchEngine "wp" "Wallpaper" + "https://unsplash.com/s/photos/{searchTerms}?license=free&orientation=landscape" + ) + (mkSearchEngine "yt" "YouTube" "https://yt.voronind.com/search?q={searchTerms}") + ]; - extensions = [ - # TODO: Use this after https://github.com/darkreader/darkreader/pull/12920 gets merged. - # (mkExtension "addon@darkreader.org" "https://addons.mozilla.org/firefox/downloads/latest/darkreader/latest.xpi") - (mkExtension "addon@darkreader.org" "file://${pkgs.callPackage args}/latest.xpi") - (mkExtension "cliget@zaidabdulla.com" "https://addons.mozilla.org/firefox/downloads/latest/cliget/latest.xpi") - (mkExtension "foxyproxy@eric.h.jung" "https://addons.mozilla.org/firefox/downloads/latest/foxyproxy-standard/latest.xpi") - (mkExtension "uBlock0@raymondhill.net" "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi") - (mkExtension "{446900e4-71c2-419f-a6a7-df9c091e268b}" "https://addons.mozilla.org/firefox/downloads/latest/bitwarden-password-manager/latest.xpi") - (mkExtension "{a6c4a591-f1b2-4f03-b3ff-767e5bedf4e7}" "https://addons.mozilla.org/firefox/downloads/latest/user-agent-string-switcher/latest.xpi") - (mkExtension "{d7742d87-e61d-4b78-b8a1-b469842139fa}" "https://addons.mozilla.org/firefox/downloads/latest/vimium-ff/latest.xpi") - (mkExtension "{e7625f06-e252-479d-ac7a-db68aeaff2cb}" "https://addons.mozilla.org/firefox/downloads/latest/togglefonts/latest.xpi") - # NOTE: This extension is helpful to find the required parameters for this config. - # Or find them yourself inside the `about:support`. - # (mkExtension "queryamoid@kaply.com" "https://github.com/mkaply/queryamoid/releases/download/v0.1/query_amo_addon_id-0.1-fx.xpi") - ]; + extensions = [ + # TODO: Use this after https://github.com/darkreader/darkreader/pull/12920 gets merged. + # (mkExtension "addon@darkreader.org" "https://addons.mozilla.org/firefox/downloads/latest/darkreader/latest.xpi") + (mkExtension "addon@darkreader.org" "file://${pkgs.callPackage args}/latest.xpi") + (mkExtension "cliget@zaidabdulla.com" "https://addons.mozilla.org/firefox/downloads/latest/cliget/latest.xpi") + (mkExtension "foxyproxy@eric.h.jung" "https://addons.mozilla.org/firefox/downloads/latest/foxyproxy-standard/latest.xpi") + (mkExtension "uBlock0@raymondhill.net" "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi") + (mkExtension "{446900e4-71c2-419f-a6a7-df9c091e268b}" "https://addons.mozilla.org/firefox/downloads/latest/bitwarden-password-manager/latest.xpi") + (mkExtension "{a6c4a591-f1b2-4f03-b3ff-767e5bedf4e7}" "https://addons.mozilla.org/firefox/downloads/latest/user-agent-string-switcher/latest.xpi") + (mkExtension "{d7742d87-e61d-4b78-b8a1-b469842139fa}" "https://addons.mozilla.org/firefox/downloads/latest/vimium-ff/latest.xpi") + (mkExtension "{e7625f06-e252-479d-ac7a-db68aeaff2cb}" "https://addons.mozilla.org/firefox/downloads/latest/togglefonts/latest.xpi") + # NOTE: This extension is helpful to find the required parameters for this config. + # Or find them yourself inside the `about:support`. + # (mkExtension "queryamoid@kaply.com" "https://github.com/mkaply/queryamoid/releases/download/v0.1/query_amo_addon_id-0.1-fx.xpi") + ]; - prefs = [ - # WARN: Remove when Dark Reader policies gets merged. - (mkLockedPref "xpinstall.signatures.required" false) + prefs = [ + # WARN: Remove when Dark Reader policies gets merged. + (mkLockedPref "xpinstall.signatures.required" false) - # Bookmarks. - (mkLockedPref "browser.microsummary.enabled" true) - (mkLockedPref "browser.places.importBookmarksHTML" true) - (mkLockedPref "browser.toolbars.bookmarks.visibility" "never") + # Bookmarks. + (mkLockedPref "browser.microsummary.enabled" true) + (mkLockedPref "browser.places.importBookmarksHTML" true) + (mkLockedPref "browser.toolbars.bookmarks.visibility" "never") - # Fonts. - (mkUserPref "browser.display.use_document_fonts" 0) - (mkLockedPref "font.minimum-size.x-cyrillic" (toString config.module.style.font.size.application)) - (mkLockedPref "font.minimum-size.x-unicode" (toString config.module.style.font.size.application)) - (mkLockedPref "font.minimum-size.x-western" (toString config.module.style.font.size.application)) - (mkLockedPref "font.name.monospace.x-cyrillic" config.module.style.font.monospace.name) - (mkLockedPref "font.name.monospace.x-unicode" config.module.style.font.monospace.name) - (mkLockedPref "font.name.monospace.x-western" config.module.style.font.monospace.name) - (mkLockedPref "font.name.sans-serif.x-cyrillic" config.module.style.font.sansSerif.name) - (mkLockedPref "font.name.sans-serif.x-unicode" config.module.style.font.sansSerif.name) - (mkLockedPref "font.name.sans-serif.x-western" config.module.style.font.sansSerif.name) - (mkLockedPref "font.name.serif.x-cyrillic" config.module.style.font.serif.name) - (mkLockedPref "font.name.serif.x-unicode" config.module.style.font.serif.name) - (mkLockedPref "font.name.serif.x-western" config.module.style.font.serif.name) + # Fonts. + (mkUserPref "browser.display.use_document_fonts" 0) + (mkLockedPref "font.minimum-size.x-cyrillic" (toString config.module.style.font.size.application)) + (mkLockedPref "font.minimum-size.x-unicode" (toString config.module.style.font.size.application)) + (mkLockedPref "font.minimum-size.x-western" (toString config.module.style.font.size.application)) + (mkLockedPref "font.name.monospace.x-cyrillic" config.module.style.font.monospace.name) + (mkLockedPref "font.name.monospace.x-unicode" config.module.style.font.monospace.name) + (mkLockedPref "font.name.monospace.x-western" config.module.style.font.monospace.name) + (mkLockedPref "font.name.sans-serif.x-cyrillic" config.module.style.font.sansSerif.name) + (mkLockedPref "font.name.sans-serif.x-unicode" config.module.style.font.sansSerif.name) + (mkLockedPref "font.name.sans-serif.x-western" config.module.style.font.sansSerif.name) + (mkLockedPref "font.name.serif.x-cyrillic" config.module.style.font.serif.name) + (mkLockedPref "font.name.serif.x-unicode" config.module.style.font.serif.name) + (mkLockedPref "font.name.serif.x-western" config.module.style.font.serif.name) - # Animations. - (mkLockedPref "browser.fullscreen.animateUp" 0) - (mkLockedPref "browser.fullscreen.autohide" true) + # Animations. + (mkLockedPref "browser.fullscreen.animateUp" 0) + (mkLockedPref "browser.fullscreen.autohide" true) - # Formats. - (mkLockedPref "image.jxl.enabled" true) + # Formats. + (mkLockedPref "image.jxl.enabled" true) - # Disable HTTP3. - # (mkLockedPref "network.http.http3.enable" false) + # Disable HTTP3. + # (mkLockedPref "network.http.http3.enable" false) - # Style. - (mkLockedPref "toolkit.legacyUserProfileCustomizations.stylesheets" true) + # Style. + (mkLockedPref "toolkit.legacyUserProfileCustomizations.stylesheets" true) - # Prefer IPv6. - (mkLockedPref "network.dns.preferIPv6" true) - ]; + # Prefer IPv6. + (mkLockedPref "network.dns.preferIPv6" true) + ]; - userChrome = '' - * { - font-family: "${config.module.style.font.serif.name}" !important; - font-size: ${toString config.module.style.font.size.application}pt !important; - } - ''; + userChrome = '' + * { + font-family: "${config.module.style.font.serif.name}" !important; + font-size: ${toString config.module.style.font.size.application}pt !important; + } + ''; - userContent = '' - @-moz-document url(about:home), url(about:newtab), url(about:privatebrowsing), url(about:blank) { - .click-target-container *, .top-sites-list * { - color: #fff !important ; - text-shadow: 2px 2px 2px #222 !important ; - } - body::before { - content: "" ; - z-index: -1 ; - position: fixed ; - top: 0 ; - left: 0 ; - background: #f9a no-repeat url("${config.module.wallpaper.path}?raw=true") center ; - background-color: #222; - background-size: cover ; - /* filter: blur(4px) ; */ - width: 100vw ; - height: 100vh ; - } - /* .logo { background-image: url("{repo}/logo.png?raw=true") !important; } */ - /* .logo { background-image: none !important; } */ - } - ''; + userContent = '' + @-moz-document url(about:home), url(about:newtab), url(about:privatebrowsing), url(about:blank) { + .click-target-container *, .top-sites-list * { + color: #fff !important ; + text-shadow: 2px 2px 2px #222 !important ; + } + body::before { + content: "" ; + z-index: -1 ; + position: fixed ; + top: 0 ; + left: 0 ; + background: #f9a no-repeat url("${config.module.wallpaper.path}?raw=true") center ; + background-color: #222; + background-size: cover ; + /* filter: blur(4px) ; */ + width: 100vw ; + height: 100vh ; + } + /* .logo { background-image: url("{repo}/logo.png?raw=true") !important; } */ + /* .logo { background-image: none !important; } */ + } + ''; - mkExtension = id: install_url: { - ${id} = { - inherit install_url; - installation_mode = "force_installed"; - }; - }; + mkExtension = id: install_url: { + ${id} = { + inherit install_url; + installation_mode = "force_installed"; + }; + }; - mkBookmark = name: url: { inherit name url; }; + mkBookmark = name: url: { inherit name url; }; - mkSearchEngine = Alias: Description: URLTemplate: { - inherit Alias Description URLTemplate; - Method = "GET"; - Name = Description; - }; + mkSearchEngine = Alias: Description: URLTemplate: { + inherit Alias Description URLTemplate; + Method = "GET"; + Name = Description; + }; - mkPref = Name: Value: Status: { - ${Name} = { inherit Value Status; }; - }; - mkLockedPref = Name: Value: mkPref Name Value "locked"; - mkUserPref = Name: Value: mkPref Name Value "user"; -in { - enable = true; - package = pkgsUnstable.firefox-esr; - # languagePacks = [ "en-US" "ru" ]; - profiles.default = { - inherit userChrome userContent; - }; - # REF: https://mozilla.github.io/policy-templates/ - policies = { - AppAutoUpdate = false; - AutofillAddressEnabled = true; - AutofillCreditCardEnabled = false; - BackgroundAppUpdate = false; - CaptivePortal = true; - DisableBuiltinPDFViewer = true; - DisableFirefoxAccounts = true; - DisableFirefoxStudies = true; - DisableFormHistory = true; - DisableMasterPasswordCreation = true; - DisablePasswordReveal = true; - DisablePocket = true; - DisableProfileImport = true; - DisableSafeMode = true; - DisableSetDesktopBackground = true; - DisableTelemetry = true; - DontCheckDefaultBrowser = false; - ExtensionUpdate = true; - HttpsOnlyMode = "enabled"; - ManagedBookmarks = [ { toplevel_name = "Pin"; } ] ++ bookmarks; - NetworkPrediction = false; - NoDefaultBookmarks = true; - OfferToSaveLogins = false; - PasswordManagerEnabled = false; - PostQuantumKeyAgreementEnabled = true; - Preferences = builtins.foldl' (acc: pref: acc // pref) { } prefs; - PromptForDownloadLocation = false; - SearchSuggestEnabled = false; - ShowHomeButton = false; - StartDownloadsInTempDirectory = false; - TranslateEnabled = false; - UseSystemPrintDialog = true; - WebsiteFilter = [ ]; - PopupBlocking = { - Allow = []; - Default = true; - Locked = true; - }; - Homepage = { - Locked = true; - StartPage = "previous-session"; - URL = "https://home.voronind.com"; - }; - DNSOverHTTPS = { - Enabled = false; - # Fallback = false; - Locked = false; - ProviderURL = "https://dns.quad9.net/dns-query"; - }; - Cookies = { - Behavior = "reject-foreign"; - AllowSession = [ - "https://yandex.ru" - ]; - Block = [ - "https://google.com" - ]; - }; - # Containers = {}; # TODO: Use containers? https://addons.mozilla.org/en-US/firefox/addon/multi-account-containers/ - Certificates = { - ImportEnterpriseRoots = false; - Install = [ ]; - }; - EnableTrackingProtection = { - Value = true; - Locked = false; - Cryptomining = true; - Fingerprinting = true; - EmailTracking = true; - Exceptions = [ - "https://example.com" - ]; - }; - EncryptedMediaExtensions = { - Enabled = true; - Locked = true; - }; - ExtensionSettings = { - # Block extension installation outside of this config. - "*" = { - install_sources = [ "*" ]; - installation_mode = "blocked"; - }; - } // builtins.foldl' (acc: ext: acc // ext) { } extensions; - "3rdparty".Extensions = { - "uBlock0@raymondhill.net".adminSettings = { - userSettings = { - uiTheme = "dark"; - cloudStorageEnabled = false; - }; - # NOTE: Check in `Support` -> `Troubleshooting Information` tab. - selectedFilterLists = [ - "user-filters" - "ublock-badware" - "ublock-privacy" - "ublock-quick-fixes" - "ublock-filters" - "easyprivacy" - "ublock-unbreak" - "urlhaus-1" - "easylist" - "plowe-0" - "adguard-cookies" - "fanboy-cookiemonster" - "ublock-cookies-easylist" - "adguard-other-annoyances" - "ublock-cookies-adguard" - "adguard-widgets" - "fanboy-social" - "ublock-annoyances" - "adguard-social" - "fanboy-thirdparty_social" - "easylist-chat" - "easylist-newsletters" - "easylist-notifications" - "easylist-annoyances" - "adguard-mobile-app-banners" - "adguard-popup-overlays" - "RUS-0" - ]; - }; - "addon@darkreader.org" = { - enabled = true; - enabledByDefault = true; - changeBrowserTheme = false; - detectDarkTheme = false; - enableContextMenus = false; - enableForPDF = false; - enableForProtectedPages = false; - fetchNews = false; - previewNewDesign = true; - syncSettings = true; - syncSitesFixes = false; - disabledFor = [ - "cloud.voronind.com" - "git.voronind.com" - "github.com" - "home.voronind.com" - ]; - theme = { - brightness = 100; - contrast = 100; - darkColorScheme = "Default"; - darkSchemeBackgroundColor = "#${config.module.style.color.bg.dark}"; - darkSchemeTextColor = "#${config.module.style.color.fg.light}"; - engine = "dynamicTheme"; # dynamicTheme, cssFilter or svgFilter. - fontFamily = config.module.style.font.sansSerif.name; - grayscale = 0; - immediateModify = true; - lightColorScheme = "Default"; - lightSchemeBackgroundColor = "#${config.module.style.color.bg.light}"; - lightSchemeTextColor = "#${config.module.style.color.fg.dark}"; - mode = 1; - scrollbarColor = "#${config.module.style.color.neutral}"; - selectionColor = "#${config.module.style.color.selection}"; - sepia = 0; - styleSystemControls = true; - stylesheet = ""; - textStroke = 0; - useFont = false; - }; - automation = { - enabled = false; - behavior = "OnOff"; - mode = ""; - }; - time = { - activation = "18:00"; - deactivation = "9:00"; - }; - location = { - latitude = null; - longitude = null; - }; - }; - "{446900e4-71c2-419f-a6a7-df9c091e268b}".environment = { - base = "https://pass.voronind.com"; - }; - # ISSUE: Fork or https://github.com/foxyproxy/browser-extension/issues/132 - # "foxyproxy@eric.h.jung" = { - # mode = "enable"; - # sync = false; - # data = [ - # { - # active = true; - # title = "Local"; - # type = "socks5"; - # hostname = "localhost"; - # port = 1080; - # color = "#ffffff"; - # proxyDNS = true; - # include = [ ]; - # exclude = [ ]; - # } - # { - # active = true; - # title = "Zapret"; - # type = "socks5"; - # hostname = "10.0.0.1"; - # port = 1080; - # color = "#ff0000"; - # proxyDNS = false; - # include = [ ]; - # exclude = [ ]; - # } - # { - # active = true; - # title = "Xray"; - # type = "socks5"; - # hostname = "10.0.0.1"; - # port = 1081; - # color = "#ffff00"; - # proxyDNS = false; - # include = [ ]; - # exclude = [ ]; - # } - # { - # active = true; - # title = "Tor"; - # type = "socks5"; - # hostname = "10.0.0.1"; - # port = 9150; - # color = "#0000ff"; - # proxyDNS = true; - # include = [ "*.onion" ]; - # exclude = [ ]; - # } - # ]; - # }; - }; - # NOTE: `firefox-esr` edition is required to change search engines. - SearchEngines = { - Add = searchEngines; - Default = "SearX"; - PreventInstalls = true; - Remove = [ - "Bing" - "DuckDuckGo" - "Google" - "Wikipedia (en)" - ]; - }; - FirefoxHome = { - Highlights = false; - Locked = true; - Pocket = false; - Search = false; - Snippets = false; - SponsoredTopSites = false; - TopSites = false; - }; - FirefoxSuggest = { - ImproveSuggest = false; - Locked = true; - SponsoredSuggestions = false; - WebSuggestions = false; - }; - PDFjs = { - Enabled = false; - EnablePermissions = false; - }; - Handlers = { - mimeTypes."application/pdf".action = "saveToDisk"; - }; - extensions = { - pdf = { - action = "useHelperApp"; - ask = true; - handlers = [ - { - name = "GNOME Document Viewer"; - path = "${pkgs.evince}/bin/evince"; - } - ]; - }; - }; - Permissions = { - Camera = { - Allow = [ ]; - Block = [ ]; - BlockNewRequests = false; - Locked = false; - }; - Microphome = { - Allow = [ ]; - Block = [ ]; - BlockNewRequests = false; - Locked = false; - }; - Location = { - Allow = [ ]; - Block = [ ]; - BlockNewRequests = true; - Locked = true; - }; - Autoplay = { - Allow = [ ]; - Block = [ ]; - Default = "block-audio-video"; # allow-audio-video | block-audio | block-audio-video - Locked = true; - }; - }; - PictureInPicture = { - Enabled = false; - Locked = false; - }; - SanitizeOnShutdown = { - Cache = true; - Cookies = false; - Downloads = false; - FormData = true; - History = false; - Locked = true; - OfflineApps = true; - Sessions = false; - SiteSettings = false; - }; - UserMessaging = { - ExtensionRecommendations = false; - FeatureRecommendations = false; - Locked = true; - MoreFromMozilla = false; - SkipOnboarding = true; - UrlbarInterventions = false; - WhatsNew = false; - }; - }; + mkPref = Name: Value: Status: { ${Name} = { inherit Value Status; }; }; + mkLockedPref = Name: Value: mkPref Name Value "locked"; + mkUserPref = Name: Value: mkPref Name Value "user"; +in +{ + enable = true; + package = pkgsUnstable.firefox-esr; + # languagePacks = [ "en-US" "ru" ]; + profiles.default = { inherit userChrome userContent; }; + # REF: https://mozilla.github.io/policy-templates/ + policies = { + AppAutoUpdate = false; + AutofillAddressEnabled = true; + AutofillCreditCardEnabled = false; + BackgroundAppUpdate = false; + CaptivePortal = true; + DisableBuiltinPDFViewer = true; + DisableFirefoxAccounts = true; + DisableFirefoxStudies = true; + DisableFormHistory = true; + DisableMasterPasswordCreation = true; + DisablePasswordReveal = true; + DisablePocket = true; + DisableProfileImport = true; + DisableSafeMode = true; + DisableSetDesktopBackground = true; + DisableTelemetry = true; + DontCheckDefaultBrowser = false; + ExtensionUpdate = true; + HttpsOnlyMode = "enabled"; + ManagedBookmarks = [ { toplevel_name = "Pin"; } ] ++ bookmarks; + NetworkPrediction = false; + NoDefaultBookmarks = true; + OfferToSaveLogins = false; + PasswordManagerEnabled = false; + PostQuantumKeyAgreementEnabled = true; + Preferences = builtins.foldl' (acc: pref: acc // pref) { } prefs; + PromptForDownloadLocation = false; + SearchSuggestEnabled = false; + ShowHomeButton = false; + StartDownloadsInTempDirectory = false; + TranslateEnabled = false; + UseSystemPrintDialog = true; + WebsiteFilter = [ ]; + PopupBlocking = { + Allow = [ ]; + Default = true; + Locked = true; + }; + Homepage = { + Locked = true; + StartPage = "previous-session"; + URL = "https://home.voronind.com"; + }; + DNSOverHTTPS = { + Enabled = false; + # Fallback = false; + Locked = false; + ProviderURL = "https://dns.quad9.net/dns-query"; + }; + Cookies = { + Behavior = "reject-foreign"; + AllowSession = [ "https://yandex.ru" ]; + Block = [ "https://google.com" ]; + }; + # Containers = {}; # TODO: Use containers? https://addons.mozilla.org/en-US/firefox/addon/multi-account-containers/ + Certificates = { + ImportEnterpriseRoots = false; + Install = [ ]; + }; + EnableTrackingProtection = { + Value = true; + Locked = false; + Cryptomining = true; + Fingerprinting = true; + EmailTracking = true; + Exceptions = [ "https://example.com" ]; + }; + EncryptedMediaExtensions = { + Enabled = true; + Locked = true; + }; + ExtensionSettings = { + # Block extension installation outside of this config. + "*" = { + install_sources = [ "*" ]; + installation_mode = "blocked"; + }; + } // builtins.foldl' (acc: ext: acc // ext) { } extensions; + "3rdparty".Extensions = { + "uBlock0@raymondhill.net".adminSettings = { + userSettings = { + uiTheme = "dark"; + cloudStorageEnabled = false; + }; + # NOTE: Check in `Support` -> `Troubleshooting Information` tab. + selectedFilterLists = [ + "user-filters" + "ublock-badware" + "ublock-privacy" + "ublock-quick-fixes" + "ublock-filters" + "easyprivacy" + "ublock-unbreak" + "urlhaus-1" + "easylist" + "plowe-0" + "adguard-cookies" + "fanboy-cookiemonster" + "ublock-cookies-easylist" + "adguard-other-annoyances" + "ublock-cookies-adguard" + "adguard-widgets" + "fanboy-social" + "ublock-annoyances" + "adguard-social" + "fanboy-thirdparty_social" + "easylist-chat" + "easylist-newsletters" + "easylist-notifications" + "easylist-annoyances" + "adguard-mobile-app-banners" + "adguard-popup-overlays" + "RUS-0" + ]; + }; + "addon@darkreader.org" = { + enabled = true; + enabledByDefault = true; + changeBrowserTheme = false; + detectDarkTheme = false; + enableContextMenus = false; + enableForPDF = false; + enableForProtectedPages = false; + fetchNews = false; + previewNewDesign = true; + syncSettings = true; + syncSitesFixes = false; + disabledFor = [ + "cloud.voronind.com" + "git.voronind.com" + "github.com" + "home.voronind.com" + ]; + theme = { + brightness = 100; + contrast = 100; + darkColorScheme = "Default"; + darkSchemeBackgroundColor = "#${config.module.style.color.bg.dark}"; + darkSchemeTextColor = "#${config.module.style.color.fg.light}"; + engine = "dynamicTheme"; # dynamicTheme, cssFilter or svgFilter. + fontFamily = config.module.style.font.sansSerif.name; + grayscale = 0; + immediateModify = true; + lightColorScheme = "Default"; + lightSchemeBackgroundColor = "#${config.module.style.color.bg.light}"; + lightSchemeTextColor = "#${config.module.style.color.fg.dark}"; + mode = 1; + scrollbarColor = "#${config.module.style.color.neutral}"; + selectionColor = "#${config.module.style.color.selection}"; + sepia = 0; + styleSystemControls = true; + stylesheet = ""; + textStroke = 0; + useFont = false; + }; + automation = { + enabled = false; + behavior = "OnOff"; + mode = ""; + }; + time = { + activation = "18:00"; + deactivation = "9:00"; + }; + location = { + latitude = null; + longitude = null; + }; + }; + "{446900e4-71c2-419f-a6a7-df9c091e268b}".environment = { + base = "https://pass.voronind.com"; + }; + # ISSUE: Fork or https://github.com/foxyproxy/browser-extension/issues/132 + # "foxyproxy@eric.h.jung" = { + # mode = "enable"; + # sync = false; + # data = [ + # { + # active = true; + # title = "Local"; + # type = "socks5"; + # hostname = "localhost"; + # port = 1080; + # color = "#ffffff"; + # proxyDNS = true; + # include = [ ]; + # exclude = [ ]; + # } + # { + # active = true; + # title = "Zapret"; + # type = "socks5"; + # hostname = "10.0.0.1"; + # port = 1080; + # color = "#ff0000"; + # proxyDNS = false; + # include = [ ]; + # exclude = [ ]; + # } + # { + # active = true; + # title = "Xray"; + # type = "socks5"; + # hostname = "10.0.0.1"; + # port = 1081; + # color = "#ffff00"; + # proxyDNS = false; + # include = [ ]; + # exclude = [ ]; + # } + # { + # active = true; + # title = "Tor"; + # type = "socks5"; + # hostname = "10.0.0.1"; + # port = 9150; + # color = "#0000ff"; + # proxyDNS = true; + # include = [ "*.onion" ]; + # exclude = [ ]; + # } + # ]; + # }; + }; + # NOTE: `firefox-esr` edition is required to change search engines. + SearchEngines = { + Add = searchEngines; + Default = "SearX"; + PreventInstalls = true; + Remove = [ + "Bing" + "DuckDuckGo" + "Google" + "Wikipedia (en)" + ]; + }; + FirefoxHome = { + Highlights = false; + Locked = true; + Pocket = false; + Search = false; + Snippets = false; + SponsoredTopSites = false; + TopSites = false; + }; + FirefoxSuggest = { + ImproveSuggest = false; + Locked = true; + SponsoredSuggestions = false; + WebSuggestions = false; + }; + PDFjs = { + Enabled = false; + EnablePermissions = false; + }; + Handlers = { + mimeTypes."application/pdf".action = "saveToDisk"; + }; + extensions = { + pdf = { + action = "useHelperApp"; + ask = true; + handlers = [ + { + name = "GNOME Document Viewer"; + path = "${pkgs.evince}/bin/evince"; + } + ]; + }; + }; + Permissions = { + Camera = { + Allow = [ ]; + Block = [ ]; + BlockNewRequests = false; + Locked = false; + }; + Microphome = { + Allow = [ ]; + Block = [ ]; + BlockNewRequests = false; + Locked = false; + }; + Location = { + Allow = [ ]; + Block = [ ]; + BlockNewRequests = true; + Locked = true; + }; + Autoplay = { + Allow = [ ]; + Block = [ ]; + Default = "block-audio-video"; # allow-audio-video | block-audio | block-audio-video + Locked = true; + }; + }; + PictureInPicture = { + Enabled = false; + Locked = false; + }; + SanitizeOnShutdown = { + Cache = true; + Cookies = false; + Downloads = false; + FormData = true; + History = false; + Locked = true; + OfflineApps = true; + Sessions = false; + SiteSettings = false; + }; + UserMessaging = { + ExtensionRecommendations = false; + FeatureRecommendations = false; + Locked = true; + MoreFromMozilla = false; + SkipOnboarding = true; + UrlbarInterventions = false; + WhatsNew = false; + }; + }; } diff --git a/home/xdg/default.nix b/home/xdg/default.nix index 4bc542b0..68f4d080 100644 --- a/home/xdg/default.nix +++ b/home/xdg/default.nix @@ -1,18 +1,19 @@ -{ homeDirectory, ... }: { - userDirs = { - enable = true; - createDirectories = true; - desktop = "${homeDirectory}/"; - documents = "${homeDirectory}/document/"; - download = "${homeDirectory}/download/"; - music = "${homeDirectory}/music/"; - pictures = "${homeDirectory}/picture/"; - publicShare = "${homeDirectory}/share/"; - templates = "${homeDirectory}/.template/"; - videos = "${homeDirectory}/video/"; - extraConfig = { - XDG_CONFIG_HOME = "${homeDirectory}/.config"; - XDG_TMP_DIR = "${homeDirectory}/tmp/"; - }; - }; +{ homeDirectory, ... }: +{ + userDirs = { + enable = true; + createDirectories = true; + desktop = "${homeDirectory}/"; + documents = "${homeDirectory}/document/"; + download = "${homeDirectory}/download/"; + music = "${homeDirectory}/music/"; + pictures = "${homeDirectory}/picture/"; + publicShare = "${homeDirectory}/share/"; + templates = "${homeDirectory}/.template/"; + videos = "${homeDirectory}/video/"; + extraConfig = { + XDG_CONFIG_HOME = "${homeDirectory}/.config"; + XDG_TMP_DIR = "${homeDirectory}/tmp/"; + }; + }; } diff --git a/host/x86_64-linux/dasha/Filesystem.nix b/host/x86_64-linux/dasha/Filesystem.nix index 6932ca65..00a7449a 100644 --- a/host/x86_64-linux/dasha/Filesystem.nix +++ b/host/x86_64-linux/dasha/Filesystem.nix @@ -1,21 +1,22 @@ -{ ... }: { - fileSystems = { - "/storage/hot" = { - device = "/dev/storage/hot"; - fsType = "ext4"; - options = [ - "noatime" - "nofail" - ]; - }; +{ ... }: +{ + fileSystems = { + "/storage/hot" = { + device = "/dev/storage/hot"; + fsType = "ext4"; + options = [ + "noatime" + "nofail" + ]; + }; - "/storage/cold" = { - device = "/dev/storage/cold"; - fsType = "ext4"; - options = [ - "noatime" - "nofail" - ]; - }; - }; + "/storage/cold" = { + device = "/dev/storage/cold"; + fsType = "ext4"; + options = [ + "noatime" + "nofail" + ]; + }; + }; } diff --git a/host/x86_64-linux/dasha/Network.nix b/host/x86_64-linux/dasha/Network.nix index fd04c4c8..b2961996 100644 --- a/host/x86_64-linux/dasha/Network.nix +++ b/host/x86_64-linux/dasha/Network.nix @@ -1,9 +1,10 @@ -{ ... }: { - networking = { - firewall.extraCommands = '' - # Local access. - iptables -I INPUT -j ACCEPT -s 10.0.0.0/8 - ip6tables -I INPUT -j ACCEPT -s fd09:8d46:0b26::/48 - ''; - }; +{ ... }: +{ + networking = { + firewall.extraCommands = '' + # Local access. + iptables -I INPUT -j ACCEPT -s 10.0.0.0/8 + ip6tables -I INPUT -j ACCEPT -s fd09:8d46:0b26::/48 + ''; + }; } diff --git a/host/x86_64-linux/dasha/default.nix b/host/x86_64-linux/dasha/default.nix index e0f72a0a..78580329 100644 --- a/host/x86_64-linux/dasha/default.nix +++ b/host/x86_64-linux/dasha/default.nix @@ -1,39 +1,40 @@ -{ ... }: { - home.nixos.enable = true; - user = { - dasha = true; - root = true; - }; +{ ... }: +{ + home.nixos.enable = true; + user = { + dasha = true; + root = true; + }; - module = { - amd.gpu.enable = true; - builder.client.enable = true; - display.primary = "DP-1"; - package.extra = true; - print.enable = true; - purpose = { - creative = true; - desktop = true; - disown = true; - gaming = true; - work = true; - }; - syncthing = { - enable = true; - user = "dasha"; - }; - sway.extraConfig = [ - "output DP-1 pos 0 0" - "output DP-2 pos 1920 0" - "workspace 1 output DP-1" - ]; - hwmon = { - file = "temp1_input"; - path = "/sys/devices/platform/coretemp.0/hwmon"; - }; - intel.cpu = { - enable = true; - powersave = true; - }; - }; + module = { + amd.gpu.enable = true; + builder.client.enable = true; + display.primary = "DP-1"; + package.extra = true; + print.enable = true; + purpose = { + creative = true; + desktop = true; + disown = true; + gaming = true; + work = true; + }; + syncthing = { + enable = true; + user = "dasha"; + }; + sway.extraConfig = [ + "output DP-1 pos 0 0" + "output DP-2 pos 1920 0" + "workspace 1 output DP-1" + ]; + hwmon = { + file = "temp1_input"; + path = "/sys/devices/platform/coretemp.0/hwmon"; + }; + intel.cpu = { + enable = true; + powersave = true; + }; + }; } diff --git a/host/x86_64-linux/desktop/Filesystem.nix b/host/x86_64-linux/desktop/Filesystem.nix index a29db5f4..39d9c5a6 100644 --- a/host/x86_64-linux/desktop/Filesystem.nix +++ b/host/x86_64-linux/desktop/Filesystem.nix @@ -1,32 +1,33 @@ -{ ... }: { - fileSystems = { - "/storage/hot" = { - device = "/dev/storage/hot"; - fsType = "ext4"; - options = [ - "noatime" - "nofail" - ]; - }; +{ ... }: +{ + fileSystems = { + "/storage/hot" = { + device = "/dev/storage/hot"; + fsType = "ext4"; + options = [ + "noatime" + "nofail" + ]; + }; - "/storage/cold_1" = { - device = "/dev/storage/cold_1"; - fsType = "ext4"; - options = [ - "noatime" - "noauto" - "nofail" - ]; - }; + "/storage/cold_1" = { + device = "/dev/storage/cold_1"; + fsType = "ext4"; + options = [ + "noatime" + "noauto" + "nofail" + ]; + }; - "/storage/cold_2" = { - device = "/dev/storage/cold_2"; - fsType = "ext4"; - options = [ - "noatime" - "noauto" - "nofail" - ]; - }; - }; + "/storage/cold_2" = { + device = "/dev/storage/cold_2"; + fsType = "ext4"; + options = [ + "noatime" + "noauto" + "nofail" + ]; + }; + }; } diff --git a/host/x86_64-linux/desktop/Network.nix b/host/x86_64-linux/desktop/Network.nix index fd04c4c8..b2961996 100644 --- a/host/x86_64-linux/desktop/Network.nix +++ b/host/x86_64-linux/desktop/Network.nix @@ -1,9 +1,10 @@ -{ ... }: { - networking = { - firewall.extraCommands = '' - # Local access. - iptables -I INPUT -j ACCEPT -s 10.0.0.0/8 - ip6tables -I INPUT -j ACCEPT -s fd09:8d46:0b26::/48 - ''; - }; +{ ... }: +{ + networking = { + firewall.extraCommands = '' + # Local access. + iptables -I INPUT -j ACCEPT -s 10.0.0.0/8 + ip6tables -I INPUT -j ACCEPT -s fd09:8d46:0b26::/48 + ''; + }; } diff --git a/host/x86_64-linux/desktop/default.nix b/host/x86_64-linux/desktop/default.nix index 64a00483..960209e3 100644 --- a/host/x86_64-linux/desktop/default.nix +++ b/host/x86_64-linux/desktop/default.nix @@ -1,40 +1,41 @@ -{ ... }: { - home.nixos.enable = true; - user = { - root = true; - voronind = true; - }; +{ ... }: +{ + home.nixos.enable = true; + user = { + root = true; + voronind = true; + }; - module = { - builder.client.enable = true; - package.extra = true; - print.enable = true; - syncthing.enable = true; - purpose = { - desktop = true; - gaming = true; - work = true; - }; - display = { - primary = "HDMI-A-1"; - rotate.HDMI-A-1 = 180; - }; - amd = { - compute.enable = true; - gpu.enable = true; - cpu = { - enable = true; - powersave = true; - }; - }; - sway.extraConfig = [ - "output DP-3 pos 0 1080" - "output HDMI-A-1 mode 1920x1080@74.986Hz pos 780 0" - "workspace 1 output HDMI-A-1" - ]; - hwmon = { - file = "temp1_input"; - path = "/sys/devices/pci0000:00/0000:00:18.3/hwmon"; - }; - }; + module = { + builder.client.enable = true; + package.extra = true; + print.enable = true; + syncthing.enable = true; + purpose = { + desktop = true; + gaming = true; + work = true; + }; + display = { + primary = "HDMI-A-1"; + rotate.HDMI-A-1 = 180; + }; + amd = { + compute.enable = true; + gpu.enable = true; + cpu = { + enable = true; + powersave = true; + }; + }; + sway.extraConfig = [ + "output DP-3 pos 0 1080" + "output HDMI-A-1 mode 1920x1080@74.986Hz pos 780 0" + "workspace 1 output HDMI-A-1" + ]; + hwmon = { + file = "temp1_input"; + path = "/sys/devices/pci0000:00/0000:00:18.3/hwmon"; + }; + }; } diff --git a/host/x86_64-linux/home/Backup.nix b/host/x86_64-linux/home/Backup.nix index e2b3675c..2c84f813 100644 --- a/host/x86_64-linux/home/Backup.nix +++ b/host/x86_64-linux/home/Backup.nix @@ -1,112 +1,110 @@ { - __findFile, - pkgs, - util, - ... -} @args: let - bash = import args; - script = pkgs.writeText "backupScript" (util.trimTabs '' - source ${bash.modulesFile} + __findFile, + pkgs, + util, + ... +}@args: +let + bash = import args; + script = pkgs.writeText "backupScript" '' + source ${bash.modulesFile} - function report() { - echo "''${*}" - notify "''${*}" - } + function report() { + echo "''${*}" + notify "''${*}" + } - # Define constants. - path_src="/storage/hot" - path_mount="/storage/cold_1" - path_backup="''${path_mount}/backup" - path_data="''${path_backup}/home" - path_media="/storage/cold_1 /storage/cold_2" + # Define constants. + path_src="/storage/hot" + path_mount="/storage/cold_1" + path_backup="''${path_mount}/backup" + path_data="''${path_backup}/home" + path_media="/storage/cold_1 /storage/cold_2" - # Check if backup drive is mounted. - if [ ! -f "''${path_mount}"/.mount ]; then - report "Backup: ''${path_mount} not mounted!" - exit 1 - fi + # Check if backup drive is mounted. + if [ ! -f "''${path_mount}"/.mount ]; then + report "Backup: ''${path_mount} not mounted!" + exit 1 + fi - # Check if hot storage is mounted. - if [ ! -f "''${path_src}"/.mount ]; then - report "Backup: ''${path_src} not mounted!" - exit 1 - fi + # Check if hot storage is mounted. + if [ ! -f "''${path_src}"/.mount ]; then + report "Backup: ''${path_src} not mounted!" + exit 1 + fi - # Cd to src storage. - cd "''${path_src}" + # Cd to src storage. + cd "''${path_src}" - # Save media list. - find ''${path_media} -type d > ''${path_backup}/cold/ColdMedia.txt || report "Backup: Failed to save media list!" - cd ''${path_backup}/cold/ - archive ColdMedia.txt && rm ColdMedia.txt || report "Backup: Failed to archive media list!" - cd - + # Save media list. + find ''${path_media} -type d > ''${path_backup}/cold/ColdMedia.txt || report "Backup: Failed to save media list!" + cd ''${path_backup}/cold/ + archive ColdMedia.txt && rm ColdMedia.txt || report "Backup: Failed to archive media list!" + cd - - # Backup data. - data=$(archive data/) - bupsize=$(tdu ''${data} | awk '{print $1}') - mv ''${data} ''${path_data}/ || report "Backup: Failed to save data!" + # Backup data. + data=$(archive data/) + bupsize=$(tdu ''${data} | awk '{print $1}') + mv ''${data} ''${path_data}/ || report "Backup: Failed to save data!" - # Backup some media. - cd ''${path_src} - paper=$(archive paper/) - mv ''${paper} ''${path_backup}/paper/ || report "Backup: Failed to save paper!" - cd - + # Backup some media. + cd ''${path_src} + paper=$(archive paper/) + mv ''${paper} ''${path_backup}/paper/ || report "Backup: Failed to save paper!" + cd - - rcp_merge ''${path_src}/sync/save/ ''${path_backup}/save/tmp/ || report "Backup: Failed to save game saves!" - rcp_merge ''${path_src}/sync/photo/ ''${path_backup}/photo/tmp/ || report "Backup: Failed to save photos!" + rcp_merge ''${path_src}/sync/save/ ''${path_backup}/save/tmp/ || report "Backup: Failed to save game saves!" + rcp_merge ''${path_src}/sync/photo/ ''${path_backup}/photo/tmp/ || report "Backup: Failed to save photos!" - # Prune media copies. - cd ''${path_backup}/paper/ - archive_prune Paper 7 - cd - + # Prune media copies. + cd ''${path_backup}/paper/ + archive_prune Paper 7 + cd - - cd ''${path_backup}/cold/ - archive_prune ColdMediaTxt 30 - cd - + cd ''${path_backup}/cold/ + archive_prune ColdMediaTxt 30 + cd - - # Prune old data copies. - cd ''${path_data} - archive_prune Data 7 - cd - + # Prune old data copies. + cd ''${path_data} + archive_prune Data 7 + cd - - # Sync writes. - sync + # Sync writes. + sync - # Notify completion & size. - notify_silent "Backup: Complete ''${bupsize}." - echo "Backup: Complete ''${bupsize}." - ''); -in { - systemd.services.backup = util.mkStaticSystemdService { - enable = true; - description = "Home system backup."; - serviceConfig = { - Type = "oneshot"; - }; - path = with pkgs; [ - bashInteractive - curl - gawk - gnutar - mount - procps - pv - rsync - xz - ]; - script = '' - ${pkgs.bashInteractive}/bin/bash ${script} - ''; - }; + # Notify completion & size. + notify_silent "Backup: Complete ''${bupsize}." + echo "Backup: Complete ''${bupsize}." + ''; +in +{ + systemd.services.backup = util.mkStaticSystemdService { + enable = true; + description = "Home system backup."; + serviceConfig.Type = "oneshot"; + path = with pkgs; [ + bashInteractive + curl + gawk + gnutar + mount + procps + pv + rsync + xz + ]; + script = '' + ${pkgs.bashInteractive}/bin/bash ${script} + ''; + }; - systemd.timers.backup = { - timerConfig = { - OnCalendar = "*-*-* 06:00:00"; - Persistent = true; - Unit = "backup.service"; - }; - wantedBy = [ - "timers.target" - ]; - }; + systemd.timers.backup = { + wantedBy = [ "timers.target" ]; + timerConfig = { + OnCalendar = "*-*-* 06:00:00"; + Persistent = true; + Unit = "backup.service"; + }; + }; } diff --git a/host/x86_64-linux/home/Bind.nix b/host/x86_64-linux/home/Bind.nix index de192a0d..3c9fe999 100644 --- a/host/x86_64-linux/home/Bind.nix +++ b/host/x86_64-linux/home/Bind.nix @@ -1,41 +1,44 @@ +{ lib, ... }: +let + storage = "/storage/hot/data"; + + binds = [ + (mkBind "change" "/var/lib/changedetection-io") + (mkBind "cups" "/var/lib/cups") + (mkBind "deluge" "/var/lib/deluge/.config/deluge") + (mkBind "dkim" "/var/dkim") + (mkBind "dovecot_index" "/var/lib/dovecot/indices") + (mkBind "forgejo" "/var/lib/forgejo") + (mkBind "grocy" "/var/lib/grocy") + (mkBind "hass" "/var/lib/hass") + (mkBind "jellyfin" "/var/lib/jellyfin") + (mkBind "jellyfin_cache" "/var/cache/jellyfin") + (mkBind "kavita" "/var/lib/kavita") + (mkBind "letsencrypt" "/etc/letsencrypt") + (mkBind "murmur" "/var/lib/murmur") + (mkBind "nextcloud" "/var/lib/nextcloud") + (mkBind "ovpn" "/var/lib/ovpn") + (mkBind "paperless" "/var/lib/paperless") + (mkBind "postgres" "/var/lib/postgresql") + (mkBind "rabbitmq" "/var/lib/rabbitmq") + (mkBind "sieve" "/var/sieve") + (mkBind "terraria" "/var/lib/terraria") + (mkBind "uptime_kuma" "/var/lib/uptime-kuma") + (mkBind "vaultwarden" "/var/lib/vaultwarden") + (mkBind "vmail" "/var/vmail") + ]; + + mkBind = name: path: { + ${path} = { + device = "${storage}/${name}"; + options = [ + "bind" + "nofail" + "X-mount.mkdir=1777" + ]; + }; + }; +in { - lib, - ... -}: let - storage = "/storage/hot/data"; - - binds = [ - (mkBind "change" "/var/lib/changedetection-io") - (mkBind "cups" "/var/lib/cups") - (mkBind "deluge" "/var/lib/deluge/.config/deluge") - (mkBind "dkim" "/var/dkim") - (mkBind "dovecot_index" "/var/lib/dovecot/indices") - (mkBind "forgejo" "/var/lib/forgejo") - (mkBind "grocy" "/var/lib/grocy") - (mkBind "hass" "/var/lib/hass") - (mkBind "jellyfin" "/var/lib/jellyfin") - (mkBind "jellyfin_cache" "/var/cache/jellyfin") - (mkBind "kavita" "/var/lib/kavita") - (mkBind "letsencrypt" "/etc/letsencrypt") - (mkBind "murmur" "/var/lib/murmur") - (mkBind "nextcloud" "/var/lib/nextcloud") - (mkBind "ovpn" "/var/lib/ovpn") - (mkBind "paperless" "/var/lib/paperless") - (mkBind "postgres" "/var/lib/postgresql") - (mkBind "rabbitmq" "/var/lib/rabbitmq") - (mkBind "sieve" "/var/sieve") - (mkBind "terraria" "/var/lib/terraria") - (mkBind "uptime_kuma" "/var/lib/uptime-kuma") - (mkBind "vaultwarden" "/var/lib/vaultwarden") - (mkBind "vmail" "/var/vmail") - ]; - - mkBind = name: path: { - ${path} = { - device = "${storage}/${name}"; - options = [ "bind" "nofail" "X-mount.mkdir=1777" ]; - }; - }; -in { - fileSystems = lib.foldl' (acc: bind: acc // bind) { } binds; + fileSystems = lib.foldl' (acc: bind: acc // bind) { } binds; } diff --git a/host/x86_64-linux/home/Blocky.nix b/host/x86_64-linux/home/Blocky.nix index 562a71c9..af5898e2 100644 --- a/host/x86_64-linux/home/Blocky.nix +++ b/host/x86_64-linux/home/Blocky.nix @@ -1,97 +1,98 @@ -{ ... }: { - services.blocky = { - enable = true; - # REF: https://0xerr0r.github.io/blocky/main/configuration/ - settings = { - bootstrapDns = "tcp+udp:1.1.1.1"; - ports.dns = 53; - # connectIPVersion = "v4"; - # httpPort = "80"; - upstreams.groups = { - default = [ - "https://dns.quad9.net/dns-query" - ]; - }; - caching = { - maxItemsCount = 100000; - maxTime = "30m"; - minTime = "5m"; - prefetchExpires = "2h"; - prefetchMaxItemsCount = 100000; - prefetchThreshold = 5; - prefetching = true; - }; - blocking = { - blockTTL = "1m"; - blockType = "zeroIP"; - loading = { - refreshPeriod = "24h"; - strategy = "blocking"; - downloads = { - attempts = 3; - cooldown = "10s"; - timeout = "5m"; - }; - }; - # SRC: https://oisd.nl - # SRC: https://v.firebog.net - denylists = { - suspicious = [ - "https://raw.githubusercontent.com/PolishFiltersTeam/KADhosts/master/KADhosts.txt" - "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" # https://github.com/StevenBlack/hosts - "https://v.firebog.net/hosts/static/w3kbl.txt" - ]; - ads = [ - "https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext" - "https://raw.githubusercontent.com/bigdargon/hostsVN/master/hosts" - "https://v.firebog.net/hosts/AdguardDNS.txt" - "https://v.firebog.net/hosts/Admiral.txt" - "https://v.firebog.net/hosts/Easylist.txt" - ]; - tracking = [ - "https://hostfiles.frogeye.fr/firstparty-trackers-hosts.txt" - "https://v.firebog.net/hosts/Easyprivacy.txt" - "https://v.firebog.net/hosts/Prigent-Ads.txt" - ]; - malicious = [ - "https://gitlab.com/quidsup/notrack-blocklists/raw/master/notrack-malware.txt" - "https://osint.digitalside.it/Threat-Intel/lists/latestdomains.txt" - "https://phishing.army/download/phishing_army_blocklist_extended.txt" - "https://raw.githubusercontent.com/AssoEchap/stalkerware-indicators/master/generated/hosts" - "https://raw.githubusercontent.com/Spam404/lists/master/main-blacklist.txt" - "https://urlhaus.abuse.ch/downloads/hostfile/" - "https://v.firebog.net/hosts/Prigent-Crypto.txt" - "https://v.firebog.net/hosts/Prigent-Malware.txt" - ]; - other = [ - "https://big.oisd.nl/domainswild" - "https://zerodot1.gitlab.io/CoinBlockerLists/hosts_browser" - ]; - }; - # allowlists = { - # other = [ - # "/.*.vk.com/" - # ]; - # }; - clientGroupsBlock = { - default = [ - "ads" - "malicious" - "other" - "suspicious" - "tracking" - ]; - }; - }; - customDNS.mapping = let - block = host: { ${host} = "0.0.0.0"; }; - in { - "voronind.com" = "10.0.0.1,fd09:8d46:b26:0:8079:82ff:fe1a:916a"; - } - // block "gosuslugi.ru" - // block "rutube.ru" - # // block "vk.com" - ; - }; - }; +{ ... }: +{ + services.blocky = { + enable = true; + # REF: https://0xerr0r.github.io/blocky/main/configuration/ + settings = { + bootstrapDns = "tcp+udp:1.1.1.1"; + ports.dns = 53; + # connectIPVersion = "v4"; + # httpPort = "80"; + upstreams.groups = { + default = [ "https://dns.quad9.net/dns-query" ]; + }; + caching = { + maxItemsCount = 100000; + maxTime = "30m"; + minTime = "5m"; + prefetchExpires = "2h"; + prefetchMaxItemsCount = 100000; + prefetchThreshold = 5; + prefetching = true; + }; + blocking = { + blockTTL = "1m"; + blockType = "zeroIP"; + loading = { + refreshPeriod = "24h"; + strategy = "blocking"; + downloads = { + attempts = 3; + cooldown = "10s"; + timeout = "5m"; + }; + }; + # SRC: https://oisd.nl + # SRC: https://v.firebog.net + denylists = { + suspicious = [ + "https://raw.githubusercontent.com/PolishFiltersTeam/KADhosts/master/KADhosts.txt" + "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" # https://github.com/StevenBlack/hosts + "https://v.firebog.net/hosts/static/w3kbl.txt" + ]; + ads = [ + "https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext" + "https://raw.githubusercontent.com/bigdargon/hostsVN/master/hosts" + "https://v.firebog.net/hosts/AdguardDNS.txt" + "https://v.firebog.net/hosts/Admiral.txt" + "https://v.firebog.net/hosts/Easylist.txt" + ]; + tracking = [ + "https://hostfiles.frogeye.fr/firstparty-trackers-hosts.txt" + "https://v.firebog.net/hosts/Easyprivacy.txt" + "https://v.firebog.net/hosts/Prigent-Ads.txt" + ]; + malicious = [ + "https://gitlab.com/quidsup/notrack-blocklists/raw/master/notrack-malware.txt" + "https://osint.digitalside.it/Threat-Intel/lists/latestdomains.txt" + "https://phishing.army/download/phishing_army_blocklist_extended.txt" + "https://raw.githubusercontent.com/AssoEchap/stalkerware-indicators/master/generated/hosts" + "https://raw.githubusercontent.com/Spam404/lists/master/main-blacklist.txt" + "https://urlhaus.abuse.ch/downloads/hostfile/" + "https://v.firebog.net/hosts/Prigent-Crypto.txt" + "https://v.firebog.net/hosts/Prigent-Malware.txt" + ]; + other = [ + "https://big.oisd.nl/domainswild" + "https://zerodot1.gitlab.io/CoinBlockerLists/hosts_browser" + ]; + }; + # allowlists = { + # other = [ + # "/.*.vk.com/" + # ]; + # }; + clientGroupsBlock = { + default = [ + "ads" + "malicious" + "other" + "suspicious" + "tracking" + ]; + }; + }; + customDNS.mapping = + let + block = host: { ${host} = "0.0.0.0"; }; + in + { + "voronind.com" = "10.0.0.1,fd09:8d46:b26:0:8079:82ff:fe1a:916a"; + } + // block "gosuslugi.ru" + // block "rutube.ru" + # // block "vk.com" + ; + }; + }; } diff --git a/host/x86_64-linux/home/Change.nix b/host/x86_64-linux/home/Change.nix index 7dd11e4e..48f38688 100644 --- a/host/x86_64-linux/home/Change.nix +++ b/host/x86_64-linux/home/Change.nix @@ -1,9 +1,10 @@ -{ ... }: { - services.changedetection-io = { - enable = true; - baseURL = "change.voronind.com"; - behindProxy = true; - listenAddress = "0.0.0.0"; - port = 5001; - }; +{ ... }: +{ + services.changedetection-io = { + enable = true; + baseURL = "change.voronind.com"; + behindProxy = true; + listenAddress = "0.0.0.0"; + port = 5001; + }; } diff --git a/host/x86_64-linux/home/Cups.nix b/host/x86_64-linux/home/Cups.nix index 07393e73..c869e563 100644 --- a/host/x86_64-linux/home/Cups.nix +++ b/host/x86_64-linux/home/Cups.nix @@ -1,22 +1,20 @@ # NOTE: Login to contaier, run passwd and use that root/pw combo for administration. `AllowFrom = all` doesn't seem to work. # ipp://10.0.0.10 # Pantum M6500W-Series +{ __findFile, pkgs, ... }@args: +let + package = pkgs.callPackage args; +in { - __findFile, - pkgs, - ... -} @args: let - package = pkgs.callPackage args; -in { - services.printing = { - enable = true; - allowFrom = [ "all" ]; - browsing = true; - defaultShared = true; - drivers = [ package ]; - listenAddresses = [ "0.0.0.0:631" ]; - startWhenNeeded = true; - stateless = false; - webInterface = true; - }; + services.printing = { + enable = true; + allowFrom = [ "all" ]; + browsing = true; + defaultShared = true; + drivers = [ package ]; + listenAddresses = [ "0.0.0.0:631" ]; + startWhenNeeded = true; + stateless = false; + webInterface = true; + }; } diff --git a/host/x86_64-linux/home/Ddns.nix b/host/x86_64-linux/home/Ddns.nix index c97f31e3..4834212d 100644 --- a/host/x86_64-linux/home/Ddns.nix +++ b/host/x86_64-linux/home/Ddns.nix @@ -1,24 +1,26 @@ -{ ... }: { - services.cloudflare-dyndns = { - enable = true; - apiTokenFile = "/storage/hot/data/CfToken"; - deleteMissing = false; - ipv4 = true; - ipv6 = true; - proxied = false; - domains = let - domain = "voronind.com"; - in [ - domain - ] ++ map (sub: "${sub}.${domain}") [ - "chat" - "cloud" - "git" - "mail" - "office" - "paste" - "play" - "vpn" - ]; - }; +{ ... }: +{ + services.cloudflare-dyndns = { + enable = true; + apiTokenFile = "/storage/hot/data/CfToken"; + deleteMissing = false; + ipv4 = true; + ipv6 = true; + proxied = false; + domains = + let + domain = "voronind.com"; + in + [ domain ] + ++ map (sub: "${sub}.${domain}") [ + "chat" + "cloud" + "git" + "mail" + "office" + "paste" + "play" + "vpn" + ]; + }; } diff --git a/host/x86_64-linux/home/Deluge.nix b/host/x86_64-linux/home/Deluge.nix index 29568541..c36529b6 100644 --- a/host/x86_64-linux/home/Deluge.nix +++ b/host/x86_64-linux/home/Deluge.nix @@ -1,14 +1,12 @@ +{ lib, ... }: { - lib, - ... -}: { - services.deluge = { - enable = true; - web.enable = true; - }; - systemd.services.deluged.serviceConfig = { - MemoryMax = "4G"; - Restart = lib.mkForce "always"; - RuntimeMaxSec = "3h"; - }; + services.deluge = { + enable = true; + web.enable = true; + }; + systemd.services.deluged.serviceConfig = { + MemoryMax = "4G"; + Restart = lib.mkForce "always"; + RuntimeMaxSec = "3h"; + }; } diff --git a/host/x86_64-linux/home/Filesystem.nix b/host/x86_64-linux/home/Filesystem.nix index 1735bef1..d516ae35 100644 --- a/host/x86_64-linux/home/Filesystem.nix +++ b/host/x86_64-linux/home/Filesystem.nix @@ -1,36 +1,37 @@ -{ ... }: { - fileSystems = { - "/storage/cold_1" = { - device = "/dev/storage/cold_1"; - fsType = "ext4"; - options = [ - "noatime" - "nofail" - ]; - }; +{ ... }: +{ + fileSystems = { + "/storage/cold_1" = { + device = "/dev/storage/cold_1"; + fsType = "ext4"; + options = [ + "noatime" + "nofail" + ]; + }; - "/storage/cold_2" = { - device = "/dev/storage/cold_2"; - fsType = "ext4"; - options = [ - "noatime" - "nofail" - ]; - }; + "/storage/cold_2" = { + device = "/dev/storage/cold_2"; + fsType = "ext4"; + options = [ + "noatime" + "nofail" + ]; + }; - "/storage/hot" = { - device = "/dev/storage/hot"; - fsType = "ext4"; - options = [ - "noatime" - "nofail" - ]; - }; - }; + "/storage/hot" = { + device = "/dev/storage/hot"; + fsType = "ext4"; + options = [ + "noatime" + "nofail" + ]; + }; + }; - # swapDevices = [{ - # device = "/storage/hot/.swapfile"; - # size = 128 * 1024; - # options = [ "nofail" ]; - # }]; + # swapDevices = [{ + # device = "/storage/hot/.swapfile"; + # size = 128 * 1024; + # options = [ "nofail" ]; + # }]; } diff --git a/host/x86_64-linux/home/Forgejo.nix b/host/x86_64-linux/home/Forgejo.nix index df505e2c..3e6b245a 100644 --- a/host/x86_64-linux/home/Forgejo.nix +++ b/host/x86_64-linux/home/Forgejo.nix @@ -1,54 +1,57 @@ -{ ... }: { - services.forgejo = { - enable = true; - stateDir = "/var/lib/forgejo"; +{ ... }: +{ + services.forgejo = { + enable = true; + stateDir = "/var/lib/forgejo"; - database = { - createDatabase = true; - name = "forgejo"; - type = "postgres"; - user = "forgejo"; - }; + database = { + createDatabase = true; + name = "forgejo"; + type = "postgres"; + user = "forgejo"; + }; - settings = let - gcArgs = "--aggressive --no-cruft --prune=now"; - gcTimeout = 600; - in { - "cron.cleanup_actions".ENABLED = true; - "cron.update_mirrors".SCHEDULE = "@midnight"; - "git".GC_ARGS = gcArgs; - "git.timeout".GC = gcTimeout; - "log".LEVEL = "Error"; - "repo-archive".ENABLED = false; - "repository.issue".MAX_PINNED = 99999; - "repository.pull-request".DEFAULT_MERGE_STYLE = "rebase"; - "service".DISABLE_REGISTRATION = true; - "server" = { - DOMAIN = "git.voronind.com"; - HTTP_ADDR = "0.0.0.0"; - ROOT_URL = "https://git.voronind.com"; - BUILTIN_SSH_SERVER_USER = "git"; - DISABLE_SSH = false; - SSH_PORT = 22144; - START_SSH_SERVER = true; - }; - "ui" = { - AMBIGUOUS_UNICODE_DETECTION = false; - }; - "repository" = { - DEFAULT_PRIVATE = "private"; - DEFAULT_PUSH_CREATE_PRIVATE = true; - }; - "cron" = { - ENABLED = true; - RUN_AT_START = true; - }; - "cron.git_gc_repos" = { - ENABLED = true; - ARGS = gcArgs; - SCHEDULE = "@midnight"; - TIMEOUT = gcTimeout; - }; - }; - }; + settings = + let + gcArgs = "--aggressive --no-cruft --prune=now"; + gcTimeout = 600; + in + { + "cron.cleanup_actions".ENABLED = true; + "cron.update_mirrors".SCHEDULE = "@midnight"; + "git".GC_ARGS = gcArgs; + "git.timeout".GC = gcTimeout; + "log".LEVEL = "Error"; + "repo-archive".ENABLED = false; + "repository.issue".MAX_PINNED = 99999; + "repository.pull-request".DEFAULT_MERGE_STYLE = "rebase"; + "service".DISABLE_REGISTRATION = true; + "server" = { + DOMAIN = "git.voronind.com"; + HTTP_ADDR = "0.0.0.0"; + ROOT_URL = "https://git.voronind.com"; + BUILTIN_SSH_SERVER_USER = "git"; + DISABLE_SSH = false; + SSH_PORT = 22144; + START_SSH_SERVER = true; + }; + "ui" = { + AMBIGUOUS_UNICODE_DETECTION = false; + }; + "repository" = { + DEFAULT_PRIVATE = "private"; + DEFAULT_PUSH_CREATE_PRIVATE = true; + }; + "cron" = { + ENABLED = true; + RUN_AT_START = true; + }; + "cron.git_gc_repos" = { + ENABLED = true; + ARGS = gcArgs; + SCHEDULE = "@midnight"; + TIMEOUT = gcTimeout; + }; + }; + }; } diff --git a/host/x86_64-linux/home/Frkn.nix b/host/x86_64-linux/home/Frkn.nix index 1753e256..6e816438 100644 --- a/host/x86_64-linux/home/Frkn.nix +++ b/host/x86_64-linux/home/Frkn.nix @@ -1,40 +1,40 @@ +{ pkgs, ... }: { - pkgs, - ... -}: { - services = { - tor = { - enable = true; - openFirewall = true; - settings = let - exclude = "{RU},{UA},{BY},{KZ},{CN},{??}"; - in { - # ExcludeExitNodes = exclude; - # ExcludeNodes = exclude; - # DNSPort = dnsport; - UseBridges = true; - ClientTransportPlugin = "obfs4 exec ${pkgs.obfs4}/bin/lyrebird"; - Bridge = [ - "obfs4 121.45.140.249:12123 0922E212E33B04F0B7C1E398161E8EDE06734F26 cert=3AQ4iJFAzxzt7a/zgXIiFEs6fvrXInXt1Dtr09DgnpvUzG/iiyRTdXYZKSYpI124Zt3ZUA iat-mode=0" - "obfs4 145.239.31.71:10161 882125D15B59BB82BE66F999056CB676D3F061F8 cert=AnD+EvcBMuQDVM7PwW7NgFAzW1M5jDm7DjQtIIcBSjoyAf1FJ2p535rrYL2Kk8POAd0+aw iat-mode=0" - "obfs4 79.137.11.45:45072 ECA3197D49A29DDECD4ACBF9BCF15E4987B78137 cert=2FKyLWkPgMNCWxBD3cNOTRxJH3XP+HdStPGKMjJfw2YbvVjihIp3X2BCrtxQya9m5II5XA iat-mode=0" - "obfs4 94.103.89.153:4443 5617848964FD6546968B5BF3FFA6C11BCCABE58B cert=tYsmuuTe9phJS0Gh8NKIpkVZP/XKs7gJCqi31o8LClwYetxzFz0fQZgsMwhNcIlZ0HG5LA iat-mode=0" - ]; - }; - client = { - enable = true; - # dns.enable = true; - socksListenAddress = { - IsolateDestAddr = true; - addr = "0.0.0.0"; - port = 9050; - }; - }; - }; + services = { + tor = { + enable = true; + openFirewall = true; + settings = + let + exclude = "{RU},{UA},{BY},{KZ},{CN},{??}"; + in + { + # ExcludeExitNodes = exclude; + # ExcludeNodes = exclude; + # DNSPort = dnsport; + UseBridges = true; + ClientTransportPlugin = "obfs4 exec ${pkgs.obfs4}/bin/lyrebird"; + Bridge = [ + "obfs4 121.45.140.249:12123 0922E212E33B04F0B7C1E398161E8EDE06734F26 cert=3AQ4iJFAzxzt7a/zgXIiFEs6fvrXInXt1Dtr09DgnpvUzG/iiyRTdXYZKSYpI124Zt3ZUA iat-mode=0" + "obfs4 145.239.31.71:10161 882125D15B59BB82BE66F999056CB676D3F061F8 cert=AnD+EvcBMuQDVM7PwW7NgFAzW1M5jDm7DjQtIIcBSjoyAf1FJ2p535rrYL2Kk8POAd0+aw iat-mode=0" + "obfs4 79.137.11.45:45072 ECA3197D49A29DDECD4ACBF9BCF15E4987B78137 cert=2FKyLWkPgMNCWxBD3cNOTRxJH3XP+HdStPGKMjJfw2YbvVjihIp3X2BCrtxQya9m5II5XA iat-mode=0" + "obfs4 94.103.89.153:4443 5617848964FD6546968B5BF3FFA6C11BCCABE58B cert=tYsmuuTe9phJS0Gh8NKIpkVZP/XKs7gJCqi31o8LClwYetxzFz0fQZgsMwhNcIlZ0HG5LA iat-mode=0" + ]; + }; + client = { + enable = true; + # dns.enable = true; + socksListenAddress = { + IsolateDestAddr = true; + addr = "0.0.0.0"; + port = 9050; + }; + }; + }; - xray = { - enable = true; - settingsFile = "/storage/hot/data/XrayClient.json"; - }; - }; + xray = { + enable = true; + settingsFile = "/storage/hot/data/XrayClient.json"; + }; + }; } diff --git a/host/x86_64-linux/home/Grocy.nix b/host/x86_64-linux/home/Grocy.nix index 4922bf51..cb36f042 100644 --- a/host/x86_64-linux/home/Grocy.nix +++ b/host/x86_64-linux/home/Grocy.nix @@ -1,16 +1,17 @@ -{ ... }: { - services.grocy = { - enable = true; - # dataDir = "/var/lib/grocy"; - hostName = "stock.voronind.com"; - nginx.enableSSL = false; - settings = { - calendar = { - firstDayOfWeek = 1; - showWeekNumber = true; - }; - culture = "en"; - currency = "RUB"; - }; - }; +{ ... }: +{ + services.grocy = { + enable = true; + # dataDir = "/var/lib/grocy"; + hostName = "stock.voronind.com"; + nginx.enableSSL = false; + settings = { + calendar = { + firstDayOfWeek = 1; + showWeekNumber = true; + }; + culture = "en"; + currency = "RUB"; + }; + }; } diff --git a/host/x86_64-linux/home/Hass.nix b/host/x86_64-linux/home/Hass.nix index 73cc236a..196260f7 100644 --- a/host/x86_64-linux/home/Hass.nix +++ b/host/x86_64-linux/home/Hass.nix @@ -1,45 +1,47 @@ -{ ... }: { - # Allow Hass to talk to Zigbee dongle. - users.users.hass.extraGroups = [ - "dialout" - "tty" - ]; +{ ... }: +{ + # Allow Hass to talk to Zigbee dongle. + users.users.hass.extraGroups = [ + "dialout" + "tty" + ]; - services.home-assistant = { - # NOTE: Missing: hacs. Inside hacs: `card-mod`, `Clock Weather Card`, `WallPanel` and `Yandex.Station`. - enable = true; - # NOTE: Using imperative config because of secrets. - config = null; - extraComponents = [ - "caldav" - "met" - "sun" - "systemmonitor" - "zha" - ]; - extraPackages = python3Packages: with python3Packages; [ - aiodhcpwatcher - aiodiscover - aiogithubapi - arrow - async-upnp-client - av - go2rtc-client - gtts - ha-ffmpeg - hassil - home-assistant-intents - mutagen - numpy - pymicro-vad - pynacl - pyspeex-noise - python-telegram-bot - pyturbojpeg - zeroconf - ]; - # lovelaceConfig = { - # title = "Home IoT control center."; - # }; - }; + services.home-assistant = { + # NOTE: Missing: hacs. Inside hacs: `card-mod`, `Clock Weather Card`, `WallPanel` and `Yandex.Station`. + enable = true; + # NOTE: Using imperative config because of secrets. + config = null; + extraComponents = [ + "caldav" + "met" + "sun" + "systemmonitor" + "zha" + ]; + extraPackages = + python3Packages: with python3Packages; [ + aiodhcpwatcher + aiodiscover + aiogithubapi + arrow + async-upnp-client + av + go2rtc-client + gtts + ha-ffmpeg + hassil + home-assistant-intents + mutagen + numpy + pymicro-vad + pynacl + pyspeex-noise + python-telegram-bot + pyturbojpeg + zeroconf + ]; + # lovelaceConfig = { + # title = "Home IoT control center."; + # }; + }; } diff --git a/host/x86_64-linux/home/Homer.nix b/host/x86_64-linux/home/Homer.nix index fa3732ca..b8655cd9 100644 --- a/host/x86_64-linux/home/Homer.nix +++ b/host/x86_64-linux/home/Homer.nix @@ -1,15 +1,17 @@ { - __findFile, - pkgs, - util, - ... -} @args: let - package = (pkgs.callPackage args); -in { - services.nginx = { - enable = true; - virtualHosts."home.voronind.com" = { - root = "${package}"; - }; - }; + __findFile, + pkgs, + util, + ... +}@args: +let + package = (pkgs.callPackage args); +in +{ + services.nginx = { + enable = true; + virtualHosts."home.voronind.com" = { + root = "${package}"; + }; + }; } diff --git a/host/x86_64-linux/home/Invidious.nix b/host/x86_64-linux/home/Invidious.nix index f323ef1b..7e5f9e6b 100644 --- a/host/x86_64-linux/home/Invidious.nix +++ b/host/x86_64-linux/home/Invidious.nix @@ -1,31 +1,32 @@ { - __findFile, - config, - inputs, - pkgs, - pkgsMaster, - ... -}: { - disabledModules = [ "services/web-apps/invidious.nix" ]; - imports = [ "${inputs.nixpkgsMaster}/nixos/modules/services/web-apps/invidious.nix" ]; + __findFile, + config, + inputs, + pkgs, + pkgsMaster, + ... +}: +{ + disabledModules = [ "services/web-apps/invidious.nix" ]; + imports = [ "${inputs.nixpkgsMaster}/nixos/modules/services/web-apps/invidious.nix" ]; - services.invidious = { - enable = true; - domain = "yt.voronind.com"; - package = pkgsMaster.invidious; - port = 3001; - nginx.enable = false; - database = { - createLocally = true; - # passwordFile = "${pkgs.writeText "InvidiousDbPassword" "invidious"}"; - }; - settings = { - admins = [ "root" ]; - captcha_enabled = false; - check_tables = true; - external_port = 443; - https_only = true; - registration_enabled = false; - }; - }; + services.invidious = { + enable = true; + domain = "yt.voronind.com"; + package = pkgsMaster.invidious; + port = 3001; + nginx.enable = false; + database = { + createLocally = true; + # passwordFile = "${pkgs.writeText "InvidiousDbPassword" "invidious"}"; + }; + settings = { + admins = [ "root" ]; + captcha_enabled = false; + check_tables = true; + external_port = 443; + https_only = true; + registration_enabled = false; + }; + }; } diff --git a/host/x86_64-linux/home/Jellyfin.nix b/host/x86_64-linux/home/Jellyfin.nix index 79fffc8f..d5ee5609 100644 --- a/host/x86_64-linux/home/Jellyfin.nix +++ b/host/x86_64-linux/home/Jellyfin.nix @@ -1,14 +1,15 @@ -{ ... }: { - # systemd.services.jellyfin.serviceConfig.MemoryMax = cfg.memLimit; +{ ... }: +{ + # systemd.services.jellyfin.serviceConfig.MemoryMax = cfg.memLimit; - users.users.jellyfin.extraGroups = [ - "video" - "render" - ]; + users.users.jellyfin.extraGroups = [ + "video" + "render" + ]; - services.jellyfin = { - enable = true; - # cacheDir = "/var/cache/jellyfin"; - # dataDir = "/var/lib/jellyfin"; - }; + services.jellyfin = { + enable = true; + # cacheDir = "/var/cache/jellyfin"; + # dataDir = "/var/lib/jellyfin"; + }; } diff --git a/host/x86_64-linux/home/Jobber.nix b/host/x86_64-linux/home/Jobber.nix index e2a8003c..695b79b1 100644 --- a/host/x86_64-linux/home/Jobber.nix +++ b/host/x86_64-linux/home/Jobber.nix @@ -1,77 +1,78 @@ # Use `nixos-container login jobber` as root and empty pw. { - __findFile, - const, - lib, - pkgsJobber, - poetry2nixJobber, - ... -}: let - script = import { - pkgs = pkgsJobber; - poetry2nix = poetry2nixJobber; - }; -in { - networking.nat = { - enable = true; - externalInterface = "enp8s0"; - internalInterfaces = [ "ve-+" ]; - }; + __findFile, + const, + lib, + pkgsJobber, + poetry2nixJobber, + ... +}: +let + script = import { + pkgs = pkgsJobber; + poetry2nix = poetry2nixJobber; + }; +in +{ + networking.nat = { + enable = true; + externalInterface = "enp8s0"; + internalInterfaces = [ "ve-+" ]; + }; - containers.jobber = { - autoStart = true; - enableTun = true; - privateNetwork = true; - hostAddress = "188.242.247.132"; - localAddress = "10.1.0.2"; + containers.jobber = { + autoStart = true; + enableTun = true; + privateNetwork = true; + hostAddress = "188.242.247.132"; + localAddress = "10.1.0.2"; - bindMounts = { - "/data" = { - hostPath = "/storage/hot/data/jobber"; - isReadOnly = true; - }; - }; + bindMounts = { + "/data" = { + hostPath = "/storage/hot/data/jobber"; + isReadOnly = true; + }; + }; - config = { ... }: let - packages = [ - script - ] ++ (with pkgsJobber; [ - firefox - geckodriver - openvpn - python311 - ]); - in { - boot.isContainer = true; - system.stateVersion = const.stateVersion; - users = { - users.root.password = ""; - mutableUsers = false; - }; - networking = { - useHostResolvConf = lib.mkForce false; - nameservers = [ - "10.30.218.2" - ]; - }; + config = + { ... }: + let + packages = + [ script ] + ++ (with pkgsJobber; [ + firefox + geckodriver + openvpn + python311 + ]); + in + { + boot.isContainer = true; + system.stateVersion = const.stateVersion; + users = { + users.root.password = ""; + mutableUsers = false; + }; + networking = { + useHostResolvConf = lib.mkForce false; + nameservers = [ "10.30.218.2" ]; + }; - systemd.services.jobber = { - description = "My job is pushing the button."; - enable = true; - path = packages; - wantedBy = [ - "multi-user.target" - ]; - environment = { - PYTHONDONTWRITEBYTECODE = "1"; - PYTHONUNBUFFERED = "1"; - }; - serviceConfig = { - ExecStart = "${script}/bin/jobber -u"; - Restart = "on-failure"; - Type = "simple"; - }; - }; - }; - }; + systemd.services.jobber = { + description = "My job is pushing the button."; + enable = true; + path = packages; + wantedBy = [ "multi-user.target" ]; + environment = { + PYTHONDONTWRITEBYTECODE = "1"; + PYTHONUNBUFFERED = "1"; + }; + serviceConfig = { + ExecStart = "${script}/bin/jobber -u"; + Restart = "on-failure"; + Type = "simple"; + }; + }; + }; + }; } diff --git a/host/x86_64-linux/home/Kavita.nix b/host/x86_64-linux/home/Kavita.nix index d546bb4e..14ccc180 100644 --- a/host/x86_64-linux/home/Kavita.nix +++ b/host/x86_64-linux/home/Kavita.nix @@ -1,13 +1,11 @@ +{ pkgs, ... }: { - pkgs, - ... -}: { - services.kavita = { - enable = true; - tokenKeyFile = pkgs.writeText "KavitaToken" "xY19aQOa939/Ie6GCRGbubVK8zRwrgBY/20AuyMpYshUjwK1Uyl7bw1yknVh6jJIFIfwq2vAjeotOUq7NEsf9Q=="; - settings = { - # IpAddresses = cfg.address; - Port = 5000; - }; - }; + services.kavita = { + enable = true; + tokenKeyFile = pkgs.writeText "KavitaToken" "xY19aQOa939/Ie6GCRGbubVK8zRwrgBY/20AuyMpYshUjwK1Uyl7bw1yknVh6jJIFIfwq2vAjeotOUq7NEsf9Q=="; + settings = { + # IpAddresses = cfg.address; + Port = 5000; + }; + }; } diff --git a/host/x86_64-linux/home/Mailserver.nix b/host/x86_64-linux/home/Mailserver.nix index 4104685a..1edad3d7 100644 --- a/host/x86_64-linux/home/Mailserver.nix +++ b/host/x86_64-linux/home/Mailserver.nix @@ -1,166 +1,158 @@ # REF: https://nixos-mailserver.readthedocs.io/en/latest/setup-guide.html +{ pkgs, util, ... }: +let + domain = "voronind.com"; + + # SEE: https://gitlab.com/simple-nixos-mailserver/nixos-mailserver#release-branches + version = "24.05"; + sha256 = "sha256:0clvw4622mqzk1aqw1qn6shl9pai097q62mq1ibzscnjayhp278b"; +in { - pkgs, - util, - ... -}: let - domain = "voronind.com"; + imports = [ + (builtins.fetchTarball { + inherit sha256; + url = "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/nixos-${version}/nixos-mailserver-nixos-${version}.tar.gz"; + }) + ]; - # SEE: https://gitlab.com/simple-nixos-mailserver/nixos-mailserver#release-branches - version = "24.05"; - sha256 = "sha256:0clvw4622mqzk1aqw1qn6shl9pai097q62mq1ibzscnjayhp278b"; -in { - imports = [ - (builtins.fetchTarball { - inherit sha256; - url = "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/nixos-${version}/nixos-mailserver-nixos-${version}.tar.gz"; - }) - ]; + mailserver = { + enable = true; + domains = [ domain ]; + fqdn = "mail.${domain}"; + sendingFqdn = domain; + localDnsResolver = false; - mailserver = { - enable = true; - domains = [ domain ]; - fqdn = "mail.${domain}"; - sendingFqdn = domain; - localDnsResolver = false; + # Use `mkpasswd -sm bcrypt`. + loginAccounts = + let + defaultQuota = "1G"; + in + { + "admin@${domain}" = { + hashedPassword = "$2b$05$1O.dxXxaVshcBNybcqDRYuTlnYt3jDBwfPZWoDtP4BjOLoL0StYsi"; + name = "admin"; + quota = defaultQuota; + }; + "account@${domain}" = { + hashedPassword = "$2b$05$sCyZHdk98KqQ1qsTIvbrUeRJlNBOwBqDgpdc1QxiSnONlEkZ8xGNO"; + name = "account"; + quota = defaultQuota; + }; + "hi@${domain}" = { + hashedPassword = "$2b$05$6fT5hIhzIasNfp9IQr/ds.5RuxH95VKU3QJWlX3hmrAzDF3mExanq"; + name = "hi"; + quota = defaultQuota; + aliases = [ "voronind@${domain}" ]; + }; + "job@${domain}" = { + hashedPassword = "$2b$05$.sUmv2.9EWPfLwJn/oZw2e1UbR7HrpNQ2THc5jjX3ysy7CY8ZWHUC"; + name = "job"; + quota = defaultQuota; + }; + "trash@${domain}" = { + hashedPassword = "$2b$05$kn5ygZjN9NR3LXjnKKRw/.DXaZQNW.1XEottlCFIoKiDpIj.JGLJm"; + name = "trash"; + quota = defaultQuota; + catchAll = [ domain ]; + }; + "noreply@${domain}" = { + hashedPassword = "$2b$05$TaKwoYmcmkAhsRRv6xG5wOkChcz50cB9BP6QPUDKNAcxMbrY6AeMK"; + name = "noreply"; + quota = defaultQuota; + sendOnly = true; + }; + }; - # Use `mkpasswd -sm bcrypt`. - loginAccounts = let - defaultQuota = "1G"; - in { - "admin@${domain}" = { - hashedPassword = "$2b$05$1O.dxXxaVshcBNybcqDRYuTlnYt3jDBwfPZWoDtP4BjOLoL0StYsi"; - name = "admin"; - quota = defaultQuota; - }; - "account@${domain}" = { - hashedPassword = "$2b$05$sCyZHdk98KqQ1qsTIvbrUeRJlNBOwBqDgpdc1QxiSnONlEkZ8xGNO"; - name = "account"; - quota = defaultQuota; - }; - "hi@${domain}" = { - hashedPassword = "$2b$05$6fT5hIhzIasNfp9IQr/ds.5RuxH95VKU3QJWlX3hmrAzDF3mExanq"; - name = "hi"; - quota = defaultQuota; - aliases = [ - "voronind@${domain}" - ]; - }; - "job@${domain}" = { - hashedPassword = "$2b$05$.sUmv2.9EWPfLwJn/oZw2e1UbR7HrpNQ2THc5jjX3ysy7CY8ZWHUC"; - name = "job"; - quota = defaultQuota; - }; - "trash@${domain}" = { - hashedPassword = "$2b$05$kn5ygZjN9NR3LXjnKKRw/.DXaZQNW.1XEottlCFIoKiDpIj.JGLJm"; - name = "trash"; - quota = defaultQuota; - catchAll = [ - domain - ]; - }; - "noreply@${domain}" = { - hashedPassword = "$2b$05$TaKwoYmcmkAhsRRv6xG5wOkChcz50cB9BP6QPUDKNAcxMbrY6AeMK"; - name = "noreply"; - quota = defaultQuota; - sendOnly = true; - }; - }; + enableImap = true; + enableImapSsl = true; + enableSubmission = true; + enableSubmissionSsl = true; - enableImap = true; - enableImapSsl = true; - enableSubmission = true; - enableSubmissionSsl = true; + enableManageSieve = true; + virusScanning = false; - enableManageSieve = true; - virusScanning = false; + certificateFile = "/etc/letsencrypt/live/${domain}/cert.pem"; + certificateScheme = "manual"; + keyFile = "/etc/letsencrypt/live/${domain}/privkey.pem"; - certificateFile = "/etc/letsencrypt/live/${domain}/cert.pem"; - certificateScheme = "manual"; - keyFile = "/etc/letsencrypt/live/${domain}/privkey.pem"; + dkimKeyDirectory = "/var/dkim"; + indexDir = "/var/lib/dovecot/indices"; + mailDirectory = "/var/vmail"; + sieveDirectory = "/var/sieve"; - dkimKeyDirectory = "/var/dkim"; - indexDir = "/var/lib/dovecot/indices"; - mailDirectory = "/var/vmail"; - sieveDirectory = "/var/sieve"; + mailboxes = + let + mkSpecialBox = specialUse: { + ${specialUse} = { + inherit specialUse; + auto = "subscribe"; + }; + }; + in + builtins.foldl' (acc: box: acc // (mkSpecialBox box)) { } [ + "All" + "Archive" + "Drafts" + "Junk" + "Sent" + "Trash" + ]; - mailboxes = let - mkSpecialBox = specialUse: { - ${specialUse} = { - inherit specialUse; - auto = "subscribe"; - }; - }; - in builtins.foldl' (acc: box: acc // (mkSpecialBox box)) {} [ - "All" - "Archive" - "Drafts" - "Junk" - "Sent" - "Trash" - ]; + dmarcReporting = { + inherit domain; + enable = true; + organizationName = "voronind"; + # email = "noreply@${domain}"; + }; - dmarcReporting = { - inherit domain; - enable = true; - organizationName = "voronind"; - # email = "noreply@${domain}"; - }; + # monitoring = { + # enable = true; + # alertAddress = "admin@${domain}"; + # }; + }; - # monitoring = { - # enable = true; - # alertAddress = "admin@${domain}"; - # }; - }; + services = { + roundcube = { + enable = true; + hostName = "mail.${domain}"; + dicts = with pkgs.aspellDicts; [ + en + ru + ]; + plugins = [ "managesieve" ]; + extraConfig = util.trimTabs '' + $config['smtp_server'] = "localhost:25"; + $config['smtp_auth_type'] = null; + $config['smtp_user'] = ""; + $config['smtp_pass'] = ""; + # $config['smtp_user'] = "%u"; + # $config['smtp_pass'] = "%p"; + ''; + }; + }; - services = { - roundcube = { - enable = true; - hostName = "mail.${domain}"; - dicts = with pkgs.aspellDicts; [ - en - ru - ]; - plugins = [ - "managesieve" - ]; - extraConfig = util.trimTabs '' - $config['smtp_server'] = "localhost:25"; - $config['smtp_auth_type'] = null; - $config['smtp_user'] = ""; - $config['smtp_pass'] = ""; - # $config['smtp_user'] = "%u"; - # $config['smtp_pass'] = "%p"; - ''; - }; - }; + systemd = { + services.autoexpunge = { + description = "Delete old mail"; + serviceConfig = { + Type = "oneshot"; + }; + path = [ pkgs.dovecot ]; + script = util.trimTabs '' + doveadm expunge -A mailbox Junk SENTBEFORE 7d + doveadm expunge -A mailbox Trash SENTBEFORE 30d + doveadm expunge -u trash@voronind.com mailbox Inbox SENTBEFORE 30d + doveadm purge -A + ''; + }; - systemd = { - services.autoexpunge = { - description = "Delete old mail"; - serviceConfig = { - Type = "oneshot"; - }; - path = [ - pkgs.dovecot - ]; - script = util.trimTabs '' - doveadm expunge -A mailbox Junk SENTBEFORE 7d - doveadm expunge -A mailbox Trash SENTBEFORE 30d - doveadm expunge -u trash@voronind.com mailbox Inbox SENTBEFORE 30d - doveadm purge -A - ''; - }; - - timers.autoexpunge = { - timerConfig = { - OnCalendar = "daily"; - Persistent = true; - Unit = "autoexpunge.service"; - }; - wantedBy = [ - "timers.target" - ]; - }; - }; + timers.autoexpunge = { + timerConfig = { + OnCalendar = "daily"; + Persistent = true; + Unit = "autoexpunge.service"; + }; + wantedBy = [ "timers.target" ]; + }; + }; } diff --git a/host/x86_64-linux/home/Mumble.nix b/host/x86_64-linux/home/Mumble.nix index 9c7b5bbb..5471150b 100644 --- a/host/x86_64-linux/home/Mumble.nix +++ b/host/x86_64-linux/home/Mumble.nix @@ -1,12 +1,13 @@ -{ ... }: { - services.murmur = { - enable = true; - clientCertRequired = true; - password = "bonjour"; - port = 22666; - registerHostname = "chat.voronind.com"; - sslCert = "/etc/letsencrypt/live/voronind.com/fullchain.pem"; - sslKey = "/etc/letsencrypt/live/voronind.com/privkey.pem"; - extraConfig = ''''; - }; +{ ... }: +{ + services.murmur = { + enable = true; + clientCertRequired = true; + password = "bonjour"; + port = 22666; + registerHostname = "chat.voronind.com"; + sslCert = "/etc/letsencrypt/live/voronind.com/fullchain.pem"; + sslKey = "/etc/letsencrypt/live/voronind.com/privkey.pem"; + extraConfig = ''''; + }; } diff --git a/host/x86_64-linux/home/Network.nix b/host/x86_64-linux/home/Network.nix index 568e7559..d53d9473 100644 --- a/host/x86_64-linux/home/Network.nix +++ b/host/x86_64-linux/home/Network.nix @@ -1,192 +1,196 @@ # 10.0.0.0/24 & fd09:8d46:0b26::/48 - phys clients (lan). # 10.0.1.0/24 - vpn clients. { - config, - const, - lib, - util, - ... -}: let - internal = "10.0.0.1"; # Lan host IP address. - internal6 = "fd09:8d46:b26:0:8079:82ff:fe1a:916a"; # Lan host IP6 address. + config, + const, + lib, + util, + ... +}: +let + internal = "10.0.0.1"; # Lan host IP address. + internal6 = "fd09:8d46:b26:0:8079:82ff:fe1a:916a"; # Lan host IP6 address. - lan = "br0"; # Lan interface. - wan = "enp8s0"; # Wan interface. -in { - # Disable systemd-resolved for DNS server. - services.resolved.enable = false; + lan = "br0"; # Lan interface. + wan = "enp8s0"; # Wan interface. +in +{ + # Disable systemd-resolved for DNS server. + services.resolved.enable = false; - # NOTE: Debugging. - # systemd.services."systemd-networkd".environment.SYSTEMD_LOG_LEVEL = "debug"; + # NOTE: Debugging. + # systemd.services."systemd-networkd".environment.SYSTEMD_LOG_LEVEL = "debug"; - # Wan configuration. - # REF: https://nixos.wiki/wiki/Systemd-networkd - # REF: man 5 systemd.network - # REF: Wifi config: https://openwrt.org/docs/guide-user/network/wifi/wifiextenders/bridgedap#wireless_access_point_-_dumb_access_point - systemd.network = { - enable = true; - networks = { - "10-${wan}" = { - matchConfig.Name = wan; - linkConfig.RequiredForOnline = "carrier"; - dhcpV4Config = { - ClientIdentifier = "mac"; - UseDNS = false; - UseRoutes = true; - }; - dhcpV6Config = { - DUIDRawData = "00:03:00:01:a8:a1:59:47:fd:a2"; - DUIDType = "vendor"; - UseDNS = false; - WithoutRA = "solicit"; - # PrefixDelegationHint = "::/56"; - }; - networkConfig = { - DHCP = "yes"; - DNS = "1.1.1.1"; - IPv6AcceptRA = true; - IPv6SendRA = false; - DHCPPrefixDelegation = true; - }; - dhcpPrefixDelegationConfig = { - UplinkInterface = ":self"; - SubnetId = 0; - Announce = false; - }; - }; - "20-enp6s0f0" = { - linkConfig.RequiredForOnline = "enslaved"; - matchConfig.Name = "enp6s0f0"; - networkConfig.Bridge = lan; - }; - "20-enp6s0f1" = { - linkConfig.RequiredForOnline = "enslaved"; - matchConfig.Name = "enp6s0f1"; - networkConfig.Bridge = lan; - }; - "20-enp7s0f0" = { - linkConfig.RequiredForOnline = "enslaved"; - matchConfig.Name = "enp7s0f0"; - networkConfig.Bridge = lan; - }; - "20-enp7s0f1" = { - linkConfig.RequiredForOnline = "enslaved"; - matchConfig.Name = "enp7s0f1"; - networkConfig.Bridge = lan; - }; - "30-${lan}" = { - matchConfig.Name = lan; - linkConfig.RequiredForOnline = "carrier"; - address = [ - "${internal}/24" - # "${internal6}/48" - ]; - networkConfig = { - DHCPPrefixDelegation = true; - DHCPServer = true; - IPv6AcceptRA = false; - IPv6SendRA = true; - }; - ipv6SendRAConfig = { - EmitDNS = true; - DNS = internal6; - }; - ipv6Prefixes = [ - { - Assign = true; - Prefix = "${internal6}/64"; - } - ]; - dhcpPrefixDelegationConfig = { - Announce = true; - SubnetId = 1; - UplinkInterface = wan; - }; - dhcpServerConfig = { - DNS = internal; - DefaultLeaseTimeSec = "12h"; - EmitDNS = true; - EmitNTP = true; - EmitRouter = true; - EmitTimezone = true; - MaxLeaseTimeSec = "24h"; - PoolOffset = 100; - PoolSize = 150; - ServerAddress = "${internal}/24"; - Timezone = const.timeZone; - UplinkInterface = wan; - }; - dhcpServerStaticLeases = let - mkStatic = Address: MACAddress: { inherit Address MACAddress; }; - in [ - # TODO: Add pocket. - (mkStatic "10.0.0.2" "9c:9d:7e:8e:3d:c7") # Wifi AP. - (mkStatic "10.0.0.3" "d8:bb:c1:cc:da:30") # Desktop. - (mkStatic "10.0.0.4" "2c:be:eb:52:53:2b") # Phone. - (mkStatic "10.0.0.5" "14:85:7f:eb:6c:25") # Work. - (mkStatic "10.0.0.6" "08:38:e6:31:54:b6") # Tablet. - (mkStatic "10.0.0.7" "2c:f0:5d:3b:07:78") # Dasha. - (mkStatic "10.0.0.8" "ac:5f:ea:ef:b5:05") # Dasha phone. - (mkStatic "10.0.0.9" "10:b1:df:ea:18:57") # Laptop. - (mkStatic "10.0.0.10" "9c:1c:37:62:3f:d5") # Printer. - (mkStatic "10.0.0.11" "dc:a6:32:f5:77:95") # RPi. - (mkStatic "10.0.0.12" "ec:9c:32:ad:bc:4a") # Camera. - (mkStatic "10.0.0.13" "c0:a5:e8:b5:d9:16") # Max. - ]; - }; - }; + # Wan configuration. + # REF: https://nixos.wiki/wiki/Systemd-networkd + # REF: man 5 systemd.network + # REF: Wifi config: https://openwrt.org/docs/guide-user/network/wifi/wifiextenders/bridgedap#wireless_access_point_-_dumb_access_point + systemd.network = { + enable = true; + networks = { + "10-${wan}" = { + matchConfig.Name = wan; + linkConfig.RequiredForOnline = "carrier"; + dhcpV4Config = { + ClientIdentifier = "mac"; + UseDNS = false; + UseRoutes = true; + }; + dhcpV6Config = { + DUIDRawData = "00:03:00:01:a8:a1:59:47:fd:a2"; + DUIDType = "vendor"; + UseDNS = false; + WithoutRA = "solicit"; + # PrefixDelegationHint = "::/56"; + }; + networkConfig = { + DHCP = "yes"; + DNS = "1.1.1.1"; + IPv6AcceptRA = true; + IPv6SendRA = false; + DHCPPrefixDelegation = true; + }; + dhcpPrefixDelegationConfig = { + UplinkInterface = ":self"; + SubnetId = 0; + Announce = false; + }; + }; + "20-enp6s0f0" = { + linkConfig.RequiredForOnline = "enslaved"; + matchConfig.Name = "enp6s0f0"; + networkConfig.Bridge = lan; + }; + "20-enp6s0f1" = { + linkConfig.RequiredForOnline = "enslaved"; + matchConfig.Name = "enp6s0f1"; + networkConfig.Bridge = lan; + }; + "20-enp7s0f0" = { + linkConfig.RequiredForOnline = "enslaved"; + matchConfig.Name = "enp7s0f0"; + networkConfig.Bridge = lan; + }; + "20-enp7s0f1" = { + linkConfig.RequiredForOnline = "enslaved"; + matchConfig.Name = "enp7s0f1"; + networkConfig.Bridge = lan; + }; + "30-${lan}" = { + matchConfig.Name = lan; + linkConfig.RequiredForOnline = "carrier"; + address = [ + "${internal}/24" + # "${internal6}/48" + ]; + networkConfig = { + DHCPPrefixDelegation = true; + DHCPServer = true; + IPv6AcceptRA = false; + IPv6SendRA = true; + }; + ipv6SendRAConfig = { + EmitDNS = true; + DNS = internal6; + }; + ipv6Prefixes = [ + { + Assign = true; + Prefix = "${internal6}/64"; + } + ]; + dhcpPrefixDelegationConfig = { + Announce = true; + SubnetId = 1; + UplinkInterface = wan; + }; + dhcpServerConfig = { + DNS = internal; + DefaultLeaseTimeSec = "12h"; + EmitDNS = true; + EmitNTP = true; + EmitRouter = true; + EmitTimezone = true; + MaxLeaseTimeSec = "24h"; + PoolOffset = 100; + PoolSize = 150; + ServerAddress = "${internal}/24"; + Timezone = const.timeZone; + UplinkInterface = wan; + }; + dhcpServerStaticLeases = + let + mkStatic = Address: MACAddress: { inherit Address MACAddress; }; + in + [ + # TODO: Add pocket. + (mkStatic "10.0.0.2" "9c:9d:7e:8e:3d:c7") # Wifi AP. + (mkStatic "10.0.0.3" "d8:bb:c1:cc:da:30") # Desktop. + (mkStatic "10.0.0.4" "2c:be:eb:52:53:2b") # Phone. + (mkStatic "10.0.0.5" "14:85:7f:eb:6c:25") # Work. + (mkStatic "10.0.0.6" "08:38:e6:31:54:b6") # Tablet. + (mkStatic "10.0.0.7" "2c:f0:5d:3b:07:78") # Dasha. + (mkStatic "10.0.0.8" "ac:5f:ea:ef:b5:05") # Dasha phone. + (mkStatic "10.0.0.9" "10:b1:df:ea:18:57") # Laptop. + (mkStatic "10.0.0.10" "9c:1c:37:62:3f:d5") # Printer. + (mkStatic "10.0.0.11" "dc:a6:32:f5:77:95") # RPi. + (mkStatic "10.0.0.12" "ec:9c:32:ad:bc:4a") # Camera. + (mkStatic "10.0.0.13" "c0:a5:e8:b5:d9:16") # Max. + ]; + }; + }; - netdevs = { - "10-${lan}" = { - netdevConfig = { - Kind = "bridge"; - Name = lan; - }; - }; - }; - }; + netdevs = { + "10-${lan}" = { + netdevConfig = { + Kind = "bridge"; + Name = lan; + }; + }; + }; + }; - networking = { - dhcpcd.enable = false; - useDHCP = false; - useNetworkd = true; - networkmanager.enable = lib.mkForce false; - firewall = { - enable = true; - extraCommands = util.trimTabs '' - # Wan access for 10.0.0.0/24 subnet. - iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -d 0/0 -o ${wan} -j MASQUERADE + networking = { + dhcpcd.enable = false; + useDHCP = false; + useNetworkd = true; + networkmanager.enable = lib.mkForce false; + firewall = { + enable = true; + extraCommands = util.trimTabs '' + # Wan access for 10.0.0.0/24 subnet. + iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -d 0/0 -o ${wan} -j MASQUERADE - # Full access from Lan. - iptables -I INPUT -j ACCEPT -i ${lan} -d ${internal} - ip6tables -I INPUT -j ACCEPT -i ${lan} -d ${internal6} + # Full access from Lan. + iptables -I INPUT -j ACCEPT -i ${lan} -d ${internal} + ip6tables -I INPUT -j ACCEPT -i ${lan} -d ${internal6} - # Public email server. - ip46tables -I INPUT -j ACCEPT -i ${wan} -p tcp --dport 25 + # Public email server. + ip46tables -I INPUT -j ACCEPT -i ${wan} -p tcp --dport 25 - # Public VPN service. - ip46tables -I INPUT -j ACCEPT -i ${wan} -p udp --dport 22145 - iptables -I INPUT -j ACCEPT -s 10.0.1.0/24 -d ${internal} + # Public VPN service. + ip46tables -I INPUT -j ACCEPT -i ${wan} -p udp --dport 22145 + iptables -I INPUT -j ACCEPT -s 10.0.1.0/24 -d ${internal} - # Public Nginx. - ip46tables -I INPUT -j ACCEPT -i ${wan} -p tcp --dport 443 + # Public Nginx. + ip46tables -I INPUT -j ACCEPT -i ${wan} -p tcp --dport 443 - # Deluge torrenting ports. - ip46tables -I INPUT -j ACCEPT -i ${wan} -p tcp --dport 54630 - ip46tables -I INPUT -j ACCEPT -i ${wan} -p udp --dport 54630 - ip46tables -I INPUT -j ACCEPT -i ${wan} -p tcp --dport 54631 - ip46tables -I INPUT -j ACCEPT -i ${wan} -p udp --dport 54631 + # Deluge torrenting ports. + ip46tables -I INPUT -j ACCEPT -i ${wan} -p tcp --dport 54630 + ip46tables -I INPUT -j ACCEPT -i ${wan} -p udp --dport 54630 + ip46tables -I INPUT -j ACCEPT -i ${wan} -p tcp --dport 54631 + ip46tables -I INPUT -j ACCEPT -i ${wan} -p udp --dport 54631 - # Terraria server. - ip46tables -I INPUT -j ACCEPT -i ${wan} -p tcp --dport 22777 + # Terraria server. + ip46tables -I INPUT -j ACCEPT -i ${wan} -p tcp --dport 22777 - # Mumble. - ip46tables -I INPUT -j ACCEPT -i ${wan} -p tcp --dport 22666 - ip46tables -I INPUT -j ACCEPT -i ${wan} -p udp --dport 22666 + # Mumble. + ip46tables -I INPUT -j ACCEPT -i ${wan} -p tcp --dport 22666 + ip46tables -I INPUT -j ACCEPT -i ${wan} -p udp --dport 22666 - # Public SSH access. - # ip46tables -I INPUT -j ACCEPT -i ${wan} -p tcp --dport 22143 - ''; - }; - }; + # Public SSH access. + # ip46tables -I INPUT -j ACCEPT -i ${wan} -p tcp --dport 22143 + ''; + }; + }; } diff --git a/host/x86_64-linux/home/Nextcloud.nix b/host/x86_64-linux/home/Nextcloud.nix index 6f65e829..e5caebf4 100644 --- a/host/x86_64-linux/home/Nextcloud.nix +++ b/host/x86_64-linux/home/Nextcloud.nix @@ -1,38 +1,30 @@ +{ config, pkgs, ... }: { - config, - pkgs, - ... -}: { - services.nextcloud = { - enable = true; - database.createLocally = true; - extraAppsEnable = true; - hostName = "cloud.voronind.com"; - https = true; - # package = pkgs.nextcloud29; - # phpOptions = { - # memory_limit = lib.mkForce "20G"; - # }; - config = { - adminpassFile = "${pkgs.writeText "NextcloudPassword" "root"}"; - adminuser = "root"; - dbname = "nextcloud"; - # dbpassFile = "${pkgs.writeText "NextcloudDbPassword" "nextcloud"}"; - dbtype = "pgsql"; - dbuser = "nextcloud"; - }; - extraApps = { - inherit (config.services.nextcloud.package.packages.apps) - contacts calendar; - }; - settings = { - allow_local_remote_servers = true; - trusted_domains = [ - "cloud.voronind.com" - ]; - trusted_proxies = [ - # proxy.address - ]; - }; - }; + services.nextcloud = { + enable = true; + database.createLocally = true; + extraAppsEnable = true; + hostName = "cloud.voronind.com"; + https = true; + # package = pkgs.nextcloud29; + # phpOptions = { + # memory_limit = lib.mkForce "20G"; + # }; + config = { + adminpassFile = "${pkgs.writeText "NextcloudPassword" "root"}"; + adminuser = "root"; + dbname = "nextcloud"; + # dbpassFile = "${pkgs.writeText "NextcloudDbPassword" "nextcloud"}"; + dbtype = "pgsql"; + dbuser = "nextcloud"; + }; + extraApps = { inherit (config.services.nextcloud.package.packages.apps) contacts calendar; }; + settings = { + allow_local_remote_servers = true; + trusted_domains = [ "cloud.voronind.com" ]; + trusted_proxies = [ + # proxy.address + ]; + }; + }; } diff --git a/host/x86_64-linux/home/Nginx.nix b/host/x86_64-linux/home/Nginx.nix index 85c368a2..39d0f4f8 100644 --- a/host/x86_64-linux/home/Nginx.nix +++ b/host/x86_64-linux/home/Nginx.nix @@ -9,42 +9,40 @@ # ssl_ciphers "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384"; # ``` # For certbot to generate new keys: `certbot certonly --manual --manual-public-ip-logging-ok --preferred-challenges dns-01 --server https://acme-v02.api.letsencrypt.org/directory -d "*.voronind.com" -d voronind.com` +{ pkgs, util, ... }@args: +let + virtualHosts = util.catSet (util.ls ./nginx) args; +in { - pkgs, - util, - ... -} @args: let - virtualHosts = util.catSet (util.ls ./nginx) args; -in { - environment.systemPackages = with pkgs; [ certbot ]; + environment.systemPackages = with pkgs; [ certbot ]; - services.nginx = { - inherit virtualHosts; - enable = true; - clientMaxBodySize = "4096m"; - recommendedOptimisation = true; - recommendedProxySettings = true; - appendConfig = util.trimTabs '' - worker_processes 4; - ''; - eventsConfig = util.trimTabs '' - worker_connections 4096; - ''; - appendHttpConfig = util.trimTabs '' - proxy_max_temp_file_size 0; - proxy_buffering off; + services.nginx = { + inherit virtualHosts; + enable = true; + clientMaxBodySize = "4096m"; + recommendedOptimisation = true; + recommendedProxySettings = true; + appendConfig = '' + worker_processes 4; + ''; + eventsConfig = '' + worker_connections 4096; + ''; + appendHttpConfig = '' + proxy_max_temp_file_size 0; + proxy_buffering off; - server { - listen 443 ssl default_server; - server_name _; + server { + listen 443 ssl default_server; + server_name _; - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - return 403; - } - ''; - }; + return 403; + } + ''; + }; } diff --git a/host/x86_64-linux/home/Ovpn.nix b/host/x86_64-linux/home/Ovpn.nix index 01607494..ec79ae65 100644 --- a/host/x86_64-linux/home/Ovpn.nix +++ b/host/x86_64-linux/home/Ovpn.nix @@ -12,51 +12,48 @@ # SEE: https://github.com/OpenVPN/openvpn/blob/master/sample/sample-config-files/server.conf # SRC: https://github.com/TinCanTech/easy-tls +{ pkgs, ... }: { - pkgs, - util, - ... -}: { - environment.systemPackages = with pkgs; [ - easyrsa - openvpn - ]; + environment.systemPackages = with pkgs; [ + easyrsa + openvpn + ]; - users = { - groups.openvpn = {}; - users.openvpn = { - group = "openvpn"; - isSystemUser = true; - # uid = 1000; - }; - }; + users = { + groups.openvpn = { }; + users.openvpn = { + group = "openvpn"; + isSystemUser = true; + # uid = 1000; + }; + }; - # NOTE: Change the `server` to match `cfg.clients` or write a substring here. - services.openvpn.servers.vpn = { - autoStart = true; - config = util.trimTabs '' - ca /var/lib/ovpn/pki/ca.crt - cert /var/lib/ovpn/pki/issued/home.crt - client-to-client - crl-verify /var/lib/ovpn/pki/crl.pem - dev tun - dh /var/lib/ovpn/dh2048.pem - explicit-exit-notify 1 - group openvpn - ifconfig-pool-persist ipp.txt - keepalive 10 120 - key /var/lib/ovpn/pki/private/home.key - persist-tun - port 22145 - proto udp - push "dhcp-option DNS 10.0.0.1" - push "dhcp-option DNS 10.0.0.1" - push "route 10.0.0.0 255.0.0.0" - server 10.0.1.0 255.255.255.0 - status openvpn-status.log - topology subnet - user openvpn - verb 4 - ''; - }; + # NOTE: Change the `server` to match `cfg.clients` or write a substring here. + services.openvpn.servers.vpn = { + autoStart = true; + config = '' + ca /var/lib/ovpn/pki/ca.crt + cert /var/lib/ovpn/pki/issued/home.crt + client-to-client + crl-verify /var/lib/ovpn/pki/crl.pem + dev tun + dh /var/lib/ovpn/dh2048.pem + explicit-exit-notify 1 + group openvpn + ifconfig-pool-persist ipp.txt + keepalive 10 120 + key /var/lib/ovpn/pki/private/home.key + persist-tun + port 22145 + proto udp + push "dhcp-option DNS 10.0.0.1" + push "dhcp-option DNS 10.0.0.1" + push "route 10.0.0.0 255.0.0.0" + server 10.0.1.0 255.255.255.0 + status openvpn-status.log + topology subnet + user openvpn + verb 4 + ''; + }; } diff --git a/host/x86_64-linux/home/Paperless.nix b/host/x86_64-linux/home/Paperless.nix index 90b31628..76753d88 100644 --- a/host/x86_64-linux/home/Paperless.nix +++ b/host/x86_64-linux/home/Paperless.nix @@ -1,24 +1,21 @@ +{ lib, pkgs, ... }: { - lib, - pkgs, - ... -}: { - services.paperless = { - enable = true; - address = "0.0.0.0"; - dataDir = "/var/lib/paperless"; - # port = cfg.port; - passwordFile = pkgs.writeText "PaperlessPassword" "root"; # NOTE: Only for initial setup, change later. - settings = { - PAPERLESS_ADMIN_USER = "root"; - PAPERLESS_DBHOST = "/run/postgresql"; - PAPERLESS_DBENGINE = "postgresql"; - PAPERLESS_DBNAME = "paperless"; - PAPERLESS_DBPASS = "paperless"; - PAPERLESS_DBUSER = "paperless"; - PAPERLESS_OCR_LANGUAGE = "rus"; - # PAPERLESS_REDIS = "redis://${config.container.module.redis.address}:${toString config.container.module.redis.port}"; - PAPERLESS_URL = "https://paper.voronind.com"; - }; - }; + services.paperless = { + enable = true; + address = "0.0.0.0"; + dataDir = "/var/lib/paperless"; + # port = cfg.port; + passwordFile = pkgs.writeText "PaperlessPassword" "root"; # NOTE: Only for initial setup, change later. + settings = { + PAPERLESS_ADMIN_USER = "root"; + PAPERLESS_DBHOST = "/run/postgresql"; + PAPERLESS_DBENGINE = "postgresql"; + PAPERLESS_DBNAME = "paperless"; + PAPERLESS_DBPASS = "paperless"; + PAPERLESS_DBUSER = "paperless"; + PAPERLESS_OCR_LANGUAGE = "rus"; + # PAPERLESS_REDIS = "redis://${config.container.module.redis.address}:${toString config.container.module.redis.port}"; + PAPERLESS_URL = "https://paper.voronind.com"; + }; + }; } diff --git a/host/x86_64-linux/home/Postgres.nix b/host/x86_64-linux/home/Postgres.nix index 58ce6705..13afe3d1 100644 --- a/host/x86_64-linux/home/Postgres.nix +++ b/host/x86_64-linux/home/Postgres.nix @@ -1,47 +1,54 @@ { - config, - lib, - pkgs, - ... -}: { - services.postgresql = let - # Populate with services here. - configurations = [ - "forgejo" - "invidious" - "mattermost" - "nextcloud" - "paperless" - "privatebin" - ]; + config, + lib, + pkgs, + ... +}: +{ + services.postgresql = + let + # Populate with services here. + configurations = [ + "forgejo" + "invidious" + "mattermost" + "nextcloud" + "paperless" + "privatebin" + ]; - ensureDatabases = [ "root" ] ++ configurations; + ensureDatabases = [ "root" ] ++ configurations; - ensureUsers = map (name: { - inherit name; - ensureDBOwnership = true; - ensureClauses = if name == "root" then { - createdb = true; - createrole = true; - superuser = true; - } else { }; - }) ensureDatabases; + ensureUsers = map (name: { + inherit name; + ensureDBOwnership = true; + ensureClauses = + if name == "root" then + { + createdb = true; + createrole = true; + superuser = true; + } + else + { }; + }) ensureDatabases; - authentication = "local all all trust"; - in { - inherit authentication ensureDatabases ensureUsers; + authentication = "local all all trust"; + in + { + inherit authentication ensureDatabases ensureUsers; - enable = true; - dataDir = "/var/lib/postgresql/14"; - package = pkgs.postgresql_14; + enable = true; + dataDir = "/var/lib/postgresql/14"; + package = pkgs.postgresql_14; - # NOTE: Debug mode. - # settings = { - # log_connections = true; - # log_destination = lib.mkForce "syslog"; - # log_disconnections = true; - # log_statement = "all"; - # logging_collector = true; - # }; - }; + # NOTE: Debug mode. + # settings = { + # log_connections = true; + # log_destination = lib.mkForce "syslog"; + # log_disconnections = true; + # log_statement = "all"; + # logging_collector = true; + # }; + }; } diff --git a/host/x86_64-linux/home/Privatebin.nix b/host/x86_64-linux/home/Privatebin.nix index 6350f295..45bcf4b4 100644 --- a/host/x86_64-linux/home/Privatebin.nix +++ b/host/x86_64-linux/home/Privatebin.nix @@ -1,45 +1,43 @@ +{ __findFile, pkgs, ... }@args: +let + package = (pkgs.callPackage args); +in { - __findFile, - pkgs, - ... -} @args: let - package = (pkgs.callPackage args); -in { - environment.systemPackages = [ package ]; - systemd.packages = [ package ]; + environment.systemPackages = [ package ]; + systemd.packages = [ package ]; - users.users.paste = { - group = "nginx"; - isSystemUser = true; - }; + users.users.paste = { + group = "nginx"; + isSystemUser = true; + }; - services = { - phpfpm.pools.paste = { - group = "nginx"; - user = "paste"; - phpPackage = pkgs.php; - settings = { - "catch_workers_output" = true; - "listen.owner" = "nginx"; - "php_admin_flag[log_errors]" = true; - "php_admin_value[error_log]" = "stderr"; - "pm" = "dynamic"; - "pm.max_children" = "32"; - "pm.max_requests" = "500"; - "pm.max_spare_servers" = "4"; - "pm.min_spare_servers" = "2"; - "pm.start_servers" = "2"; - }; - phpEnv = { - # CONFIG_PATH = "${package}/cfg"; # NOTE: Not working? - }; - }; + services = { + phpfpm.pools.paste = { + group = "nginx"; + user = "paste"; + phpPackage = pkgs.php; + settings = { + "catch_workers_output" = true; + "listen.owner" = "nginx"; + "php_admin_flag[log_errors]" = true; + "php_admin_value[error_log]" = "stderr"; + "pm" = "dynamic"; + "pm.max_children" = "32"; + "pm.max_requests" = "500"; + "pm.max_spare_servers" = "4"; + "pm.min_spare_servers" = "2"; + "pm.start_servers" = "2"; + }; + phpEnv = { + # CONFIG_PATH = "${package}/cfg"; # NOTE: Not working? + }; + }; - nginx = { - enable = true; - virtualHosts."paste.voronind.com" = { - root = "${package}"; - }; - }; - }; + nginx = { + enable = true; + virtualHosts."paste.voronind.com" = { + root = "${package}"; + }; + }; + }; } diff --git a/host/x86_64-linux/home/Rabbitmq.nix b/host/x86_64-linux/home/Rabbitmq.nix index b9471a02..c4613fa1 100644 --- a/host/x86_64-linux/home/Rabbitmq.nix +++ b/host/x86_64-linux/home/Rabbitmq.nix @@ -1,8 +1,9 @@ -{ ... }: { - services.rabbitmq = { - enable = true; - # configItems = { - # "loopback_users" = "none"; - # }; - }; +{ ... }: +{ + services.rabbitmq = { + enable = true; + # configItems = { + # "loopback_users" = "none"; + # }; + }; } diff --git a/host/x86_64-linux/home/Redis.nix b/host/x86_64-linux/home/Redis.nix index 46e8109f..31d7b635 100644 --- a/host/x86_64-linux/home/Redis.nix +++ b/host/x86_64-linux/home/Redis.nix @@ -1,9 +1,10 @@ -{ ... }: { - services.redis.servers.main = { - enable = true; - # port = cfg.port; - # extraParams = [ - # "--protected-mode no" - # ]; - }; +{ ... }: +{ + services.redis.servers.main = { + enable = true; + # port = cfg.port; + # extraParams = [ + # "--protected-mode no" + # ]; + }; } diff --git a/host/x86_64-linux/home/SearX.nix b/host/x86_64-linux/home/SearX.nix index 80ccd8eb..a22bd803 100644 --- a/host/x86_64-linux/home/SearX.nix +++ b/host/x86_64-linux/home/SearX.nix @@ -1,108 +1,107 @@ +{ config, pkgs, ... }: { - config, - pkgs, - ... -}: { - services.searx = { - enable = true; - package = pkgs.searxng; - # REF: https://github.com/searxng/searxng/blob/master/searx/settings.yml - settings = { - general = { - debug = false; - enable_metrics = false; - instance_name = "SearX"; - }; - server = { - # bind_address = cfg.address; - image_proxy = false; - limiter = false; - method = "GET"; - port = 34972; - public_instance = false; - secret_key = "searxxx"; - }; - search = { - autocomplete = ""; - autocomplete_min = 4; - default_lang = "auto"; - safe_search = 0; - }; - ui = { - center_alignment = false; - default_locale = ""; - default_theme = "simple"; - hotkeys = "vim"; - infinite_scroll = false; - simple_style = "dark"; - }; - outgoing = { - enable_http2 = true; - max_request_timeout = 10.0; - pool_connections = 100; - pool_maxsize = 20; - request_timeout = 3.0; - # proxies = { - # "all://" = with config.container.module; [ - # # "socks5:${frkn.address}:${frkn.port}" - # "socks5:${frkn.address}:1081" - # # "socks5:${frkn.address}:9150" - # ]; - # }; - # using_tor_proxy = true; - # extra_proxy_timeout = 10; - }; - # plugins = [ ]; - enabled_plugins = [ - "Basic Calculator" - "Hostnames plugin" - "Tracker URL remover" - ]; - hostnames = { - replace = { - "(.*\.)?youtu\.be$" = "yt.voronind.com"; - "(.*\.)?youtube\.com$" = "yt.voronind.com"; - }; - remove = [ - "(.*\.)?dzen\.ru$" - "(.*\.)?facebook.com$" - "(.*\.)?gosuslugi\.ru$" - "(.*\.)?quora\.com$" - "(.*\.)?rutube\.ru$" - "(.*\.)?vk\.com$" - ]; - low_priority = [ - "(.*\.)?google(\..*)?$" - "(.*\.)?microsoft\.com$" - ]; - high_priority = [ - "(.*\.)?4pda.to$" - "(.*\.)?github.com$" - "(.*\.)?wikipedia.org$" - ]; - }; - categories_as_tabs = { - files = { }; - general = { }; - images = { }; - it = { }; - map = { }; - news = { }; - videos = { }; - }; - engines = let - mkEnable = name: { - inherit name; - disabled = false; - }; - mkDisable = name: { - inherit name; - disabled = true; - }; - in [ - (mkEnable "bing") - (mkDisable "qwant") - ]; - }; - }; + services.searx = { + enable = true; + package = pkgs.searxng; + # REF: https://github.com/searxng/searxng/blob/master/searx/settings.yml + settings = { + general = { + debug = false; + enable_metrics = false; + instance_name = "SearX"; + }; + server = { + # bind_address = cfg.address; + image_proxy = false; + limiter = false; + method = "GET"; + port = 34972; + public_instance = false; + secret_key = "searxxx"; + }; + search = { + autocomplete = ""; + autocomplete_min = 4; + default_lang = "auto"; + safe_search = 0; + }; + ui = { + center_alignment = false; + default_locale = ""; + default_theme = "simple"; + hotkeys = "vim"; + infinite_scroll = false; + simple_style = "dark"; + }; + outgoing = { + enable_http2 = true; + max_request_timeout = 10.0; + pool_connections = 100; + pool_maxsize = 20; + request_timeout = 3.0; + # proxies = { + # "all://" = with config.container.module; [ + # # "socks5:${frkn.address}:${frkn.port}" + # "socks5:${frkn.address}:1081" + # # "socks5:${frkn.address}:9150" + # ]; + # }; + # using_tor_proxy = true; + # extra_proxy_timeout = 10; + }; + # plugins = [ ]; + enabled_plugins = [ + "Basic Calculator" + "Hostnames plugin" + "Tracker URL remover" + ]; + hostnames = { + replace = { + "(.*\.)?youtu\.be$" = "yt.voronind.com"; + "(.*\.)?youtube\.com$" = "yt.voronind.com"; + }; + remove = [ + "(.*\.)?dzen\.ru$" + "(.*\.)?facebook.com$" + "(.*\.)?gosuslugi\.ru$" + "(.*\.)?quora\.com$" + "(.*\.)?rutube\.ru$" + "(.*\.)?vk\.com$" + ]; + low_priority = [ + "(.*\.)?google(\..*)?$" + "(.*\.)?microsoft\.com$" + ]; + high_priority = [ + "(.*\.)?4pda.to$" + "(.*\.)?github.com$" + "(.*\.)?wikipedia.org$" + ]; + }; + categories_as_tabs = { + files = { }; + general = { }; + images = { }; + it = { }; + map = { }; + news = { }; + videos = { }; + }; + engines = + let + mkEnable = name: { + inherit name; + disabled = false; + }; + mkDisable = name: { + inherit name; + disabled = true; + }; + in + [ + (mkEnable "bing") + (mkDisable "qwant") + ]; + }; + }; } diff --git a/host/x86_64-linux/home/Terraria.nix b/host/x86_64-linux/home/Terraria.nix index b0aadeeb..c44f8fb5 100644 --- a/host/x86_64-linux/home/Terraria.nix +++ b/host/x86_64-linux/home/Terraria.nix @@ -1,20 +1,18 @@ +{ pkgs, ... }: { - pkgs, - ... -}: { - # NOTE: Admin with `tmux -S /var/lib/terraria/terraria.sock attach-session -t 0` - environment.systemPackages = with pkgs; [ tmux ]; + # NOTE: Admin with `tmux -S /var/lib/terraria/terraria.sock attach-session -t 0` + environment.systemPackages = with pkgs; [ tmux ]; - services.terraria = { - enable = true; - autoCreatedWorldSize = "large"; - messageOfTheDay = "<3"; - maxPlayers = 4; - noUPnP = false; - openFirewall = false; - password = "mishadima143"; - port = 22777; - secure = false; - worldPath = "/var/lib/terraria/.local/share/Terraria/Worlds/World.wld"; - }; + services.terraria = { + enable = true; + autoCreatedWorldSize = "large"; + messageOfTheDay = "<3"; + maxPlayers = 4; + noUPnP = false; + openFirewall = false; + password = "mishadima143"; + port = 22777; + secure = false; + worldPath = "/var/lib/terraria/.local/share/Terraria/Worlds/World.wld"; + }; } diff --git a/host/x86_64-linux/home/UptimeKuma.nix b/host/x86_64-linux/home/UptimeKuma.nix index 8ba436f9..eddee7a6 100644 --- a/host/x86_64-linux/home/UptimeKuma.nix +++ b/host/x86_64-linux/home/UptimeKuma.nix @@ -1,19 +1,17 @@ +{ lib, ... }: { - lib, - ... -}: { - services.uptime-kuma = { - enable = true; - settings = { - DATA_DIR = "/var/lib/uptime-kuma/"; - PORT = "64901"; - # HOST = cfg.address; - }; - }; + services.uptime-kuma = { + enable = true; + settings = { + DATA_DIR = "/var/lib/uptime-kuma/"; + PORT = "64901"; + # HOST = cfg.address; + }; + }; - systemd.services.uptime-kuma = { - serviceConfig = { - DynamicUser = lib.mkForce false; - }; - }; + systemd.services.uptime-kuma = { + serviceConfig = { + DynamicUser = lib.mkForce false; + }; + }; } diff --git a/host/x86_64-linux/home/Vaultwarden.nix b/host/x86_64-linux/home/Vaultwarden.nix index ffa53086..5e2e4433 100644 --- a/host/x86_64-linux/home/Vaultwarden.nix +++ b/host/x86_64-linux/home/Vaultwarden.nix @@ -1,15 +1,16 @@ -{ ... }: { - services.vaultwarden = { - enable = true; - dbBackend = "sqlite"; - environmentFile = "/var/lib/vaultwarden/Env"; - config = { - DATA_FOLDER = "/var/lib/vaultwarden"; - DOMAIN = "https://pass.voronind.com"; - # ROCKET_ADDRESS = cfg.address; - ROCKET_PORT = 8001; - SIGNUPS_ALLOWED = false; - WEB_VAULT_ENABLED = true; - }; - }; +{ ... }: +{ + services.vaultwarden = { + enable = true; + dbBackend = "sqlite"; + environmentFile = "/var/lib/vaultwarden/Env"; + config = { + DATA_FOLDER = "/var/lib/vaultwarden"; + DOMAIN = "https://pass.voronind.com"; + # ROCKET_ADDRESS = cfg.address; + ROCKET_PORT = 8001; + SIGNUPS_ALLOWED = false; + WEB_VAULT_ENABLED = true; + }; + }; } diff --git a/host/x86_64-linux/home/default.nix b/host/x86_64-linux/home/default.nix index e7ee8e94..8b992668 100644 --- a/host/x86_64-linux/home/default.nix +++ b/host/x86_64-linux/home/default.nix @@ -1,60 +1,61 @@ -{ ... }: { - home.nixos.enable = true; - user = { - root = true; - voronind = true; - }; +{ ... }: +{ + home.nixos.enable = true; + user = { + root = true; + voronind = true; + }; - module = { - builder.server.enable = true; - display.primary = "HDMI-A-1"; - purpose = { - desktop = true; - router = true; - server = true; - }; - syncthing = { - enable = true; - dataDir = "/storage/hot/sync"; - user = "root"; - group = "root"; - }; - dpi.bypass = { - enable = true; - params = [ - "--dpi-desync=fake,disorder2" + module = { + builder.server.enable = true; + display.primary = "HDMI-A-1"; + purpose = { + desktop = true; + router = true; + server = true; + }; + syncthing = { + enable = true; + dataDir = "/storage/hot/sync"; + user = "root"; + group = "root"; + }; + dpi.bypass = { + enable = true; + params = [ + "--dpi-desync=fake,disorder2" - "--dpi-desync-ttl=1" - "--dpi-desync-autottl=2" + "--dpi-desync-ttl=1" + "--dpi-desync-autottl=2" - # "--dpi-desync-ttl6=1" - # "--dpi-desync-autottl6=2" + # "--dpi-desync-ttl6=1" + # "--dpi-desync-autottl6=2" - # "--dpi-desync-any-protocol" - ]; - whitelist = [ - "youtube.com" - "googlevideo.com" - "ytimg.com" - "youtu.be" - "rutracker.org" - "rutracker.cc" - "rutrk.org" - "t-ru.org" - "medium.com" - ]; - }; - amd = { - cpu.enable = true; - gpu.enable = true; - }; - ftpd = { - enable = true; - storage = "/storage/hot/ftp"; - }; - hwmon = { - file = "temp1_input"; - path = "/sys/devices/pci0000:00/0000:00:18.3/hwmon"; - }; - }; + # "--dpi-desync-any-protocol" + ]; + whitelist = [ + "youtube.com" + "googlevideo.com" + "ytimg.com" + "youtu.be" + "rutracker.org" + "rutracker.cc" + "rutrk.org" + "t-ru.org" + "medium.com" + ]; + }; + amd = { + cpu.enable = true; + gpu.enable = true; + }; + ftpd = { + enable = true; + storage = "/storage/hot/ftp"; + }; + hwmon = { + file = "temp1_input"; + path = "/sys/devices/pci0000:00/0000:00:18.3/hwmon"; + }; + }; } diff --git a/host/x86_64-linux/home/nginx/Camera.nix b/host/x86_64-linux/home/nginx/Camera.nix index 81526afa..eead1a01 100644 --- a/host/x86_64-linux/home/nginx/Camera.nix +++ b/host/x86_64-linux/home/nginx/Camera.nix @@ -1,20 +1,18 @@ +{ ... }: { - util, - ... -}: { - "camera.voronind.com".extraConfig = util.trimTabs '' - listen 443 ssl; + "camera.voronind.com".extraConfig = '' + listen 443 ssl; - location / { - allow 10.0.0.0/8; - allow fd09:8d46:b26::/48; - deny all; - return 301 rtsp://10.0.0.12:554/live/main; - } + location / { + allow 10.0.0.0/8; + allow fd09:8d46:b26::/48; + deny all; + return 301 rtsp://10.0.0.12:554/live/main; + } - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - ''; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ''; } diff --git a/host/x86_64-linux/home/nginx/Change.nix b/host/x86_64-linux/home/nginx/Change.nix index 044c15d7..f819e3e0 100644 --- a/host/x86_64-linux/home/nginx/Change.nix +++ b/host/x86_64-linux/home/nginx/Change.nix @@ -1,23 +1,21 @@ +{ ... }: { - util, - ... -}: { - "change.voronind.com".extraConfig = util.trimTabs '' - listen 443 ssl; + "change.voronind.com".extraConfig = '' + listen 443 ssl; - location / { - allow 10.0.0.0/8; - allow fd09:8d46:b26::/48; - deny all; + location / { + allow 10.0.0.0/8; + allow fd09:8d46:b26::/48; + deny all; - proxy_pass http://127.0.0.1:5001$request_uri; + proxy_pass http://127.0.0.1:5001$request_uri; - add_header Referrer-Policy 'origin'; - } + add_header Referrer-Policy 'origin'; + } - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - ''; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ''; } diff --git a/host/x86_64-linux/home/nginx/Cups.nix b/host/x86_64-linux/home/nginx/Cups.nix index 5dfbfa8e..97474f07 100644 --- a/host/x86_64-linux/home/nginx/Cups.nix +++ b/host/x86_64-linux/home/nginx/Cups.nix @@ -1,25 +1,23 @@ +{ ... }: { - util, - ... -}: { - "print.voronind.com".extraConfig = util.trimTabs '' - listen 443 ssl; + "print.voronind.com".extraConfig = '' + listen 443 ssl; - location / { - allow 10.0.0.0/8; - allow fd09:8d46:b26::/48; - deny all; + location / { + allow 10.0.0.0/8; + allow fd09:8d46:b26::/48; + deny all; - proxy_pass http://127.0.0.1:631$request_uri; + proxy_pass http://127.0.0.1:631$request_uri; - proxy_set_header Host "127.0.0.1"; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; - } + proxy_set_header Host "127.0.0.1"; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; + } - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - ''; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ''; } diff --git a/host/x86_64-linux/home/nginx/Deluge.nix b/host/x86_64-linux/home/nginx/Deluge.nix index 684a46a4..49786710 100644 --- a/host/x86_64-linux/home/nginx/Deluge.nix +++ b/host/x86_64-linux/home/nginx/Deluge.nix @@ -1,20 +1,18 @@ +{ ... }: { - util, - ... -}: { - "download.voronind.com".extraConfig = util.trimTabs '' - listen 443 ssl; + "download.voronind.com".extraConfig = '' + listen 443 ssl; - location / { - allow 10.0.0.0/8; - allow fd09:8d46:b26::/48; - deny all; - proxy_pass http://127.0.0.1:8112$request_uri; - } + location / { + allow 10.0.0.0/8; + allow fd09:8d46:b26::/48; + deny all; + proxy_pass http://127.0.0.1:8112$request_uri; + } - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - ''; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ''; } diff --git a/host/x86_64-linux/home/nginx/Forgejo.nix b/host/x86_64-linux/home/nginx/Forgejo.nix index d5f9d626..0300b13f 100644 --- a/host/x86_64-linux/home/nginx/Forgejo.nix +++ b/host/x86_64-linux/home/nginx/Forgejo.nix @@ -1,24 +1,22 @@ +{ ... }: { - util, - ... -}: { - "git.voronind.com".extraConfig = util.trimTabs '' - listen 443 ssl; + "git.voronind.com".extraConfig = '' + listen 443 ssl; - location ~ ^/(admin|api|user) { - allow 10.0.0.0/8; - allow fd09:8d46:b26::/48; - deny all; - proxy_pass http://127.0.0.1:3000$request_uri; - } + location ~ ^/(admin|api|user) { + allow 10.0.0.0/8; + allow fd09:8d46:b26::/48; + deny all; + proxy_pass http://127.0.0.1:3000$request_uri; + } - location / { - proxy_pass http://127.0.0.1:3000$request_uri; - } + location / { + proxy_pass http://127.0.0.1:3000$request_uri; + } - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - ''; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ''; } diff --git a/host/x86_64-linux/home/nginx/Grocy.nix b/host/x86_64-linux/home/nginx/Grocy.nix index 5b8386be..b22c3fee 100644 --- a/host/x86_64-linux/home/nginx/Grocy.nix +++ b/host/x86_64-linux/home/nginx/Grocy.nix @@ -1,30 +1,26 @@ +{ config, lib, ... }: { - config, - lib, - util, - ... -}: { - "stock.voronind.com" = { - locations."~ \\.php$".extraConfig = lib.mkForce (util.trimTabs '' - allow 10.0.0.0/8; - allow fd09:8d46:b26::/48; - deny all; + "stock.voronind.com" = { + locations."~ \\.php$".extraConfig = lib.mkForce '' + allow 10.0.0.0/8; + allow fd09:8d46:b26::/48; + deny all; - fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass unix:${config.services.phpfpm.pools.grocy.socket}; - include ${config.services.nginx.package}/conf/fastcgi.conf; - include ${config.services.nginx.package}/conf/fastcgi_params; - ''); + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass unix:${config.services.phpfpm.pools.grocy.socket}; + include ${config.services.nginx.package}/conf/fastcgi.conf; + include ${config.services.nginx.package}/conf/fastcgi_params; + ''; - extraConfig = lib.mkForce (util.trimTabs '' - listen 443 ssl; + extraConfig = lib.mkForce '' + listen 443 ssl; - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - try_files $uri /index.php; - ''); - }; + try_files $uri /index.php; + ''; + }; } diff --git a/host/x86_64-linux/home/nginx/Hass.nix b/host/x86_64-linux/home/nginx/Hass.nix index f039c71f..8e6b2e23 100644 --- a/host/x86_64-linux/home/nginx/Hass.nix +++ b/host/x86_64-linux/home/nginx/Hass.nix @@ -1,27 +1,25 @@ +{ ... }: { - util, - ... -}: { - "iot.voronind.com".extraConfig = util.trimTabs '' - listen 443 ssl; + "iot.voronind.com".extraConfig = '' + listen 443 ssl; - location / { - allow 10.0.0.0/8; - allow fd09:8d46:b26::/48; - deny all; + location / { + allow 10.0.0.0/8; + allow fd09:8d46:b26::/48; + deny all; - # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $host; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; + # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $host; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; - proxy_pass http://127.0.0.1:8123$request_uri; - } + proxy_pass http://127.0.0.1:8123$request_uri; + } - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - ''; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ''; } diff --git a/host/x86_64-linux/home/nginx/Homer.nix b/host/x86_64-linux/home/nginx/Homer.nix index 63302150..cca75c6f 100644 --- a/host/x86_64-linux/home/nginx/Homer.nix +++ b/host/x86_64-linux/home/nginx/Homer.nix @@ -1,20 +1,18 @@ +{ ... }: { - util, - ... -}: { - "home.voronind.com".extraConfig = util.trimTabs '' - listen 443 ssl; + "home.voronind.com".extraConfig = '' + listen 443 ssl; - location / { - allow 10.0.0.0/8; - allow fd09:8d46:b26::/48; - deny all; - try_files $uri $uri/index.html; - } + location / { + allow 10.0.0.0/8; + allow fd09:8d46:b26::/48; + deny all; + try_files $uri $uri/index.html; + } - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - ''; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ''; } diff --git a/host/x86_64-linux/home/nginx/Invidious.nix b/host/x86_64-linux/home/nginx/Invidious.nix index 148ac138..6c66ce5a 100644 --- a/host/x86_64-linux/home/nginx/Invidious.nix +++ b/host/x86_64-linux/home/nginx/Invidious.nix @@ -1,30 +1,28 @@ +{ ... }: { - util, - ... -}: { - "yt.voronind.com".extraConfig = util.trimTabs '' - listen 443 ssl; + "yt.voronind.com".extraConfig = '' + listen 443 ssl; - location / { - allow 10.0.0.0/8; - allow fd09:8d46:b26::/48; - deny all; + location / { + allow 10.0.0.0/8; + allow fd09:8d46:b26::/48; + deny all; - proxy_pass http://127.0.0.1:3001$request_uri; + proxy_pass http://127.0.0.1:3001$request_uri; - proxy_set_header X-Forwarded-For $remote_addr; - proxy_set_header Host $host; - proxy_http_version 1.1; - proxy_set_header Connection ""; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header Host $host; + proxy_http_version 1.1; + proxy_set_header Connection ""; - proxy_hide_header Content-Security-Policy; - proxy_hide_header X-Frame-Options; - proxy_hide_header X-Content-Type-Options; - } + proxy_hide_header Content-Security-Policy; + proxy_hide_header X-Frame-Options; + proxy_hide_header X-Content-Type-Options; + } - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - ''; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ''; } diff --git a/host/x86_64-linux/home/nginx/Jellyfin.nix b/host/x86_64-linux/home/nginx/Jellyfin.nix index 0a1e1f5c..a7e61404 100644 --- a/host/x86_64-linux/home/nginx/Jellyfin.nix +++ b/host/x86_64-linux/home/nginx/Jellyfin.nix @@ -1,20 +1,18 @@ +{ ... }: { - util, - ... -}: { - "watch.voronind.com".extraConfig = util.trimTabs '' - listen 443 ssl; + "watch.voronind.com".extraConfig = '' + listen 443 ssl; - location / { - allow 10.0.0.0/8; - allow fd09:8d46:b26::/48; - deny all; - proxy_pass http://127.0.0.1:8096$request_uri; - } + location / { + allow 10.0.0.0/8; + allow fd09:8d46:b26::/48; + deny all; + proxy_pass http://127.0.0.1:8096$request_uri; + } - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - ''; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ''; } diff --git a/host/x86_64-linux/home/nginx/Kavita.nix b/host/x86_64-linux/home/nginx/Kavita.nix index b363fb37..a68bc9c8 100644 --- a/host/x86_64-linux/home/nginx/Kavita.nix +++ b/host/x86_64-linux/home/nginx/Kavita.nix @@ -1,20 +1,18 @@ +{ ... }: { - util, - ... -}: { - "read.voronind.com".extraConfig = util.trimTabs '' - listen 443 ssl; + "read.voronind.com".extraConfig = '' + listen 443 ssl; - location / { - allow 10.0.0.0/8; - allow fd09:8d46:b26::/48; - deny all; - proxy_pass http://127.0.0.1:5000$request_uri; - } + location / { + allow 10.0.0.0/8; + allow fd09:8d46:b26::/48; + deny all; + proxy_pass http://127.0.0.1:5000$request_uri; + } - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - ''; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ''; } diff --git a/host/x86_64-linux/home/nginx/Mailserver.nix b/host/x86_64-linux/home/nginx/Mailserver.nix index 43dfa0d2..3d0ed923 100644 --- a/host/x86_64-linux/home/nginx/Mailserver.nix +++ b/host/x86_64-linux/home/nginx/Mailserver.nix @@ -1,29 +1,25 @@ +{ config, lib, ... }: { - config, - lib, - util, - ... -}: { - "mail.voronind.com" = { - enableACME = false; - forceSSL = false; - locations."~* \\.php(/|$)".extraConfig = lib.mkForce (util.trimTabs '' - allow 10.0.0.0/8; - allow fd09:8d46:b26::/48; - deny all; + "mail.voronind.com" = { + enableACME = false; + forceSSL = false; + locations."~* \\.php(/|$)".extraConfig = lib.mkForce '' + allow 10.0.0.0/8; + allow fd09:8d46:b26::/48; + deny all; - fastcgi_pass unix:${config.services.phpfpm.pools.roundcube.socket}; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_split_path_info ^(.+\.php)(/.+)$; - include ${config.services.nginx.package}/conf/fastcgi.conf; - ''); - extraConfig = lib.mkForce (util.trimTabs '' - listen 443 ssl; + fastcgi_pass unix:${config.services.phpfpm.pools.roundcube.socket}; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + include ${config.services.nginx.package}/conf/fastcgi.conf; + ''; + extraConfig = lib.mkForce '' + listen 443 ssl; - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - ''); - }; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ''; + }; } diff --git a/host/x86_64-linux/home/nginx/Nextcloud.nix b/host/x86_64-linux/home/nginx/Nextcloud.nix index 1021ce21..e386a3fb 100644 --- a/host/x86_64-linux/home/nginx/Nextcloud.nix +++ b/host/x86_64-linux/home/nginx/Nextcloud.nix @@ -1,22 +1,20 @@ +{ ... }: { - util, - ... -}: { - "cloud.voronind.com" = { - locations."~ ^/(settings/admin|settings/users|settings/apps|login|api)".extraConfig = util.trimTabs '' - allow 10.0.0.0/8; - allow fd09:8d46:b26::/48; - deny all; - try_files $uri $uri/ /index.php$request_uri; - ''; + "cloud.voronind.com" = { + locations."~ ^/(settings/admin|settings/users|settings/apps|login|api)".extraConfig = '' + allow 10.0.0.0/8; + allow fd09:8d46:b26::/48; + deny all; + try_files $uri $uri/ /index.php$request_uri; + ''; - extraConfig = util.trimTabs '' - listen 443 ssl; + extraConfig = '' + listen 443 ssl; - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - ''; - }; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ''; + }; } diff --git a/host/x86_64-linux/home/nginx/OnlyOffice.nix b/host/x86_64-linux/home/nginx/OnlyOffice.nix index cb4e3c14..9d07345e 100644 --- a/host/x86_64-linux/home/nginx/OnlyOffice.nix +++ b/host/x86_64-linux/home/nginx/OnlyOffice.nix @@ -1,21 +1,18 @@ +{ lib, ... }: { - lib, - util, - ... -}: { - "office.voronind.com" = { - locations."/".extraConfig = lib.mkForce (util.trimTabs '' - add_header X-Forwarded-Proto https; - proxy_pass http://127.0.0.1:8000$request_uri; - ''); + "office.voronind.com" = { + locations."/".extraConfig = lib.mkForce '' + add_header X-Forwarded-Proto https; + proxy_pass http://127.0.0.1:8000$request_uri; + ''; - extraConfig = util.trimTabs '' - listen 443 ssl; + extraConfig = '' + listen 443 ssl; - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - ''; - }; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ''; + }; } diff --git a/host/x86_64-linux/home/nginx/Paperless.nix b/host/x86_64-linux/home/nginx/Paperless.nix index a49f4a5e..a07d9053 100644 --- a/host/x86_64-linux/home/nginx/Paperless.nix +++ b/host/x86_64-linux/home/nginx/Paperless.nix @@ -1,20 +1,18 @@ +{ ... }: { - util, - ... -}: { - "paper.voronind.com".extraConfig = util.trimTabs '' - listen 443 ssl; + "paper.voronind.com".extraConfig = '' + listen 443 ssl; - location / { - allow 10.0.0.0/8; - allow fd09:8d46:b26::/48; - deny all; - proxy_pass http://127.0.0.1:28981$request_uri; - } + location / { + allow 10.0.0.0/8; + allow fd09:8d46:b26::/48; + deny all; + proxy_pass http://127.0.0.1:28981$request_uri; + } - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - ''; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ''; } diff --git a/host/x86_64-linux/home/nginx/Printer.nix b/host/x86_64-linux/home/nginx/Printer.nix index da210a76..70076c7f 100644 --- a/host/x86_64-linux/home/nginx/Printer.nix +++ b/host/x86_64-linux/home/nginx/Printer.nix @@ -1,20 +1,18 @@ +{ ... }: { - util, - ... -}: { - "printer.voronind.com".extraConfig = util.trimTabs '' - listen 443 ssl; + "printer.voronind.com".extraConfig = '' + listen 443 ssl; - location / { - allow 10.0.0.0/8; - allow fd09:8d46:b26::/48; - deny all; - proxy_pass http://10.0.0.10:80$request_uri; - } + location / { + allow 10.0.0.0/8; + allow fd09:8d46:b26::/48; + deny all; + proxy_pass http://10.0.0.10:80$request_uri; + } - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - ''; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ''; } diff --git a/host/x86_64-linux/home/nginx/Privatebin.nix b/host/x86_64-linux/home/nginx/Privatebin.nix index af5178ff..6478f40f 100644 --- a/host/x86_64-linux/home/nginx/Privatebin.nix +++ b/host/x86_64-linux/home/nginx/Privatebin.nix @@ -1,44 +1,41 @@ +{ config, ... }: { - config, - util, - ... -}: { - "paste.voronind.com" = { - locations = { - "= /".extraConfig = util.trimTabs '' - return 403; - ''; + "paste.voronind.com" = { + locations = { + "= /".extraConfig = '' + return 403; + ''; - "~ \\.php$".extraConfig = util.trimTabs '' - fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass unix:${config.services.phpfpm.pools.paste.socket}; - include ${config.services.nginx.package}/conf/fastcgi.conf; - include ${config.services.nginx.package}/conf/fastcgi_params; - ''; + "~ \\.php$".extraConfig = '' + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass unix:${config.services.phpfpm.pools.paste.socket}; + include ${config.services.nginx.package}/conf/fastcgi.conf; + include ${config.services.nginx.package}/conf/fastcgi_params; + ''; - "~ \\.(js|css|ttf|woff2?|png|jpe?g|svg)$".extraConfig = util.trimTabs '' - add_header Cache-Control "public, max-age=15778463"; - add_header Referrer-Policy no-referrer; - add_header X-Content-Type-Options nosniff; - add_header X-Download-Options noopen; - add_header X-Permitted-Cross-Domain-Policies none; - add_header X-Robots-Tag none; - add_header X-XSS-Protection "1; mode=block"; - access_log off; - ''; + "~ \\.(js|css|ttf|woff2?|png|jpe?g|svg)$".extraConfig = '' + add_header Cache-Control "public, max-age=15778463"; + add_header Referrer-Policy no-referrer; + add_header X-Content-Type-Options nosniff; + add_header X-Download-Options noopen; + add_header X-Permitted-Cross-Domain-Policies none; + add_header X-Robots-Tag none; + add_header X-XSS-Protection "1; mode=block"; + access_log off; + ''; - "/".extraConfig = util.trimTabs '' - rewrite ^ /index.php; - ''; - }; + "/".extraConfig = '' + rewrite ^ /index.php; + ''; + }; - extraConfig = util.trimTabs '' - listen 443 ssl; - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - try_files $uri /index.php; - ''; - }; + extraConfig = '' + listen 443 ssl; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + try_files $uri /index.php; + ''; + }; } diff --git a/host/x86_64-linux/home/nginx/Resume.nix b/host/x86_64-linux/home/nginx/Resume.nix index 7fdceebf..ec605a43 100644 --- a/host/x86_64-linux/home/nginx/Resume.nix +++ b/host/x86_64-linux/home/nginx/Resume.nix @@ -1,20 +1,18 @@ +{ ... }: { - util, - ... -}: { - "resume.voronind.com".extraConfig = util.trimTabs '' - server_name resume.voronind.com; - listen 443 ssl; + "resume.voronind.com".extraConfig = '' + server_name resume.voronind.com; + listen 443 ssl; - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - if ($http_accept_language ~ ru) { - return 301 https://git.voronind.com/voronind/resume/releases/download/latest/VoronindRu.pdf; - } + if ($http_accept_language ~ ru) { + return 301 https://git.voronind.com/voronind/resume/releases/download/latest/VoronindRu.pdf; + } - return 301 https://git.voronind.com/voronind/resume/releases/download/latest/VoronindEn.pdf; - ''; + return 301 https://git.voronind.com/voronind/resume/releases/download/latest/VoronindEn.pdf; + ''; } diff --git a/host/x86_64-linux/home/nginx/Router.nix b/host/x86_64-linux/home/nginx/Router.nix index 97383970..3b859bc7 100644 --- a/host/x86_64-linux/home/nginx/Router.nix +++ b/host/x86_64-linux/home/nginx/Router.nix @@ -1,20 +1,18 @@ +{ ... }: { - util, - ... -}: { - "router.voronind.com".extraConfig = util.trimTabs '' - listen 443 ssl; + "router.voronind.com".extraConfig = '' + listen 443 ssl; - location / { - allow 10.0.0.0/8; - allow fd09:8d46:b26::/48; - deny all; - proxy_pass http://10.0.0.2:80$request_uri; - } + location / { + allow 10.0.0.0/8; + allow fd09:8d46:b26::/48; + deny all; + proxy_pass http://10.0.0.2:80$request_uri; + } - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - ''; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ''; } diff --git a/host/x86_64-linux/home/nginx/SearX.nix b/host/x86_64-linux/home/nginx/SearX.nix index 48c6c64f..5fa9306b 100644 --- a/host/x86_64-linux/home/nginx/SearX.nix +++ b/host/x86_64-linux/home/nginx/SearX.nix @@ -1,20 +1,18 @@ +{ ... }: { - util, - ... -}: { - "search.voronind.com".extraConfig = util.trimTabs '' - listen 443 ssl; + "search.voronind.com".extraConfig = '' + listen 443 ssl; - location / { - allow 10.0.0.0/8; - allow fd09:8d46:b26::/48; - deny all; - proxy_pass http://127.0.0.1:34972$request_uri; - } + location / { + allow 10.0.0.0/8; + allow fd09:8d46:b26::/48; + deny all; + proxy_pass http://127.0.0.1:34972$request_uri; + } - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - ''; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ''; } diff --git a/host/x86_64-linux/home/nginx/Sync.nix b/host/x86_64-linux/home/nginx/Sync.nix index 8a57f65e..37b8406f 100644 --- a/host/x86_64-linux/home/nginx/Sync.nix +++ b/host/x86_64-linux/home/nginx/Sync.nix @@ -1,24 +1,22 @@ +{ ... }: { - util, - ... -}: { - "sync.voronind.com".extraConfig = util.trimTabs '' - listen 443 ssl; + "sync.voronind.com".extraConfig = '' + listen 443 ssl; - location / { - allow 10.0.0.0/8; - allow fd09:8d46:b26::/48; - deny all; + location / { + allow 10.0.0.0/8; + allow fd09:8d46:b26::/48; + deny all; - proxy_set_header Host "localhost"; - proxy_set_header X-Forwarded-Host "localhost"; + proxy_set_header Host "localhost"; + proxy_set_header X-Forwarded-Host "localhost"; - proxy_pass http://127.0.0.1:8384$request_uri; - } + proxy_pass http://127.0.0.1:8384$request_uri; + } - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - ''; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ''; } diff --git a/host/x86_64-linux/home/nginx/UptimeKuma.nix b/host/x86_64-linux/home/nginx/UptimeKuma.nix index c7726e2c..a560658f 100644 --- a/host/x86_64-linux/home/nginx/UptimeKuma.nix +++ b/host/x86_64-linux/home/nginx/UptimeKuma.nix @@ -1,20 +1,18 @@ +{ ... }: { - util, - ... -}: { - "status.voronind.com".extraConfig = util.trimTabs '' - listen 443 ssl; + "status.voronind.com".extraConfig = '' + listen 443 ssl; - location / { - allow 10.0.0.0/8; - allow fd09:8d46:b26::/48; - deny all; - proxy_pass http://127.0.0.1:64901$request_uri; - } + location / { + allow 10.0.0.0/8; + allow fd09:8d46:b26::/48; + deny all; + proxy_pass http://127.0.0.1:64901$request_uri; + } - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - ''; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ''; } diff --git a/host/x86_64-linux/home/nginx/Valutwarden.nix b/host/x86_64-linux/home/nginx/Valutwarden.nix index aee257b6..6527b6da 100644 --- a/host/x86_64-linux/home/nginx/Valutwarden.nix +++ b/host/x86_64-linux/home/nginx/Valutwarden.nix @@ -1,20 +1,18 @@ +{ ... }: { - util, - ... -}: { - "pass.voronind.com".extraConfig = util.trimTabs '' - listen 443 ssl; + "pass.voronind.com".extraConfig = '' + listen 443 ssl; - location / { - allow 10.0.0.0/8; - allow fd09:8d46:b26::/48; - deny all; - proxy_pass http://127.0.0.1:8001$request_uri; - } + location / { + allow 10.0.0.0/8; + allow fd09:8d46:b26::/48; + deny all; + proxy_pass http://127.0.0.1:8001$request_uri; + } - ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; - include /etc/letsencrypt/conf/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; - ''; + ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem; + include /etc/letsencrypt/conf/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; + ''; } diff --git a/host/x86_64-linux/laptop/Network.nix b/host/x86_64-linux/laptop/Network.nix index fd04c4c8..b2961996 100644 --- a/host/x86_64-linux/laptop/Network.nix +++ b/host/x86_64-linux/laptop/Network.nix @@ -1,9 +1,10 @@ -{ ... }: { - networking = { - firewall.extraCommands = '' - # Local access. - iptables -I INPUT -j ACCEPT -s 10.0.0.0/8 - ip6tables -I INPUT -j ACCEPT -s fd09:8d46:0b26::/48 - ''; - }; +{ ... }: +{ + networking = { + firewall.extraCommands = '' + # Local access. + iptables -I INPUT -j ACCEPT -s 10.0.0.0/8 + ip6tables -I INPUT -j ACCEPT -s fd09:8d46:0b26::/48 + ''; + }; } diff --git a/host/x86_64-linux/laptop/default.nix b/host/x86_64-linux/laptop/default.nix index 545752ca..3c027fe8 100644 --- a/host/x86_64-linux/laptop/default.nix +++ b/host/x86_64-linux/laptop/default.nix @@ -1,33 +1,34 @@ -{ ... }: { - home.nixos.enable = true; - user = { - dasha = true; - root = true; - voronind = true; - }; +{ ... }: +{ + home.nixos.enable = true; + user = { + dasha = true; + root = true; + voronind = true; + }; - module = { - builder.client.enable = true; - display.primary = "eDP-1"; - print.enable = true; - purpose = { - creative = true; - disown = true; - gaming = true; - laptop = true; - work = true; - }; - syncthing = { - enable = true; - user = "dasha"; - }; - amd = { - compute.enable = true; - cpu = { - enable = true; - powersave = true; - }; - gpu.enable = true; - }; - }; + module = { + builder.client.enable = true; + display.primary = "eDP-1"; + print.enable = true; + purpose = { + creative = true; + disown = true; + gaming = true; + laptop = true; + work = true; + }; + syncthing = { + enable = true; + user = "dasha"; + }; + amd = { + compute.enable = true; + cpu = { + enable = true; + powersave = true; + }; + gpu.enable = true; + }; + }; } diff --git a/host/x86_64-linux/live/default.nix b/host/x86_64-linux/live/default.nix index b3271265..5ad665b7 100644 --- a/host/x86_64-linux/live/default.nix +++ b/host/x86_64-linux/live/default.nix @@ -1,30 +1,27 @@ +{ inputs, lib, ... }: { - inputs, - lib, - ... -}: { - imports = [ - "${inputs.nixpkgs}/nixos/modules/installer/cd-dvd/channel.nix" - "${inputs.nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix" - ]; + imports = [ + "${inputs.nixpkgs}/nixos/modules/installer/cd-dvd/channel.nix" + "${inputs.nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix" + ]; - networking.wireless.enable = lib.mkForce false; + networking.wireless.enable = lib.mkForce false; - # Override my settings to allow SSH logins using root password. - services.openssh.settings = { - PasswordAuthentication = lib.mkForce true; - PermitRootLogin = lib.mkForce "yes"; - }; + # Override my settings to allow SSH logins using root password. + services.openssh.settings = { + PasswordAuthentication = lib.mkForce true; + PermitRootLogin = lib.mkForce "yes"; + }; - # Root user setup. - home.nixos.enable = true; - user = { - root = true; - voronind = true; - }; + # Root user setup. + home.nixos.enable = true; + user = { + root = true; + voronind = true; + }; - module = { - builder.client.enable = true; - purpose.live = true; - }; + module = { + builder.client.enable = true; + purpose.live = true; + }; } diff --git a/host/x86_64-linux/max/Filesystem.nix b/host/x86_64-linux/max/Filesystem.nix index 30d37b43..950b0bcf 100644 --- a/host/x86_64-linux/max/Filesystem.nix +++ b/host/x86_64-linux/max/Filesystem.nix @@ -1,19 +1,18 @@ -{ ... }: { - fileSystems = { - "/home" = { - device = "/dev/storage/home"; - fsType = "ext4"; - options = [ - "noatime" - ]; - }; - }; +{ ... }: +{ + fileSystems = { + "/home" = { + device = "/dev/storage/home"; + fsType = "ext4"; + options = [ "noatime" ]; + }; + }; - swapDevices = [{ - device = "/dev/storage/swap"; - randomEncryption.enable = true; - options = [ - "nofail" - ]; - }]; + swapDevices = [ + { + device = "/dev/storage/swap"; + randomEncryption.enable = true; + options = [ "nofail" ]; + } + ]; } diff --git a/host/x86_64-linux/max/Network.nix b/host/x86_64-linux/max/Network.nix index fd04c4c8..b2961996 100644 --- a/host/x86_64-linux/max/Network.nix +++ b/host/x86_64-linux/max/Network.nix @@ -1,9 +1,10 @@ -{ ... }: { - networking = { - firewall.extraCommands = '' - # Local access. - iptables -I INPUT -j ACCEPT -s 10.0.0.0/8 - ip6tables -I INPUT -j ACCEPT -s fd09:8d46:0b26::/48 - ''; - }; +{ ... }: +{ + networking = { + firewall.extraCommands = '' + # Local access. + iptables -I INPUT -j ACCEPT -s 10.0.0.0/8 + ip6tables -I INPUT -j ACCEPT -s fd09:8d46:0b26::/48 + ''; + }; } diff --git a/host/x86_64-linux/max/Power.nix b/host/x86_64-linux/max/Power.nix index d10de60f..82b806c4 100644 --- a/host/x86_64-linux/max/Power.nix +++ b/host/x86_64-linux/max/Power.nix @@ -1,100 +1,98 @@ +{ __findFile, pkgs, ... }: +let + wm2fc = pkgs.callPackage { }; +in { - __findFile, - pkgs, - ... -}: let - wm2fc = pkgs.callPackage {}; -in { - # hardware.cpu.amd.ryzen-smu.enable = true; + # hardware.cpu.amd.ryzen-smu.enable = true; - environment.systemPackages = with pkgs; [ - # SRC: https://github.com/FlyGoat/RyzenAdj - # ./ryzenadj --stapm-limit=45000 --fast-limit=45000 --slow-limit=45000 --tctl-temp=90 - # ryzenAdj --info - # radg [TEMP] - ryzenadj + environment.systemPackages = with pkgs; [ + # SRC: https://github.com/FlyGoat/RyzenAdj + # ./ryzenadj --stapm-limit=45000 --fast-limit=45000 --slow-limit=45000 --tctl-temp=90 + # ryzenAdj --info + # radg [TEMP] + ryzenadj - # SRC: https://github.com/nbfc-linux/nbfc-linux - nbfc-linux + # SRC: https://github.com/nbfc-linux/nbfc-linux + nbfc-linux - wm2fc - ]; + wm2fc + ]; - systemd.services.radj = { - enable = true; - description = "Ryzen Adj temperature limiter."; - serviceConfig.Type = "simple"; - wantedBy = [ "multi-user.target" ]; - path = with pkgs; [ - coreutils - ryzenadj - ]; - script = '' - ryzenadj --tctl-temp=55 - while true; do - sleep 60 - ryzenadj --tctl-temp=55 &> /dev/null - done - ''; - }; + systemd.services.radj = { + enable = true; + description = "Ryzen Adj temperature limiter."; + serviceConfig.Type = "simple"; + wantedBy = [ "multi-user.target" ]; + path = with pkgs; [ + coreutils + ryzenadj + ]; + script = '' + ryzenadj --tctl-temp=55 + while true; do + sleep 60 + ryzenadj --tctl-temp=55 &> /dev/null + done + ''; + }; - systemd.services.fan = { - enable = true; - description = "The fan control"; - wantedBy = [ "multi-user.target" ]; - serviceConfig = { - ExecStop = "${wm2fc}/bin/wm2fc a"; - Type = "simple"; - }; - path = with pkgs; [ - coreutils - wm2fc - ]; - script = '' - old=0 - smooth=0 - while true; do - temp=$(cat /sys/devices/pci0000\:00/0000\:00\:18.3/hwmon/*/temp1_input) - value=0 + systemd.services.fan = { + enable = true; + description = "The fan control"; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + ExecStop = "${wm2fc}/bin/wm2fc a"; + Type = "simple"; + }; + path = with pkgs; [ + coreutils + wm2fc + ]; + script = '' + old=0 + smooth=0 + while true; do + temp=$(cat /sys/devices/pci0000\:00/0000\:00\:18.3/hwmon/*/temp1_input) + value=0 - if [ $temp -gt 80000 ] - then value=184 - elif [ $temp -gt 70000 ] - then value=128 - elif [ $temp -gt 60000 ] - then value=92 - # elif [ $temp -gt 50000 ] - # then value=69 - elif [ $temp -gt 45000 ] - then value=46 - elif [ $temp -gt 40000 ] - then value=23 - else value=0 - fi + if [ $temp -gt 80000 ] + then value=184 + elif [ $temp -gt 70000 ] + then value=128 + elif [ $temp -gt 60000 ] + then value=92 + # elif [ $temp -gt 50000 ] + # then value=69 + elif [ $temp -gt 45000 ] + then value=46 + elif [ $temp -gt 40000 ] + then value=23 + else value=0 + fi - if [[ $old != $value ]]; then - # 30 = 60s smooth. - if [[ $value -lt $old ]] && [[ $smooth -lt 30 ]]; then - smooth=$((smooth+1)) - else - old=$value - smooth=0 - wm2fc $value - fi - else - smooth=0 - fi + if [[ $old != $value ]]; then + # 30 = 60s smooth. + if [[ $value -lt $old ]] && [[ $smooth -lt 30 ]]; then + smooth=$((smooth+1)) + else + old=$value + smooth=0 + wm2fc $value + fi + else + smooth=0 + fi - sleep 2 - done - ''; - }; + sleep 2 + done + ''; + }; - # security.wrappers.wm2fc = { - # source = "${wm2fc}/bin/wm2fc"; - # owner = "root"; - # group = "root"; - # setuid = true; - # permissions = "u+rx,g+x,o+x"; - # }; + # security.wrappers.wm2fc = { + # source = "${wm2fc}/bin/wm2fc"; + # owner = "root"; + # group = "root"; + # setuid = true; + # permissions = "u+rx,g+x,o+x"; + # }; } diff --git a/host/x86_64-linux/max/Sleep.nix b/host/x86_64-linux/max/Sleep.nix index 5e47a89e..dbf1946b 100644 --- a/host/x86_64-linux/max/Sleep.nix +++ b/host/x86_64-linux/max/Sleep.nix @@ -1,10 +1,8 @@ +{ ... }: { - util, - ... -}: { - # REF: https://github.com/Sabrina-Fox/WM2-Help#known-wm2-2023-specific-issues-linux - services.udev.extraRules = util.trimTabs '' - SUBSYSTEM=="i2c", KERNEL=="i2c-PNP0C50:00", ATTR{power/wakeup}="disabled" - SUBSYSTEM=="i2c", KERNEL=="i2c-GXTP7385:00", ATTR{power/wakeup}="disabled" - ''; + # REF: https://github.com/Sabrina-Fox/WM2-Help#known-wm2-2023-specific-issues-linux + services.udev.extraRules = '' + SUBSYSTEM=="i2c", KERNEL=="i2c-PNP0C50:00", ATTR{power/wakeup}="disabled" + SUBSYSTEM=="i2c", KERNEL=="i2c-GXTP7385:00", ATTR{power/wakeup}="disabled" + ''; } diff --git a/host/x86_64-linux/max/default.nix b/host/x86_64-linux/max/default.nix index 59a416e1..dcfe9113 100644 --- a/host/x86_64-linux/max/default.nix +++ b/host/x86_64-linux/max/default.nix @@ -1,42 +1,37 @@ # SEE: https://github.com/Sabrina-Fox/WM2-Help +{ __findFile, pkgs, ... }: { - __findFile, - pkgs, - ... -}: { - home.nixos.enable = true; - user = { - root = true; - voronind = true; - }; + home.nixos.enable = true; + user = { + root = true; + voronind = true; + }; - module = { - builder.client.enable = true; - package.extra = true; - print.enable = true; - syncthing.enable = true; - purpose = { - creative = true; - gaming = true; - laptop = true; - work = true; - }; - display = { - primary = "eDP-1"; - }; - sway.extraConfig = [ - "output eDP-1 scale 1.75" - ]; - hwmon = { - file = "temp1_input"; - path = "/sys/devices/pci0000:00/0000:00:18.3/hwmon"; - }; - amd = { - gpu.enable = true; - cpu = { - enable = true; - powersave = true; - }; - }; - }; + module = { + builder.client.enable = true; + package.extra = true; + print.enable = true; + syncthing.enable = true; + purpose = { + creative = true; + gaming = true; + laptop = true; + work = true; + }; + display = { + primary = "eDP-1"; + }; + sway.extraConfig = [ "output eDP-1 scale 1.75" ]; + hwmon = { + file = "temp1_input"; + path = "/sys/devices/pci0000:00/0000:00:18.3/hwmon"; + }; + amd = { + gpu.enable = true; + cpu = { + enable = true; + powersave = true; + }; + }; + }; } diff --git a/host/x86_64-linux/pocket/Logind.nix b/host/x86_64-linux/pocket/Logind.nix index a5730e50..cd139de8 100644 --- a/host/x86_64-linux/pocket/Logind.nix +++ b/host/x86_64-linux/pocket/Logind.nix @@ -1,4 +1,5 @@ -{ ... }: { - # Don't suspend on lid closed. - services.logind.lidSwitch = "ignore"; +{ ... }: +{ + # Don't suspend on lid closed. + services.logind.lidSwitch = "ignore"; } diff --git a/host/x86_64-linux/pocket/Network.nix b/host/x86_64-linux/pocket/Network.nix index fd04c4c8..b2961996 100644 --- a/host/x86_64-linux/pocket/Network.nix +++ b/host/x86_64-linux/pocket/Network.nix @@ -1,9 +1,10 @@ -{ ... }: { - networking = { - firewall.extraCommands = '' - # Local access. - iptables -I INPUT -j ACCEPT -s 10.0.0.0/8 - ip6tables -I INPUT -j ACCEPT -s fd09:8d46:0b26::/48 - ''; - }; +{ ... }: +{ + networking = { + firewall.extraCommands = '' + # Local access. + iptables -I INPUT -j ACCEPT -s 10.0.0.0/8 + ip6tables -I INPUT -j ACCEPT -s fd09:8d46:0b26::/48 + ''; + }; } diff --git a/host/x86_64-linux/pocket/default.nix b/host/x86_64-linux/pocket/default.nix index 1ac0c8bf..508535ac 100644 --- a/host/x86_64-linux/pocket/default.nix +++ b/host/x86_64-linux/pocket/default.nix @@ -1,37 +1,36 @@ -{ ... }: { - home.nixos.enable = true; - user = { - root = true; - voronind = true; - }; +{ ... }: +{ + home.nixos.enable = true; + user = { + root = true; + voronind = true; + }; - module = { - builder.client.enable = true; - package.extra = true; - print.enable = true; - purpose = { - creative = true; - gaming = true; - laptop = true; - work = true; - }; - display = { - primary = "DSI-1"; - rotate = { - tty = 90; - DSI-1 = 90; - }; - }; - sway.extraConfig = [ - "input type:touch map_to_output DSI-1" - ]; - hwmon = { - file = "temp1_input"; - path = "/sys/devices/platform/coretemp.0/hwmon"; - }; - intel.cpu = { - enable = true; - powersave = true; - }; - }; + module = { + builder.client.enable = true; + package.extra = true; + print.enable = true; + purpose = { + creative = true; + gaming = true; + laptop = true; + work = true; + }; + display = { + primary = "DSI-1"; + rotate = { + tty = 90; + DSI-1 = 90; + }; + }; + sway.extraConfig = [ "input type:touch map_to_output DSI-1" ]; + hwmon = { + file = "temp1_input"; + path = "/sys/devices/platform/coretemp.0/hwmon"; + }; + intel.cpu = { + enable = true; + powersave = true; + }; + }; } diff --git a/host/x86_64-linux/work/Fprint.nix b/host/x86_64-linux/work/Fprint.nix index 1ca044fb..bdf5d16b 100644 --- a/host/x86_64-linux/work/Fprint.nix +++ b/host/x86_64-linux/work/Fprint.nix @@ -1,16 +1,12 @@ +{ pkgs, ... }: { - pkgs, - ... -}: { - environment.systemPackages = with pkgs; [ - fprintd - ]; + environment.systemPackages = with pkgs; [ fprintd ]; - services.fprintd = { - enable = true; - tod = { - enable = true; - driver = pkgs.libfprint-2-tod1-vfs0090; - }; - }; + services.fprintd = { + enable = true; + tod = { + enable = true; + driver = pkgs.libfprint-2-tod1-vfs0090; + }; + }; } diff --git a/host/x86_64-linux/work/Network.nix b/host/x86_64-linux/work/Network.nix index 8d4e8367..7ec16f0b 100644 --- a/host/x86_64-linux/work/Network.nix +++ b/host/x86_64-linux/work/Network.nix @@ -1,9 +1,10 @@ -{ ... }: { - networking = { - firewall.extraCommands = '' - # Ssh access. - iptables -I INPUT -j ACCEPT -s 10.0.0.0/8 -p tcp --dport 22143 - ip6tables -I INPUT -j ACCEPT -s fd09:8d46:0b26::/48 -p tcp --dport 22143 - ''; - }; +{ ... }: +{ + networking = { + firewall.extraCommands = '' + # Ssh access. + iptables -I INPUT -j ACCEPT -s 10.0.0.0/8 -p tcp --dport 22143 + ip6tables -I INPUT -j ACCEPT -s fd09:8d46:0b26::/48 -p tcp --dport 22143 + ''; + }; } diff --git a/host/x86_64-linux/work/default.nix b/host/x86_64-linux/work/default.nix index e16f38cd..2fe7b78c 100644 --- a/host/x86_64-linux/work/default.nix +++ b/host/x86_64-linux/work/default.nix @@ -1,35 +1,36 @@ -{ ... }: { - # Keyd Print to Macro remap. - services.keyd.keyboards.default.settings.main.print = "layer(layer_number)"; +{ ... }: +{ + # Keyd Print to Macro remap. + services.keyd.keyboards.default.settings.main.print = "layer(layer_number)"; - home.nixos.enable = true; - user = { - dasha = true; - root = true; - voronind = true; - }; + home.nixos.enable = true; + user = { + dasha = true; + root = true; + voronind = true; + }; - module = { - display.primary = "eDP-1"; - package.extra = true; - print.enable = true; - syncthing.enable = true; - builder.client.enable = true; - powerlimit.thinkpad.enable = true; - purpose = { - creative = true; - disown = true; - gaming = true; - laptop = true; - work = true; - }; - hwmon = { - file = "temp1_input"; - path = "/sys/devices/platform/coretemp.0/hwmon"; - }; - intel.cpu = { - enable = true; - powersave = true; - }; - }; + module = { + display.primary = "eDP-1"; + package.extra = true; + print.enable = true; + syncthing.enable = true; + builder.client.enable = true; + powerlimit.thinkpad.enable = true; + purpose = { + creative = true; + disown = true; + gaming = true; + laptop = true; + work = true; + }; + hwmon = { + file = "temp1_input"; + path = "/sys/devices/platform/coretemp.0/hwmon"; + }; + intel.cpu = { + enable = true; + powersave = true; + }; + }; } diff --git a/lib/Util.nix b/lib/Util.nix index 0709e6eb..58517c7e 100644 --- a/lib/Util.nix +++ b/lib/Util.nix @@ -1,30 +1,37 @@ # Collection of common functions. +{ lib }: { - lib -}: rec { - # Remove tabs indentation, - trimTabs = text: let - shouldStripTab = lines: builtins.all (line: (line == "") || (lib.strings.hasPrefix " " line)) lines; - stripTab = lines: builtins.map (line: lib.strings.removePrefix " " line) lines; - stripTabs = lines: if (shouldStripTab lines) then (stripTabs (stripTab lines)) else lines; - in builtins.concatStringsSep "\n" (stripTabs (lib.strings.splitString "\n" text)); + # Remove tabs indentation, + trimTabs = + text: + let + shouldStripTab = lines: builtins.all (line: (line == "") || (lib.strings.hasPrefix " " line)) lines; + stripTab = lines: builtins.map (line: lib.strings.removePrefix " " line) lines; + stripTabs = lines: if (shouldStripTab lines) then (stripTabs (stripTab lines)) else lines; + in + builtins.concatStringsSep "\n" (stripTabs (lib.strings.splitString "\n" text)); - # List all files in a dir. - ls = path: map (f: "${path}/${f}") (builtins.attrNames (builtins.readDir path)); + # List all files in a dir. + ls = path: map (f: "${path}/${f}") (builtins.attrNames (builtins.readDir path)); - # Concat all files by `text` key. - catText = files: args: builtins.foldl' (acc: mod: acc + (trimTabs (import mod args).text)) "" files; + # Concat all files by `text` key. + catText = files: args: builtins.foldl' (acc: mod: acc + (import mod args).text) "" files; - # Concat all file paths by `file` key. - catFile = files: args: builtins.foldl' (acc: mod: acc + (trimTabs (builtins.readFile (import mod args).file))) "" files; + # Concat all file paths by `file` key. + catFile = + files: args: builtins.foldl' (acc: mod: acc + (builtins.readFile (import mod args).file)) "" files; - # Concat all files as a set. - catSet = files: args: builtins.foldl' (acc: mod: acc // mod) { } (map (file: import file args) files); + # Concat all files as a set. + catSet = + files: args: builtins.foldl' (acc: mod: acc // mod) { } (map (file: import file args) files); - # Systemd service that does not restart with system switch. - mkStaticSystemdService = params: params // { - restartIfChanged = false; - stopIfChanged = false; - unitConfig.X-StopOnRemoval = false; - }; + # Systemd service that does not restart with system switch. + mkStaticSystemdService = + params: + params + // { + restartIfChanged = false; + stopIfChanged = false; + unitConfig.X-StopOnRemoval = false; + }; } diff --git a/option/AmdCompute.nix b/option/AmdCompute.nix index db5688b0..69e605b9 100644 --- a/option/AmdCompute.nix +++ b/option/AmdCompute.nix @@ -1,6 +1,4 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.amd.compute.enable = lib.mkEnableOption "the AMD Rocm support i.e. for Blender."; + options.module.amd.compute.enable = lib.mkEnableOption "the AMD Rocm support i.e. for Blender."; } diff --git a/option/AmdCpu.nix b/option/AmdCpu.nix index 25e2ff6b..c5554835 100644 --- a/option/AmdCpu.nix +++ b/option/AmdCpu.nix @@ -1,9 +1,7 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.amd.cpu = { - enable = lib.mkEnableOption "the AMD Cpu support."; - powersave = lib.mkEnableOption "the AMD Cpu powersave."; - }; + options.module.amd.cpu = { + enable = lib.mkEnableOption "the AMD Cpu support."; + powersave = lib.mkEnableOption "the AMD Cpu powersave."; + }; } diff --git a/option/AmdGpu.nix b/option/AmdGpu.nix index c6259dfe..2fe86e11 100644 --- a/option/AmdGpu.nix +++ b/option/AmdGpu.nix @@ -1,6 +1,4 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.amd.gpu.enable = lib.mkEnableOption "the AMD Gpu support."; + options.module.amd.gpu.enable = lib.mkEnableOption "the AMD Gpu support."; } diff --git a/option/AutoUpdateSigned.nix b/option/AutoUpdateSigned.nix index f95d3f7e..b08dacfc 100644 --- a/option/AutoUpdateSigned.nix +++ b/option/AutoUpdateSigned.nix @@ -1,6 +1,4 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.autoupdate.enable = lib.mkEnableOption "the system auto-updates."; + options.module.autoupdate.enable = lib.mkEnableOption "the system auto-updates."; } diff --git a/option/Bluetooth.nix b/option/Bluetooth.nix index 17ff185b..1477aca3 100644 --- a/option/Bluetooth.nix +++ b/option/Bluetooth.nix @@ -1,6 +1,4 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.bluetooth.enable = lib.mkEnableOption "the bluetooth support."; + options.module.bluetooth.enable = lib.mkEnableOption "the bluetooth support."; } diff --git a/option/Brightness.nix b/option/Brightness.nix index 4b7a77ed..cb9d257b 100644 --- a/option/Brightness.nix +++ b/option/Brightness.nix @@ -1,6 +1,4 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.brightness.enable = lib.mkEnableOption "the brightness control."; + options.module.brightness.enable = lib.mkEnableOption "the brightness control."; } diff --git a/option/Display.nix b/option/Display.nix index 20e719bf..55094e6e 100644 --- a/option/Display.nix +++ b/option/Display.nix @@ -1,20 +1,25 @@ # Screen configuration. +{ lib, ... }: { - lib, - ... -}: { - options.module.display = { - dpiAware = lib.mkOption { - default = false; - type = lib.types.bool; - }; - primary = lib.mkOption { - default = "*"; - type = lib.types.str; - }; - rotate = lib.mkOption { - default = { }; - type = with lib.types; attrsOf (enum [ 0 90 180 270 ]); - }; - }; + options.module.display = { + dpiAware = lib.mkOption { + default = false; + type = lib.types.bool; + }; + primary = lib.mkOption { + default = "*"; + type = lib.types.str; + }; + rotate = lib.mkOption { + default = { }; + type = + with lib.types; + attrsOf (enum [ + 0 + 90 + 180 + 270 + ]); + }; + }; } diff --git a/option/DisplayManager.nix b/option/DisplayManager.nix index cfa3f26b..77f32d7c 100644 --- a/option/DisplayManager.nix +++ b/option/DisplayManager.nix @@ -1,6 +1,4 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.dm.enable = lib.mkEnableOption "the display manager."; + options.module.dm.enable = lib.mkEnableOption "the display manager."; } diff --git a/option/Distrobox.nix b/option/Distrobox.nix index af6204a5..c2612755 100644 --- a/option/Distrobox.nix +++ b/option/Distrobox.nix @@ -1,6 +1,4 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.distrobox.enable = lib.mkEnableOption "the distrobox."; + options.module.distrobox.enable = lib.mkEnableOption "the distrobox."; } diff --git a/option/Docker.nix b/option/Docker.nix index 5be9fc0d..e81eff0b 100644 --- a/option/Docker.nix +++ b/option/Docker.nix @@ -1,16 +1,14 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.docker = { - enable = lib.mkEnableOption "the docker."; - rootless = lib.mkOption { - default = false; - type = lib.types.bool; - }; - autostart = lib.mkOption { - default = false; - type = lib.types.bool; - }; - }; + options.module.docker = { + enable = lib.mkEnableOption "the docker."; + rootless = lib.mkOption { + default = false; + type = lib.types.bool; + }; + autostart = lib.mkOption { + default = false; + type = lib.types.bool; + }; + }; } diff --git a/option/Dpi.nix b/option/Dpi.nix index d67edbfa..ea3ca58e 100644 --- a/option/Dpi.nix +++ b/option/Dpi.nix @@ -1,49 +1,46 @@ +{ lib, pkgsMaster, ... }: { - lib, - pkgsMaster, - ... -}: { - options.module.dpi.bypass = { - enable = lib.mkEnableOption "the Zapret DPI bypass service."; - package = lib.mkPackageOption pkgsMaster "zapret" { }; - params = lib.mkOption { - default = [ ]; - type = with lib.types; listOf str; - }; - whitelist = lib.mkOption { - default = [ ]; - type = with lib.types; listOf str; - }; - blacklist = lib.mkOption { - default = [ ]; - type = with lib.types; listOf str; - }; - qnum = lib.mkOption { - default = 200; - type = lib.types.int; - }; - configureFirewall = lib.mkOption { - default = true; - type = lib.types.bool; - }; - httpSupport = lib.mkOption { - default = true; - type = lib.types.bool; - }; - httpMode = lib.mkOption { - default = "first"; - type = lib.types.enum [ - "first" - "full" - ]; - }; - udpSupport = lib.mkOption { - default = false; - type = lib.types.bool; - }; - udpPorts = lib.mkOption { - default = [ ]; - type = with lib.types; listOf str; - }; - }; + options.module.dpi.bypass = { + enable = lib.mkEnableOption "the Zapret DPI bypass service."; + package = lib.mkPackageOption pkgsMaster "zapret" { }; + params = lib.mkOption { + default = [ ]; + type = with lib.types; listOf str; + }; + whitelist = lib.mkOption { + default = [ ]; + type = with lib.types; listOf str; + }; + blacklist = lib.mkOption { + default = [ ]; + type = with lib.types; listOf str; + }; + qnum = lib.mkOption { + default = 200; + type = lib.types.int; + }; + configureFirewall = lib.mkOption { + default = true; + type = lib.types.bool; + }; + httpSupport = lib.mkOption { + default = true; + type = lib.types.bool; + }; + httpMode = lib.mkOption { + default = "first"; + type = lib.types.enum [ + "first" + "full" + ]; + }; + udpSupport = lib.mkOption { + default = false; + type = lib.types.bool; + }; + udpPorts = lib.mkOption { + default = [ ]; + type = with lib.types; listOf str; + }; + }; } diff --git a/option/Ftpd.nix b/option/Ftpd.nix index 591b31e5..1226acb6 100644 --- a/option/Ftpd.nix +++ b/option/Ftpd.nix @@ -1,12 +1,10 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.ftpd = { - enable = lib.mkEnableOption "the FTP server"; - storage = lib.mkOption { - default = null; - type = lib.types.str; - }; - }; + options.module.ftpd = { + enable = lib.mkEnableOption "the FTP server"; + storage = lib.mkOption { + default = null; + type = lib.types.str; + }; + }; } diff --git a/option/Gnome.nix b/option/Gnome.nix index 8a0df255..aba48a2e 100644 --- a/option/Gnome.nix +++ b/option/Gnome.nix @@ -1,6 +1,4 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.gnome.enable = lib.mkEnableOption "the Gnome DE."; + options.module.gnome.enable = lib.mkEnableOption "the Gnome DE."; } diff --git a/option/Hwmon.nix b/option/Hwmon.nix index 87332f88..21ae9c84 100644 --- a/option/Hwmon.nix +++ b/option/Hwmon.nix @@ -1,16 +1,14 @@ # Hardware monitor configuration. +{ lib, ... }: { - lib, - ... -}: { - options.module.hwmon = { - path = lib.mkOption { - default = ""; - type = lib.types.str; - }; - file = lib.mkOption { - default = ""; - type = lib.types.str; - }; - }; + options.module.hwmon = { + path = lib.mkOption { + default = ""; + type = lib.types.str; + }; + file = lib.mkOption { + default = ""; + type = lib.types.str; + }; + }; } diff --git a/option/IntelCpu.nix b/option/IntelCpu.nix index b97b76d6..e39a4f10 100644 --- a/option/IntelCpu.nix +++ b/option/IntelCpu.nix @@ -1,9 +1,7 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.intel.cpu = { - enable = lib.mkEnableOption "the support for Intel CPUs."; - powersave = lib.mkEnableOption "the Intel CPU powersave."; - }; + options.module.intel.cpu = { + enable = lib.mkEnableOption "the support for Intel CPUs."; + powersave = lib.mkEnableOption "the Intel CPU powersave."; + }; } diff --git a/option/Kernel.nix b/option/Kernel.nix index fd6733c1..2d6a87e3 100644 --- a/option/Kernel.nix +++ b/option/Kernel.nix @@ -1,20 +1,18 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.kernel = { - enable = lib.mkEnableOption "the kernel tweaks."; - hardening = lib.mkOption { - default = false; - type = lib.types.bool; - }; - hotspotTtlBypass = lib.mkOption { - default = false; - type = lib.types.bool; - }; - latest = lib.mkOption { - default = false; - type = lib.types.bool; - }; - }; + options.module.kernel = { + enable = lib.mkEnableOption "the kernel tweaks."; + hardening = lib.mkOption { + default = false; + type = lib.types.bool; + }; + hotspotTtlBypass = lib.mkOption { + default = false; + type = lib.types.bool; + }; + latest = lib.mkOption { + default = false; + type = lib.types.bool; + }; + }; } diff --git a/option/Keyboard.nix b/option/Keyboard.nix index db051fd2..52ea678f 100644 --- a/option/Keyboard.nix +++ b/option/Keyboard.nix @@ -1,16 +1,14 @@ # Keyboard configuration. +{ lib, ... }: { - lib, - ... -}: { - options.module.keyboard = { - layouts = lib.mkOption { - default = "us,ru"; - type = lib.types.str; - }; - options = lib.mkOption { - default = "grp:toggle"; - type = lib.types.str; - }; - }; + options.module.keyboard = { + layouts = lib.mkOption { + default = "us,ru"; + type = lib.types.str; + }; + options = lib.mkOption { + default = "grp:toggle"; + type = lib.types.str; + }; + }; } diff --git a/option/Keyd.nix b/option/Keyd.nix index fb5b569e..460a82b8 100644 --- a/option/Keyd.nix +++ b/option/Keyd.nix @@ -1,6 +1,4 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.keyd.enable = lib.mkEnableOption "the keyboard remaps."; + options.module.keyd.enable = lib.mkEnableOption "the keyboard remaps."; } diff --git a/option/Ollama.nix b/option/Ollama.nix index 48c0665d..5de7bd8d 100644 --- a/option/Ollama.nix +++ b/option/Ollama.nix @@ -1,19 +1,17 @@ +{ config, lib, ... }: +let + cfg = config.module.ollama; +in { - config, - lib, - ... -}: let - cfg = config.module.ollama; -in { - options.module.ollama = { - enable = lib.mkEnableOption "the local LLM server."; - models = lib.mkOption { - default = [ cfg.primaryModel ]; - type = with lib.types; listOf str; - }; - primaryModel = lib.mkOption { - default = "llama3.2"; - type = lib.types.str; - }; - }; + options.module.ollama = { + enable = lib.mkEnableOption "the local LLM server."; + models = lib.mkOption { + default = [ cfg.primaryModel ]; + type = with lib.types; listOf str; + }; + primaryModel = lib.mkOption { + default = "llama3.2"; + type = lib.types.str; + }; + }; } diff --git a/option/Package.nix b/option/Package.nix index ca1cfc47..0bdacb68 100644 --- a/option/Package.nix +++ b/option/Package.nix @@ -1,14 +1,12 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.package = { - common = lib.mkEnableOption "Common Apps."; - core = lib.mkEnableOption "Core apps."; - creative = lib.mkEnableOption "Creative Apps."; - desktop = lib.mkEnableOption "Desktop Apps."; - dev = lib.mkEnableOption "Dev Apps."; - extra = lib.mkEnableOption "Extra Apps."; - gaming = lib.mkEnableOption "Gaming Apps."; - }; + options.module.package = { + common = lib.mkEnableOption "Common Apps."; + core = lib.mkEnableOption "Core apps."; + creative = lib.mkEnableOption "Creative Apps."; + desktop = lib.mkEnableOption "Desktop Apps."; + dev = lib.mkEnableOption "Dev Apps."; + extra = lib.mkEnableOption "Extra Apps."; + gaming = lib.mkEnableOption "Gaming Apps."; + }; } diff --git a/option/Podman.nix b/option/Podman.nix index cc49a3cf..cc1d214c 100644 --- a/option/Podman.nix +++ b/option/Podman.nix @@ -1,6 +1,4 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.podman.enable = lib.mkEnableOption "the OCI Podman."; + options.module.podman.enable = lib.mkEnableOption "the OCI Podman."; } diff --git a/option/Polkit.nix b/option/Polkit.nix index 66dcec81..9fa8aa61 100644 --- a/option/Polkit.nix +++ b/option/Polkit.nix @@ -1,6 +1,4 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.polkit.enable = lib.mkEnableOption "the polkit."; + options.module.polkit.enable = lib.mkEnableOption "the polkit."; } diff --git a/option/Portal.nix b/option/Portal.nix index b8e31b0a..8aac24e5 100644 --- a/option/Portal.nix +++ b/option/Portal.nix @@ -1,6 +1,4 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.portal.enable = lib.mkEnableOption "the portals."; + options.module.portal.enable = lib.mkEnableOption "the portals."; } diff --git a/option/PowerlimitThinkpad.nix b/option/PowerlimitThinkpad.nix index 617cc58a..27141b9e 100644 --- a/option/PowerlimitThinkpad.nix +++ b/option/PowerlimitThinkpad.nix @@ -1,24 +1,22 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.powerlimit.thinkpad = { - enable = lib.mkEnableOption "the powerlimit service"; - onMin = lib.mkOption { - default = 40; - type = lib.types.int; - }; - onMax = lib.mkOption { - default = 80; - type = lib.types.int; - }; - offMin = lib.mkOption { - default = 90; - type = lib.types.int; - }; - offMax = lib.mkOption { - default = 95; - type = lib.types.int; - }; - }; + options.module.powerlimit.thinkpad = { + enable = lib.mkEnableOption "the powerlimit service"; + onMin = lib.mkOption { + default = 40; + type = lib.types.int; + }; + onMax = lib.mkOption { + default = 80; + type = lib.types.int; + }; + offMin = lib.mkOption { + default = 90; + type = lib.types.int; + }; + offMax = lib.mkOption { + default = 95; + type = lib.types.int; + }; + }; } diff --git a/option/Powersave.nix b/option/Powersave.nix index d8e451ed..b2fcd641 100644 --- a/option/Powersave.nix +++ b/option/Powersave.nix @@ -1,22 +1,20 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.powersave = { - enable = lib.mkEnableOption "the powersave"; - cpu.boost = { - disableCmd = lib.mkOption { - default = null; - type = lib.types.str; - }; - enableCmd = lib.mkOption { - default = null; - type = lib.types.str; - }; - controlFile = lib.mkOption { - default = null; - type = lib.types.str; - }; - }; - }; + options.module.powersave = { + enable = lib.mkEnableOption "the powersave"; + cpu.boost = { + disableCmd = lib.mkOption { + default = null; + type = lib.types.str; + }; + enableCmd = lib.mkOption { + default = null; + type = lib.types.str; + }; + controlFile = lib.mkOption { + default = null; + type = lib.types.str; + }; + }; + }; } diff --git a/option/Print.nix b/option/Print.nix index 5ae96544..67d9d1ea 100644 --- a/option/Print.nix +++ b/option/Print.nix @@ -1,6 +1,4 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.print.enable = lib.mkEnableOption "the support for printers."; + options.module.print.enable = lib.mkEnableOption "the support for printers."; } diff --git a/option/Purpose.nix b/option/Purpose.nix index 409151ce..f08aecb6 100644 --- a/option/Purpose.nix +++ b/option/Purpose.nix @@ -1,17 +1,15 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.purpose = { - creative = lib.mkEnableOption "creativity modules."; - desktop = lib.mkEnableOption "desktop modules."; - disown = lib.mkEnableOption "modules for machines not used by me."; - gaming = lib.mkEnableOption "gaming modules."; - laptop = lib.mkEnableOption "laptop modules."; - live = lib.mkEnableOption "live modules."; - phone = lib.mkEnableOption "phone modules."; - router = lib.mkEnableOption "router modules."; - server = lib.mkEnableOption "server modules."; - work = lib.mkEnableOption "work modules."; - }; + options.module.purpose = { + creative = lib.mkEnableOption "creativity modules."; + desktop = lib.mkEnableOption "desktop modules."; + disown = lib.mkEnableOption "modules for machines not used by me."; + gaming = lib.mkEnableOption "gaming modules."; + laptop = lib.mkEnableOption "laptop modules."; + live = lib.mkEnableOption "live modules."; + phone = lib.mkEnableOption "phone modules."; + router = lib.mkEnableOption "router modules."; + server = lib.mkEnableOption "server modules."; + work = lib.mkEnableOption "work modules."; + }; } diff --git a/option/RemoteBuild.nix b/option/RemoteBuild.nix index 05f25912..3bd1d3f5 100644 --- a/option/RemoteBuild.nix +++ b/option/RemoteBuild.nix @@ -1,9 +1,7 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.builder = { - server.enable = lib.mkEnableOption "the builder server."; - client.enable = lib.mkEnableOption "the builder client."; - }; + options.module.builder = { + server.enable = lib.mkEnableOption "the builder server."; + client.enable = lib.mkEnableOption "the builder client."; + }; } diff --git a/option/Sound.nix b/option/Sound.nix index efd71ce1..baeef5ed 100644 --- a/option/Sound.nix +++ b/option/Sound.nix @@ -1,6 +1,4 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.sound.enable = lib.mkEnableOption "the sound."; + options.module.sound.enable = lib.mkEnableOption "the sound."; } diff --git a/option/Style.nix b/option/Style.nix index c0f1b80f..6de1fb30 100644 --- a/option/Style.nix +++ b/option/Style.nix @@ -1,134 +1,138 @@ # Styling like colors, fonts, cursor etc. { - __findFile, - config, - inputs, - lib, - pkgs, - ... -}: let - cfg = config.module.style; - stylix = config.lib.stylix or config.home-manager.config.lib.stylix; + __findFile, + config, + inputs, + lib, + pkgs, + ... +}: +let + cfg = config.module.style; + stylix = config.lib.stylix or config.home-manager.config.lib.stylix; - mkTypeOption = default: type: lib.mkOption { inherit default type; }; - mkFloatOption = default: mkTypeOption default lib.types.float; - mkIntOption = default: mkTypeOption default lib.types.int; - mkPkgOption = default: mkTypeOption default lib.types.package; - mkStrOption = default: mkTypeOption default lib.types.str; -in { - options.module.style = { - color = { - accent = mkStrOption stylix.colors.base0A; - heading = mkStrOption stylix.colors.base0D; - highlight = mkStrOption stylix.colors.base03; - keyword = mkStrOption stylix.colors.base0E; - link = mkStrOption stylix.colors.base09; - misc = mkStrOption stylix.colors.base0F; - negative = mkStrOption stylix.colors.base08; - neutral = mkStrOption stylix.colors.base0C; - positive = mkStrOption stylix.colors.base0B; - selection = mkStrOption stylix.colors.base02; - bg = { - dark = mkStrOption stylix.colors.base00; - light = mkStrOption stylix.colors.base07; - regular = mkStrOption stylix.colors.base01; - }; - fg = { - dark = mkStrOption stylix.colors.base04; - light = mkStrOption stylix.colors.base06; - regular = mkStrOption stylix.colors.base05; - }; + mkTypeOption = default: type: lib.mkOption { inherit default type; }; + mkFloatOption = default: mkTypeOption default lib.types.float; + mkIntOption = default: mkTypeOption default lib.types.int; + mkPkgOption = default: mkTypeOption default lib.types.package; + mkStrOption = default: mkTypeOption default lib.types.str; +in +{ + options.module.style = { + color = { + accent = mkStrOption stylix.colors.base0A; + heading = mkStrOption stylix.colors.base0D; + highlight = mkStrOption stylix.colors.base03; + keyword = mkStrOption stylix.colors.base0E; + link = mkStrOption stylix.colors.base09; + misc = mkStrOption stylix.colors.base0F; + negative = mkStrOption stylix.colors.base08; + neutral = mkStrOption stylix.colors.base0C; + positive = mkStrOption stylix.colors.base0B; + selection = mkStrOption stylix.colors.base02; + bg = { + dark = mkStrOption stylix.colors.base00; + light = mkStrOption stylix.colors.base07; + regular = mkStrOption stylix.colors.base01; + }; + fg = { + dark = mkStrOption stylix.colors.base04; + light = mkStrOption stylix.colors.base06; + regular = mkStrOption stylix.colors.base05; + }; - accentR = mkStrOption stylix.colors.base0A-rgb-r; - accentG = mkStrOption stylix.colors.base0A-rgb-g; - accentB = mkStrOption stylix.colors.base0A-rgb-b; + accentR = mkStrOption stylix.colors.base0A-rgb-r; + accentG = mkStrOption stylix.colors.base0A-rgb-g; + accentB = mkStrOption stylix.colors.base0A-rgb-b; - accentDecR = mkStrOption stylix.colors.base0A-dec-r; - accentDecG = mkStrOption stylix.colors.base0A-dec-g; - accentDecB = mkStrOption stylix.colors.base0A-dec-b; + accentDecR = mkStrOption stylix.colors.base0A-dec-r; + accentDecG = mkStrOption stylix.colors.base0A-dec-g; + accentDecB = mkStrOption stylix.colors.base0A-dec-b; - bgR = mkStrOption stylix.colors.base00-rgb-r; - bgG = mkStrOption stylix.colors.base00-rgb-g; - bgB = mkStrOption stylix.colors.base00-rgb-b; + bgR = mkStrOption stylix.colors.base00-rgb-r; + bgG = mkStrOption stylix.colors.base00-rgb-g; + bgB = mkStrOption stylix.colors.base00-rgb-b; - border = mkStrOption stylix.colors.base01; - borderR = mkStrOption stylix.colors.base01-rgb-r; - borderG = mkStrOption stylix.colors.base01-rgb-g; - borderB = mkStrOption stylix.colors.base01-rgb-b; + border = mkStrOption stylix.colors.base01; + borderR = mkStrOption stylix.colors.base01-rgb-r; + borderG = mkStrOption stylix.colors.base01-rgb-g; + borderB = mkStrOption stylix.colors.base01-rgb-b; - negativeR = mkStrOption stylix.colors.base08-rgb-r; - negativeG = mkStrOption stylix.colors.base08-rgb-g; - negativeB = mkStrOption stylix.colors.base08-rgb-b; + negativeR = mkStrOption stylix.colors.base08-rgb-r; + negativeG = mkStrOption stylix.colors.base08-rgb-g; + negativeB = mkStrOption stylix.colors.base08-rgb-b; - neutralR = mkStrOption stylix.colors.base0C-rgb-r; - neutralG = mkStrOption stylix.colors.base0C-rgb-g; - neutralB = mkStrOption stylix.colors.base0C-rgb-b; + neutralR = mkStrOption stylix.colors.base0C-rgb-r; + neutralG = mkStrOption stylix.colors.base0C-rgb-g; + neutralB = mkStrOption stylix.colors.base0C-rgb-b; - positiveR = mkStrOption stylix.colors.base0B-rgb-r; - positiveG = mkStrOption stylix.colors.base0B-rgb-g; - positiveB = mkStrOption stylix.colors.base0B-rgb-b; + positiveR = mkStrOption stylix.colors.base0B-rgb-r; + positiveG = mkStrOption stylix.colors.base0B-rgb-g; + positiveB = mkStrOption stylix.colors.base0B-rgb-b; - transparent = mkStrOption "ffffff00"; - }; + transparent = mkStrOption "ffffff00"; + }; - cursor = { - package = mkPkgOption (inputs.nix-cursors.packages.${pkgs.system}.google-cursor.override { - accent_color = "#${cfg.color.fg.light}"; - background_color = "#${cfg.color.fg.light}"; - outline_color = "#${cfg.color.border}"; - }); - name = mkStrOption "GoogleDot-Custom"; - size = mkIntOption 22; + cursor = { + package = mkPkgOption ( + inputs.nix-cursors.packages.${pkgs.system}.google-cursor.override { + accent_color = "#${cfg.color.fg.light}"; + background_color = "#${cfg.color.fg.light}"; + outline_color = "#${cfg.color.border}"; + } + ); + name = mkStrOption "GoogleDot-Custom"; + size = mkIntOption 22; - # package = mkPkgOption (inputs.nix-cursors.packages.${pkgs.system}.fuchsia-cursor.override { - # accent_color = "#${cfg.color.accent}"; - # background_color = "#${cfg.color.fg.light}"; - # outline_color = "#${cfg.color.border}"; - # }); - # name = mkStrOption "Fuchsia-Custom"; - # size = mkIntOption 16; + # package = mkPkgOption (inputs.nix-cursors.packages.${pkgs.system}.fuchsia-cursor.override { + # accent_color = "#${cfg.color.accent}"; + # background_color = "#${cfg.color.fg.light}"; + # outline_color = "#${cfg.color.border}"; + # }); + # name = mkStrOption "Fuchsia-Custom"; + # size = mkIntOption 16; - # name = mkStrOption "phinger-cursors-light"; - # package = mkPkgOption pkgs.phinger-cursors; - # size = mkIntOption 24; - }; + # name = mkStrOption "phinger-cursors-light"; + # package = mkPkgOption pkgs.phinger-cursors; + # size = mkIntOption 24; + }; - font = { - emoji = { - name = mkStrOption "Noto Color Emoji"; - package = mkPkgOption pkgs.noto-fonts-emoji; - }; - monospace = { - name = mkStrOption "Terminess Nerd Font Mono"; - package = mkPkgOption (pkgs.nerdfonts.override { fonts = [ "Terminus" ]; }); - }; - sansSerif = { - name = mkStrOption "SF Pro Display"; - package = mkPkgOption (pkgs.callPackage { }); - }; - serif = { - name = mkStrOption "SF Pro Display"; - package = mkPkgOption (pkgs.callPackage { }); - }; - size = { - application = mkIntOption 12; - desktop = mkIntOption 14; - popup = mkIntOption 12; - terminal = mkIntOption 14; - }; - }; + font = { + emoji = { + name = mkStrOption "Noto Color Emoji"; + package = mkPkgOption pkgs.noto-fonts-emoji; + }; + monospace = { + name = mkStrOption "Terminess Nerd Font Mono"; + package = mkPkgOption (pkgs.nerdfonts.override { fonts = [ "Terminus" ]; }); + }; + sansSerif = { + name = mkStrOption "SF Pro Display"; + package = mkPkgOption (pkgs.callPackage { }); + }; + serif = { + name = mkStrOption "SF Pro Display"; + package = mkPkgOption (pkgs.callPackage { }); + }; + size = { + application = mkIntOption 12; + desktop = mkIntOption 14; + popup = mkIntOption 12; + terminal = mkIntOption 14; + }; + }; - opacity = { - application = mkFloatOption 0.85; - desktop = mkFloatOption 0.85; - hex = mkStrOption "D9"; - popup = mkFloatOption 0.85; - terminal = mkFloatOption 0.85; - }; + opacity = { + application = mkFloatOption 0.85; + desktop = mkFloatOption 0.85; + hex = mkStrOption "D9"; + popup = mkFloatOption 0.85; + terminal = mkFloatOption 0.85; + }; - window = { - border = mkIntOption 4; - gap = mkIntOption 8; - }; - }; + window = { + border = mkIntOption 4; + gap = mkIntOption 8; + }; + }; } diff --git a/option/Sway.nix b/option/Sway.nix index 9eb3f5a1..eff79209 100644 --- a/option/Sway.nix +++ b/option/Sway.nix @@ -1,12 +1,10 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.sway = { - enable = lib.mkEnableOption "the Sway WM."; - extraConfig = lib.mkOption { - default = [ ]; - type = with lib.types; listOf str; - }; - }; + options.module.sway = { + enable = lib.mkEnableOption "the Sway WM."; + extraConfig = lib.mkOption { + default = [ ]; + type = with lib.types; listOf str; + }; + }; } diff --git a/option/Syncthing.nix b/option/Syncthing.nix index b8e921ab..ab0709f9 100644 --- a/option/Syncthing.nix +++ b/option/Syncthing.nix @@ -1,28 +1,26 @@ +{ config, lib, ... }: +let + cfg = config.module.syncthing; +in { - config, - lib, - ... -}: let - cfg = config.module.syncthing; -in { - # NOTE: Access at `http://localhost:8384`. - options.module.syncthing = { - enable = lib.mkEnableOption "the file sync."; - dataDir = lib.mkOption { - default = "/home/${cfg.user}/sync"; - type = lib.types.str; - }; - settings = lib.mkOption { - default = { }; - type = lib.types.attrs; - }; - user = lib.mkOption { - default = "voronind"; - type = lib.types.str; - }; - group = lib.mkOption { - default = "users"; - type = lib.types.str; - }; - }; + # NOTE: Access at `http://localhost:8384`. + options.module.syncthing = { + enable = lib.mkEnableOption "the file sync."; + dataDir = lib.mkOption { + default = "/home/${cfg.user}/sync"; + type = lib.types.str; + }; + settings = lib.mkOption { + default = { }; + type = lib.types.attrs; + }; + user = lib.mkOption { + default = "voronind"; + type = lib.types.str; + }; + group = lib.mkOption { + default = "users"; + type = lib.types.str; + }; + }; } diff --git a/option/Tablet.nix b/option/Tablet.nix index cd52d8e1..a91724a9 100644 --- a/option/Tablet.nix +++ b/option/Tablet.nix @@ -1,6 +1,4 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.tablet.enable = lib.mkEnableOption "the support for tables."; + options.module.tablet.enable = lib.mkEnableOption "the support for tables."; } diff --git a/option/VirtManager.nix b/option/VirtManager.nix index c02a5dd4..7514ba38 100644 --- a/option/VirtManager.nix +++ b/option/VirtManager.nix @@ -1,6 +1,4 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.virtmanager.enable = lib.mkEnableOption "the VM support."; + options.module.virtmanager.enable = lib.mkEnableOption "the VM support."; } diff --git a/option/Wallpaper.nix b/option/Wallpaper.nix index 55b56b78..dccfd5ac 100644 --- a/option/Wallpaper.nix +++ b/option/Wallpaper.nix @@ -1,21 +1,19 @@ # Download the wallpaper here. +{ pkgs, lib, ... }: +let + url = "https://i.imgur.com/XG8bA49.jpeg"; + sha256 = "sha256-xVdZ8wSN+PMoX1z7mdF9d4Gklxt41jASvz/LYtfGosE="; + forceContrastText = false; +in { - pkgs, - lib, - ... -}: let - url = "https://i.imgur.com/XG8bA49.jpeg"; - sha256 = "sha256-xVdZ8wSN+PMoX1z7mdF9d4Gklxt41jASvz/LYtfGosE="; - forceContrastText = false; -in { - options.module.wallpaper = { - forceContrastText = lib.mkOption { - default = lib.warnIf forceContrastText "Wallpaper: Forced text contrast." forceContrastText; - type = lib.types.bool; - }; - path = lib.mkOption { - default = pkgs.fetchurl { inherit url sha256; }; - type = lib.types.path; - }; - }; + options.module.wallpaper = { + forceContrastText = lib.mkOption { + default = lib.warnIf forceContrastText "Wallpaper: Forced text contrast." forceContrastText; + type = lib.types.bool; + }; + path = lib.mkOption { + default = pkgs.fetchurl { inherit url sha256; }; + type = lib.types.path; + }; + }; } diff --git a/option/Waybar.nix b/option/Waybar.nix index 5441c3b6..baf7d0d6 100644 --- a/option/Waybar.nix +++ b/option/Waybar.nix @@ -1,6 +1,4 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.waybar.enable = lib.mkEnableOption "the Waybar."; + options.module.waybar.enable = lib.mkEnableOption "the Waybar."; } diff --git a/option/Wayland.nix b/option/Wayland.nix index 01a96a59..7cb20027 100644 --- a/option/Wayland.nix +++ b/option/Wayland.nix @@ -1,6 +1,4 @@ +{ lib, ... }: { - lib, - ... -}: { - options.module.wayland.enable = lib.mkEnableOption "the wayland."; + options.module.wayland.enable = lib.mkEnableOption "the wayland."; } diff --git a/overlay/Example.nix b/overlay/Example.nix index 4d8e9d80..ad853d5f 100644 --- a/overlay/Example.nix +++ b/overlay/Example.nix @@ -2,26 +2,27 @@ # Overlays can change parameters in package builds, like source version. # This way you can change something in package without recreating the whole build process. # More info: https://nixos.wiki/wiki/Overlays -{ ... }: { - # Use a different revision. - # nixpkgs.overlays = [ (final: prev: { - # yt-dlp = prev.yt-dlp.overrideAttrs (old: { - # src = prev.fetchFromGitHub { - # owner = "yt-dlp"; - # repo = "yt-dlp"; - # rev = "2024.03.10"; - # hash = "sha256-A6uciGErM4QgLrY5jMFGlPV2uH9O2cOhj5+IapyjVo0="; - # }; - # }); - # })]; +{ ... }: +{ + # Use a different revision. + # nixpkgs.overlays = [ (final: prev: { + # yt-dlp = prev.yt-dlp.overrideAttrs (old: { + # src = prev.fetchFromGitHub { + # owner = "yt-dlp"; + # repo = "yt-dlp"; + # rev = "2024.03.10"; + # hash = "sha256-A6uciGErM4QgLrY5jMFGlPV2uH9O2cOhj5+IapyjVo0="; + # }; + # }); + # })]; - # Apply patch to a program. - # nixpkgs.overlays = [ (final: prev: { - # keyd = prev.keyd.overrideAttrs (old: { - # patches = (old.patches or []) ++ [(prev.fetchpatch { - # url = "https://patch-diff.githubusercontent.com/raw/rvaiya/keyd/pull/545.patch"; - # hash = "sha256-aal8oAXws6DcpeCl7G9GMJQXeLDDbyotWFut0Rf82WI="; - # })]; - # }); - # })]; + # Apply patch to a program. + # nixpkgs.overlays = [ (final: prev: { + # keyd = prev.keyd.overrideAttrs (old: { + # patches = (old.patches or []) ++ [(prev.fetchpatch { + # url = "https://patch-diff.githubusercontent.com/raw/rvaiya/keyd/pull/545.patch"; + # hash = "sha256-aal8oAXws6DcpeCl7G9GMJQXeLDDbyotWFut0Rf82WI="; + # })]; + # }); + # })]; } diff --git a/overlay/Keyd.nix b/overlay/Keyd.nix index bbd5d516..26090093 100644 --- a/overlay/Keyd.nix +++ b/overlay/Keyd.nix @@ -1,42 +1,41 @@ # HACK: Add a patch for https://github.com/rvaiya/keyd/pull/545 +{ lib, ... }: { - lib, - util, - ... -}: { - nixpkgs.overlays = [(final: prev: { - keyd = prev.keyd.overrideAttrs (old: rec { - patches = (old.patches or [ ]) ++ [ - (prev.fetchpatch { - hash = "sha256-aal8oAXws6DcpeCl7G9GMJQXeLDDbyotWFut0Rf82WI="; - url = "https://patch-diff.githubusercontent.com/raw/rvaiya/keyd/pull/545.patch"; - }) - ]; + nixpkgs.overlays = [ + (final: prev: { + keyd = prev.keyd.overrideAttrs (old: rec { + patches = (old.patches or [ ]) ++ [ + (prev.fetchpatch { + hash = "sha256-aal8oAXws6DcpeCl7G9GMJQXeLDDbyotWFut0Rf82WI="; + url = "https://patch-diff.githubusercontent.com/raw/rvaiya/keyd/pull/545.patch"; + }) + ]; - postInstall = let - pypkgs = prev.python3.pkgs; - appMap = pypkgs.buildPythonApplication rec { - inherit (prev.keyd) version src; - inherit patches; - dontBuild = true; - format = "other"; - meta.mainProgram = "keyd-application-mapper"; - pname = "keyd-application-mapper"; - postPatch = util.trimTabs '' - substituteInPlace scripts/${pname} \ - --replace /bin/sh ${prev.runtimeShell} - ''; - propagatedBuildInputs = with pypkgs; [ - xlib - ]; - installPhase = util.trimTabs '' - install -Dm555 -t $out/bin scripts/${pname} - ''; - }; - in '' - ln -sf ${lib.getExe appMap} $out/bin/${appMap.pname} - rm -rf $out/etc - ''; - }); - })]; + postInstall = + let + pypkgs = prev.python3.pkgs; + appMap = pypkgs.buildPythonApplication rec { + inherit (prev.keyd) version src; + inherit patches; + dontBuild = true; + format = "other"; + meta.mainProgram = "keyd-application-mapper"; + pname = "keyd-application-mapper"; + propagatedBuildInputs = with pypkgs; [ xlib ]; + postPatch = '' + substituteInPlace scripts/${pname} \ + --replace /bin/sh ${prev.runtimeShell} + ''; + installPhase = '' + install -Dm555 -t $out/bin scripts/${pname} + ''; + }; + in + '' + ln -sf ${lib.getExe appMap} $out/bin/${appMap.pname} + rm -rf $out/etc + ''; + }); + }) + ]; } diff --git a/overlay/Nvim.nix b/overlay/Nvim.nix index 3c7dfed5..ebe6281d 100644 --- a/overlay/Nvim.nix +++ b/overlay/Nvim.nix @@ -1,13 +1,11 @@ +{ __findFile, ... }: { - __findFile, - ... -}: { - # SEE: https://github.com/neovim/neovim/issues/22478 - nixpkgs.overlays = [(final: prev: { - neovim-unwrapped = prev.neovim-unwrapped.overrideAttrs (old: { - patches = (old.patches or [ ]) ++ [ - - ]; - }); - })]; + # SEE: https://github.com/neovim/neovim/issues/22478 + nixpkgs.overlays = [ + (final: prev: { + neovim-unwrapped = prev.neovim-unwrapped.overrideAttrs (old: { + patches = (old.patches or [ ]) ++ [ ]; + }); + }) + ]; } diff --git a/overlay/Swappy.nix b/overlay/Swappy.nix index f6e12e75..59dcaa59 100644 --- a/overlay/Swappy.nix +++ b/overlay/Swappy.nix @@ -1,15 +1,16 @@ { - __findFile, - config, - pkgs, - ... -} @args: { - # SEE: https://github.com/jtheoof/swappy/issues/131 - nixpkgs.overlays = [(final: prev: { - swappy = prev.swappy.overrideAttrs (old: { - patches = (old.patches or [ ]) ++ [ - (import args).file - ]; - }); - })]; + __findFile, + config, + pkgs, + ... +}@args: +{ + # SEE: https://github.com/jtheoof/swappy/issues/131 + nixpkgs.overlays = [ + (final: prev: { + swappy = prev.swappy.overrideAttrs (old: { + patches = (old.patches or [ ]) ++ [ (import args).file ]; + }); + }) + ]; } diff --git a/overlay/Tmux.nix b/overlay/Tmux.nix index 3ff2659f..b043c645 100644 --- a/overlay/Tmux.nix +++ b/overlay/Tmux.nix @@ -1,22 +1,18 @@ +{ __findFile, ... }: { - __findFile, - config, - pkgs, - ... -} @args: { - # SEE: https://github.com/tmux/tmux/issues/4264 - # FIXME: Later. - nixpkgs.overlays = [(final: prev: { - tmux = prev.tmux.overrideAttrs (old: { - src = prev.fetchFromGitHub { - hash = "sha256-EuTEN+B+rE76nLQRIljy2PL2gp+rVGk+ygEhQA2nZww="; - owner = "tmux"; - repo = "tmux"; - rev = "db978db27161f57b01f22407d2dda2bce203c2cf"; - }; - patches = (old.patches or [ ]) ++ [ - - ]; - }); - })]; + # SEE: https://github.com/tmux/tmux/issues/4264 + # FIXME: Later. + nixpkgs.overlays = [ + (final: prev: { + tmux = prev.tmux.overrideAttrs (old: { + src = prev.fetchFromGitHub { + hash = "sha256-EuTEN+B+rE76nLQRIljy2PL2gp+rVGk+ygEhQA2nZww="; + owner = "tmux"; + repo = "tmux"; + rev = "db978db27161f57b01f22407d2dda2bce203c2cf"; + }; + patches = (old.patches or [ ]) ++ [ ]; + }); + }) + ]; } diff --git a/package/applefont/default.nix b/package/applefont/default.nix index 6c446b87..c5f45823 100644 --- a/package/applefont/default.nix +++ b/package/applefont/default.nix @@ -2,57 +2,59 @@ # They are not available in Nixpkgs repo, so this script # downloads the fonts from Apple website and adds them to Nix store. { - fetchurl, - lib, - p7zip, - stdenv, -}: let - pro = fetchurl { - sha256 = "1krvzxz7kal6y0l5cx9svmgikqdj5v0fl5vnfjig0z4nwp903ir1"; - url = "https://devimages-cdn.apple.com/design/resources/download/SF-Pro.dmg"; - }; - compact = fetchurl { - sha256 = "0ncybkrzqazw13azy2s30ss7ml5pxaia6hbmqq9wn7xhlhrxlniy"; - url = "https://devimages-cdn.apple.com/design/resources/download/SF-Compact.dmg"; - }; - mono = fetchurl { - sha256 = "0ibrk9fvbq52f5qnv1a8xlsazd3x3jnwwhpn2gwhdkdawdw0njkd"; - url = "https://devimages-cdn.apple.com/design/resources/download/SF-Mono.dmg"; - }; - ny = fetchurl { - sha256 = "1x7qi3dqwq1p4l3md31cd93mcds3ba7rgsmpz0kg7h3caasfsbhw"; - url = "https://devimages-cdn.apple.com/design/resources/download/NY.dmg"; - }; -in stdenv.mkDerivation { - name = "applefont"; - dontUnpack = true; - nativeBuildInputs = [ - p7zip - ]; - installPhase = let - unpackFont = dmg: dir: pkg: '' - 7z x '${dmg}' - pushd '${dir}' - 7z x '${pkg}' - 7z x 'Payload~' - cp Library/Fonts/* $TMPDIR - popd - ''; - in '' - ${unpackFont pro "SFProFonts" "SF Pro Fonts.pkg"} - ${unpackFont mono "SFMonoFonts" "SF Mono Fonts.pkg"} - ${unpackFont compact "SFCompactFonts" "SF Compact Fonts.pkg"} - ${unpackFont ny "NYFonts" "NY Fonts.pkg"} + fetchurl, + lib, + p7zip, + stdenv, +}: +let + pro = fetchurl { + sha256 = "1krvzxz7kal6y0l5cx9svmgikqdj5v0fl5vnfjig0z4nwp903ir1"; + url = "https://devimages-cdn.apple.com/design/resources/download/SF-Pro.dmg"; + }; + compact = fetchurl { + sha256 = "0ncybkrzqazw13azy2s30ss7ml5pxaia6hbmqq9wn7xhlhrxlniy"; + url = "https://devimages-cdn.apple.com/design/resources/download/SF-Compact.dmg"; + }; + mono = fetchurl { + sha256 = "0ibrk9fvbq52f5qnv1a8xlsazd3x3jnwwhpn2gwhdkdawdw0njkd"; + url = "https://devimages-cdn.apple.com/design/resources/download/SF-Mono.dmg"; + }; + ny = fetchurl { + sha256 = "1x7qi3dqwq1p4l3md31cd93mcds3ba7rgsmpz0kg7h3caasfsbhw"; + url = "https://devimages-cdn.apple.com/design/resources/download/NY.dmg"; + }; +in +stdenv.mkDerivation { + name = "applefont"; + dontUnpack = true; + nativeBuildInputs = [ p7zip ]; + installPhase = + let + unpackFont = dmg: dir: pkg: '' + 7z x '${dmg}' + pushd '${dir}' + 7z x '${pkg}' + 7z x 'Payload~' + cp Library/Fonts/* $TMPDIR + popd + ''; + in + '' + ${unpackFont pro "SFProFonts" "SF Pro Fonts.pkg"} + ${unpackFont mono "SFMonoFonts" "SF Mono Fonts.pkg"} + ${unpackFont compact "SFCompactFonts" "SF Compact Fonts.pkg"} + ${unpackFont ny "NYFonts" "NY Fonts.pkg"} - mkdir -p $out/usr/share/fonts/{TTF,OTF} - mv $TMPDIR/*.otf $out/usr/share/fonts/OTF - mv $TMPDIR/*.ttf $out/usr/share/fonts/TTF - ''; + mkdir -p $out/usr/share/fonts/{TTF,OTF} + mv $TMPDIR/*.otf $out/usr/share/fonts/OTF + mv $TMPDIR/*.ttf $out/usr/share/fonts/TTF + ''; - meta = with lib; { - description = "Apple San Francisco, New York fonts."; - homepage = "https://developer.apple.com/fonts"; - license = licenses.mit; - meta.platforms = platforms.all; - }; + meta = with lib; { + description = "Apple San Francisco, New York fonts."; + homepage = "https://developer.apple.com/fonts"; + license = licenses.mit; + meta.platforms = platforms.all; + }; } diff --git a/package/darkreader/default.nix b/package/darkreader/default.nix index 076cb089..d8afc513 100644 --- a/package/darkreader/default.nix +++ b/package/darkreader/default.nix @@ -1,23 +1,22 @@ { - __findFile, - buildNpmPackage, - fetchFromGitHub, - ... -}: buildNpmPackage rec { - version = "4.9.96"; - pname = "dark-reader"; - npmDepsHash = "sha256-dSuCL8GZXiksqVQ+TypzOdAROn3q30ExaGCJu72GLyY="; - src = fetchFromGitHub { - hash = "sha256-2AYIFVTTMns1u0jKk3XeFuYdC1MfG9aOCMjAfZtlXuI="; - owner = "darkreader"; - repo = "darkreader"; - rev = "v${version}"; - }; - patches = [ - - ]; - installPhase = '' - mkdir -p $out - cp build/release/darkreader-firefox.xpi $out/latest.xpi - ''; + __findFile, + buildNpmPackage, + fetchFromGitHub, + ... +}: +buildNpmPackage rec { + version = "4.9.96"; + pname = "dark-reader"; + npmDepsHash = "sha256-dSuCL8GZXiksqVQ+TypzOdAROn3q30ExaGCJu72GLyY="; + patches = [ ]; + src = fetchFromGitHub { + hash = "sha256-2AYIFVTTMns1u0jKk3XeFuYdC1MfG9aOCMjAfZtlXuI="; + owner = "darkreader"; + repo = "darkreader"; + rev = "v${version}"; + }; + installPhase = '' + mkdir -p $out + cp build/release/darkreader-firefox.xpi $out/latest.xpi + ''; } diff --git a/package/default.nix b/package/default.nix index 8575987b..629d7dff 100644 --- a/package/default.nix +++ b/package/default.nix @@ -1,170 +1,179 @@ { - pkgs, - pkgsMaster, - pkgsUnstable, - ... -} @args: { - core = (with pkgs; [ - android-tools # Android adb tool. Can be used to connect to itself via wireless debugging. - bat # Pretty cat. - binwalk # Can analyze files for other files inside them. - bridge-utils # Network bridges. - btop # System monitoring. - chafa # CLI file manager. - coreutils # UNIX Core utilities. - cryptsetup # Filesystem encryption (LUKS). - curl # Http client. - ddrescue # Data rescue extractor. - diffutils # Diff tool. - dnsutils # NS utilities. - exiftool # Image info. - file # Get general info about a file. - findutils # Find tool. - gawk # Awk. - gcc # C compiler. - gdu # TUI storage analyzer. - git # Version control system. - gnugrep # Grep. - gnumake # Make. - gnused # Sed. - gnutar # Tar. - gzip # Fast compression. - htop # System monitors. - imagemagick # Image converter and transformation tool. - inetutils # Things like FTP. - iputils # IP tools. - jq # Json parser. - libjxl # Jpeg XL. - lm_sensors # Hardware sensors, like temperature and fan speeds. - lshw # Detailed hardware info tool. - lsof # Find current file users. - ltex-ls # Latex LSP for neovim spellcheck. - man # App to read manuals. - neovim # Text editor. - nmap # Network scanning. - openssh # Ssh client. - openssl # Cryptography. - openvpn # Vpn client. - parallel # Run programs in parallel. - parted # CLI disk partition tool. - powertop # Monitor power usage. - pv # IO progress bar. - qrencode # Generate QR codes. - radare2 # Hex editor. - ripgrep # Better grep. - rsync # File copy tool. - smartmontools # S.M.A.R.T. tools. - sqlite # Serverless file-based database engine. - sshfs # Ssh client. - tcpdump # Sniff tool. - testdisk # Apps to recover data from drives. - tmux # Terminal multiplexor. - tree # Show directory stricture as a tree. - tree-sitter # A parser generator tool and an incremental parsing library. - tun2socks # Use proxy as a vpn. - unzip # Zip archive/unarchive tools. - usbutils # Usb utilities like udiskctl. - utillinux # Common Linux utilities. - ventoy # Boot multiple ISO/images from a single USB stick. - wcurl # CLI http client. - wireguard-tools # Tools to work with Wireguard. - xz # Archive and compression tools. - yazi # File manager. - zip # Zip utility. + pkgs, + pkgsMaster, + pkgsUnstable, + ... +}@args: +{ + core = + (with pkgs; [ + android-tools # Android adb tool. Can be used to connect to itself via wireless debugging. + bat # Pretty cat. + binwalk # Can analyze files for other files inside them. + bridge-utils # Network bridges. + btop # System monitoring. + chafa # CLI file manager. + coreutils # UNIX Core utilities. + cryptsetup # Filesystem encryption (LUKS). + curl # Http client. + ddrescue # Data rescue extractor. + diffutils # Diff tool. + dnsutils # NS utilities. + exiftool # Image info. + file # Get general info about a file. + findutils # Find tool. + gawk # Awk. + gcc # C compiler. + gdu # TUI storage analyzer. + git # Version control system. + gnugrep # Grep. + gnumake # Make. + gnused # Sed. + gnutar # Tar. + gzip # Fast compression. + htop # System monitors. + imagemagick # Image converter and transformation tool. + inetutils # Things like FTP. + iputils # IP tools. + jq # Json parser. + libjxl # Jpeg XL. + lm_sensors # Hardware sensors, like temperature and fan speeds. + lshw # Detailed hardware info tool. + lsof # Find current file users. + ltex-ls # Latex LSP for neovim spellcheck. + man # App to read manuals. + neovim # Text editor. + nmap # Network scanning. + openssh # Ssh client. + openssl # Cryptography. + openvpn # Vpn client. + parallel # Run programs in parallel. + parted # CLI disk partition tool. + powertop # Monitor power usage. + pv # IO progress bar. + qrencode # Generate QR codes. + radare2 # Hex editor. + ripgrep # Better grep. + rsync # File copy tool. + smartmontools # S.M.A.R.T. tools. + sqlite # Serverless file-based database engine. + sshfs # Ssh client. + tcpdump # Sniff tool. + testdisk # Apps to recover data from drives. + tmux # Terminal multiplexor. + tree # Show directory stricture as a tree. + tree-sitter # A parser generator tool and an incremental parsing library. + tun2socks # Use proxy as a vpn. + unzip # Zip archive/unarchive tools. + usbutils # Usb utilities like udiskctl. + utillinux # Common Linux utilities. + ventoy # Boot multiple ISO/images from a single USB stick. + wcurl # CLI http client. + wireguard-tools # Tools to work with Wireguard. + xz # Archive and compression tools. + yazi # File manager. + zip # Zip utility. - # (pkgs.callPackage ./ytdlp {}) # Youtube downloader bin package. - (pkgs.callPackage ./yamusicdownload { }) # Yandex music downloader. - ]) ++ (with pkgsUnstable; [ - fastfetch # Systeminfo summary. - ffmpeg # Video/audio converter. - ]) ++ (with pkgsMaster; [ - xray # Proxy. - yt-dlp # Video downloader. - zapret # FRKN. - ]); + # (pkgs.callPackage ./ytdlp {}) # Youtube downloader bin package. + (pkgs.callPackage ./yamusicdownload { }) # Yandex music downloader. + ]) + ++ (with pkgsUnstable; [ + fastfetch # Systeminfo summary. + ffmpeg # Video/audio converter. + ]) + ++ (with pkgsMaster; [ + xray # Proxy. + yt-dlp # Video downloader. + zapret # FRKN. + ]); - desktop = with pkgs; [ - adwaita-icon-theme # GTK icons. - foot # Terminal emulator. - fuzzel # Application launcher. - grim # Screenshots. - mako # Notification system. - networkmanagerapplet # Internet configuration. - pamixer # Sound controls. - pavucontrol # Sound applet. - playerctl # Multimedia controls. - pulseaudio # Audio. - slurp # Screen selection. - swappy # Screenshot editing. - sway # Sway WM. - waybar # Sway bar. - wf-recorder # Screen recording. + desktop = with pkgs; [ + adwaita-icon-theme # GTK icons. + foot # Terminal emulator. + fuzzel # Application launcher. + grim # Screenshots. + mako # Notification system. + networkmanagerapplet # Internet configuration. + pamixer # Sound controls. + pavucontrol # Sound applet. + playerctl # Multimedia controls. + pulseaudio # Audio. + slurp # Screen selection. + swappy # Screenshot editing. + sway # Sway WM. + waybar # Sway bar. + wf-recorder # Screen recording. - (pkgs.callPackage ./swayscript args) - ]; + (pkgs.callPackage ./swayscript args) + ]; - common = (with pkgs; [ - evince # Document viewer. - gimp # Image manipulation program. - glib # Gnome lib for gvfs mtp usage with Nintendo Switch. - gnome-calculator # Calculator. - gparted # GUI disk utility just in case. - jellyfin-media-player # Jellyfin client (self-hosted Netflix). - loupe # Image viewer. - mumble # VoIP. - obs-studio # Streaming/recording app. - onlyoffice-bin # Office documents app suite. - remmina # RDP app. - upscayl # Image upscaler. + common = + (with pkgs; [ + evince # Document viewer. + gimp # Image manipulation program. + glib # Gnome lib for gvfs mtp usage with Nintendo Switch. + gnome-calculator # Calculator. + gparted # GUI disk utility just in case. + jellyfin-media-player # Jellyfin client (self-hosted Netflix). + loupe # Image viewer. + mumble # VoIP. + obs-studio # Streaming/recording app. + onlyoffice-bin # Office documents app suite. + remmina # RDP app. + upscayl # Image upscaler. - (mpv.override { scripts = [ mpvScripts.mpris ]; }) # Media player. - ]) ++ (with pkgsUnstable; [ - tor-browser # Privacy browser. - ]); + (mpv.override { scripts = [ mpvScripts.mpris ]; }) # Media player. + ]) + ++ (with pkgsUnstable; [ + tor-browser # Privacy browser. + ]); - gaming = with pkgs; [ - bottles # GUI for Wine. - dxvk # Directx to Vulkan. - gamescope # Compositor for Steam. - mangohud # Realtime stats overlay. - scanmem # Memory edit tool. - steam # Gaming platform. - vkd3d # Directx to Vulkan. - wine64 # Run Windows software on Linux. - (steam.override { - extraLibraries = _: with pkgs; [ - (callPackage ./openssl100 {}) - curlWithGnuTls - ]; - }).run + gaming = with pkgs; [ + bottles # GUI for Wine. + dxvk # Directx to Vulkan. + gamescope # Compositor for Steam. + mangohud # Realtime stats overlay. + scanmem # Memory edit tool. + steam # Gaming platform. + vkd3d # Directx to Vulkan. + wine64 # Run Windows software on Linux. + (steam.override { + extraLibraries = + _: with pkgs; [ + (callPackage ./openssl100 { }) + curlWithGnuTls + ]; + }).run - # (import ./steamrun args).pkg # Steam env to run native games. - ]; + # (import ./steamrun args).pkg # Steam env to run native games. + ]; - creative = with pkgs; [ - aseprite # Pixel Art draw app. # WARN: Always builds from source. - blender-hip # Blender with HiP support. - krita # Draw! - ]; + creative = with pkgs; [ + aseprite # Pixel Art draw app. # WARN: Always builds from source. + blender-hip # Blender with HiP support. + krita # Draw! + ]; - dev = with pkgs; [ - android-studio - jetbrains.idea-community - ]; + dev = with pkgs; [ + android-studio + jetbrains.idea-community + ]; - extra = (with pkgs; [ - anilibria-winmaclinux # Anime! - appimage-run # Tool to run .AppImage files in NixOS. - blanket # Sounds generator. - calibre # Book library manager. - cbonsai # Draw trees. - cmatrix # CLI Screensavers. - cowsay # Cow quotes. - gnome-font-viewer # Font viewer. - jamesdsp # Active audio processing. - lolcat # CLI funni colors. - p7zip # Weird archive tool. - ]) ++ (with pkgsUnstable; [ - universal-android-debloater # Debloat Android devices. - ]); + extra = + (with pkgs; [ + anilibria-winmaclinux # Anime! + appimage-run # Tool to run .AppImage files in NixOS. + blanket # Sounds generator. + calibre # Book library manager. + cbonsai # Draw trees. + cmatrix # CLI Screensavers. + cowsay # Cow quotes. + gnome-font-viewer # Font viewer. + jamesdsp # Active audio processing. + lolcat # CLI funni colors. + p7zip # Weird archive tool. + ]) + ++ (with pkgsUnstable; [ + universal-android-debloater # Debloat Android devices. + ]); } diff --git a/package/homer/Config.nix b/package/homer/Config.nix index 28ebf176..d4a3ac89 100644 --- a/package/homer/Config.nix +++ b/package/homer/Config.nix @@ -1,97 +1,95 @@ +{ pkgs, config, ... }: +let + iconTheme = "fa-solid"; + links = [ (mkLink "Status" "fa-heartbeat" "https://status.voronind.com") ]; + services = [ + (mkGroup "App" "fa-server" [ + (mkLink "Change" "fa-user-secret" "https://change.voronind.com") + (mkLink "Cloud" "fa-cloud" "https://cloud.voronind.com") + (mkLink "Download" "fa-download" "https://download.voronind.com") + (mkLink "Git" "fab fa-git-alt" "https://git.voronind.com") + (mkLink "Iot" "fa-home" "https://iot.voronind.com") + (mkLink "Mail" "fa-envelope" "https://mail.voronind.com") + (mkLink "Paper" "fa-paperclip" "https://paper.voronind.com") + (mkLink "Pass" "fa-key" "https://pass.voronind.com") + (mkLink "Paste" "fa-paste" "https://paste.voronind.com") + (mkLink "Print" "fa-print" "https://print.voronind.com") + (mkLink "Read" "fa-book" "https://read.voronind.com") + (mkLink "Search" "fa-search" "https://search.voronind.com") + (mkLink "Stock" "fa-boxes-stacked" "https://stock.voronind.com") + (mkLink "Watch" "fa-film" "https://watch.voronind.com") + (mkLink "YouTube" "fab fa-youtube" "https://yt.voronind.com") + ]) + (mkGroup "System" "fa-shield" [ + (mkLink "Camera" "fa-camera" "https://camera.voronind.com") + (mkLink "Printer" "fa-print" "https://printer.voronind.com") + (mkLink "Router" "fa-route" "https://router.voronind.com") + (mkLink "Sync" "fa-sync" "https://sync.voronind.com") + ]) + (mkGroup "Bookmark" "fa-bookmark" [ + (mkLink "2gis" "fa-map-location-dot" "https://2gis.ru") + (mkLink "MonkeyType" "fa-keyboard" "https://monkeytype.com") + (mkLink "Reddit" "fab fa-reddit" "https://reddit.com") + (mkLink "Toolbox" "fa-toolbox" "https://it-tools.tech") + (mkLink "Zigbee" "fa-satellite-dish" "https://zigbee.blakadder.com") + ]) + (mkGroup "Pirate" "fa-skull-crossbones" [ + (mkLink "1337x" "fa-skull-crossbones" "https://1337x.to") + (mkLink "Cs.rin.ru" "fa-skull-crossbones" "https://cs.rin.ru/forum/index.php") + (mkLink "DigitalCore" "fa-skull-crossbones" "https://digitalcore.club") + (mkLink "FitGirl" "fa-skull-crossbones" "https://fitgirl-repacks.site") + (mkLink "Hf" "fa-skull-crossbones" "https://happyfappy.org") + (mkLink "Lst" "fa-skull-crossbones" "https://lst.gg") + (mkLink "NnmClub" "fa-skull-crossbones" "https://nnmclub.to") + (mkLink "Rutor" "fa-skull-crossbones" "https://rutor.info") + (mkLink "Rutracker" "fa-skull-crossbones" "https://rutracker.org") + (mkLink "Switch Upd" "fa-skull-crossbones" "https://sigmapatches.su") + (mkLink "Tapochek.net" "fa-skull-crossbones" "https://tapochek.net/index.php") + ]) + ]; + + mkGroup = name: icon: items: { + inherit name items; + icon = "${iconTheme} ${icon}"; + }; + + mkLink = name: icon: url: { + inherit name url; + icon = "${iconTheme} ${icon}"; + target = "_blank"; + }; + + cfg = { + inherit services links; + connectivityCheck = false; + footer = false; + header = false; + subtitle = "Home"; + theme = "default"; + title = "Dashboard"; + colors = + let + style = with config.module.style.color; { + background = "#${bg.dark}"; + card-background = "#${bg.regular}"; + card-shadow = "#${bg.regular}"; + highlight-hover = "#${accent}"; + highlight-primary = "#${fg.regular}"; + highlight-secondary = "#${bg.dark}"; + link = "#${fg.regular}"; + link-hover = "#${accent}"; + text = "#${fg.regular}"; + text-header = "#${fg.regular}"; + text-subtitle = "#${fg.light}"; + text-title = "#${fg.light}"; + }; + in + { + dark = style; + light = style; + }; + }; +in { - pkgs, - config, - ... -}: let - iconTheme = "fa-solid"; - links = [ - (mkLink "Status" "fa-heartbeat" "https://status.voronind.com") - ]; - services = [ - (mkGroup "App" "fa-server" [ - (mkLink "Change" "fa-user-secret" "https://change.voronind.com") - (mkLink "Cloud" "fa-cloud" "https://cloud.voronind.com") - (mkLink "Download" "fa-download" "https://download.voronind.com") - (mkLink "Git" "fab fa-git-alt" "https://git.voronind.com") - (mkLink "Iot" "fa-home" "https://iot.voronind.com") - (mkLink "Mail" "fa-envelope" "https://mail.voronind.com") - (mkLink "Paper" "fa-paperclip" "https://paper.voronind.com") - (mkLink "Pass" "fa-key" "https://pass.voronind.com") - (mkLink "Paste" "fa-paste" "https://paste.voronind.com") - (mkLink "Print" "fa-print" "https://print.voronind.com") - (mkLink "Read" "fa-book" "https://read.voronind.com") - (mkLink "Search" "fa-search" "https://search.voronind.com") - (mkLink "Stock" "fa-boxes-stacked" "https://stock.voronind.com") - (mkLink "Watch" "fa-film" "https://watch.voronind.com") - (mkLink "YouTube" "fab fa-youtube" "https://yt.voronind.com") - ]) - (mkGroup "System" "fa-shield" [ - (mkLink "Camera" "fa-camera" "https://camera.voronind.com") - (mkLink "Printer" "fa-print" "https://printer.voronind.com") - (mkLink "Router" "fa-route" "https://router.voronind.com") - (mkLink "Sync" "fa-sync" "https://sync.voronind.com") - ]) - (mkGroup "Bookmark" "fa-bookmark" [ - (mkLink "2gis" "fa-map-location-dot" "https://2gis.ru") - (mkLink "MonkeyType" "fa-keyboard" "https://monkeytype.com") - (mkLink "Reddit" "fab fa-reddit" "https://reddit.com") - (mkLink "Toolbox" "fa-toolbox" "https://it-tools.tech") - (mkLink "Zigbee" "fa-satellite-dish" "https://zigbee.blakadder.com") - ]) - (mkGroup "Pirate" "fa-skull-crossbones" [ - (mkLink "1337x" "fa-skull-crossbones" "https://1337x.to") - (mkLink "Cs.rin.ru" "fa-skull-crossbones" "https://cs.rin.ru/forum/index.php") - (mkLink "DigitalCore" "fa-skull-crossbones" "https://digitalcore.club") - (mkLink "FitGirl" "fa-skull-crossbones" "https://fitgirl-repacks.site") - (mkLink "Hf" "fa-skull-crossbones" "https://happyfappy.org") - (mkLink "Lst" "fa-skull-crossbones" "https://lst.gg") - (mkLink "NnmClub" "fa-skull-crossbones" "https://nnmclub.to") - (mkLink "Rutor" "fa-skull-crossbones" "https://rutor.info") - (mkLink "Rutracker" "fa-skull-crossbones" "https://rutracker.org") - (mkLink "Switch Upd" "fa-skull-crossbones" "https://sigmapatches.su") - (mkLink "Tapochek.net" "fa-skull-crossbones" "https://tapochek.net/index.php") - ]) - ]; - - mkGroup = name: icon: items: { - inherit name items; - icon = "${iconTheme} ${icon}"; - }; - - mkLink = name: icon: url: { - inherit name url; - icon = "${iconTheme} ${icon}"; - target = "_blank"; - }; - - cfg = { - inherit services links; - connectivityCheck = false; - footer = false; - header = false; - subtitle = "Home"; - theme = "default"; - title = "Dashboard"; - colors = let - style = with config.module.style.color; { - background = "#${bg.dark}"; - card-background = "#${bg.regular}"; - card-shadow = "#${bg.regular}"; - highlight-hover = "#${accent}"; - highlight-primary = "#${fg.regular}"; - highlight-secondary = "#${bg.dark}"; - link = "#${fg.regular}"; - link-hover = "#${accent}"; - text = "#${fg.regular}"; - text-header = "#${fg.regular}"; - text-subtitle = "#${fg.light}"; - text-title = "#${fg.light}"; - }; - in { - dark = style; - light = style; - }; - }; -in { - file = (pkgs.formats.yaml { }).generate "HomerConfig" cfg; + file = (pkgs.formats.yaml { }).generate "HomerConfig" cfg; } diff --git a/package/homer/default.nix b/package/homer/default.nix index 66389373..dae6a27a 100644 --- a/package/homer/default.nix +++ b/package/homer/default.nix @@ -1,29 +1,29 @@ { - config, - pkgs, - stdenv, - ... -} @args: let - cfg = (import ./Config.nix args).file; -in stdenv.mkDerivation (finalAttrs: { - dontUnpack = true; - pname = "Homer"; - version = "24.05.1"; - src = pkgs.fetchurl { - sha256 = "sha256-Ji/7BSKCnnhj4NIdGngTHcGRRbx9UWrx48bBsKkEj34="; - url = "https://github.com/bastienwirtz/homer/releases/download/v${finalAttrs.version}/homer.zip"; - }; - nativeBuildInputs = with pkgs; [ - unzip - ]; - installPhase = '' - runHook preInstall + config, + pkgs, + stdenv, + ... +}@args: +let + cfg = (import ./Config.nix args).file; +in +stdenv.mkDerivation (finalAttrs: { + dontUnpack = true; + pname = "Homer"; + version = "24.05.1"; + nativeBuildInputs = with pkgs; [ unzip ]; + src = pkgs.fetchurl { + sha256 = "sha256-Ji/7BSKCnnhj4NIdGngTHcGRRbx9UWrx48bBsKkEj34="; + url = "https://github.com/bastienwirtz/homer/releases/download/v${finalAttrs.version}/homer.zip"; + }; + installPhase = '' + runHook preInstall - mkdir -p $out/assets - pushd $out - unzip $src - cp ${cfg} $out/assets/config.yml + mkdir -p $out/assets + pushd $out + unzip $src + cp ${cfg} $out/assets/config.yml - runHook postInstall - ''; + runHook postInstall + ''; }) diff --git a/package/jobber/default.nix b/package/jobber/default.nix index 3565678f..addefe38 100644 --- a/package/jobber/default.nix +++ b/package/jobber/default.nix @@ -1,8 +1,5 @@ -{ - poetry2nix, - pkgs, - ... -}: let - inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication; +{ poetry2nix, pkgs, ... }: +let + inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication; in - mkPoetryApplication { projectDir = ./project; } +mkPoetryApplication { projectDir = ./project; } diff --git a/package/openssl100/default.nix b/package/openssl100/default.nix index 926c2887..62c71d8d 100644 --- a/package/openssl100/default.nix +++ b/package/openssl100/default.nix @@ -1,34 +1,32 @@ # SRC: https://git.azahi.cc/nixfiles/tree/packages/openssl_1_0_0.nix { - autoPatchelfHook, - fetchurl, - lib, - stdenvNoCC, -}: stdenvNoCC.mkDerivation (finalAttrs: { - pname = "openssl"; - version = "1.0.0"; + autoPatchelfHook, + fetchurl, + stdenvNoCC, +}: +stdenvNoCC.mkDerivation (finalAttrs: { + pname = "openssl"; + version = "1.0.0"; - sourceRoot = "x86_64"; + sourceRoot = "x86_64"; - dontBuild = true; - dontConfigure = true; - dontPatch = true; + dontBuild = true; + dontConfigure = true; + dontPatch = true; - src = fetchurl { - url = "https://downloads.dotslashplay.it/resources/openssl/openssl_${finalAttrs.version}.tar.xz"; - hash = "sha256-B8/FdkheAwrAtscn6dvUuen1slfRglM/kJb2xGm7uvA="; - }; + src = fetchurl { + url = "https://downloads.dotslashplay.it/resources/openssl/openssl_${finalAttrs.version}.tar.xz"; + hash = "sha256-B8/FdkheAwrAtscn6dvUuen1slfRglM/kJb2xGm7uvA="; + }; - nativeBuildInputs = [ - autoPatchelfHook - ]; + nativeBuildInputs = [ autoPatchelfHook ]; - installPhase = '' - runHook preInstall + installPhase = '' + runHook preInstall - install -Dm555 -t $out/lib libcrypto.so.1.0.0 - install -Dm555 -t $out/lib libssl.so.1.0.0 + install -Dm555 -t $out/lib libcrypto.so.1.0.0 + install -Dm555 -t $out/lib libssl.so.1.0.0 - runHook postInstall - ''; + runHook postInstall + ''; }) diff --git a/package/print/default.nix b/package/print/default.nix index 7e968998..192966e6 100644 --- a/package/print/default.nix +++ b/package/print/default.nix @@ -1,43 +1,44 @@ # SEE: https://github.com/NixOS/nixpkgs/blob/nixos-24.05/pkgs/misc/drivers/pantum-driver/default.nix { - fetchurl, - pkgs, - stdenv, - ... -}: stdenv.mkDerivation rec { - pname = "pantum-driver"; - dontUnpack = true; - version = "1.1.106"; - src = fetchurl { - hash = "sha256-IflzEM2kqqMqOQWZ5Eu906dEa85h+NFRmoR7y7WPX7Q="; - url = "https://cloud.voronind.com/s/k6Ea6QsrsKcAeNg/download/Pantum%20Ubuntu%20Driver%20V1_1_106.zip"; - }; - buildInputs = with pkgs; [ - cups - libjpeg8 - libusb1 - ]; - nativeBuildInputs = with pkgs; [ - autoPatchelfHook - dpkg - unzip - ]; - installPhase = '' - unzip $src - pushd Pantum\ Ubuntu\ Driver\ V1.1.106/ + fetchurl, + pkgs, + stdenv, + ... +}: +stdenv.mkDerivation rec { + pname = "pantum-driver"; + dontUnpack = true; + version = "1.1.106"; + src = fetchurl { + hash = "sha256-IflzEM2kqqMqOQWZ5Eu906dEa85h+NFRmoR7y7WPX7Q="; + url = "https://cloud.voronind.com/s/k6Ea6QsrsKcAeNg/download/Pantum%20Ubuntu%20Driver%20V1_1_106.zip"; + }; + buildInputs = with pkgs; [ + cups + libjpeg8 + libusb1 + ]; + nativeBuildInputs = with pkgs; [ + autoPatchelfHook + dpkg + unzip + ]; + installPhase = '' + unzip $src + pushd Pantum\ Ubuntu\ Driver\ V1.1.106/ - dpkg-deb -x ./Resources/pantum_${version}-1_amd64.deb . + dpkg-deb -x ./Resources/pantum_${version}-1_amd64.deb . - mkdir -p $out $out/lib - cp -r etc $out/ - cp -r usr/lib/cups $out/lib/ - cp -r usr/local/lib/* $out/lib/ - cp -r usr/share $out/ - cp Resources/locale/en_US.UTF-8/* $out/share/doc/pantum/ - ''; - # + '' - # cp -r opt/pantum/* $out/ - # ln -s $out/lib/libqpdf.so* $out/lib/libqpdf.so - # ln -s $out/lib/libqpdf.so $out/lib/libqpdf.so.21 - # ''; + mkdir -p $out $out/lib + cp -r etc $out/ + cp -r usr/lib/cups $out/lib/ + cp -r usr/local/lib/* $out/lib/ + cp -r usr/share $out/ + cp Resources/locale/en_US.UTF-8/* $out/share/doc/pantum/ + ''; + # + '' + # cp -r opt/pantum/* $out/ + # ln -s $out/lib/libqpdf.so* $out/lib/libqpdf.so + # ln -s $out/lib/libqpdf.so $out/lib/libqpdf.so.21 + # ''; } diff --git a/package/privatebin/Config.nix b/package/privatebin/Config.nix index 41518b7a..7272246c 100644 --- a/package/privatebin/Config.nix +++ b/package/privatebin/Config.nix @@ -1,54 +1,55 @@ +{ pkgs, lib, ... }: +let + cfg = { + main = { + compression = "none"; + defaultformatter = "plaintext"; + discussion = false; + email = true; + fileupload = false; + languageselection = false; + name = "voronind pastebin"; + password = true; + qrcode = true; + sizelimit = 10 * 1000 * 1000; + template = "bootstrap"; + }; + expire = { + default = "1week"; + }; + formatter_options = { + markdown = "Markdown"; + plaintext = "Plain Text"; + syntaxhighlighting = "Source Code"; + }; + traffic = { + limit = 10; + }; + purge = { + limit = 0; + batchsize = 10; + }; + model = { + class = "Database"; + }; + model_options = { + "opt[12]" = true; + dsn = "pgsql:dbname=privatebin"; + pwd = "privatebin"; + tbl = "privatebin_"; + usr = "privatebin"; + }; + }; +in { - config, - pkgs, - lib, - util, - ... -}: let - cfg = { - main = { - compression = "none"; - defaultformatter = "plaintext"; - discussion = false; - email = true; - fileupload = false; - languageselection = false; - name = "voronind pastebin"; - password = true; - qrcode = true; - sizelimit = 10 * 1000 * 1000; - template = "bootstrap"; - }; - expire = { - default = "1week"; - }; - formatter_options = { - markdown = "Markdown"; - plaintext = "Plain Text"; - syntaxhighlighting = "Source Code"; - }; - traffic = { - limit = 10; - }; - purge = { - limit = 0; - batchsize = 10; - }; - model = { - class = "Database"; - }; - model_options = { - "opt[12]" = true; - dsn = "pgsql:dbname=privatebin"; - pwd = "privatebin"; - tbl = "privatebin_"; - usr = "privatebin"; - }; - }; -in { - file = (pkgs.formats.ini { - mkKeyValue = with lib.generators; mkKeyValueDefault { - mkValueString = v: if builtins.isString v then "\"${toString v}\"" else toString v; - } " = "; - }).generate "PrivateBinConfig" cfg; + file = + (pkgs.formats.ini { + mkKeyValue = + with lib.generators; + mkKeyValueDefault { + mkValueString = v: if builtins.isString v then "\"${toString v}\"" else toString v; + } " = "; + }).generate + "PrivateBinConfig" + cfg; } diff --git a/package/privatebin/default.nix b/package/privatebin/default.nix index ce06904e..6abe23d9 100644 --- a/package/privatebin/default.nix +++ b/package/privatebin/default.nix @@ -1,36 +1,38 @@ { - config, - php, - pkgs, - ... -} @args: let - cfg = (import ./Config.nix args).file; -in php.buildComposerProject (finalAttrs: { - pname = "PrivateBin"; - vendorHash = "sha256-JGuO8kXLLXqq76EccdNSoHwYO5OuJT3Au1O2O2szAHI="; - version = "1.7.4"; - src = pkgs.fetchFromGitHub { - hash = "sha256-RFP6rhzfBzTmqs4eJXv7LqdniWoeBJpQQ6fLdoGd5Fk="; - owner = "PrivateBin"; - repo = "PrivateBin"; - rev = finalAttrs.version; - }; - installPhase = '' - runHook preInstall + config, + php, + pkgs, + ... +}@args: +let + cfg = (import ./Config.nix args).file; +in +php.buildComposerProject (finalAttrs: { + pname = "PrivateBin"; + vendorHash = "sha256-JGuO8kXLLXqq76EccdNSoHwYO5OuJT3Au1O2O2szAHI="; + version = "1.7.4"; + src = pkgs.fetchFromGitHub { + hash = "sha256-RFP6rhzfBzTmqs4eJXv7LqdniWoeBJpQQ6fLdoGd5Fk="; + owner = "PrivateBin"; + repo = "PrivateBin"; + rev = finalAttrs.version; + }; + installPhase = '' + runHook preInstall - mv $out/share/php/PrivateBin/* $out - rm -r $out/share + mv $out/share/php/PrivateBin/* $out + rm -r $out/share - cp ${cfg} $out/cfg/conf.php + cp ${cfg} $out/cfg/conf.php - touch $out/.env - pushd $out + touch $out/.env + pushd $out - runHook postInstall - ''; - postFixup = '' - substituteInPlace $out/index.php --replace-fail \ - "define('PATH', ''')" \ - "define('PATH', '$out/')" - ''; + runHook postInstall + ''; + postFixup = '' + substituteInPlace $out/index.php --replace-fail \ + "define('PATH', ''')" \ + "define('PATH', '$out/')" + ''; }) diff --git a/package/steamrun/default.nix b/package/steamrun/default.nix index 07347e0f..31531ba5 100644 --- a/package/steamrun/default.nix +++ b/package/steamrun/default.nix @@ -1,12 +1,11 @@ { - __findFile, - inputs, - pkgs, - ... -}: { - pkg = pkgs.callPackage "${inputs.nixpkgs}/pkgs/by-name/st/steam/package.nix" { - extraLibraries = pkgs: [ - (pkgs.callPackage {}) - ]; - }; + __findFile, + inputs, + pkgs, + ... +}: +{ + pkg = pkgs.callPackage "${inputs.nixpkgs}/pkgs/by-name/st/steam/package.nix" { + extraLibraries = pkgs: [ (pkgs.callPackage { }) ]; + }; } diff --git a/package/swayscript/default.nix b/package/swayscript/default.nix index 7c43d033..51a7ef09 100644 --- a/package/swayscript/default.nix +++ b/package/swayscript/default.nix @@ -1,5 +1,2 @@ -{ - pkgs, - util, - ... -} @args: pkgs.writeShellScriptBin "swayscript" (util.catText (util.ls ./script) args + "\${@}") +{ pkgs, util, ... }@args: +pkgs.writeShellScriptBin "swayscript" (util.catText (util.ls ./script) args + "\${@}") diff --git a/package/swayscript/script/DisplayWidget.nix b/package/swayscript/script/DisplayWidget.nix index c105a968..c3fefeb5 100644 --- a/package/swayscript/script/DisplayWidget.nix +++ b/package/swayscript/script/DisplayWidget.nix @@ -1,125 +1,126 @@ -{ ... }: { - text = '' - function monitor() { - notify_short - toggle() { - local output=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name') - local state=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .power') +{ ... }: +{ + text = '' + function monitor() { + notify_short + toggle() { + local output=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name') + local state=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .power') - if ''${state}; then - swaymsg "output \"''${output}\" power off" - else - swaymsg "output \"''${output}\" power on" - fi + if ''${state}; then + swaymsg "output \"''${output}\" power off" + else + swaymsg "output \"''${output}\" power on" + fi - pkill -RTMIN+4 waybar - } - _sway_iterate_sockets toggle - } + pkill -RTMIN+4 waybar + } + _sway_iterate_sockets toggle + } - function monitorreset() { - swaymsg 'output * power on' - pkill -RTMIN+4 waybar - } + function monitorreset() { + swaymsg 'output * power on' + pkill -RTMIN+4 waybar + } - function gaming() { - notify_short - toggle() { - local output=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name') - local state=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .adaptive_sync_status') + function gaming() { + notify_short + toggle() { + local output=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name') + local state=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .adaptive_sync_status') - if [[ "''${state}" = "disabled" ]]; then - swaymsg "output \"''${output}\" adaptive_sync on" - else - swaymsg "output \"''${output}\" adaptive_sync off" - fi + if [[ "''${state}" = "disabled" ]]; then + swaymsg "output \"''${output}\" adaptive_sync on" + else + swaymsg "output \"''${output}\" adaptive_sync off" + fi - pkill -RTMIN+4 waybar - } - _sway_iterate_sockets toggle - } + pkill -RTMIN+4 waybar + } + _sway_iterate_sockets toggle + } - function gamingreset() { - swaymsg 'output * adaptive_sync off' - pkill -RTMIN+4 waybar - } + function gamingreset() { + swaymsg 'output * adaptive_sync off' + pkill -RTMIN+4 waybar + } - function dnd() { - toggle() { - local state=$(makoctl mode) + function dnd() { + toggle() { + local state=$(makoctl mode) - if [[ "''${state}" = "dnd" ]]; then - makoctl mode -s default - notify_short - else - notify_short - makoctl mode -s dnd - fi + if [[ "''${state}" = "dnd" ]]; then + makoctl mode -s default + notify_short + else + notify_short + makoctl mode -s dnd + fi - pkill -RTMIN+4 waybar - } - _sway_iterate_sockets toggle - } + pkill -RTMIN+4 waybar + } + _sway_iterate_sockets toggle + } - # Reset the state of everything. - function displayreset() { - notify_long - [[ "''$(monitorstate)" = "Y" ]] && monitorreset - [[ "''$(gamingstate)" = "Y" ]] && gamingreset - [[ "''$(recordingstate)" = "Y" ]] && pkill wf-recorder - [[ "''$(dndstate)" = "Y" ]] && dnd - true - } + # Reset the state of everything. + function displayreset() { + notify_long + [[ "''$(monitorstate)" = "Y" ]] && monitorreset + [[ "''$(gamingstate)" = "Y" ]] && gamingreset + [[ "''$(recordingstate)" = "Y" ]] && pkill wf-recorder + [[ "''$(dndstate)" = "Y" ]] && dnd + true + } - # Waybar output. - function displaywidget() { - local _monitorstate=$(monitorstate) - local _gamingstate=$(gamingstate) - local _recordingstate=$(recordingstate) - local _dndstate=$(dndstate) - local class="" + # Waybar output. + function displaywidget() { + local _monitorstate=$(monitorstate) + local _gamingstate=$(gamingstate) + local _recordingstate=$(recordingstate) + local _dndstate=$(dndstate) + local class="" - if [[ "''${_monitorstate}" = "Y" ]] || [[ "''${_gamingstate}" = "Y" ]] || [[ "''${_recordingstate}" = "Y" ]] || [[ "''${_dndstate}" = "Y" ]]; then - class="modified" - fi + if [[ "''${_monitorstate}" = "Y" ]] || [[ "''${_gamingstate}" = "Y" ]] || [[ "''${_recordingstate}" = "Y" ]] || [[ "''${_dndstate}" = "Y" ]]; then + class="modified" + fi - printf "%s" "{\"text\": \"󰍹\", \"tooltip\": \"󰍶 ''${_dndstate}\\t󰶐 ''${_monitorstate}\\n󰡈 ''${_gamingstate}\\t󰻂 ''${_recordingstate}\", \"class\": \"''${class}\"}\n" - } + printf "%s" "{\"text\": \"󰍹\", \"tooltip\": \"󰍶 ''${_dndstate}\\t󰶐 ''${_monitorstate}\\n󰡈 ''${_gamingstate}\\t󰻂 ''${_recordingstate}\", \"class\": \"''${class}\"}\n" + } - function monitorstate() { - local outputs=($(swaymsg -t get_outputs | jq -r '.[] | .power')) + function monitorstate() { + local outputs=($(swaymsg -t get_outputs | jq -r '.[] | .power')) - for state in "''${outputs[@]}"; do - ''${state} || { - printf "%s" Y - return 1 - } - done + for state in "''${outputs[@]}"; do + ''${state} || { + printf "%s" Y + return 1 + } + done - printf "%s" n - return 0 - } + printf "%s" n + return 0 + } - function recordingstate() { - [[ "$(ps cax | rg wf-recorder)" = "" ]] && printf "%s" n || printf "%s" Y - } + function recordingstate() { + [[ "$(ps cax | rg wf-recorder)" = "" ]] && printf "%s" n || printf "%s" Y + } - function dndstate() { - [[ "$(makoctl mode)" = "dnd" ]] && printf "%s" Y || printf "%s" n - } + function dndstate() { + [[ "$(makoctl mode)" = "dnd" ]] && printf "%s" Y || printf "%s" n + } - function gamingstate() { - local outputs=($(swaymsg -t get_outputs | jq -r '.[] | .adaptive_sync_status')) + function gamingstate() { + local outputs=($(swaymsg -t get_outputs | jq -r '.[] | .adaptive_sync_status')) - for state in "''${outputs[@]}"; do - [[ "''${state}" = "disabled" ]] || { - printf "%s" Y - return 1 - } - done + for state in "''${outputs[@]}"; do + [[ "''${state}" = "disabled" ]] || { + printf "%s" Y + return 1 + } + done - printf "%s" n - return 0 - } - ''; + printf "%s" n + return 0 + } + ''; } diff --git a/package/swayscript/script/NetworkWidget.nix b/package/swayscript/script/NetworkWidget.nix index 7fdccf69..a31d5273 100644 --- a/package/swayscript/script/NetworkWidget.nix +++ b/package/swayscript/script/NetworkWidget.nix @@ -1,79 +1,80 @@ -{ ... }: { - text = '' - # Waybar output. - function networkwidget() { - local IFS=$'\n' - local internet=$(nmcli networking connectivity check) - local _ethernets=($(nmcli connection show --active | rg ethernet | sed "s/ .*//")) - local _vpns=($(nmcli connection show --active | rg vpn | sed "s/ .*//")) - local _wifis=($(nmcli connection show --active | rg wifi | sed "s/ .*//")) - local _bts_raw=($(bluetoothctl devices Connected)) - local _bts=() - local _bt_lowest=100 - local icon="󰖩" - local class="" +{ ... }: +{ + text = '' + # Waybar output. + function networkwidget() { + local IFS=$'\n' + local internet=$(nmcli networking connectivity check) + local _ethernets=($(nmcli connection show --active | rg ethernet | sed "s/ .*//")) + local _vpns=($(nmcli connection show --active | rg vpn | sed "s/ .*//")) + local _wifis=($(nmcli connection show --active | rg wifi | sed "s/ .*//")) + local _bts_raw=($(bluetoothctl devices Connected)) + local _bts=() + local _bt_lowest=100 + local icon="󰖩" + local class="" - for bt in ''${_bts_raw[@]}; do - local name=$(printf "%s" ''${bt} | cut -d\ -f3) - local mac=$(printf "%s" ''${bt} | cut -d\ -f2 | sed -e "s/:/_/g") - local bat=$(dbus-send --print-reply=literal --system --dest=org.bluez /org/bluez/hci0/dev_''${mac} org.freedesktop.DBus.Properties.Get string:"org.bluez.Battery1" string:"Percentage" 2> /dev/null | cut -d\ -f12) - local btinfo="''${name}" + for bt in ''${_bts_raw[@]}; do + local name=$(printf "%s" ''${bt} | cut -d\ -f3) + local mac=$(printf "%s" ''${bt} | cut -d\ -f2 | sed -e "s/:/_/g") + local bat=$(dbus-send --print-reply=literal --system --dest=org.bluez /org/bluez/hci0/dev_''${mac} org.freedesktop.DBus.Properties.Get string:"org.bluez.Battery1" string:"Percentage" 2> /dev/null | cut -d\ -f12) + local btinfo="''${name}" - if [[ "''${bat}" != "" ]]; then - btinfo+=" ''${bat}%" - [[ ''${bat} -lt ''${_bt_lowest} ]] && _bt_lowest=bat - fi + if [[ "''${bat}" != "" ]]; then + btinfo+=" ''${bat}%" + [[ ''${bat} -lt ''${_bt_lowest} ]] && _bt_lowest=bat + fi - _bts+=("''${btinfo}") - done + _bts+=("''${btinfo}") + done - if [[ "''${_bts}" != "" ]]; then - icon="󱛃" + if [[ "''${_bts}" != "" ]]; then + icon="󱛃" - if [[ "''${_bt_lowest}" != "" ]] && [[ ''${_bt_lowest} -lt 21 ]]; then - class="btlow" - fi - fi + if [[ "''${_bt_lowest}" != "" ]] && [[ ''${_bt_lowest} -lt 21 ]]; then + class="btlow" + fi + fi - if [[ "''${_vpns}" != "" ]]; then - class="vpn" - icon="󱚿" - fi + if [[ "''${_vpns}" != "" ]]; then + class="vpn" + icon="󱚿" + fi - if [[ "''${internet}" != "full" ]]; then - class="issue" - icon="󱚵" - fi + if [[ "''${internet}" != "full" ]]; then + class="issue" + icon="󱚵" + fi - for net in ''${_vpns[@]}; do - networks+=" ''${net}\\n" - done + for net in ''${_vpns[@]}; do + networks+=" ''${net}\\n" + done - for net in ''${_ethernets[@]}; do - networks+=" ''${net}\\n" - done + for net in ''${_ethernets[@]}; do + networks+=" ''${net}\\n" + done - for net in ''${_wifis[@]}; do - networks+="󰖩 ''${net}\\n" - done + for net in ''${_wifis[@]}; do + networks+="󰖩 ''${net}\\n" + done - for bt in ''${_bts[@]}; do - networks+="󰂯 ''${bt}\\n" - done + for bt in ''${_bts[@]}; do + networks+="󰂯 ''${bt}\\n" + done - networks=''${networks%\\n} - printf "%s" "{\"text\": \"''${icon}\", \"tooltip\": \"''${networks}\", \"class\": \"''${class}\"}\n" - } + networks=''${networks%\\n} + printf "%s" "{\"text\": \"''${icon}\", \"tooltip\": \"''${networks}\", \"class\": \"''${class}\"}\n" + } - # Toggle network. - function network() { - notify_short - local state=$(nmcli networking) - if [[ "''${state}" = "enabled" ]]; then - nmcli networking off - else - nmcli networking on - fi - } - ''; + # Toggle network. + function network() { + notify_short + local state=$(nmcli networking) + if [[ "''${state}" = "enabled" ]]; then + nmcli networking off + else + nmcli networking on + fi + } + ''; } diff --git a/package/swayscript/script/Notify.nix b/package/swayscript/script/Notify.nix index 5bfb5c37..c10783cb 100644 --- a/package/swayscript/script/Notify.nix +++ b/package/swayscript/script/Notify.nix @@ -1,22 +1,19 @@ +{ __findFile, pkgs, ... }: { - __findFile, - pkgs, - ... -}: { - text = '' - function notify() { - [[ "''$(dndstate)" = "Y" ]] && return - ${pkgs.pipewire}/bin/pw-cat -p ${} & - } + text = '' + function notify() { + [[ "''$(dndstate)" = "Y" ]] && return + ${pkgs.pipewire}/bin/pw-cat -p ${} & + } - function notify_short() { - [[ "''$(dndstate)" = "Y" ]] && return - ${pkgs.pipewire}/bin/pw-cat -p ${} & - } + function notify_short() { + [[ "''$(dndstate)" = "Y" ]] && return + ${pkgs.pipewire}/bin/pw-cat -p ${} & + } - function notify_long() { - [[ "''$(dndstate)" = "Y" ]] && return - ${pkgs.pipewire}/bin/pw-cat -p ${} & - } - ''; + function notify_long() { + [[ "''$(dndstate)" = "Y" ]] && return + ${pkgs.pipewire}/bin/pw-cat -p ${} & + } + ''; } diff --git a/package/swayscript/script/Reload.nix b/package/swayscript/script/Reload.nix index deb45fb7..341f9c94 100644 --- a/package/swayscript/script/Reload.nix +++ b/package/swayscript/script/Reload.nix @@ -1,30 +1,31 @@ -{ ... }: { - text = '' - # Reload. - function reload() { - # notify_long - re() { - # Sway. - swaymsg reload +{ ... }: +{ + text = '' + # Reload. + function reload() { + # notify_long + re() { + # Sway. + swaymsg reload - # Waybar. - pkill waybar - swaymsg exec waybar + # Waybar. + pkill waybar + swaymsg exec waybar - # Tmux. - tmux source-file ~/.config/tmux/tmux.conf + # Tmux. + tmux source-file ~/.config/tmux/tmux.conf - # Bash. - pkill -SIGUSR1 bash + # Bash. + pkill -SIGUSR1 bash - # Notifications. - makoctl reload + # Notifications. + makoctl reload - # Reset displays. - displayreset - } + # Reset displays. + displayreset + } - _sway_iterate_sockets re - } - ''; + _sway_iterate_sockets re + } + ''; } diff --git a/package/swayscript/script/Scratchpad.nix b/package/swayscript/script/Scratchpad.nix index fc758734..d45d432c 100644 --- a/package/swayscript/script/Scratchpad.nix +++ b/package/swayscript/script/Scratchpad.nix @@ -1,14 +1,15 @@ -{ ... }: { - text = '' - # Kill all windows in Sway scratchpad. - function scratchpad_kill() { - # notify_short - kill() { - for window in $(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?) | select(.name == "__i3_scratch").floating_nodes[].id'); do - swaymsg [ con_id="$window" ] kill - done - } - _sway_iterate_sockets kill - } - ''; +{ ... }: +{ + text = '' + # Kill all windows in Sway scratchpad. + function scratchpad_kill() { + # notify_short + kill() { + for window in $(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?) | select(.name == "__i3_scratch").floating_nodes[].id'); do + swaymsg [ con_id="$window" ] kill + done + } + _sway_iterate_sockets kill + } + ''; } diff --git a/package/swayscript/script/Sound.nix b/package/swayscript/script/Sound.nix index a92455f4..b83da2c0 100644 --- a/package/swayscript/script/Sound.nix +++ b/package/swayscript/script/Sound.nix @@ -1,17 +1,18 @@ -{ ... }: { - text = '' - function sound_output_cycle() { - notify_short - local IFS=$'\n' - local current=$(pactl get-default-sink) - local all=($(pactl list short sinks | cut -f2)) - local i_current=$(_index_of ''${current} ''${all[@]}) - local i_total=''${#all[@]}; ((i_total--)) - local i_target=0 +{ ... }: +{ + text = '' + function sound_output_cycle() { + notify_short + local IFS=$'\n' + local current=$(pactl get-default-sink) + local all=($(pactl list short sinks | cut -f2)) + local i_current=$(_index_of ''${current} ''${all[@]}) + local i_total=''${#all[@]}; ((i_total--)) + local i_target=0 - [[ "''${i_current}" -lt "''${i_total}" ]] && i_target=$((i_current+1)) + [[ "''${i_current}" -lt "''${i_total}" ]] && i_target=$((i_current+1)) - pactl set-default-sink ''${all[''${i_target}]} - } - ''; + pactl set-default-sink ''${all[''${i_target}]} + } + ''; } diff --git a/package/swayscript/script/Util.nix b/package/swayscript/script/Util.nix index 6c91622d..cfefa7e0 100644 --- a/package/swayscript/script/Util.nix +++ b/package/swayscript/script/Util.nix @@ -1,19 +1,16 @@ +{ __findFile, ... }: { - __findFile, - pkgs, - ... -}: { - text = '' - # Find currently active SWAYSOCK paths. - function _sway_find_sockets() { - ls /run/user/''${UID}/sway-ipc.''${UID}.*.sock - } + text = '' + # Find currently active SWAYSOCK paths. + function _sway_find_sockets() { + ls /run/user/''${UID}/sway-ipc.''${UID}.*.sock + } - function _sway_iterate_sockets() { - local IFS=$'\n' - for socket in $(_sway_find_sockets); do - SWAYSOCK="''${socket}" ''${1} - done - } - ''; + function _sway_iterate_sockets() { + local IFS=$'\n' + for socket in $(_sway_find_sockets); do + SWAYSOCK="''${socket}" ''${1} + done + } + ''; } diff --git a/package/swayscript/script/Vpn.nix b/package/swayscript/script/Vpn.nix index d5578cb9..9b3ba004 100644 --- a/package/swayscript/script/Vpn.nix +++ b/package/swayscript/script/Vpn.nix @@ -1,18 +1,19 @@ -{ ... }: { - text = '' - # Toggle vpn. - function vpn() { - notify_short - if [[ "$(_vpn)" = "on" ]]; then - nmcli connection down Vpn - else - nmcli connection up Vpn - fi - } +{ ... }: +{ + text = '' + # Toggle vpn. + function vpn() { + notify_short + if [[ "$(_vpn)" = "on" ]]; then + nmcli connection down Vpn + else + nmcli connection up Vpn + fi + } - function _vpn() { - local state=$(nmcli connection show Vpn | rg -i state.*activated) - [ "''${state}" != "" ] && printf on || printf off - } - ''; + function _vpn() { + local state=$(nmcli connection show Vpn | rg -i state.*activated) + [ "''${state}" != "" ] && printf on || printf off + } + ''; } diff --git a/package/wm2fc/default.nix b/package/wm2fc/default.nix index d4d85386..5bb471f5 100644 --- a/package/wm2fc/default.nix +++ b/package/wm2fc/default.nix @@ -1,29 +1,28 @@ # SRC: https://github.com/matega/win-max-2-fan-control # NOTE: Speeds are from 0 to 184 (23 int). "a" for auto (disable). { - autoPatchelfHook, - fetchFromGitHub, - lib, - stdenv, -}: stdenv.mkDerivation { - # dontUnpack = true; - name = "wm2fc"; - src = fetchFromGitHub { - hash = "sha256-rU0n+4glTWHWjbvbc7Se0O53g1mVDwBP5SkH4ftwNWk="; - owner = "matega"; - repo = "win-max-2-fan-control"; - rev = "a9e65011e0b45d0a76fc5307ad2b7b585410dece"; - }; - installPhase = '' - runHook preInstall - install -Dm755 dist/Debug/GNU-Linux/winmax2fancontrol $out/bin/wm2fc - runHook postInstall - ''; - meta = with lib; { - description = "GPD Win Max 2 Fan Control PoC"; - license = licenses.gpl3; - mainProgram = "wm2fc"; - meta.platforms = platforms.all; - }; + fetchFromGitHub, + lib, + stdenv, +}: +stdenv.mkDerivation { + # dontUnpack = true; + name = "wm2fc"; + src = fetchFromGitHub { + hash = "sha256-rU0n+4glTWHWjbvbc7Se0O53g1mVDwBP5SkH4ftwNWk="; + owner = "matega"; + repo = "win-max-2-fan-control"; + rev = "a9e65011e0b45d0a76fc5307ad2b7b585410dece"; + }; + installPhase = '' + runHook preInstall + install -Dm755 dist/Debug/GNU-Linux/winmax2fancontrol $out/bin/wm2fc + runHook postInstall + ''; + meta = with lib; { + description = "GPD Win Max 2 Fan Control PoC"; + license = licenses.gpl3; + mainProgram = "wm2fc"; + meta.platforms = platforms.all; + }; } - diff --git a/package/yamusicdownload/default.nix b/package/yamusicdownload/default.nix index c4292de3..9f36bc41 100644 --- a/package/yamusicdownload/default.nix +++ b/package/yamusicdownload/default.nix @@ -1,22 +1,21 @@ -{ - pkgs, - ... -}: with pkgs.python3Packages; buildPythonPackage { - format = "pyproject"; - meta.mainProgram = "yandex-music-downloader"; - pname = "yandex-music-downloader"; - version = "1.0.0"; - propagatedBuildInputs = [ - browser-cookie3 - eyed3 - requests - setuptools - setuptools-git - ]; - src = pkgs.fetchFromGitHub { - hash = "sha256-WOFesD7HjskyqHaXZAPy3pgSPaEO+tOyQ+5MV3ZO7XU="; - owner = "llistochek"; - repo = "yandex-music-downloader"; - rev = "08ea384869cbc31efb1e78b831e2356882219951"; - }; +{ pkgs, ... }: +with pkgs.python3Packages; +buildPythonPackage { + format = "pyproject"; + meta.mainProgram = "yandex-music-downloader"; + pname = "yandex-music-downloader"; + version = "1.0.0"; + propagatedBuildInputs = [ + browser-cookie3 + eyed3 + requests + setuptools + setuptools-git + ]; + src = pkgs.fetchFromGitHub { + hash = "sha256-WOFesD7HjskyqHaXZAPy3pgSPaEO+tOyQ+5MV3ZO7XU="; + owner = "llistochek"; + repo = "yandex-music-downloader"; + rev = "08ea384869cbc31efb1e78b831e2356882219951"; + }; } diff --git a/package/ytdlp/default.nix b/package/ytdlp/default.nix index 62a74c4f..8ab26f2f 100644 --- a/package/ytdlp/default.nix +++ b/package/ytdlp/default.nix @@ -1,31 +1,31 @@ { - autoPatchelfHook, - fetchurl, - lib, - stdenv, -}: let - hash = "sha256-rwVwteYBlqF4WhLn9I/Hy3tXRbC7mHDKL+btkN3YC0Y="; - version = "2024.05.27"; -in stdenv.mkDerivation { - dontUnpack = true; - name = "ytdlp"; - src = fetchurl { - sha256 = "${hash}"; - url = "https://github.com/yt-dlp/yt-dlp/releases/download/${version}/yt-dlp_linux"; - }; - nativeBuildInputs = [ - autoPatchelfHook - ]; - installPhase = '' - mkdir -p $out/bin - cp $src $out/bin/yt-dlp - chmod +x $out/bin/yt-dlp - ''; - meta = with lib; { - description = "Youtube Downloader."; - homepage = "https://github.com/yt-dlp/yt-dlp"; - license = licenses.unlicense; - mainProgram = "yt-dlp"; - meta.platforms = platforms.all; - }; + autoPatchelfHook, + fetchurl, + lib, + stdenv, +}: +let + hash = "sha256-rwVwteYBlqF4WhLn9I/Hy3tXRbC7mHDKL+btkN3YC0Y="; + version = "2024.05.27"; +in +stdenv.mkDerivation { + dontUnpack = true; + name = "ytdlp"; + src = fetchurl { + sha256 = "${hash}"; + url = "https://github.com/yt-dlp/yt-dlp/releases/download/${version}/yt-dlp_linux"; + }; + nativeBuildInputs = [ autoPatchelfHook ]; + installPhase = '' + mkdir -p $out/bin + cp $src $out/bin/yt-dlp + chmod +x $out/bin/yt-dlp + ''; + meta = with lib; { + description = "Youtube Downloader."; + homepage = "https://github.com/yt-dlp/yt-dlp"; + license = licenses.unlicense; + mainProgram = "yt-dlp"; + meta.platforms = platforms.all; + }; } diff --git a/patch/swappy/DefaultColor.nix b/patch/swappy/DefaultColor.nix index 7a6da8a6..6ce4abcf 100644 --- a/patch/swappy/DefaultColor.nix +++ b/patch/swappy/DefaultColor.nix @@ -1,60 +1,58 @@ +{ config, pkgs, ... }: +let + color = config.module.style.color; + accentR = color.accentDecR; + accentG = color.accentDecG; + accentB = color.accentDecB; +in { - config, - pkgs, - ... -}: let - color = config.module.style.color; - accentR = color.accentDecR; - accentG = color.accentDecG; - accentB = color.accentDecB; -in { - file = pkgs.writeText "SwappyDefaultColorPatch" '' -diff --git a/res/style/swappy.css b/res/style/swappy.css -index 66013b3..9c88f84 100644 ---- a/res/style/swappy.css -+++ b/res/style/swappy.css -@@ -21,9 +21,9 @@ - } + file = pkgs.writeText "SwappyDefaultColorPatch" '' + diff --git a/res/style/swappy.css b/res/style/swappy.css + index 66013b3..9c88f84 100644 + --- a/res/style/swappy.css + +++ b/res/style/swappy.css + @@ -21,9 +21,9 @@ + } - .color-box .color-green image { -- background-color: rgb(0, 255, 0); -+ background-color: rgb(255, 255, 255); - } + .color-box .color-green image { + - background-color: rgb(0, 255, 0); + + background-color: rgb(255, 255, 255); + } - .color-box .color-blue image { -- background-color: rgb(0, 0, 255); -+ background-color: rgb(0, 0, 0); - } -diff --git a/src/application.c b/src/application.c -index 5b98590..5c7e99c 100644 ---- a/src/application.c -+++ b/src/application.c -@@ -601,11 +601,11 @@ void color_red_clicked_handler(GtkWidget *widget, struct swappy_state *state) { + .color-box .color-blue image { + - background-color: rgb(0, 0, 255); + + background-color: rgb(0, 0, 0); + } + diff --git a/src/application.c b/src/application.c + index 5b98590..5c7e99c 100644 + --- a/src/application.c + +++ b/src/application.c + @@ -601,11 +601,11 @@ void color_red_clicked_handler(GtkWidget *widget, struct swappy_state *state) { - void color_green_clicked_handler(GtkWidget *widget, - struct swappy_state *state) { -- action_update_color_state(state, 0, 1, 0, 1, false); -+ action_update_color_state(state, 0, 0, 0, 1, false); - } + void color_green_clicked_handler(GtkWidget *widget, + struct swappy_state *state) { + - action_update_color_state(state, 0, 1, 0, 1, false); + + action_update_color_state(state, 0, 0, 0, 1, false); + } - void color_blue_clicked_handler(GtkWidget *widget, struct swappy_state *state) { -- action_update_color_state(state, 0, 0, 1, 1, false); -+ action_update_color_state(state, 1, 1, 1, 1, false); - } + void color_blue_clicked_handler(GtkWidget *widget, struct swappy_state *state) { + - action_update_color_state(state, 0, 0, 1, 1, false); + + action_update_color_state(state, 1, 1, 1, 1, false); + } - void color_custom_clicked_handler(GtkWidget *widget, -@@ -875,9 +875,9 @@ static gboolean is_file_from_stdin(const char *file) { - } + void color_custom_clicked_handler(GtkWidget *widget, + @@ -875,9 +875,9 @@ static gboolean is_file_from_stdin(const char *file) { + } - static void init_settings(struct swappy_state *state) { -- state->settings.r = 1; -- state->settings.g = 0; -- state->settings.b = 0; -+ state->settings.r = ${accentR}; -+ state->settings.g = ${accentG}; -+ state->settings.b = ${accentB}; - state->settings.a = 1; - state->settings.w = state->config->line_size; - state->settings.t = state->config->text_size; - ''; + static void init_settings(struct swappy_state *state) { + - state->settings.r = 1; + - state->settings.g = 0; + - state->settings.b = 0; + + state->settings.r = ${accentR}; + + state->settings.g = ${accentG}; + + state->settings.b = ${accentB}; + state->settings.a = 1; + state->settings.w = state->config->line_size; + state->settings.t = state->config->text_size; + ''; } diff --git a/secret/default.nix b/secret/default.nix index 68e356df..1e246c64 100644 --- a/secret/default.nix +++ b/secret/default.nix @@ -1,77 +1,81 @@ -{ ... }: { - # Password used for root user. - hashedPassword = "$y$j9T$oqCB16i5E2t1t/HAWaFd5.$tTaHtAcifXaDVpTcRv.yH2/eWKxKE9xM8KcqXHfHrD7"; # Use `mkpasswd -s`. +{ ... }: +{ + # Password used for root user. + hashedPassword = "$y$j9T$oqCB16i5E2t1t/HAWaFd5.$tTaHtAcifXaDVpTcRv.yH2/eWKxKE9xM8KcqXHfHrD7"; # Use `mkpasswd -s`. - ssh = { - # Keys that are allowed to connect via SSH. - trustedKeys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJTI4IUkHH0JSzWDKOAMbzEDbyBXOrmTHRy+tpqJ8twx nix-on-droid@nothing2" - (builtins.readFile ./Ssh.key) - ]; + ssh = { + # Keys that are allowed to connect via SSH. + trustedKeys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJTI4IUkHH0JSzWDKOAMbzEDbyBXOrmTHRy+tpqJ8twx nix-on-droid@nothing2" + (builtins.readFile ./Ssh.key) + ]; - # Keys that are allowd to connect via SSH to nixbuild user for Nix remote builds. - builderKey = "nixbuilder-1:Skghjixd8lPzNe2ZEgYLM9Pu/wF9wiZtZGsdm3bo9h0="; - buildKeys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIENY0NICXvlTOSZEwivRHEGO1PUzgsmoHwf+zqS7WsGV root@max" - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEHkH1xq78T2H1/c/Ej2O46v16Cuivt8zW3kUd0K6hwL root@pocket" - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuuw5ek5wGB9KdBhCTxjV+CBpPU6RIOynHkFYC4dau3 root@dasha" - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFgiYKFkMfiGOZCZIk+O7LtaoF6A3cHEFCqaPwXOM4rR root@work" - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGIf192IxsksM6u8UY+eqpHopebgV+NNq2G03ssdXIgz root@desktop" - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJSWdbkYsRiDlKu8iT/k+JN4KY08iX9qh4VyqxlpEZcE root@home" - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOaoyC/grc3SfO5blKWRUwW+dLlcfyvuvWjymprfIeqN root@laptop" - ]; - }; + # Keys that are allowd to connect via SSH to nixbuild user for Nix remote builds. + builderKey = "nixbuilder-1:Skghjixd8lPzNe2ZEgYLM9Pu/wF9wiZtZGsdm3bo9h0="; + buildKeys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIENY0NICXvlTOSZEwivRHEGO1PUzgsmoHwf+zqS7WsGV root@max" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEHkH1xq78T2H1/c/Ej2O46v16Cuivt8zW3kUd0K6hwL root@pocket" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuuw5ek5wGB9KdBhCTxjV+CBpPU6RIOynHkFYC4dau3 root@dasha" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFgiYKFkMfiGOZCZIk+O7LtaoF6A3cHEFCqaPwXOM4rR root@work" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGIf192IxsksM6u8UY+eqpHopebgV+NNq2G03ssdXIgz root@desktop" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJSWdbkYsRiDlKu8iT/k+JN4KY08iX9qh4VyqxlpEZcE root@home" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOaoyC/grc3SfO5blKWRUwW+dLlcfyvuvWjymprfIeqN root@laptop" + ]; + }; - crypto = { - # Git commit signing. - sign.git = { - allowed = ./Signers.key; - format = "ssh"; - key = ./Ssh.key; - }; + crypto = { + # Git commit signing. + sign.git = { + allowed = ./Signers.key; + format = "ssh"; + key = ./Ssh.key; + }; - # List of accepted public keys. - publicKeys = [ - { - source = ./Gpg.key; - trust = 5; - } - ]; - }; + # List of accepted public keys. + publicKeys = [ + { + source = ./Gpg.key; + trust = 5; + } + ]; + }; - tg = { - # Ob fs lo l. - bt = "ht" - + "tp" - + "s://ap" - + "i.tel" - + "egra" - + "m.or" - + "g/bo" - + "t2046" - + "84944" - + "1:A" - + "AHQpjRK" - + "4xpL" - + "8tEUyN" - + "4JTSD" - + "UUze" - + "4J0wSI" - + "y4/" - + "sen" - + "dMes" - + "sage"; - dt = dn: "{\\\"cha" - + "t_i" - + "d\\\":\\\"155" - + "8973" - + "58\\\",\\\"te" - + "xt\\\":\\\"$" - + "1\\\",\\\"di" - + "sabl" - + "e_no" - + "tific" - + "atio" - + "n\\\":\\\"${dn}\\\"}"; - }; + tg = { + # Ob fs lo l. + bt = + "ht" + + "tp" + + "s://ap" + + "i.tel" + + "egra" + + "m.or" + + "g/bo" + + "t2046" + + "84944" + + "1:A" + + "AHQpjRK" + + "4xpL" + + "8tEUyN" + + "4JTSD" + + "UUze" + + "4J0wSI" + + "y4/" + + "sen" + + "dMes" + + "sage"; + dt = + dn: + "{\\\"cha" + + "t_i" + + "d\\\":\\\"155" + + "8973" + + "58\\\",\\\"te" + + "xt\\\":\\\"$" + + "1\\\",\\\"di" + + "sabl" + + "e_no" + + "tific" + + "atio" + + "n\\\":\\\"${dn}\\\"}"; + }; } diff --git a/system/Bootloader.nix b/system/Bootloader.nix index 38c94bc7..e90d6c0b 100644 --- a/system/Bootloader.nix +++ b/system/Bootloader.nix @@ -1,32 +1,31 @@ -{ ... }: { - # Enable non-free firmware. - hardware.enableRedistributableFirmware = true; +{ ... }: +{ + # Enable non-free firmware. + hardware.enableRedistributableFirmware = true; - # Configure bootloader. - boot = { - tmp.useTmpfs = true; - loader = { - efi.canTouchEfiVariables = true; - systemd-boot = { - enable = true; - configurationLimit = 10; - }; - }; - initrd = { - kernelModules = [ - "dm-snapshot" - ]; - availableKernelModules = [ - "ahci" - "ata_piix" - "mptspi" - "nvme" - "sd_mod" - "sr_mod" - "usb_storage" - "usbhid" - "xhci_pci" - ]; - }; - }; + # Configure bootloader. + boot = { + tmp.useTmpfs = true; + loader = { + efi.canTouchEfiVariables = true; + systemd-boot = { + enable = true; + configurationLimit = 10; + }; + }; + initrd = { + kernelModules = [ "dm-snapshot" ]; + availableKernelModules = [ + "ahci" + "ata_piix" + "mptspi" + "nvme" + "sd_mod" + "sr_mod" + "usb_storage" + "usbhid" + "xhci_pci" + ]; + }; + }; } diff --git a/system/Crypto.nix b/system/Crypto.nix index b881f708..bd22ab67 100644 --- a/system/Crypto.nix +++ b/system/Crypto.nix @@ -1,33 +1,29 @@ +{ pkgs, ... }: { - pkgs, - ... -}: { - # GPG. - services.udev.packages = [ - pkgs.yubikey-personalization - ]; + # GPG. + services.udev.packages = [ pkgs.yubikey-personalization ]; - programs.gnupg.agent = { - enable = true; - enableSSHSupport = true; - pinentryPackage = pkgs.pinentry-tty; - }; + programs.gnupg.agent = { + enable = true; + enableSSHSupport = true; + pinentryPackage = pkgs.pinentry-tty; + }; - # PCSC. - services.pcscd.enable = true; + # PCSC. + services.pcscd.enable = true; - # Yubikey touch notification. - # ISSUE: Not working on Sway with Mako for some reason. - programs.yubikey-touch-detector.enable = true; + # Yubikey touch notification. + # ISSUE: Not working on Sway with Mako for some reason. + programs.yubikey-touch-detector.enable = true; - environment.systemPackages = with pkgs; [ - libfido2 - yubikey-manager - # yubioath-desktop # OTP. - ]; + environment.systemPackages = with pkgs; [ + libfido2 + yubikey-manager + # yubioath-desktop # OTP. + ]; - # Store GPG data on tmpfs. - # environment.variables = { - # GNUPGHOME = "$(mktemp -d -t gnupg-$(date +%Y-%m-%d)-XXXXXXXXXX)"; - # }; + # Store GPG data on tmpfs. + # environment.variables = { + # GNUPGHOME = "$(mktemp -d -t gnupg-$(date +%Y-%m-%d)-XXXXXXXXXX)"; + # }; } diff --git a/system/Dbus.nix b/system/Dbus.nix index 11c4da24..822f5abc 100644 --- a/system/Dbus.nix +++ b/system/Dbus.nix @@ -1,3 +1,4 @@ -{ ... }: { - services.dbus.implementation = "broker"; +{ ... }: +{ + services.dbus.implementation = "broker"; } diff --git a/system/Filesystem.nix b/system/Filesystem.nix index 3ca566b9..1caa2e03 100644 --- a/system/Filesystem.nix +++ b/system/Filesystem.nix @@ -1,17 +1,16 @@ # I use the same layout on all hosts with GPT labels. # This way I can configure system's FS in one place here. -{ ... }: { - fileSystems = { - "/" = { - device = "/dev/disk/by-partlabel/NIXROOT"; - fsType = "ext4"; - options = [ - "noatime" - ]; - }; - "/boot" = { - device = "/dev/disk/by-partlabel/NIXBOOT"; - fsType = "vfat"; - }; - }; +{ ... }: +{ + fileSystems = { + "/" = { + device = "/dev/disk/by-partlabel/NIXROOT"; + fsType = "ext4"; + options = [ "noatime" ]; + }; + "/boot" = { + device = "/dev/disk/by-partlabel/NIXBOOT"; + fsType = "vfat"; + }; + }; } diff --git a/system/Firewall.nix b/system/Firewall.nix index 5013fa53..b986e8f6 100644 --- a/system/Firewall.nix +++ b/system/Firewall.nix @@ -1,22 +1,20 @@ +{ lib, ... }: { - lib, - ... -}: { - networking.firewall = { - enable = true; + networking.firewall = { + enable = true; - # NOTE: Configure manually with `extraCommands`. - allowedTCPPortRanges = lib.mkForce [ ]; - allowedTCPPorts = lib.mkForce [ ]; - allowedUDPPortRanges = lib.mkForce [ ]; - allowedUDPPorts = lib.mkForce [ ]; + # NOTE: Configure manually with `extraCommands`. + allowedTCPPortRanges = lib.mkForce [ ]; + allowedTCPPorts = lib.mkForce [ ]; + allowedUDPPortRanges = lib.mkForce [ ]; + allowedUDPPorts = lib.mkForce [ ]; - allowPing = true; - rejectPackets = false; # Drop. + allowPing = true; + rejectPackets = false; # Drop. - logRefusedConnections = false; - logRefusedPackets = false; - logRefusedUnicastsOnly = true; - logReversePathDrops = false; - }; + logRefusedConnections = false; + logRefusedPackets = false; + logRefusedUnicastsOnly = true; + logReversePathDrops = false; + }; } diff --git a/system/Font.nix b/system/Font.nix index f52a9d6b..e73808c7 100644 --- a/system/Font.nix +++ b/system/Font.nix @@ -1,12 +1,9 @@ +{ __findFile, pkgs, ... }: { - __findFile, - pkgs, - ... -}: { - fonts.packages = with pkgs; [ - (nerdfonts.override { fonts = [ "Terminus" ]; }) - (pkgs.callPackage { }) - font-awesome - minecraftia - ]; + fonts.packages = with pkgs; [ + (nerdfonts.override { fonts = [ "Terminus" ]; }) + (pkgs.callPackage { }) + font-awesome + minecraftia + ]; } diff --git a/system/Fstrim.nix b/system/Fstrim.nix index 7b475809..c7d1151b 100644 --- a/system/Fstrim.nix +++ b/system/Fstrim.nix @@ -1,3 +1,4 @@ -{ ... }: { - services.fstrim.enable = true; +{ ... }: +{ + services.fstrim.enable = true; } diff --git a/system/Locale.nix b/system/Locale.nix index 74c95dd4..483949da 100644 --- a/system/Locale.nix +++ b/system/Locale.nix @@ -1,20 +1,18 @@ +{ const, ... }: { - const, - ... -}: { - time.timeZone = const.timeZone; - i18n = { - defaultLocale = "en_US.UTF-8"; - extraLocaleSettings = { - LC_ADDRESS = "ru_RU.UTF-8"; - LC_IDENTIFICATION = "ru_RU.UTF-8"; - LC_MEASUREMENT = "ru_RU.UTF-8"; - LC_MONETARY = "ru_RU.UTF-8"; - LC_NAME = "ru_RU.UTF-8"; - LC_NUMERIC = "en_GB.UTF-8"; - LC_PAPER = "ru_RU.UTF-8"; - LC_TELEPHONE = "ru_RU.UTF-8"; - LC_TIME = "en_GB.UTF-8"; - }; - }; + time.timeZone = const.timeZone; + i18n = { + defaultLocale = "en_US.UTF-8"; + extraLocaleSettings = { + LC_ADDRESS = "ru_RU.UTF-8"; + LC_IDENTIFICATION = "ru_RU.UTF-8"; + LC_MEASUREMENT = "ru_RU.UTF-8"; + LC_MONETARY = "ru_RU.UTF-8"; + LC_NAME = "ru_RU.UTF-8"; + LC_NUMERIC = "en_GB.UTF-8"; + LC_PAPER = "ru_RU.UTF-8"; + LC_TELEPHONE = "ru_RU.UTF-8"; + LC_TIME = "en_GB.UTF-8"; + }; + }; } diff --git a/system/Logind.nix b/system/Logind.nix index 311853eb..53b4ec9f 100644 --- a/system/Logind.nix +++ b/system/Logind.nix @@ -1,4 +1,5 @@ -{ ... }: { - # Disable the power key. - services.logind.powerKey = "ignore"; +{ ... }: +{ + # Disable the power key. + services.logind.powerKey = "ignore"; } diff --git a/system/Network.nix b/system/Network.nix index bdf1ae34..f4f3ef1f 100644 --- a/system/Network.nix +++ b/system/Network.nix @@ -1,25 +1,24 @@ +{ pkgs, ... }: { - pkgs, - util, - ... -}: { - networking = { - networkmanager = { - enable = true; - dispatcherScripts = [{ - source = pkgs.writeText "nm-wb-dispatcher" (util.trimTabs '' - ${pkgs.procps}/bin/pkill -RTMIN+7 waybar - ''); - }]; - # unmanaged = [ - # "type:bridge" - # "type:ethernet" - # "type:loopback" - # # "type:wireguard" - # ]; - }; - }; + networking = { + networkmanager = { + enable = true; + dispatcherScripts = [ + { + source = pkgs.writeText "nm-wb-dispatcher" '' + ${pkgs.procps}/bin/pkill -RTMIN+7 waybar + ''; + } + ]; + # unmanaged = [ + # "type:bridge" + # "type:ethernet" + # "type:loopback" + # # "type:wireguard" + # ]; + }; + }; - # NOTE: Debugging. - # systemd.services."systemd-networkd".environment.SYSTEMD_LOG_LEVEL = "debug"; + # NOTE: Debugging. + # systemd.services."systemd-networkd".environment.SYSTEMD_LOG_LEVEL = "debug"; } diff --git a/system/Nix.nix b/system/Nix.nix index ad4767c9..2d7d4c51 100644 --- a/system/Nix.nix +++ b/system/Nix.nix @@ -1,19 +1,17 @@ +{ inputs, ... }: { - inputs, - ... -}: { - nixpkgs.config.allowUnfree = true; - nixpkgs.config.allowInsecurePredicate = x: true; # HACK: Nix is fucking annoying. - nix.registry.nixpkgs.flake = inputs.nixpkgs; - nix.settings = { - auto-optimise-store = true; - keep-derivations = true; - keep-outputs = true; - min-free = 1 * 1000 * 1000 * 1000; - experimental-features = [ - "flakes" - "nix-command" - "pipe-operators" - ]; - }; + nixpkgs.config.allowUnfree = true; + nixpkgs.config.allowInsecurePredicate = x: true; # HACK: Nix is fucking annoying. + nix.registry.nixpkgs.flake = inputs.nixpkgs; + nix.settings = { + auto-optimise-store = true; + keep-derivations = true; + keep-outputs = true; + min-free = 1 * 1000 * 1000 * 1000; + experimental-features = [ + "flakes" + "nix-command" + "pipe-operators" + ]; + }; } diff --git a/system/Pam.nix b/system/Pam.nix index 35818029..f1b32bca 100644 --- a/system/Pam.nix +++ b/system/Pam.nix @@ -1,16 +1,17 @@ -{ ... }: { - security.pam.loginLimits = [ - { - domain = "*"; - item = "nofile"; - type = "soft"; - value = "999999999"; - } - { - domain = "@users"; - item = "rtprio"; - type = "-"; - value = 1; - } - ]; +{ ... }: +{ + security.pam.loginLimits = [ + { + domain = "*"; + item = "nofile"; + type = "soft"; + value = "999999999"; + } + { + domain = "@users"; + item = "rtprio"; + type = "-"; + value = 1; + } + ]; } diff --git a/system/Shell.nix b/system/Shell.nix index e6fec60d..85a63387 100644 --- a/system/Shell.nix +++ b/system/Shell.nix @@ -1,7 +1,5 @@ +{ lib, ... }: { - lib, - ... -}: { - # Remove default aliases for `l`, `ll` etc as they break my function definitions. - environment.shellAliases = lib.mkForce { }; + # Remove default aliases for `l`, `ll` etc as they break my function definitions. + environment.shellAliases = lib.mkForce { }; } diff --git a/system/Sshd.nix b/system/Sshd.nix index 27f33529..7e8f0e10 100644 --- a/system/Sshd.nix +++ b/system/Sshd.nix @@ -1,36 +1,34 @@ +{ secret, ... }: { - secret, - ... -}: { - users.users.root.openssh.authorizedKeys.keys = secret.ssh.trustedKeys; - services.openssh = { - enable = true; - allowSFTP = true; - ports = [ - 22143 - ]; - listenAddresses = [{ - addr = "0.0.0.0"; - port = 22143; - }]; - settings = { - GSSAPIAuthentication = false; - HostbasedAuthentication = false; - KbdInteractiveAuthentication = false; - KerberosAuthentication = false; - LoginGraceTime = "1m"; - MaxSessions = 10; - PasswordAuthentication = false; - PermitEmptyPasswords = false; - PermitRootLogin = "prohibit-password"; - PubkeyAuthentication = true; - StrictModes = false; - UseDns = false; - UsePAM = true; - AllowUsers = [ - "root" - "nixbuilder" - ]; - }; - }; + users.users.root.openssh.authorizedKeys.keys = secret.ssh.trustedKeys; + services.openssh = { + enable = true; + allowSFTP = true; + ports = [ 22143 ]; + listenAddresses = [ + { + addr = "0.0.0.0"; + port = 22143; + } + ]; + settings = { + GSSAPIAuthentication = false; + HostbasedAuthentication = false; + KbdInteractiveAuthentication = false; + KerberosAuthentication = false; + LoginGraceTime = "1m"; + MaxSessions = 10; + PasswordAuthentication = false; + PermitEmptyPasswords = false; + PermitRootLogin = "prohibit-password"; + PubkeyAuthentication = true; + StrictModes = false; + UseDns = false; + UsePAM = true; + AllowUsers = [ + "root" + "nixbuilder" + ]; + }; + }; } diff --git a/system/Stylix.nix b/system/Stylix.nix index 0e2db634..75942c11 100644 --- a/system/Stylix.nix +++ b/system/Stylix.nix @@ -1,33 +1,41 @@ +{ config, ... }: +let + style = config.module.style; + wallpaper = config.module.wallpaper; +in { - config, - ... -}: let - style = config.module.style; - wallpaper = config.module.wallpaper; -in { - stylix = { - inherit (config.module.style) cursor; - enable = true; - autoEnable = true; - image = wallpaper.path; - polarity = "dark"; - fonts = with style.font; { - inherit emoji monospace sansSerif serif; - sizes = with size; { - inherit desktop terminal; - applications = application; - popups = popup; - }; - }; - opacity = with style.opacity; { - inherit desktop terminal; - applications = application; - popups = popups; - }; - override = if wallpaper.forceContrastText then { - base04 = "000000"; - base05 = "ffffff"; - base06 = "ffffff"; - } else { }; - }; + stylix = { + inherit (config.module.style) cursor; + enable = true; + autoEnable = true; + image = wallpaper.path; + polarity = "dark"; + fonts = with style.font; { + inherit + emoji + monospace + sansSerif + serif + ; + sizes = with size; { + inherit desktop terminal; + applications = application; + popups = popup; + }; + }; + opacity = with style.opacity; { + inherit desktop terminal; + applications = application; + popups = popups; + }; + override = + if wallpaper.forceContrastText then + { + base04 = "000000"; + base05 = "ffffff"; + base06 = "ffffff"; + } + else + { }; + }; } diff --git a/system/Systemd.nix b/system/Systemd.nix index 101454c5..d8b82e85 100644 --- a/system/Systemd.nix +++ b/system/Systemd.nix @@ -1,21 +1,20 @@ -{ ... }: { - # HACK: Fix for broken tmpfiles setup for some services like PowerLimit. - systemd.timers.tmpfilesfix = { - timerConfig = { - OnBootSec = 5; - Unit = "systemd-tmpfiles-resetup.service"; - }; - wantedBy = [ - "timers.target" - ]; - }; +{ ... }: +{ + # HACK: Fix for broken tmpfiles setup for some services like PowerLimit. + systemd.timers.tmpfilesfix = { + wantedBy = [ "timers.target" ]; + timerConfig = { + OnBootSec = 5; + Unit = "systemd-tmpfiles-resetup.service"; + }; + }; - # Systemd custom target for Sway. - systemd.user.targets.gui-session = { - after = [ "graphical-session-pre.target" ]; - bindsTo = [ "graphical-session.target" ]; - description = "GUI session."; - documentation = [ "man:systemd.special(7)" ]; - wants = [ "graphical-session-pre.target" ]; - }; + # Systemd custom target for Sway. + systemd.user.targets.gui-session = { + after = [ "graphical-session-pre.target" ]; + bindsTo = [ "graphical-session.target" ]; + description = "GUI session."; + documentation = [ "man:systemd.special(7)" ]; + wants = [ "graphical-session-pre.target" ]; + }; } diff --git a/system/Udev.nix b/system/Udev.nix index 274c3954..39ddfeaf 100644 --- a/system/Udev.nix +++ b/system/Udev.nix @@ -1,14 +1,12 @@ +{ pkgs, ... }: +let + waybar_reload = pkgs.writeShellScriptBin "bt-wb-dispatcher" '' + ${pkgs.procps}/bin/pkill -RTMIN+7 waybar + ''; +in { - pkgs, - util, - ... -}: let - waybar_reload = pkgs.writeShellScriptBin "bt-wb-dispatcher" (util.trimTabs '' - ${pkgs.procps}/bin/pkill -RTMIN+7 waybar - ''); -in { - services.udev.extraRules = util.trimTabs '' - ACTION=="add", SUBSYSTEM=="bluetooth", RUN+="${waybar_reload}/bin/bt-wb-dispatcher" - ACTION=="remove", SUBSYSTEM=="bluetooth", RUN+="${waybar_reload}/bin/bt-wb-dispatcher" - ''; + services.udev.extraRules = '' + ACTION=="add", SUBSYSTEM=="bluetooth", RUN+="${waybar_reload}/bin/bt-wb-dispatcher" + ACTION=="remove", SUBSYSTEM=="bluetooth", RUN+="${waybar_reload}/bin/bt-wb-dispatcher" + ''; } diff --git a/system/Users.nix b/system/Users.nix index fd731c01..53edb55e 100644 --- a/system/Users.nix +++ b/system/Users.nix @@ -1,7 +1,8 @@ -{ ... }: { - # Default UMASK. - # security.loginDefs.settings.UMASK = "077"; +{ ... }: +{ + # Default UMASK. + # security.loginDefs.settings.UMASK = "077"; - # Disallow users modification outside of this config. - users.mutableUsers = false; + # Disallow users modification outside of this config. + users.mutableUsers = false; } diff --git a/system/Vm.nix b/system/Vm.nix index 83028c2c..d369b2f4 100644 --- a/system/Vm.nix +++ b/system/Vm.nix @@ -1,29 +1,27 @@ +{ lib, ... }: { - lib, - ... -}: { - # SEE: https://github.com/name-snrl/nixos-configuration/blob/e7f6b0f664dbee82e3bf3e85a98cdc3088abe602/modules/nixos/profiles/system/vm-config.nix#L1 - virtualisation.vmVariant = { - module = { - autoupdate.enable = lib.mkForce false; - builder.client.enable = lib.mkForce false; - keyd.enable = lib.mkForce false; - }; - virtualisation = { - cores = 4; - diskImage = null; - diskSize = 20 * 1024; - memorySize = 4 * 1024; - msize = 1024 * 1024; - restrictNetwork = false; - resolution = { - x = 1280; - y = 720; - }; - sharedDirectories.experiments = { - source = "$HOME"; - target = "/mnt/home"; - }; - }; - }; + # SEE: https://github.com/name-snrl/nixos-configuration/blob/e7f6b0f664dbee82e3bf3e85a98cdc3088abe602/modules/nixos/profiles/system/vm-config.nix#L1 + virtualisation.vmVariant = { + module = { + autoupdate.enable = lib.mkForce false; + builder.client.enable = lib.mkForce false; + keyd.enable = lib.mkForce false; + }; + virtualisation = { + cores = 4; + diskImage = null; + diskSize = 20 * 1024; + memorySize = 4 * 1024; + msize = 1024 * 1024; + restrictNetwork = false; + resolution = { + x = 1280; + y = 720; + }; + sharedDirectories.experiments = { + source = "$HOME"; + target = "/mnt/home"; + }; + }; + }; } diff --git a/system/Zram.nix b/system/Zram.nix index 24b13184..511f113c 100644 --- a/system/Zram.nix +++ b/system/Zram.nix @@ -1,3 +1,4 @@ -{ ... }: { - zramSwap.enable = true; +{ ... }: +{ + zramSwap.enable = true; } diff --git a/user/Dasha.nix b/user/Dasha.nix index 797f4552..a61a70b8 100644 --- a/user/Dasha.nix +++ b/user/Dasha.nix @@ -1,32 +1,36 @@ { - config, - lib, - pkgs, - ... -}: let - cfg = config.user; -in { - options.user.dasha = lib.mkEnableOption "dasha."; + config, + lib, + pkgs, + ... +}: +let + cfg = config.user; +in +{ + options.user.dasha = lib.mkEnableOption "dasha."; - config = lib.mkIf cfg.dasha { - environment.systemPackages = with pkgs; [ nautilus ]; # NOTE: She wants it. - home.nixos.users = [{ - homeDirectory = "/home/dasha"; - username = "dasha"; - }]; - users.users.dasha = { - createHome = true; - description = "Daria Dranchak"; - hashedPassword = "$y$j9T$WGMPv/bRhGBUidcZLZ7CE/$raZhwFFdI/XvegVZVHLILJLMiBkOxSErc6gao/Cxt33"; - isNormalUser = true; - uid = 1001; - extraGroups = [ - "input" - "keyd" - "libvirtd" - "networkmanager" - "video" - ]; - }; - }; + config = lib.mkIf cfg.dasha { + environment.systemPackages = with pkgs; [ nautilus ]; # NOTE: She wants it. + home.nixos.users = [ + { + homeDirectory = "/home/dasha"; + username = "dasha"; + } + ]; + users.users.dasha = { + createHome = true; + description = "Daria Dranchak"; + hashedPassword = "$y$j9T$WGMPv/bRhGBUidcZLZ7CE/$raZhwFFdI/XvegVZVHLILJLMiBkOxSErc6gao/Cxt33"; + isNormalUser = true; + uid = 1001; + extraGroups = [ + "input" + "keyd" + "libvirtd" + "networkmanager" + "video" + ]; + }; + }; } diff --git a/user/Root.nix b/user/Root.nix index 6467eea8..16a0097b 100644 --- a/user/Root.nix +++ b/user/Root.nix @@ -1,25 +1,28 @@ { - config, - lib, - secret, - util, - ... -}: let - cfg = config.user; -in { - options.user.root = lib.mkEnableOption "root."; + config, + lib, + secret, + ... +}: +let + cfg = config.user; +in +{ + options.user.root = lib.mkEnableOption "root."; - config = lib.mkIf cfg.root { - users.users.root.hashedPassword = secret.hashedPassword; - home.nixos.users = [{ - homeDirectory = "/root"; - username = "root"; - }]; - security.sudo = { - enable = false; - extraConfig = util.trimTabs '' - Defaults rootpw - ''; - }; - }; + config = lib.mkIf cfg.root { + users.users.root.hashedPassword = secret.hashedPassword; + home.nixos.users = [ + { + homeDirectory = "/root"; + username = "root"; + } + ]; + security.sudo = { + enable = false; + extraConfig = '' + Defaults rootpw + ''; + }; + }; } diff --git a/user/Voronind.nix b/user/Voronind.nix index 2f0125f8..edeee8a3 100644 --- a/user/Voronind.nix +++ b/user/Voronind.nix @@ -1,31 +1,35 @@ { - config, - lib, - secret, - ... -}: let - cfg = config.user; -in { - options.user.voronind = lib.mkEnableOption "voronind."; + config, + lib, + secret, + ... +}: +let + cfg = config.user; +in +{ + options.user.voronind = lib.mkEnableOption "voronind."; - config = lib.mkIf cfg.voronind { - home.nixos.users = [{ - homeDirectory = "/home/voronind"; - username = "voronind"; - }]; - users.users.voronind = { - createHome = true; - description = "Dmitry Voronin"; - hashedPassword = secret.hashedPassword; - isNormalUser = true; - uid = 1000; - extraGroups = [ - "input" - "keyd" - "libvirtd" - "networkmanager" - "video" - ]; - }; - }; + config = lib.mkIf cfg.voronind { + home.nixos.users = [ + { + homeDirectory = "/home/voronind"; + username = "voronind"; + } + ]; + users.users.voronind = { + createHome = true; + description = "Dmitry Voronin"; + hashedPassword = secret.hashedPassword; + isNormalUser = true; + uid = 1000; + extraGroups = [ + "input" + "keyd" + "libvirtd" + "networkmanager" + "video" + ]; + }; + }; }