diff options
Diffstat (limited to '')
39 files changed, 1314 insertions, 1113 deletions
diff --git a/modules/common/alacritty.nix b/modules/common/alacritty.nix index 892516b..704ce79 100644 --- a/modules/common/alacritty.nix +++ b/modules/common/alacritty.nix @@ -1,13 +1,10 @@ -{ - config, - lib, - ... -}: -with lib; let +{ config, lib, ... }: +with lib; +let cfg = config.nixfiles.modules.alacritty; -in { - options.nixfiles.modules.alacritty.enable = - mkEnableOption "Alacritty terminal emulator"; +in +{ + options.nixfiles.modules.alacritty.enable = mkEnableOption "Alacritty terminal emulator"; config = mkIf cfg.enable { hm.programs.alacritty = { diff --git a/modules/common/aria2.nix b/modules/common/aria2.nix index 449d96c..cdf1c4f 100644 --- a/modules/common/aria2.nix +++ b/modules/common/aria2.nix @@ -1,11 +1,9 @@ -{ - config, - lib, - ... -}: -with lib; let +{ config, lib, ... }: +with lib; +let cfg = config.nixfiles.modules.aria2; -in { +in +{ options.nixfiles.modules.aria2.enable = mkEnableOption "aria2"; config = mkIf cfg.enable { diff --git a/modules/common/bat.nix b/modules/common/bat.nix index 89444d9..a95d67d 100644 --- a/modules/common/bat.nix +++ b/modules/common/bat.nix @@ -1,11 +1,9 @@ -{ - config, - lib, - ... -}: -with lib; let +{ config, lib, ... }: +with lib; +let cfg = config.nixfiles.modules.bat; -in { +in +{ options.nixfiles.modules.bat.enable = mkEnableOption "bat, an alternative to cat"; config = mkIf cfg.enable { diff --git a/modules/common/common/documentation.nix b/modules/common/common/documentation.nix index e9d4a79..2202e11 100644 --- a/modules/common/common/documentation.nix +++ b/modules/common/common/documentation.nix @@ -4,7 +4,8 @@ this, ... }: -with lib; { +with lib; +{ config = mkMerge [ (mkIf this.isHeadful { hm.manual = { diff --git a/modules/common/common/home-manager.nix b/modules/common/common/home-manager.nix index 97d7286..3c9fa0e 100644 --- a/modules/common/common/home-manager.nix +++ b/modules/common/common/home-manager.nix @@ -4,17 +4,21 @@ localUsername ? lib.my.username, ... }: -with lib; { +with lib; +{ imports = [ - (mkAliasOptionModule ["hm"] ["home-manager" "users" localUsername]) + (mkAliasOptionModule [ "hm" ] [ + "home-manager" + "users" + localUsername + ]) ]; hm = { news.display = "silent"; # NOTE Inheriting directly from `system.stateVersion` does not work with # nix-darwin for some reason. - home.stateVersion = with builtins; - head (split "\n" (readFile "${inputs.nixpkgs}/.version")); + home.stateVersion = with builtins; head (split "\n" (readFile "${inputs.nixpkgs}/.version")); }; home-manager = { diff --git a/modules/common/common/networking.nix b/modules/common/common/networking.nix index e5d27d8..2e19162 100644 --- a/modules/common/common/networking.nix +++ b/modules/common/common/networking.nix @@ -1,3 +1,4 @@ -{pkgs, ...}: { - environment.systemPackages = with pkgs; [myip]; +{ pkgs, ... }: +{ + environment.systemPackages = with pkgs; [ myip ]; } diff --git a/modules/common/common/nix.nix b/modules/common/common/nix.nix index ecd5874..6cc32d3 100644 --- a/modules/common/common/nix.nix +++ b/modules/common/common/nix.nix @@ -4,96 +4,96 @@ lib, localUsername ? lib.my.username, pkgs, + pkgsPr, this, ... }: -with lib; { - _module.args = let - importNixpkgs = nixpkgs: - import nixpkgs { - inherit (config.nixpkgs) config; - inherit (this) system; - }; - in rec { - pkgsLocal = importNixpkgs "${config.my.home}/src/nixpkgs"; # Impure! - pkgsMaster = importNixpkgs inputs.nixpkgs-master; - pkgsStable = importNixpkgs inputs.nixpkgs-stable; - pkgsRev = rev: hash: - importNixpkgs (pkgs.fetchFromGitHub { - owner = "NixOS"; - repo = "nixpkgs"; - inherit rev hash; - }); - pkgsPr = pr: pkgsRev "refs/pull/${toString pr}/head"; - }; +with lib; +{ + _module.args = + let + importNixpkgs = + nixpkgs: + import nixpkgs { + inherit (config.nixpkgs) config; + inherit (this) system; + }; + in + rec { + pkgsLocal = importNixpkgs "${config.my.home}/src/nixpkgs"; # Impure! + pkgsMaster = importNixpkgs inputs.nixpkgs-master; + pkgsStable = importNixpkgs inputs.nixpkgs-stable; + pkgsRev = + rev: hash: + importNixpkgs ( + pkgs.fetchFromGitHub { + owner = "NixOS"; + repo = "nixpkgs"; + inherit rev hash; + } + ); + pkgsPr = pr: pkgsRev "refs/pull/${toString pr}/head"; + }; - nix = let - notSelfInputs = filterAttrs (n: _: n != "self") inputs; - in { - settings = { - # https://nixos.org/manual/nix/unstable/contributing/experimental-features.html#currently-available-experimental-features - # https://github.com/NixOS/nix/blob/master/src/libutil/experimental-features.cc - experimental-features = concatStringsSep " " [ - "flakes" - "nix-command" - "recursive-nix" - "repl-flake" - ]; + nixpkgs.overlays = with inputs; [ + self.overlays.default + (_: _: { + inherit (pkgsPr 298756 "sha256-AxNXEDRb9yEde0sPEBRxfXSAu/ZL6/BlOzSj+aoOlHk=") qolibri; + inherit (pkgsPr 298346 "sha256-CSEUeivyTWxVskjWzDUal8KYthk7UYMOM4KdjZyhV3o=") dmalloc; + }) + ]; - keep-derivations = - if this.isHeadful - then "true" - else "false"; - keep-outputs = - if this.isHeadful - then "true" - else "false"; + nix = + let + notSelfInputs = filterAttrs (n: _: n != "self") inputs; + in + { + settings = { + # https://nixos.org/manual/nix/unstable/contributing/experimental-features.html#currently-available-experimental-features + # https://github.com/NixOS/nix/blob/master/src/libutil/experimental-features.cc + experimental-features = concatStringsSep " " [ + "flakes" + "nix-command" + "recursive-nix" + "repl-flake" + ]; - flake-registry = "${inputs.flake-registry}/flake-registry.json"; + keep-derivations = if this.isHeadful then "true" else "false"; + keep-outputs = if this.isHeadful then "true" else "false"; - warn-dirty = false; + flake-registry = "${inputs.flake-registry}/flake-registry.json"; - keep-going = true; + warn-dirty = false; - substituters = [ - "https://azahi.cachix.org" - "https://cache.iog.io" - "https://cachix.cachix.org" - "https://nix-community.cachix.org" - "https://organist.cachix.org" - "https://pre-commit-hooks.cachix.org" - "https://tweag-nickel.cachix.org" - ]; - trusted-public-keys = [ - "azahi.cachix.org-1:2bayb+iWYMAVw3ZdEpVg+NPOHCXncw7WMQ0ElX1GO3s=" - "cachix.cachix.org-1:eWNHQldwUO7G2VkjpnjDbWwy4KQ/HNxht7H4SSoMckM=" - "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - "organist.cachix.org-1:GB9gOx3rbGl7YEh6DwOscD1+E/Gc5ZCnzqwObNH2Faw=" - "pre-commit-hooks.cachix.org-1:Pkk3Panw5AW24TOv6kz3PvLhlH8puAsJTBbOPmBo7Rc=" - "tweag-nickel.cachix.org-1:GIthuiK4LRgnW64ALYEoioVUQBWs0jexyoYVeLDBwRA=" - ]; + keep-going = true; - trusted-users = ["root" localUsername]; - }; + substituters = [ + "https://azahi.cachix.org" + "https://nix-community.cachix.org" + ]; + trusted-public-keys = [ + "azahi.cachix.org-1:2bayb+iWYMAVw3ZdEpVg+NPOHCXncw7WMQ0ElX1GO3s=" + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; - nixPath = - mapAttrsToList (n: v: "${n}=${v}") notSelfInputs - ++ ["nixfiles=${config.my.home}/src/nixfiles"]; + trusted-users = [ + "root" + localUsername + ]; + }; - registry = - mapAttrs (_: flake: {inherit flake;}) notSelfInputs - // {nixfiles.flake = inputs.self;}; - }; + nixPath = mapAttrsToList (n: v: "${n}=${v}") notSelfInputs ++ [ + "nixfiles=${config.my.home}/src/nixfiles" + ]; - nixpkgs.overlays = with inputs; [ - self.overlays.default - (_: _: { - }) - ]; + registry = mapAttrs (_: flake: { inherit flake; }) notSelfInputs // { + nixfiles.flake = inputs.self; + }; + }; environment = { - systemPackages = with pkgs; + systemPackages = + with pkgs; optionals this.isHeadful [ nix-top nix-tree @@ -104,9 +104,10 @@ with lib; { hm = { # Used primarily in conjunction with the "nixfiles" script. - home.file.".nix-defexpr/default.nix".text = let - hostname = strings.escapeNixIdentifier this.hostname; - in + home.file.".nix-defexpr/default.nix".text = + let + hostname = strings.escapeNixIdentifier this.hostname; + in optionalString this.isHeadful '' let self = builtins.getFlake "nixfiles"; diff --git a/modules/common/common/secrets.nix b/modules/common/common/secrets.nix index fdc2501..3c05c09 100644 --- a/modules/common/common/secrets.nix +++ b/modules/common/common/secrets.nix @@ -6,19 +6,24 @@ this, ... }: -with lib; { - imports = [(mkAliasOptionModule ["secrets"] ["age" "secrets"])]; +with lib; +{ + imports = [ + (mkAliasOptionModule [ "secrets" ] [ + "age" + "secrets" + ]) + ]; config = { age.identityPaths = - if this.isHeadful - then ["${config.my.home}/.ssh/id_${my.ssh.type}"] + if this.isHeadful then + [ "${config.my.home}/.ssh/id_${my.ssh.type}" ] else - map (attr: attr.path) (filter (attr: attr.type == my.ssh.type) - config.services.openssh.hostKeys); + map (attr: attr.path) (filter (attr: attr.type == my.ssh.type) config.services.openssh.hostKeys); - environment.systemPackages = with pkgs; [agenix]; + environment.systemPackages = with pkgs; [ agenix ]; - nixpkgs.overlays = [inputs.agenix.overlays.default]; + nixpkgs.overlays = [ inputs.agenix.overlays.default ]; }; } diff --git a/modules/common/common/shell/default.nix b/modules/common/common/shell/default.nix index 8c3fa8a..883bfae 100644 --- a/modules/common/common/shell/default.nix +++ b/modules/common/common/shell/default.nix @@ -6,53 +6,55 @@ this, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.common.shell; -in { +in +{ options.nixfiles.modules.common.shell.aliases = mkOption { description = "An attribute set of shell aliases."; type = with types; attrsOf str; - default = {}; + default = { }; }; config = { hm = { - imports = [inputs.nix-index-database.hmModules.nix-index]; + imports = [ inputs.nix-index-database.hmModules.nix-index ]; programs = { bash = { enable = true; - initExtra = let - aliasCompletions = - concatStringsSep "\n" - (mapAttrsToList - (name: _: "complete -F _complete_alias ${name}") - cfg.aliases); - in '' - # Apropriated from the default NixOS prompt settings. - if [ "$TERM" != "dumb" ] || [ -n "$INSIDE_EMACS" ]; then - PROMPT_COLOR="1;31m" - ((UID)) && PROMPT_COLOR="1;32m" - if [ -n "$INSIDE_EMACS" ] || [ "$TERM" = "eterm" ] || [ "$TERM" = "eterm-color" ]; then - PS1="\n\[\033[$PROMPT_COLOR\][\u@\h:\w]\\$\[\033[0m\] " - else - PS1="\n\[\033[$PROMPT_COLOR\][\[\e]0;\u@\h: \w\a\]\u@\h:\w]\\$\[\033[0m\] " - fi - if test "$TERM" = "xterm"; then - PS1="\[\033]2;\h:\u:\w\007\]$PS1" - fi - fi + initExtra = + let + aliasCompletions = concatStringsSep "\n" ( + mapAttrsToList (name: _: "complete -F _complete_alias ${name}") cfg.aliases + ); + in + '' + # Apropriated from the default NixOS prompt settings. + if [ "$TERM" != "dumb" ] || [ -n "$INSIDE_EMACS" ]; then + PROMPT_COLOR="1;31m" + ((UID)) && PROMPT_COLOR="1;32m" + if [ -n "$INSIDE_EMACS" ] || [ "$TERM" = "eterm" ] || [ "$TERM" = "eterm-color" ]; then + PS1="\n\[\033[$PROMPT_COLOR\][\u@\h:\w]\\$\[\033[0m\] " + else + PS1="\n\[\033[$PROMPT_COLOR\][\[\e]0;\u@\h: \w\a\]\u@\h:\w]\\$\[\033[0m\] " + fi + if test "$TERM" = "xterm"; then + PS1="\[\033]2;\h:\u:\w\007\]$PS1" + fi + fi - source "${./functions.bash}" + source "${./functions.bash}" - source "${getExe' pkgs.complete-alias "complete_alias"}" - ${aliasCompletions} + source "${getExe' pkgs.complete-alias "complete_alias"}" + ${aliasCompletions} - # https://github.com/garabik/grc?tab=readme-ov-file#bash - GRC_ALIASES=true - source ${pkgs.grc}/etc/profile.d/grc.sh - ''; + # https://github.com/garabik/grc?tab=readme-ov-file#bash + GRC_ALIASES=true + source ${pkgs.grc}/etc/profile.d/grc.sh + ''; shellOptions = [ "autocd" @@ -74,57 +76,109 @@ in { ]; shellAliases = - listToAttrs - (map - ({ - name, - value, - }: - nameValuePair name (with pkgs; let - pkg = - if this.isHeadful - then - (pkgs.coreutils.overrideAttrs (_: super: { - patches = - (super.patches or []) - ++ [ - (fetchpatch { - url = "https://raw.githubusercontent.com/jarun/advcpmv/a1f8b505e691737db2f7f2b96275802c45f65c59/advcpmv-0.9-9.4.patch"; - hash = "sha256-4fdqpkENPfra4nFQU4+xNrlfq6Dw/2JIZXUOMmdMtcM="; - }) - ]; - })) - else coreutils; - in "${getExe' pkg "coreutils"} --coreutils-prog=${value}")) - ( - let - mkAlias = { - name ? head command, - command, - }: { - inherit name; - value = concatStringsSep " " command; - }; + listToAttrs ( + map + ( + { name, value }: + nameValuePair name ( + with pkgs; + let + pkg = + if this.isHeadful then + (pkgs.coreutils.overrideAttrs ( + _: super: { + patches = (super.patches or [ ]) ++ [ + (fetchpatch { + url = "https://raw.githubusercontent.com/jarun/advcpmv/a1f8b505e691737db2f7f2b96275802c45f65c59/advcpmv-0.9-9.4.patch"; + hash = "sha256-4fdqpkENPfra4nFQU4+xNrlfq6Dw/2JIZXUOMmdMtcM="; + }) + ]; + } + )) + else + coreutils; + in + "${getExe' pkg "coreutils"} --coreutils-prog=${value}" + ) + ) + ( + let + mkAlias = + { + name ? head command, + command, + }: + { + inherit name; + value = concatStringsSep " " command; + }; - progressBar = optionalString this.isHeadful "--progress-bar"; - in [ - (mkAlias {command = ["cp" "--interactive" "--recursive" progressBar];}) - (mkAlias {command = ["mv" "--interactive" progressBar];}) - (mkAlias {command = ["rm" "--interactive=once"];}) - (mkAlias {command = ["ln" "--interactive"];}) - (mkAlias {command = ["mkdir" "--parents"];}) - (mkAlias {command = ["rmdir" "--parents"];}) - (mkAlias { - name = "lower"; - command = ["tr" "'[:upper:]'" "'[:lower:]'"]; - }) - (mkAlias { - name = "upper"; - command = ["tr" "'[:lower:]'" "'[:upper:]'"]; - }) - ] - )) - // (genAttrs ["grep" "egrep" "fgrep"] (name: "${pkgs.gnugrep}/bin/${name} --color=always")) + progressBar = optionalString this.isHeadful "--progress-bar"; + in + [ + (mkAlias { + command = [ + "cp" + "--interactive" + "--recursive" + progressBar + ]; + }) + (mkAlias { + command = [ + "mv" + "--interactive" + progressBar + ]; + }) + (mkAlias { + command = [ + "rm" + "--interactive=once" + ]; + }) + (mkAlias { + command = [ + "ln" + "--interactive" + ]; + }) + (mkAlias { + command = [ + "mkdir" + "--parents" + ]; + }) + (mkAlias { + command = [ + "rmdir" + "--parents" + ]; + }) + (mkAlias { + name = "lower"; + command = [ + "tr" + "'[:upper:]'" + "'[:lower:]'" + ]; + }) + (mkAlias { + name = "upper"; + command = [ + "tr" + "'[:lower:]'" + "'[:upper:]'" + ]; + }) + ] + ) + ) + // (genAttrs [ + "grep" + "egrep" + "fgrep" + ] (name: "${pkgs.gnugrep}/bin/${name} --color=always")) // cfg.aliases; }; @@ -134,7 +188,7 @@ in { nix-index-database.comma.enable = true; }; - home.packages = with pkgs; [grc]; + home.packages = with pkgs; [ grc ]; }; environment = { diff --git a/modules/common/common/stylix.nix b/modules/common/common/stylix.nix index 30bf582..f1b8f81 100644 --- a/modules/common/common/stylix.nix +++ b/modules/common/common/stylix.nix @@ -1,11 +1,8 @@ +{ lib, pkgs, ... }: +with lib; { - lib, - pkgs, - ... -}: -with lib; { imports = [ - (mkAliasOptionModule ["colors"] [ + (mkAliasOptionModule [ "colors" ] [ "lib" "stylix" "colors" @@ -45,12 +42,12 @@ with lib; { }; serif = { - package = pkgs.iosevka-bin.override {variant = "Etoile";}; + package = pkgs.iosevka-bin.override { variant = "Etoile"; }; name = "Iosevka Etoile"; }; sansSerif = { - package = pkgs.iosevka-bin.override {variant = "Aile";}; + package = pkgs.iosevka-bin.override { variant = "Aile"; }; name = "Iosevka Aile"; }; diff --git a/modules/common/common/users.nix b/modules/common/common/users.nix index aee0e38..dc1b32e 100644 --- a/modules/common/common/users.nix +++ b/modules/common/common/users.nix @@ -3,6 +3,13 @@ localUsername ? lib.my.username, ... }: -with lib; { - imports = [(mkAliasOptionModule ["my"] ["users" "users" localUsername])]; +with lib; +{ + imports = [ + (mkAliasOptionModule [ "my" ] [ + "users" + "users" + localUsername + ]) + ]; } diff --git a/modules/common/common/xdg.nix b/modules/common/common/xdg.nix index 04ca544..4463c15 100644 --- a/modules/common/common/xdg.nix +++ b/modules/common/common/xdg.nix @@ -1,18 +1,35 @@ +{ config, lib, ... }: +with lib; { - config, - lib, - ... -}: -with lib; { - imports = let - withBase = a: ["nixfiles" "modules" "common" "xdg" a]; - in [ - (mkAliasOptionModule ["dirs" "cache"] (withBase "cacheHome")) - (mkAliasOptionModule ["dirs" "config"] (withBase "configHome")) - (mkAliasOptionModule ["dirs" "data"] (withBase "dataHome")) - (mkAliasOptionModule ["dirs" "state"] (withBase "stateHome")) - (mkAliasOptionModule ["userDirs"] (withBase "userDirs")) - ]; + imports = + let + withBase = a: [ + "nixfiles" + "modules" + "common" + "xdg" + a + ]; + in + [ + (mkAliasOptionModule [ + "dirs" + "cache" + ] (withBase "cacheHome")) + (mkAliasOptionModule [ + "dirs" + "config" + ] (withBase "configHome")) + (mkAliasOptionModule [ + "dirs" + "data" + ] (withBase "dataHome")) + (mkAliasOptionModule [ + "dirs" + "state" + ] (withBase "stateHome")) + (mkAliasOptionModule [ "userDirs" ] (withBase "userDirs")) + ]; options.nixfiles.modules.common.xdg = { cacheHome = mkOption { @@ -33,21 +50,23 @@ with lib; { }; userDirs = mkOption { type = types.attrs; - default = let - inherit (config.my) home; - tmp = home + "/tmp"; - in { - enable = true; + default = + let + inherit (config.my) home; + tmp = home + "/tmp"; + in + { + enable = true; - desktop = tmp; - documents = "${home}/doc"; - download = tmp; - music = tmp; - pictures = tmp; - publicShare = "${home}/share"; - templates = tmp; - videos = tmp; - }; + desktop = tmp; + documents = "${home}/doc"; + download = tmp; + music = tmp; + pictures = tmp; + publicShare = "${home}/share"; + templates = tmp; + videos = tmp; + }; }; }; } diff --git a/modules/common/curl.nix b/modules/common/curl.nix index 1514a09..6895262 100644 --- a/modules/common/curl.nix +++ b/modules/common/curl.nix @@ -4,9 +4,11 @@ pkgs, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.curl; -in { +in +{ options.nixfiles.modules.curl.enable = mkEnableOption "cURL"; config = mkIf cfg.enable { diff --git a/modules/common/direnv.nix b/modules/common/direnv.nix index 3429218..ececad8 100644 --- a/modules/common/direnv.nix +++ b/modules/common/direnv.nix @@ -1,11 +1,9 @@ -{ - config, - lib, - ... -}: -with lib; let +{ config, lib, ... }: +with lib; +let cfg = config.nixfiles.modules.direnv; -in { +in +{ options.nixfiles.modules.direnv.enable = mkEnableOption "direnv"; config = mkIf cfg.enable { diff --git a/modules/common/editorconfig.nix b/modules/common/editorconfig.nix index 537912f..5dfe845 100644 --- a/modules/common/editorconfig.nix +++ b/modules/common/editorconfig.nix @@ -1,11 +1,9 @@ -{ - config, - lib, - ... -}: -with lib; let +{ config, lib, ... }: +with lib; +let cfg = config.nixfiles.modules.editorconfig; -in { +in +{ options.nixfiles.modules.editorconfig.enable = mkEnableOption "Editorconfig"; config = mkIf cfg.enable { diff --git a/modules/common/emacs/default.nix b/modules/common/emacs/default.nix index 9259011..2d0fe67 100644 --- a/modules/common/emacs/default.nix +++ b/modules/common/emacs/default.nix @@ -7,9 +7,11 @@ this, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.emacs; -in { +in +{ options.nixfiles.modules.emacs.enable = mkEnableOption "GNU Emacs"; config = mkIf cfg.enable { @@ -29,211 +31,225 @@ in { hm = { stylix.targets.emacs.enable = false; - xdg.configFile = mapAttrs (_: value: - value - // { - onChange = with config.hm.programs; '' - export EMACSDIR="''${XDG_CONFIG_HOME:-$HOME/.config}/emacs" - export DOOMDIR="''${XDG_CONFIG_HOME:-$HOME/.config}/doom" - - if [[ ! -d "$EMACSDIR/.git" ]]; then - ${getExe git.package} clone --depth=1 --branch=master \ - "https://github.com/doomemacs/doomemacs" "$EMACSDIR" - fi + xdg.configFile = + mapAttrs + ( + _: value: + value + // { + onChange = with config.hm.programs; '' + export EMACSDIR="''${XDG_CONFIG_HOME:-$HOME/.config}/emacs" + export DOOMDIR="''${XDG_CONFIG_HOME:-$HOME/.config}/doom" - if [[ ! -d "$DOOMDIR/snippets" ]]; then - mkdir -p "$DOOMDIR/snippets" - fi + if [[ ! -d "$EMACSDIR/.git" ]]; then + ${getExe git.package} clone --depth=1 --branch=master \ + "https://github.com/doomemacs/doomemacs" "$EMACSDIR" + fi - if [[ -x "$EMACSDIR/bin/doom" ]]; then - if [[ ! -d "$EMACSDIR/.local" ]]; then - PATH="''${PATH:-/bin:/usr/bin:/usr/local/bin}:${emacs.package}/bin:${git.package}/bin" \ - "$EMACSDIR/bin/doom" install --force --verbose - fi + if [[ ! -d "$DOOMDIR/snippets" ]]; then + mkdir -p "$DOOMDIR/snippets" + fi - PATH="''${PATH:-/bin:/usr/bin:/usr/local/bin}:${emacs.package}/bin:${git.package}/bin" \ - "$EMACSDIR/bin/doom" sync -e -p --force --verbose - fi - ''; - }) { - "doom/init.el".source = ./doom/init.el; - "doom/packages.el".source = ./doom/packages.el; - "doom/config.el" = { - text = concatLines [ - (let - extraBins = with pkgs; - [ - (aspellWithDicts (p: with p; [en ru])) # :checkers (spell +aspell) - asmfmt # :editor format - cargo # :lang rust - clang-tools # :lang (cc +lsp) :editor format - cmake-format # :lang cc :editor format - cmigemo # :lang japanese - config.hm.programs.emacs.package # !doom - config.nix.package # !doom - delve # :lang go :tools debugger - dockerfile-language-server-nodejs # :tools (docker +lsp) - dockfmt # :tools docker :editor format - editorconfig-core-c # :tools editorconfig - fd # doom! - gcc # :lang cc - ghc # :lang haskell - gnuplot # :lang (org +gnuplot) - gnutar # :tools tree-sitter - gnutls # doom! :app irc - go # :lang go - godef # :lang go - gomodifytags # :lang go - gopls # :lang (go +lsp) - gore # :lang go - gotests # :lang go - gotools # :lang go - graphviz # :lang (org +roam2) :lang plantuml - gzip # :tools tree-sitter - haskellPackages.cabal-fmt # :lang haskell :editor format - haskellPackages.cabal-install # :lang haskell - haskellPackages.haskell-language-server # :lang (haskell +lsp) - haskellPackages.hoogle # :lang haskell - haskellPackages.ormolu # :lang haskell :editor format - html-tidy # :lang web :editor format - jdk # :lang java :lang plantuml :checkers grammar - languagetool # :checkers grammar - libxml2 # :lang data :editor format - markdownlint-cli # :lang markdown - nil # :lang (nix +lsp) - nls # :lang (nickel +lsp) - nodePackages.bash-language-server # :lang (sh +lsp) - nodePackages.eslint # :lang (json +lsp) - nodePackages.js-beautify # :lang web - nodePackages.prettier # :editor format - nodePackages.stylelint # :lang web - nodePackages.vscode-css-languageserver-bin # lang (web +lsp) - nodePackages.vscode-html-languageserver-bin # lang (web +lsp) - nodePackages.vscode-json-languageserver-bin # lang (json +lsp) - nodejs # :tools debugger - pandoc # :lang org markdown latex - pinentry-emacs # doom! - pipenv # :lang python - poetry # :lang python - pre-commit # :tools magit - python3 # :lang python - python3Packages.black # :lang python :editor format - python3Packages.isort # :lang python :editor format - python3Packages.nose # :lang python - python3Packages.pyflakes # :lang python :editor format - python3Packages.pytest # :lang python - python3Packages.python-lsp-server # :lang python :editor format - ripgrep # doom! - rust-analyzer # :lang (rust +lsp) - rustc # :lang rust - rustfmt # :lang rust - shellcheck # :lang sh - shfmt # :lang sh :editor format - sqlite # :lang (org +roam2) :tools lookup - terraform-ls # :tools (terraform +lsp) - texlab # lang (tex +lsp) - texlive.combined.scheme-full # :lang org tex - unzip # :tools debugger - wordnet # :tools (lookup +dictionary +offline) - yaml-language-server # :lang (yaml +lsp) - zig # :lang zig :editor format - zls # :lang (zig +lsp) - zstd # :emacs undo - ] - ++ ( - # GDB doesn't support[1] Apple Silicon. - # - # [1]: https://inbox.sourceware.org/gdb/6b48224b-9e2e-518d-793b-df4fc5514884@arm.com/ - if (this.system != "aarch64-darwin") - then [gdb] # :tools debugger - else [lldb] # :tools debugger - ); + if [[ -x "$EMACSDIR/bin/doom" ]]; then + if [[ ! -d "$EMACSDIR/.local" ]]; then + PATH="''${PATH:-/bin:/usr/bin:/usr/local/bin}:${emacs.package}/bin:${git.package}/bin" \ + "$EMACSDIR/bin/doom" install --force --verbose + fi - parinferRustLibrary = - if (hasSuffix "linux" this.system) - then "${pkgs.parinfer-rust}/lib/libparinfer_rust.so" - else "${pkgs.parinfer-rust}/lib/libparinfer_rust.dylib"; - in '' - ;; Integrate packages which are required by various modules - ;; without polluting the user's profile. - (setq exec-path (append exec-path '(${ - concatMapStringsSep " " (x: ''"${x}/bin"'') extraBins - }))) - (setenv "PATH" (concat (getenv "PATH") ":${ - concatMapStringsSep ":" (x: "${x}/bin") extraBins - }")) + PATH="''${PATH:-/bin:/usr/bin:/usr/local/bin}:${emacs.package}/bin:${git.package}/bin" \ + "$EMACSDIR/bin/doom" sync -e -p --force --verbose + fi + ''; + } + ) + { + "doom/init.el".source = ./doom/init.el; + "doom/packages.el".source = ./doom/packages.el; + "doom/config.el" = { + text = concatLines [ + ( + let + extraBins = + with pkgs; + [ + (aspellWithDicts ( + p: with p; [ + en + ru + ] + )) # :checkers (spell +aspell) + asmfmt # :editor format + cargo # :lang rust + clang-tools # :lang (cc +lsp) :editor format + cmake-format # :lang cc :editor format + cmigemo # :lang japanese + config.hm.programs.emacs.package # !doom + config.nix.package # !doom + delve # :lang go :tools debugger + dockerfile-language-server-nodejs # :tools (docker +lsp) + dockfmt # :tools docker :editor format + editorconfig-core-c # :tools editorconfig + fd # doom! + gcc # :lang cc + ghc # :lang haskell + gnuplot # :lang (org +gnuplot) + gnutar # :tools tree-sitter + gnutls # doom! :app irc + go # :lang go + godef # :lang go + gomodifytags # :lang go + gopls # :lang (go +lsp) + gore # :lang go + gotests # :lang go + gotools # :lang go + graphviz # :lang (org +roam2) :lang plantuml + gzip # :tools tree-sitter + haskellPackages.cabal-fmt # :lang haskell :editor format + haskellPackages.cabal-install # :lang haskell + haskellPackages.haskell-language-server # :lang (haskell +lsp) + haskellPackages.hoogle # :lang haskell + haskellPackages.ormolu # :lang haskell :editor format + html-tidy # :lang web :editor format + jdk # :lang java :lang plantuml :checkers grammar + languagetool # :checkers grammar + libxml2 # :lang data :editor format + markdownlint-cli # :lang markdown + nil # :lang (nix +lsp) + nixfmt # :lang nix :editor format + nls # :lang (nickel +lsp) + nodePackages.bash-language-server # :lang (sh +lsp) + nodePackages.eslint # :lang (json +lsp) + nodePackages.js-beautify # :lang web + nodePackages.prettier # :editor format + nodePackages.stylelint # :lang web + nodePackages.vscode-css-languageserver-bin # lang (web +lsp) + nodePackages.vscode-html-languageserver-bin # lang (web +lsp) + nodePackages.vscode-json-languageserver-bin # lang (json +lsp) + nodejs # :tools debugger + pandoc # :lang org markdown latex + pinentry-emacs # doom! + pipenv # :lang python + poetry # :lang python + pre-commit # :tools magit + python3 # :lang python + python3Packages.black # :lang python :editor format + python3Packages.isort # :lang python :editor format + python3Packages.nose # :lang python + python3Packages.pyflakes # :lang python :editor format + python3Packages.pytest # :lang python + python3Packages.python-lsp-server # :lang python :editor format + ripgrep # doom! + rust-analyzer # :lang (rust +lsp) + rustc # :lang rust + rustfmt # :lang rust + shellcheck # :lang sh + shfmt # :lang sh :editor format + sqlite # :lang (org +roam2) :tools lookup + terraform-ls # :tools (terraform +lsp) + texlab # lang (tex +lsp) + texlive.combined.scheme-full # :lang org tex + unzip # :tools debugger + wordnet # :tools (lookup +dictionary +offline) + yaml-language-server # :lang (yaml +lsp) + zig # :lang zig :editor format + zls # :lang (zig +lsp) + zstd # :emacs undo + ] + ++ ( + # GDB doesn't support[1] Apple Silicon. + # + # [1]: https://inbox.sourceware.org/gdb/6b48224b-9e2e-518d-793b-df4fc5514884@arm.com/ + if (this.system != "aarch64-darwin") then + [ gdb ] # :tools debugger + else + [ lldb ] # :tools debugger + ); - ;; HACK Explicitly load specific Emacs packages from Nixpkgs. - ;; For some reason providing them as "extraPackages" doesn't - ;; work. - (add-to-list 'load-path "${pkgs.mu.mu4e}/share/emacs/site-lisp/mu4e") - (add-to-list 'load-path "${pkgs.emacsPackages.vterm}/share/emacs/site-lisp/elpa/vterm-${pkgs.emacsPackages.vterm.version}") + parinferRustLibrary = + if (hasSuffix "linux" this.system) then + "${pkgs.parinfer-rust}/lib/libparinfer_rust.so" + else + "${pkgs.parinfer-rust}/lib/libparinfer_rust.dylib"; + in + '' + ;; Integrate packages which are required by various modules + ;; without polluting the user's profile. + (setq exec-path (append exec-path '(${concatMapStringsSep " " (x: ''"${x}/bin"'') extraBins}))) + (setenv "PATH" (concat (getenv "PATH") ":${concatMapStringsSep ":" (x: "${x}/bin") extraBins}")) - (appendq! auth-sources '(("${config.secrets.authinfo.path}"))) + ;; HACK Explicitly load specific Emacs packages from Nixpkgs. + ;; For some reason providing them as "extraPackages" doesn't + ;; work. + (add-to-list 'load-path "${pkgs.mu.mu4e}/share/emacs/site-lisp/mu4e") + (add-to-list 'load-path "${pkgs.emacsPackages.vterm}/share/emacs/site-lisp/elpa/vterm-${pkgs.emacsPackages.vterm.version}") - ;; :input japanese - (setq migemo-dictionary "${pkgs.cmigemo}/share/migemo/utf-8/migemo-dict" - skk-large-jisyo "${pkgs.skk-dicts}/share/SKK-JISYO.L") + (appendq! auth-sources '(("${config.secrets.authinfo.path}"))) - ;; :editor parinfer - (setq parinfer-rust-auto-download nil - parinfer-rust-library "${parinferRustLibrary}") + ;; :input japanese + (setq migemo-dictionary "${pkgs.cmigemo}/share/migemo/utf-8/migemo-dict" + skk-large-jisyo "${pkgs.skk-dicts}/share/SKK-JISYO.L") - ;; :lang nix - ;; HACK Trick `nix-mode' to use alejandra instead of nixfmt. - (setq nix-nixfmt-bin "${pkgs.writeShellScript "nixfmt" '' - ${getExe pkgs.alejandra} "$@" - ''}") + ;; :editor parinfer + (setq parinfer-rust-auto-download nil + parinfer-rust-library "${parinferRustLibrary}") - ;; :lang (org +roam2) :email mu4e - (setq emacsql-sqlite-executable "${getExe pkgs.emacsql-sqlite}") + ;; :lang (org +roam2) :email mu4e + (setq emacsql-sqlite-executable "${getExe pkgs.emacsql-sqlite}") - ;; :lang plantuml - (setq plantuml-jar-path "${pkgs.plantuml}/lib/plantuml.jar" - plantuml-executable-path "${getExe' pkgs.plantuml "plantuml"}" - org-plantuml-jar-path plantuml-jar-path - org-plantuml-executable-path plantuml-executable-path) + ;; :lang plantuml + (setq plantuml-jar-path "${pkgs.plantuml}/lib/plantuml.jar" + plantuml-executable-path "${getExe' pkgs.plantuml "plantuml"}" + org-plantuml-jar-path plantuml-jar-path + org-plantuml-executable-path plantuml-executable-path) - ;; :app irc - (setq circe-default-nick "${my.username}" - circe-default-realname "${my.email}" - circe-default-user circe-default-nick) - '') - (with config.stylix.fonts; '' - (setq doom-font "${monospace.name}-${toString sizes.terminal}" - doom-serif-font "${serif.name}-${toString sizes.terminal}" - doom-variable-pitch-font "${sansSerif.name}-${toString sizes.terminal}") - '') - (with config.hm.accounts.email; let - mu4eAccounts = let - muAccounts = filter (a: a.mu.enable) (attrValues accounts); - in - concatMapStringsSep "\n" - (a: - with a; let - personalAddresses = concatMapStringsSep " " (v: ''"${v}"'') aliases; - in '' - (set-email-account! "${name}" - '((user-full-name . "${realName}") - (user-mail-address . "${address}") - (mu4e-inbox-folder . "/${name}/${folders.inbox}") - (mu4e-sent-folder . "/${name}/${folders.sent}") - (mu4e-drafts-folder . "/${name}/${folders.drafts}") - (mu4e-trash-folder . "/${name}/${folders.trash}") - (mu4e-refile-folder . "/${name}/Archive") - (+mu4e-personal-addresses . (${personalAddresses}))) - t) - '') - muAccounts; - in '' - (setq mu4e-root-maildir "${maildirBasePath}") + ;; :app irc + (setq circe-default-nick "${my.username}" + circe-default-realname "${my.email}" + circe-default-user circe-default-nick) + '' + ) + (with config.stylix.fonts; '' + (setq doom-font "${monospace.name}-${toString sizes.terminal}" + doom-serif-font "${serif.name}-${toString sizes.terminal}" + doom-variable-pitch-font "${sansSerif.name}-${toString sizes.terminal}") + '') + ( + with config.hm.accounts.email; + let + mu4eAccounts = + let + muAccounts = filter (a: a.mu.enable) (attrValues accounts); + in + concatMapStringsSep "\n" ( + a: + with a; + let + personalAddresses = concatMapStringsSep " " (v: ''"${v}"'') aliases; + in + '' + (set-email-account! "${name}" + '((user-full-name . "${realName}") + (user-mail-address . "${address}") + (mu4e-inbox-folder . "/${name}/${folders.inbox}") + (mu4e-sent-folder . "/${name}/${folders.sent}") + (mu4e-drafts-folder . "/${name}/${folders.drafts}") + (mu4e-trash-folder . "/${name}/${folders.trash}") + (mu4e-refile-folder . "/${name}/Archive") + (+mu4e-personal-addresses . (${personalAddresses}))) + t) + '' + ) muAccounts; + in + '' + (setq mu4e-root-maildir "${maildirBasePath}") - ${mu4eAccounts} - '') - (builtins.readFile ./doom/config.el) - ]; - }; - }; + ${mu4eAccounts} + '' + ) + (builtins.readFile ./doom/config.el) + ]; + }; + }; programs = { emacs = { diff --git a/modules/common/emacs/doom/config.el b/modules/common/emacs/doom/config.el index e31d41d..7f5693c 100644 --- a/modules/common/emacs/doom/config.el +++ b/modules/common/emacs/doom/config.el @@ -52,7 +52,7 @@ ;;; Org ;; -(setq org-directory "~/doc/org") +(setq org-directory "~/doc/org/") ;; For some reason only using `after!' work here. `setq-hook!' and etc doesn't ;; produce expected results. diff --git a/modules/common/eza.nix b/modules/common/eza.nix index be590b4..96b7d4c 100644 --- a/modules/common/eza.nix +++ b/modules/common/eza.nix @@ -4,9 +4,11 @@ pkgs, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.eza; -in { +in +{ options.nixfiles.modules.eza.enable = mkEnableOption "eza, an alternative to ls"; config = mkIf cfg.enable { @@ -16,6 +18,6 @@ in { la = "${ll} --header --all"; }; - hm.home.packages = [pkgs.eza]; + hm.home.packages = [ pkgs.eza ]; }; } diff --git a/modules/common/git.nix b/modules/common/git.nix index c6be614..fbe190e 100644 --- a/modules/common/git.nix +++ b/modules/common/git.nix @@ -6,11 +6,12 @@ pkgs, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.git; -in { - options.nixfiles.modules.git.client.enable = - mkEnableOption "Git client"; +in +{ + options.nixfiles.modules.git.client.enable = mkEnableOption "Git client"; config = mkIf cfg.client.enable { secrets = { @@ -75,6 +76,8 @@ in { autoStash = true; autoSquash = true; }; + rerere.enabled = true; + branch.sort = "-committerdate"; diff = { mnemonicPrefix = true; renames = "copies"; @@ -89,51 +92,54 @@ in { annotate = true; confirm = "always"; }; + column.ui = "auto"; github.user = my.username; gitlab.user = my.username; } - // mapAttrs' - (name: value: nameValuePair ''url "git@${value}:"'' {insteadOf = "${name}:";}) { + // mapAttrs' (name: value: nameValuePair ''url "git@${value}:"'' { insteadOf = "${name}:"; }) { "bitbucket" = "bitbucket.com"; "codeberg" = "codeberg.org"; "github" = "github.com"; "gitlab" = "gitlab.com"; "sourcehut" = "git.sr.ht"; } - // mapAttrs' - (name: values: nameValuePair ''url "https://${values}/"'' {insteadOf = "${name}:";}) { - "alpine" = "gitlab.alpinelinux.org"; - "debian" = "salsa.debian.org"; - "freedesktop" = "gitlab.freedesktop.org"; - "gnome" = "gitlab.gnome.org"; - "haskell" = "gitlab.haskell.org"; - "homotopic" = "gitlab.homotopic.tech"; - "horizon" = "gitlab.horizon-haskell.net"; - "kde" = "invent.kde.org"; - "nixca" = "gitlab.nixca.dev"; - "notabug" = "notabug.org"; - "opencode" = "opencode.net"; - "torproject" = "gitlab.torproject.org"; - "videolan" = "code.videolan.org"; - }; + // + mapAttrs' (name: values: nameValuePair ''url "https://${values}/"'' { insteadOf = "${name}:"; }) + { + "alpine" = "gitlab.alpinelinux.org"; + "debian" = "salsa.debian.org"; + "freedesktop" = "gitlab.freedesktop.org"; + "gnome" = "gitlab.gnome.org"; + "haskell" = "gitlab.haskell.org"; + "homotopic" = "gitlab.homotopic.tech"; + "horizon" = "gitlab.horizon-haskell.net"; + "kde" = "invent.kde.org"; + "nixca" = "gitlab.nixca.dev"; + "notabug" = "notabug.org"; + "opencode" = "opencode.net"; + "torproject" = "gitlab.torproject.org"; + "videolan" = "code.videolan.org"; + }; - aliases = let - git = getExe config.hm.programs.git.package; - curl = getExe pkgs.curl; - in { - amend = "commit --amend"; - cat = "cat-file -p"; - fast = "clone --depth=1"; - fixup = "commit --fixup"; - fuck = "!${git} reset --hard && ${git} clean --force -dx"; - get = "pull --all --recurse-submodules --autostash"; - gud = ''commit -m "git gud"''; - refresh = "clean --force -dx"; - tree = "log --graph --date=relative --pretty=tformat:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%an %ad)%Creset'"; - uncommit = "reset --soft HEAD~1"; - untrack = "rm --cache --"; - wtc = "!${curl} -sq whatthecommit.com/index.txt | ${git} commit -F -"; - }; + aliases = + let + git = getExe config.hm.programs.git.package; + curl = getExe pkgs.curl; + in + { + amend = "commit --amend"; + cat = "cat-file -p"; + fast = "clone --depth=1"; + fixup = "commit --fixup"; + fuck = "!${git} reset --hard && ${git} clean --force -dx"; + get = "pull --all --recurse-submodules --autostash"; + gud = ''commit -m "git gud"''; + refresh = "clean --force -dx"; + tree = "log --graph --date=relative --pretty=tformat:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%an %ad)%Creset'"; + uncommit = "reset --soft HEAD~1"; + untrack = "rm --cache --"; + wtc = "!${curl} -sq whatthecommit.com/index.txt | ${git} commit -F -"; + }; # All helper tools/editor generated files should go here. This must be # kept void of any project-specific or residual files. diff --git a/modules/common/gnupg.nix b/modules/common/gnupg.nix index c0f10f9..b32d94c 100644 --- a/modules/common/gnupg.nix +++ b/modules/common/gnupg.nix @@ -1,11 +1,9 @@ -{ - config, - lib, - ... -}: -with lib; let +{ config, lib, ... }: +with lib; +let cfg = config.nixfiles.modules.gnupg; -in { +in +{ options.nixfiles.modules.gnupg.enable = mkEnableOption "GnuPG"; config = mkIf cfg.enable { @@ -33,26 +31,42 @@ in { list-options = "show-uid-validity"; verify-options = "show-uid-validity"; } - // (let - cipherAlgos = ["AES256" "AES192" "AES"]; - digestAlgos = ["SHA512" "SHA384" "SHA256" "SHA224"]; - compressionAlgos = ["ZLIB" "BZIP2" "ZIP" "Uncompressed"]; - - cs = concatStringsSep " "; - in { - default-preference-list = - cs (cipherAlgos ++ digestAlgos ++ compressionAlgos); - - personal-cipher-preferences = cs cipherAlgos; - personal-digest-preferences = cs digestAlgos; - personal-compress-preferences = cs compressionAlgos; - - s2k-cipher-algo = head cipherAlgos; - s2k-digest-algo = head digestAlgos; - - digest-algo = head digestAlgos; - cert-digest-algo = head digestAlgos; - }); + // ( + let + cipherAlgos = [ + "AES256" + "AES192" + "AES" + ]; + digestAlgos = [ + "SHA512" + "SHA384" + "SHA256" + "SHA224" + ]; + compressionAlgos = [ + "ZLIB" + "BZIP2" + "ZIP" + "Uncompressed" + ]; + + cs = concatStringsSep " "; + in + { + default-preference-list = cs (cipherAlgos ++ digestAlgos ++ compressionAlgos); + + personal-cipher-preferences = cs cipherAlgos; + personal-digest-preferences = cs digestAlgos; + personal-compress-preferences = cs compressionAlgos; + + s2k-cipher-algo = head cipherAlgos; + s2k-digest-algo = head digestAlgos; + + digest-algo = head digestAlgos; + cert-digest-algo = head digestAlgos; + } + ); }; }; } diff --git a/modules/common/htop.nix b/modules/common/htop.nix index bf3f1e4..647abf7 100644 --- a/modules/common/htop.nix +++ b/modules/common/htop.nix @@ -1,13 +1,10 @@ -{ - config, - lib, - ... -}: -with lib; let +{ config, lib, ... }: +with lib; +let cfg = config.nixfiles.modules.htop; -in { - options.nixfiles.modules.htop.enable = - mkEnableOption "htop"; +in +{ + options.nixfiles.modules.htop.enable = mkEnableOption "htop"; config = mkIf cfg.enable { hm.programs.htop = { diff --git a/modules/common/mpv.nix b/modules/common/mpv.nix index e857b5b..9cd1e91 100644 --- a/modules/common/mpv.nix +++ b/modules/common/mpv.nix @@ -4,28 +4,33 @@ pkgs, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.mpv; -in { +in +{ options.nixfiles.modules.mpv.enable = mkEnableOption "mpv"; config = mkIf cfg.enable { hm.programs.mpv = { enable = true; - package = with pkgs; - wrapMpv (mpv-unwrapped.override { - bs2bSupport = false; - cacaSupport = false; - dvbinSupport = false; - dvdnavSupport = false; - swiftSupport = false; - }) { - scripts = with mpvScripts; [ - autoload - sponsorblock - ]; - }; + package = + with pkgs; + wrapMpv + (mpv-unwrapped.override { + bs2bSupport = false; + cacaSupport = false; + dvbinSupport = false; + dvdnavSupport = false; + swiftSupport = false; + }) + { + scripts = with mpvScripts; [ + autoload + sponsorblock + ]; + }; bindings = { "RIGHT" = "seek 10"; @@ -63,87 +68,89 @@ in { "extension.jpg".profile = "extension.png"; }; - config = let - lang = concatStringsSep "," [ - "Japanese" - "japanese" - "jp" - "jpn" - "jaJP" - "ja-JP" - "English" - "english" - "en" - "eng" - "enUS" - "en-US" - "Russian" - "russian" - "ru" - "rus" - "ruRU" - "ru-RU" - ]; - in { - autofit-larger = "100%x95%"; - cache = true; - cursor-autohide = 1000; - cursor-autohide-fs-only = true; - demuxer-max-back-bytes = "20M"; - demuxer-max-bytes = "20M"; - force-seekable = true; - fullscreen = true; - msg-color = true; - msg-module = true; - prefetch-playlist = true; - save-position-on-quit = true; - screenshot-format = "png"; - screenshot-template = "%F [%p]"; - stop-screensaver = true; - term-osd-bar = true; - use-filedir-conf = true; - - osd-bar-align-y = 0; - osd-bar-h = 2; - osd-bar-w = 60; - osd-border-color = "#FF262626"; - osd-border-size = 2; - osd-color = "#FFFFFFFF"; - osd-duration = 1000; - osd-font-size = 40; - osd-fractions = true; - osd-level = 1; - osd-shadow-color = "#33000000"; - - # osc = false; - - blend-subtitles = true; - embeddedfonts = false; - sub-ass-force-margins = true; - sub-ass-force-style = "kerning=yes"; - sub-auto = "fuzzy"; - sub-border-color = "#FF262626"; - sub-border-size = 2.5; - sub-color = "#FFFFFFFF"; - sub-file-paths-append = "srt"; - sub-fix-timing = true; - sub-font-size = 40; - sub-scale-with-window = true; - sub-shadow-color = "#33000000"; - sub-shadow-offset = 1; - sub-spacing = 0.5; - sub-use-margins = true; - - audio-file-auto = "fuzzy"; - volume = 100; - volume-max = 200; - - alang = lang; - slang = lang; - - ytdl = true; - ytdl-raw-options = ''sub-lang="${lang}",write-sub=''; - }; + config = + let + lang = concatStringsSep "," [ + "Japanese" + "japanese" + "jp" + "jpn" + "jaJP" + "ja-JP" + "English" + "english" + "en" + "eng" + "enUS" + "en-US" + "Russian" + "russian" + "ru" + "rus" + "ruRU" + "ru-RU" + ]; + in + { + autofit-larger = "100%x95%"; + cache = true; + cursor-autohide = 1000; + cursor-autohide-fs-only = true; + demuxer-max-back-bytes = "20M"; + demuxer-max-bytes = "20M"; + force-seekable = true; + fullscreen = true; + msg-color = true; + msg-module = true; + prefetch-playlist = true; + save-position-on-quit = true; + screenshot-format = "png"; + screenshot-template = "%F [%p]"; + stop-screensaver = true; + term-osd-bar = true; + use-filedir-conf = true; + + osd-bar-align-y = 0; + osd-bar-h = 2; + osd-bar-w = 60; + osd-border-color = "#FF262626"; + osd-border-size = 2; + osd-color = "#FFFFFFFF"; + osd-duration = 1000; + osd-font-size = 40; + osd-fractions = true; + osd-level = 1; + osd-shadow-color = "#33000000"; + + # osc = false; + + blend-subtitles = true; + embeddedfonts = false; + sub-ass-force-margins = true; + sub-ass-force-style = "kerning=yes"; + sub-auto = "fuzzy"; + sub-border-color = "#FF262626"; + sub-border-size = 2.5; + sub-color = "#FFFFFFFF"; + sub-file-paths-append = "srt"; + sub-fix-timing = true; + sub-font-size = 40; + sub-scale-with-window = true; + sub-shadow-color = "#33000000"; + sub-shadow-offset = 1; + sub-spacing = 0.5; + sub-use-margins = true; + + audio-file-auto = "fuzzy"; + volume = 100; + volume-max = 200; + + alang = lang; + slang = lang; + + ytdl = true; + ytdl-raw-options = ''sub-lang="${lang}",write-sub=''; + }; }; }; } diff --git a/modules/common/nmap.nix b/modules/common/nmap.nix index 85beb21..71b3d0b 100644 --- a/modules/common/nmap.nix +++ b/modules/common/nmap.nix @@ -5,9 +5,11 @@ inputs, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.nmap; -in { +in +{ options.nixfiles.modules.nmap.enable = mkEnableOption "Nmap"; config = mkIf cfg.enable { @@ -23,7 +25,10 @@ in { ".nmap/scripts/vulscan/vulscan.nse".source = "${inputs.nmap-vulscan}/vulscan.nse"; }; - packages = with pkgs; [nmap nmap-formatter]; + packages = with pkgs; [ + nmap + nmap-formatter + ]; activation.regenerateNmapScripts = with pkgs; '' ${getExe' nmap "nmap"} --script-updatedb @@ -33,27 +38,29 @@ in { systemd.user = { services.update-nmap-vulscan-lists = { Service = { - ExecStart = getExe (pkgs.writeShellApplication { - name = "update-nmap-vulscan-lists"; - runtimeInputs = [pkgs.curl]; - text = '' - declare -a vulscandbs=( - "cve" - "exploitdb" - "openvas" - "osvdb" - "scipvuldb" - "securityfocus" - "securitytracker" - "xforce" - ) - for i in "''${vulscandbs[@]}"; do - curl \ - -o "${config.my.home}/.nmap/scripts/vulscan/$i.csv" \ - "https://www.computec.ch/projekte/vulscan/download/$i.csv" - done - ''; - }); + ExecStart = getExe ( + pkgs.writeShellApplication { + name = "update-nmap-vulscan-lists"; + runtimeInputs = [ pkgs.curl ]; + text = '' + declare -a vulscandbs=( + "cve" + "exploitdb" + "openvas" + "osvdb" + "scipvuldb" + "securityfocus" + "securitytracker" + "xforce" + ) + for i in "''${vulscandbs[@]}"; do + curl \ + -o "${config.my.home}/.nmap/scripts/vulscan/$i.csv" \ + "https://www.computec.ch/projekte/vulscan/download/$i.csv" + done + ''; + } + ); }; }; @@ -65,7 +72,7 @@ in { Persistent = true; Unit = "update-nmap-vulscan-lists.service"; }; - Install.WantedBy = ["timers.target"]; + Install.WantedBy = [ "timers.target" ]; }; }; }; diff --git a/modules/common/openssh.nix b/modules/common/openssh.nix index ecaf4de..f60a1ef 100644 --- a/modules/common/openssh.nix +++ b/modules/common/openssh.nix @@ -4,11 +4,12 @@ pkgs, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.openssh; -in { - options.nixfiles.modules.openssh.client.enable = - mkEnableOption "OpenSSH client"; +in +{ + options.nixfiles.modules.openssh.client.enable = mkEnableOption "OpenSSH client"; config = mkIf cfg.client.enable { hm = { @@ -29,26 +30,35 @@ in { serverAliveCountMax = 30; serverAliveInterval = 60; - matchBlocks = let - mkBlock = name: { - hostname ? name, - port ? 22022, # NOTE This is not the default OpenSSH port. - user ? my.username, - identityFile ? "${config.my.home}/.ssh/${my.username}_${my.ssh.type}", - extraAttrs ? {}, - }: - nameValuePair name ({inherit hostname port user identityFile;} - // extraAttrs); + matchBlocks = + let + mkBlock = + name: + { + hostname ? name, + port ? 22022, # NOTE This is not the default OpenSSH port. + user ? my.username, + identityFile ? "${config.my.home}/.ssh/${my.username}_${my.ssh.type}", + extraAttrs ? { }, + }: + nameValuePair name ( + { + inherit + hostname + port + user + identityFile + ; + } + // extraAttrs + ); - internalServers = - mapAttrs' mkBlock - (mapAttrs (name: _: { - hostname = "${name}.${my.domain.shire}"; - }) (filterAttrs (_: attr: - hasAttr "wireguard" attr - && attr.isHeadless) - my.configurations)); - in + internalServers = mapAttrs' mkBlock ( + mapAttrs (name: _: { hostname = "${name}.${my.domain.shire}"; }) ( + filterAttrs (_: attr: hasAttr "wireguard" attr && attr.isHeadless) my.configurations + ) + ); + in internalServers // (mapAttrs' mkBlock { gitolite = { diff --git a/modules/common/password-store.nix b/modules/common/password-store.nix index c9a71ce..e5cd756 100644 --- a/modules/common/password-store.nix +++ b/modules/common/password-store.nix @@ -4,26 +4,28 @@ pkgs, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.password-store; -in { - options.nixfiles.modules.password-store.enable = - mkEnableOption "the standard UNIX password manager"; +in +{ + options.nixfiles.modules.password-store.enable = mkEnableOption "the standard UNIX password manager"; config = mkIf cfg.enable { hm.programs = { password-store = { enable = true; - package = pkgs.pass.withExtensions (p: with p; [pass-otp]); + package = pkgs.pass.withExtensions (p: with p; [ pass-otp ]); settings.PASSWORD_STORE_DIR = "${config.my.home}/.password-store"; }; # HACK https://github.com/NixOS/nixpkgs/issues/183604 - bash.initExtra = let - completions = "${config.hm.programs.password-store.package}/share/bash-completion/completions"; - in + bash.initExtra = + let + completions = "${config.hm.programs.password-store.package}/share/bash-completion/completions"; + in mkAfter '' source ${completions}/pass-otp source ${completions}/pass diff --git a/modules/common/profiles/default.nix b/modules/common/profiles/default.nix index a17ff08..79ce39d 100644 --- a/modules/common/profiles/default.nix +++ b/modules/common/profiles/default.nix @@ -5,9 +5,11 @@ this, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.profiles.default; -in { +in +{ imports = [ ./dev ./email.nix diff --git a/modules/common/profiles/dev/containers.nix b/modules/common/profiles/dev/containers.nix index e90c88e..8f3bfc6 100644 --- a/modules/common/profiles/dev/containers.nix +++ b/modules/common/profiles/dev/containers.nix @@ -4,9 +4,11 @@ pkgs, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.profiles.dev.containers; -in { +in +{ options.nixfiles.modules.profiles.dev.containers.enable = mkEnableOption "Tools for working with containers and container orchestration" // { diff --git a/modules/common/profiles/dev/default.nix b/modules/common/profiles/dev/default.nix index 52dc49f..6ac1fe6 100644 --- a/modules/common/profiles/dev/default.nix +++ b/modules/common/profiles/dev/default.nix @@ -4,17 +4,18 @@ pkgs, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.profiles.dev; -in { +in +{ imports = [ ./containers.nix ./hidden.nix ./sql.nix ]; - options.nixfiles.modules.profiles.dev.enable = - mkEnableOption "Catch-all profile for stuff related to software development and etc."; + options.nixfiles.modules.profiles.dev.enable = mkEnableOption "Catch-all profile for stuff related to software development and etc."; config = mkIf cfg.enable { nixfiles.modules = { diff --git a/modules/common/profiles/dev/sql.nix b/modules/common/profiles/dev/sql.nix index 3e1c4b2..c2d4894 100644 --- a/modules/common/profiles/dev/sql.nix +++ b/modules/common/profiles/dev/sql.nix @@ -4,9 +4,11 @@ pkgs, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.profiles.dev.sql; -in { +in +{ options.nixfiles.modules.profiles.dev.sql.enable = mkEnableOption "SQL stuff and database management tools" // { @@ -20,81 +22,84 @@ in { litecli ]; - xdg = let - mainSection = { - destructive_warning = "True"; - enable_pager = "True"; - keyword_casing = "auto"; - less_chatty = "True"; - log_file = "/dev/null"; - log_level = "CRITICAL"; - multi_line = "False"; - syntax_style = "default"; - table_format = "fancy_grid"; - }; + xdg = + let + mainSection = { + destructive_warning = "True"; + enable_pager = "True"; + keyword_casing = "auto"; + less_chatty = "True"; + log_file = "/dev/null"; + log_level = "CRITICAL"; + multi_line = "False"; + syntax_style = "default"; + table_format = "fancy_grid"; + }; - colorsSection = with config.colors.withHashtag; { - "arg-toolbar" = "noinherit bold"; - "arg-toolbar.text" = "nobold"; - "bottom-toolbar" = "bg:${base01} ${base06}"; - "bottom-toolbar.off" = "bg:${base01} ${base02}"; - "bottom-toolbar.on" = "bg:${base01} ${base07}"; - "bottom-toolbar.transaction.failed" = "bg:${base01} ${base08} bold"; - "bottom-toolbar.transaction.valid" = "bg:${base01} ${base0B} bold"; - "completion-menu.completion" = "bg:${base01} ${base06}"; - "completion-menu.completion.current" = "bg:${base06} ${base01}"; - "completion-menu.meta.completion" = "bg:${base01} ${base13}"; - "completion-menu.meta.completion.current" = "bg:${base09} ${base01}"; - "completion-menu.multi-column-meta" = "bg:${base09} ${base01}"; - "scrollbar" = "bg:${base01}"; - "scrollbar.arrow" = "bg:${base01}"; - "search" = "bg:${base17} ${base07}"; - "search-toolbar" = "noinherit bold"; - "search-toolbar.text" = "nobold"; - "search.current" = "bg:${base14} ${base07}"; - "selected" = "bg:${base0D} ${base07}"; - "system-toolbar" = "noinherit bold"; - }; + colorsSection = with config.colors.withHashtag; { + "arg-toolbar" = "noinherit bold"; + "arg-toolbar.text" = "nobold"; + "bottom-toolbar" = "bg:${base01} ${base06}"; + "bottom-toolbar.off" = "bg:${base01} ${base02}"; + "bottom-toolbar.on" = "bg:${base01} ${base07}"; + "bottom-toolbar.transaction.failed" = "bg:${base01} ${base08} bold"; + "bottom-toolbar.transaction.valid" = "bg:${base01} ${base0B} bold"; + "completion-menu.completion" = "bg:${base01} ${base06}"; + "completion-menu.completion.current" = "bg:${base06} ${base01}"; + "completion-menu.meta.completion" = "bg:${base01} ${base13}"; + "completion-menu.meta.completion.current" = "bg:${base09} ${base01}"; + "completion-menu.multi-column-meta" = "bg:${base09} ${base01}"; + "scrollbar" = "bg:${base01}"; + "scrollbar.arrow" = "bg:${base01}"; + "search" = "bg:${base17} ${base07}"; + "search-toolbar" = "noinherit bold"; + "search-toolbar.text" = "nobold"; + "search.current" = "bg:${base14} ${base07}"; + "selected" = "bg:${base0D} ${base07}"; + "system-toolbar" = "noinherit bold"; + }; - mkCliConfig = { - name, - custom, - }: { - "${name}/config" = { - text = generators.toINI {} { - main = mainSection // custom; - colors = mapAttrs (_: v: "'${v}'") colorsSection; + mkCliConfig = + { name, custom }: + { + "${name}/config" = { + text = generators.toINI { } { + main = mainSection // custom; + colors = mapAttrs (_: v: "'${v}'") colorsSection; + }; + }; }; - }; + in + { + configFile = mkMerge ( + map mkCliConfig [ + { + name = "pgcli"; + custom = { + prompt = "'\\u@\\h:\\d> '"; + multi_line_mode = "psql"; + on_error = "STOP"; + auto_expand = "True"; + expand = "True"; + keyring = "False"; + vi = "True"; + casing_file = "/dev/null"; + history_file = "/dev/null"; + }; + } + { + name = "litecli"; + custom = { + prompt = "'\\d> '"; + prompt_continuation = "'-> '"; + auto_vertical_output = "True"; + key_bindings = "vi"; + audit_log = "/dev/null"; + }; + } + ] + ); }; - in { - configFile = mkMerge (map mkCliConfig [ - { - name = "pgcli"; - custom = { - prompt = "'\\u@\\h:\\d> '"; - multi_line_mode = "psql"; - on_error = "STOP"; - auto_expand = "True"; - expand = "True"; - keyring = "False"; - vi = "True"; - casing_file = "/dev/null"; - history_file = "/dev/null"; - }; - } - { - name = "litecli"; - custom = { - prompt = "'\\d> '"; - prompt_continuation = "'-> '"; - auto_vertical_output = "True"; - key_bindings = "vi"; - audit_log = "/dev/null"; - }; - } - ]); - }; }; }; } diff --git a/modules/common/profiles/email.nix b/modules/common/profiles/email.nix index 3c809af..a525692 100644 --- a/modules/common/profiles/email.nix +++ b/modules/common/profiles/email.nix @@ -5,45 +5,51 @@ this, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.profiles.email; -in { - options.nixfiles.modules.profiles.email.enable = - mkEnableOption "Local Email management" // {default = this.isHeadful;}; +in +{ + options.nixfiles.modules.profiles.email.enable = mkEnableOption "Local Email management" // { + default = this.isHeadful; + }; config = mkIf cfg.enable { hm = { accounts.email = { maildirBasePath = "${config.my.home}/doc/mail"; - accounts = let - mkAccount = attrs: - mkMerge [ - { - mbsync = { - enable = true; - create = "both"; - expunge = "both"; - patterns = ["*"]; - }; - msmtp.enable = true; - mu.enable = true; - thunderbird = { - enable = hasSuffix "linux" this.system; - settings = id: { - "mail.identity.id_${id}.compose_html" = false; - "mail.identity.id_${id}.reply_on_top" = 0; + accounts = + let + mkAccount = + attrs: + mkMerge [ + { + mbsync = { + enable = true; + create = "both"; + expunge = "both"; + patterns = [ "*" ]; }; - }; - } - attrs - ]; + msmtp.enable = true; + mu.enable = true; + thunderbird = { + enable = hasSuffix "linux" this.system; + settings = id: { + "mail.identity.id_${id}.compose_html" = false; + "mail.identity.id_${id}.reply_on_top" = 0; + }; + }; + } + attrs + ]; - getPassword = { - path, - line ? 0, - }: - assert (builtins.isInt line); + getPassword = + { + path, + line ? 0, + }: + assert (builtins.isInt line); concatStringsSep " " ( [ (getExe config.hm.programs.password-store.package) @@ -57,48 +63,54 @@ in { "'${toString line}!d'" ] ); - in { - shire = mkAccount rec { - address = my.email; - aliases = [address "frodo@rohan.net" "azahi@shire.net"]; - realName = my.fullname; - gpg = { - inherit (my.pgp) key; - signByDefault = true; - encryptByDefault = false; - }; + in + { + shire = mkAccount rec { + address = my.email; + aliases = [ + address + "frodo@rohan.net" + "azahi@shire.net" + ]; + realName = my.fullname; + gpg = { + inherit (my.pgp) key; + signByDefault = true; + encryptByDefault = false; + }; - primary = true; + primary = true; - imap = { - host = "shire.net"; - port = 993; - tls.enable = true; - }; - smtp = { - host = "shire.net"; - port = 465; - tls.enable = true; + imap = { + host = "shire.net"; + port = 993; + tls.enable = true; + }; + smtp = { + host = "shire.net"; + port = 465; + tls.enable = true; + }; + userName = "azahi@shire.net"; + passwordCommand = getPassword { path = "email/shire.net/azahi"; }; }; - userName = "azahi@shire.net"; - passwordCommand = getPassword { - path = "email/shire.net/azahi"; - }; - }; - yahoo = mkAccount rec { - address = "admin@yahoo.com"; - aliases = [address "admin@yahoo.com"]; - realName = "Firstname Lastname"; + yahoo = mkAccount rec { + address = "admin@yahoo.com"; + aliases = [ + address + "admin@yahoo.com" + ]; + realName = "Firstname Lastname"; - flavor = "yahoo.com"; - userName = "admin@yahoo.com"; - passwordCommand = getPassword { - path = "email/yahoo.com/admin"; - line = 2; + flavor = "yahoo.com"; + userName = "admin@yahoo.com"; + passwordCommand = getPassword { + path = "email/yahoo.com/admin"; + line = 2; + }; }; }; - }; }; programs = { diff --git a/modules/common/profiles/headful.nix b/modules/common/profiles/headful.nix index 1578ccc..cd29225 100644 --- a/modules/common/profiles/headful.nix +++ b/modules/common/profiles/headful.nix @@ -5,11 +5,14 @@ this, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.profiles.headful; -in { - options.nixfiles.modules.profiles.headful.enable = - mkEnableOption "headful profile" // {default = this.isHeadful;}; +in +{ + options.nixfiles.modules.profiles.headful.enable = mkEnableOption "headful profile" // { + default = this.isHeadful; + }; config = mkIf cfg.enable { nixfiles.modules = { diff --git a/modules/common/profiles/headless.nix b/modules/common/profiles/headless.nix index cc7c326..1f8096c 100644 --- a/modules/common/profiles/headless.nix +++ b/modules/common/profiles/headless.nix @@ -5,19 +5,21 @@ this, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.profiles.headless; -in { - options.nixfiles.modules.profiles.headless.enable = - mkEnableOption "headless profile" // {default = this.isHeadless;}; +in +{ + options.nixfiles.modules.profiles.headless.enable = mkEnableOption "headless profile" // { + default = this.isHeadless; + }; config = mkIf cfg.enable { hm.home.file = { ".hushlogin".text = ""; - ".bash_history".source = - config.hm.lib.file.mkOutOfStoreSymlink "/dev/null"; + ".bash_history".source = config.hm.lib.file.mkOutOfStoreSymlink "/dev/null"; }; - environment.systemPackages = with pkgs; [alacritty.terminfo]; + environment.systemPackages = with pkgs; [ alacritty.terminfo ]; }; } diff --git a/modules/common/qutebrowser.nix b/modules/common/qutebrowser.nix index a3b82d3..8fdcf48 100644 --- a/modules/common/qutebrowser.nix +++ b/modules/common/qutebrowser.nix @@ -4,9 +4,11 @@ pkgs, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.qutebrowser; -in { +in +{ options.nixfiles.modules.qutebrowser.enable = mkEnableOption "Qutebrowser"; config = mkIf cfg.enable { @@ -20,9 +22,11 @@ in { enable = true; keyBindings.normal = mkIf mpv.enable { - "z" = let - mpv = getExe config.hm.programs.mpv.package; - in "hint links spawn --detach ${mpv} {hint-url}"; + "z" = + let + mpv = getExe config.hm.programs.mpv.package; + in + "hint links spawn --detach ${mpv} {hint-url}"; }; searchEngines = rec { @@ -147,7 +151,11 @@ in { shrink = true; timestamp_format = "%y-%m-%d"; min_chars = 3; - open_categories = ["bookmarks" "quickmarks" "history"]; + open_categories = [ + "bookmarks" + "quickmarks" + "history" + ]; scrollbar = { width = 0; @@ -164,11 +172,7 @@ in { }; editor.command = [ - ( - if alacritty.enable - then getExe pkgs.alacritty - else getExe pkgs.xterm - ) + (if alacritty.enable then getExe pkgs.alacritty else getExe pkgs.xterm) "-e" (getExe' config.programs.vim.package "vim") "-f" @@ -192,7 +196,11 @@ in { smooth = false; }; - spellcheck.languages = ["en-US" "en-GB" "ru-RU"]; + spellcheck.languages = [ + "en-US" + "en-GB" + "ru-RU" + ]; statusbar.position = "bottom"; @@ -233,7 +241,7 @@ in { url = rec { default_page = "about:blank"; - start_pages = [default_page]; + start_pages = [ default_page ]; }; window = { @@ -248,76 +256,87 @@ in { }; extraConfig = - (let - mkPaddingDictionary = { - name, - bottom, - left, - right, - top, - }: let - n = "c.${name}.padding"; - b = "'bottom': ${toString bottom}"; - l = "'left': ${toString left}"; - r = "'right': ${toString right}"; - t = "'top': ${toString top}"; - in "${n} = {${b}, ${l}, ${r}, ${t}}"; - - final = map mkPaddingDictionary [ - { - name = "hints"; - bottom = 3; - left = 3; - right = 3; - top = 3; - } - { - name = "statusbar"; - bottom = 1; - left = 0; - right = 3; - top = 1; - } - { - name = "tabs"; - bottom = 1; - left = 6; - right = 6; - top = 1; - } - ]; - in - concatLines final + "\n") - + (let - allowSetting = setting: url: "config.set('content.${setting}', True, '${url}')"; - - allowMediaCaptureSetting = url: [ - (allowSetting "desktop_capture" url) - (allowSetting "media.audio_video_capture" url) - ]; - allowedMediaCapture = flatten (map allowMediaCaptureSetting [ - "https://discord.com" - "https://web.telegram.org" - ]); - - allowNotificationsSetting = allowSetting "notifications.enabled"; - allowedNotifications = map allowNotificationsSetting [ - "https://discord.com" - "https://web.telegram.org" - ]; + ( + let + mkPaddingDictionary = + { + name, + bottom, + left, + right, + top, + }: + let + n = "c.${name}.padding"; + b = "'bottom': ${toString bottom}"; + l = "'left': ${toString left}"; + r = "'right': ${toString right}"; + t = "'top': ${toString top}"; + in + "${n} = {${b}, ${l}, ${r}, ${t}}"; + + final = map mkPaddingDictionary [ + { + name = "hints"; + bottom = 3; + left = 3; + right = 3; + top = 3; + } + { + name = "statusbar"; + bottom = 1; + left = 0; + right = 3; + top = 1; + } + { + name = "tabs"; + bottom = 1; + left = 6; + right = 6; + top = 1; + } + ]; + in + concatLines final + "\n" + ) + + ( + let + allowSetting = setting: url: "config.set('content.${setting}', True, '${url}')"; + + allowMediaCaptureSetting = url: [ + (allowSetting "desktop_capture" url) + (allowSetting "media.audio_video_capture" url) + ]; + allowedMediaCapture = flatten ( + map allowMediaCaptureSetting [ + "https://discord.com" + "https://web.telegram.org" + ] + ); + + allowNotificationsSetting = allowSetting "notifications.enabled"; + allowedNotifications = map allowNotificationsSetting [ + "https://discord.com" + "https://web.telegram.org" + ]; - final = allowedMediaCapture ++ allowedNotifications; - in - concatLines final + "\n"); + final = allowedMediaCapture ++ allowedNotifications; + in + concatLines final + "\n" + ); }; - home.activation.installQutebrowserDictionaries = let - dictcli = "${pkgs.qutebrowser}/share/qutebrowser/scripts/dictcli.py"; - in '' - if [[ ! -d "''${XDG_DATA_HOME:-$HOME/.local/share}/qutebrowser/qtwebengine_dictionaries" ]]; then - ${dictcli} install en-US en-GB ru-RU - fi - ''; + home.activation.installQutebrowserDictionaries = + let + dictcli = "${pkgs.qutebrowser}/share/qutebrowser/scripts/dictcli.py"; + in + '' + if [[ ! -d "''${XDG_DATA_HOME:-$HOME/.local/share}/qutebrowser/qtwebengine_dictionaries" ]]; then + ${dictcli} install en-US en-GB ru-RU + fi + ''; }; }; } diff --git a/modules/common/subversion.nix b/modules/common/subversion.nix index 2bd5e42..9398592 100644 --- a/modules/common/subversion.nix +++ b/modules/common/subversion.nix @@ -4,9 +4,11 @@ pkgs, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.subversion; -in { +in +{ options.nixfiles.modules.subversion.enable = mkEnableOption "Subversion"; config = mkIf cfg.enable { @@ -14,7 +16,7 @@ in { hm.home = { file = { - ".subversion/config".text = generators.toINI {} { + ".subversion/config".text = generators.toINI { } { auth = { password-stores = "gpg-agent"; ssl-client-cert-file-prompt = "no"; @@ -26,8 +28,9 @@ in { diff-cmd = getExe pkgs.colordiff; }; miscellany = { - global-ignores = with config.hm.programs.git; - optionalString (ignores != []) (concatStringsSep " " ignores); + global-ignores = + with config.hm.programs.git; + optionalString (ignores != [ ]) (concatStringsSep " " ignores); diff-ignore-content-type = "no"; }; working-copy = { @@ -37,7 +40,7 @@ in { }; }; - ".subversion/servers".text = generators.toINI {} { + ".subversion/servers".text = generators.toINI { } { global = { store-auth-creds = "yes"; store-passwords = "yes"; @@ -46,7 +49,7 @@ in { }; }; - packages = [(pkgs.subversionClient.override {saslSupport = true;})]; + packages = [ (pkgs.subversionClient.override { saslSupport = true; }) ]; }; }; } diff --git a/modules/common/tmux.nix b/modules/common/tmux.nix index e978f72..a754222 100644 --- a/modules/common/tmux.nix +++ b/modules/common/tmux.nix @@ -1,13 +1,10 @@ -{ - config, - lib, - ... -}: -with lib; let +{ config, lib, ... }: +with lib; +let cfg = config.nixfiles.modules.tmux; -in { - options.nixfiles.modules.tmux.enable = - mkEnableOption "tmux"; +in +{ + options.nixfiles.modules.tmux.enable = mkEnableOption "tmux"; config = mkIf cfg.enable { hm.programs.tmux = { diff --git a/modules/common/vim/default.nix b/modules/common/vim/default.nix index e305cf1..93729bc 100644 --- a/modules/common/vim/default.nix +++ b/modules/common/vim/default.nix @@ -4,9 +4,11 @@ pkgs, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.vim; -in { +in +{ options.nixfiles.modules.vim = { enable = mkEnableOption "Vim"; @@ -35,7 +37,7 @@ in { hm.stylix.targets.vim.enable = false; environment = with config.programs.vim; { - systemPackages = [package]; + systemPackages = [ package ]; variables = rec { EDITOR = mkOverride 15 (getExe' package "vim"); VISUAL = EDITOR; diff --git a/modules/common/vscode.nix b/modules/common/vscode.nix index 8901113..bd840d8 100644 --- a/modules/common/vscode.nix +++ b/modules/common/vscode.nix @@ -5,15 +5,22 @@ pkgs, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.vscode; -in { +in +{ options.nixfiles.modules.vscode = { enable = mkEnableOption "VSCode"; - package = with pkgs; + package = + with pkgs; mkOption { - type = types.enum [vscodium vscode vscode-fhs]; + type = types.enum [ + vscodium + vscode + vscode-fhs + ]; default = vscodium; description = "Which package to use as a VSCode implementation."; }; @@ -29,203 +36,209 @@ in { hm = { stylix.targets.vscode.enable = false; - programs.vscode = with config.nixfiles; - with modules; - with profiles; { - enable = true; - - inherit (cfg) package; - - extensions = with pkgs.open-vsx; - [ - editorconfig.editorconfig - efoerster.texlab - github.vscode-pull-request-github - gitlab.gitlab-workflow - golang.go - graphql.vscode-graphql - graphql.vscode-graphql-execution - graphql.vscode-graphql-syntax - hashicorp.hcl - hashicorp.terraform - haskell.haskell - jnoortheen.nix-ide - kahole.magit - mads-hartmann.bash-ide-vscode - mkhl.direnv - ms-kubernetes-tools.vscode-kubernetes-tools - ms-python.python - redhat.ansible - redhat.vscode-xml - redhat.vscode-yaml - rust-lang.rust - signageos.signageos-vscode-sops - skellock.just - streetsidesoftware.code-spell-checker - streetsidesoftware.code-spell-checker-british-english - streetsidesoftware.code-spell-checker-russian - streetsidesoftware.code-spell-checker-scientific-terms - tamasfe.even-better-toml - task.vscode-task - vscode-org-mode.org-mode - ziglang.vscode-zig - ] - ++ optional cfg.vim.enable vscodevim.vim; - - userSettings = { - editor = { - codeLens = false; - cursorStyle = "block"; - detectIndentation = true; - minimap.enabled = false; - renderWhitespace = "trailing"; - rulers = [80 120]; - smoothScrolling = false; - tabCompletion = "on"; - cursorSurroundingLines = 10; - scrollBeyondLastColumn = 10; - }; + programs.vscode = + with config.nixfiles; + with modules; + with profiles; + { + enable = true; + + inherit (cfg) package; + + extensions = + with pkgs.open-vsx; + [ + editorconfig.editorconfig + efoerster.texlab + github.vscode-pull-request-github + gitlab.gitlab-workflow + golang.go + graphql.vscode-graphql + graphql.vscode-graphql-execution + graphql.vscode-graphql-syntax + hashicorp.hcl + hashicorp.terraform + haskell.haskell + jnoortheen.nix-ide + kahole.magit + mads-hartmann.bash-ide-vscode + mkhl.direnv + ms-kubernetes-tools.vscode-kubernetes-tools + ms-python.python + redhat.ansible + redhat.vscode-xml + redhat.vscode-yaml + rust-lang.rust + signageos.signageos-vscode-sops + skellock.just + streetsidesoftware.code-spell-checker + streetsidesoftware.code-spell-checker-british-english + streetsidesoftware.code-spell-checker-russian + streetsidesoftware.code-spell-checker-scientific-terms + tamasfe.even-better-toml + task.vscode-task + vscode-org-mode.org-mode + ziglang.vscode-zig + ] + ++ optional cfg.vim.enable vscodevim.vim; + + userSettings = { + editor = { + codeLens = false; + cursorStyle = "block"; + detectIndentation = true; + minimap.enabled = false; + renderWhitespace = "trailing"; + rulers = [ + 80 + 120 + ]; + smoothScrolling = false; + tabCompletion = "on"; + cursorSurroundingLines = 10; + scrollBeyondLastColumn = 10; + }; - keyboard.dispatch = "keyCode"; + keyboard.dispatch = "keyCode"; - diffEditor.codeLens = false; + diffEditor.codeLens = false; - files = { - autoSave = "off"; - enableTrash = false; - }; + files = { + autoSave = "off"; + enableTrash = false; + }; - workbench = { - activityBar.location = "hidden"; - colorTheme = "Default Light Modern"; - editor.highlightModifiedTabs = true; - enableExperiments = false; - settings.enableNaturalLanguageSearch = false; - startupEditor = "none"; - tips.enabled = false; - tree.indent = 4; - welcomePage = { - walkthroughs.openOnInstall = false; - preferReducedMotion = true; + workbench = { + activityBar.location = "hidden"; + colorTheme = "Default Light Modern"; + editor.highlightModifiedTabs = true; + enableExperiments = false; + settings.enableNaturalLanguageSearch = false; + startupEditor = "none"; + tips.enabled = false; + tree.indent = 4; + welcomePage = { + walkthroughs.openOnInstall = false; + preferReducedMotion = true; + }; }; - }; - extensions = { - autoCheckUpdates = false; - autoUpdate = false; - ignoreRecommendations = true; - }; + extensions = { + autoCheckUpdates = false; + autoUpdate = false; + ignoreRecommendations = true; + }; - terminal.integrated = { - enableBell = true; - }; + terminal.integrated = { + enableBell = true; + }; - update = { - mode = "none"; - showReleaseNotes = false; - }; + update = { + mode = "none"; + showReleaseNotes = false; + }; - telemetry = { - enableCrashReporter = false; - enableTelemetry = false; - }; + telemetry = { + enableCrashReporter = false; + enableTelemetry = false; + }; - security.workspace.trust.enabled = false; + security.workspace.trust.enabled = false; - # Extensions. + # Extensions. - ansible = { ansible = { - useFullyQualifiedCollectionNames = true; - reuseTerminal = true; + ansible = { + useFullyQualifiedCollectionNames = true; + reuseTerminal = true; + }; + validation.lint.path = getExe' pkgs.ansible-lint "ansible-lint"; }; - validation.lint.path = getExe' pkgs.ansible-lint "ansible-lint"; - }; - bashIde.shellcheckPath = getExe' pkgs.shellcheck "shellcheck"; + bashIde.shellcheckPath = getExe' pkgs.shellcheck "shellcheck"; - cSpell.language = "en-GB,en,ru"; + cSpell.language = "en-GB,en,ru"; - direnv = { - restart.automatic = true; - }; + direnv = { + restart.automatic = true; + }; - magit = { - forge-enabled = true; - git-path = getExe config.hm.programs.git.package; - }; + magit = { + forge-enabled = true; + git-path = getExe config.hm.programs.git.package; + }; - git.openRepositoryInParentFolders = "always"; + git.openRepositoryInParentFolders = "always"; - github = { - branchProtection = true; - gitProtocol = "ssh"; - }; + github = { + branchProtection = true; + gitProtocol = "ssh"; + }; - terraform = { - languageServer.path = getExe' pkgs.terraform-ls "terraform-ls"; - languageServer.terraform.path = getExe pkgs.opentofu; - }; + terraform = { + languageServer.path = getExe' pkgs.terraform-ls "terraform-ls"; + languageServer.terraform.path = getExe pkgs.opentofu; + }; - haskell = { - formattingProvider = "ormolu"; - serverExecutablePath = getExe' pkgs.haskell-language-server "haskell-language-server"; - }; + haskell = { + formattingProvider = "ormolu"; + serverExecutablePath = getExe' pkgs.haskell-language-server "haskell-language-server"; + }; - nix = { - enableLanguageServer = true; - serverPath = getExe pkgs.nil; - }; + nix = { + enableLanguageServer = true; + serverPath = getExe pkgs.nil; + }; - python = with pkgs.python311Packages; { - experiments.optOutFrom = ["All"]; - pipenvPath = getExe' pkgs.pipenv "pipenv"; - poetryPath = getExe' pkgs.poetry "poetry"; - formatting = { - provider = "black"; - autopep8Path = getExe' autopep8 "autopep8"; - blackPath = getExe' black "black"; - yapfPath = getExe' yapf "yapf"; - }; - linting = { - enabled = true; - banditPath = getExe' bandit "bandit"; - flake8Path = getExe' flake8 "flake8"; - mypyPath = getExe' mypy "mypy"; - pycodestylePath = getExe' pycodestyle "pycodestyle"; - pydocstylePath = getExe' pydocstyle "pydocstyle"; - pylamaPath = getExe' pylama "pylama"; - pylintPath = getExe' pylint "pylint"; - }; - testing = { - pytestPath = getExe' pytest "pytest"; + python = with pkgs.python311Packages; { + experiments.optOutFrom = [ "All" ]; + pipenvPath = getExe' pkgs.pipenv "pipenv"; + poetryPath = getExe' pkgs.poetry "poetry"; + formatting = { + provider = "black"; + autopep8Path = getExe' autopep8 "autopep8"; + blackPath = getExe' black "black"; + yapfPath = getExe' yapf "yapf"; + }; + linting = { + enabled = true; + banditPath = getExe' bandit "bandit"; + flake8Path = getExe' flake8 "flake8"; + mypyPath = getExe' mypy "mypy"; + pycodestylePath = getExe' pycodestyle "pycodestyle"; + pydocstylePath = getExe' pydocstyle "pydocstyle"; + pylamaPath = getExe' pylama "pylama"; + pylintPath = getExe' pylint "pylint"; + }; + testing = { + pytestPath = getExe' pytest "pytest"; + }; }; - }; - rust-client = { - disableRustup = true; - rustupPath = getExe' pkgs.rustup "rustup"; - rustfmt_path = getExe pkgs.rustfmt; - }; + rust-client = { + disableRustup = true; + rustupPath = getExe' pkgs.rustup "rustup"; + rustfmt_path = getExe pkgs.rustfmt; + }; - vim = mkIf cfg.vim.enable { - easymotion = true; + vim = mkIf cfg.vim.enable { + easymotion = true; - leader = " "; + leader = " "; - useSystemClipboard = true; - }; + useSystemClipboard = true; + }; - zig.zls = { - checkForUpdate = false; - path = getExe' pkgs.zls "zls"; - }; + zig.zls = { + checkForUpdate = false; + path = getExe' pkgs.zls "zls"; + }; - redhat.telemetry.enabled = false; + redhat.telemetry.enabled = false; + }; }; - }; }; - nixpkgs.overlays = [inputs.vscode-extensions.overlays.default]; + nixpkgs.overlays = [ inputs.vscode-extensions.overlays.default ]; }; } diff --git a/modules/common/wget.nix b/modules/common/wget.nix index 1cd8eae..0e8ee64 100644 --- a/modules/common/wget.nix +++ b/modules/common/wget.nix @@ -4,9 +4,11 @@ pkgs, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.wget; -in { +in +{ options.nixfiles.modules.wget.enable = mkEnableOption "wget"; config = mkIf cfg.enable { @@ -30,6 +32,6 @@ in { ''; }; - environment.systemPackages = with pkgs; [wget]; + environment.systemPackages = with pkgs; [ wget ]; }; } diff --git a/modules/common/zathura.nix b/modules/common/zathura.nix index b13d2a6..bc92258 100644 --- a/modules/common/zathura.nix +++ b/modules/common/zathura.nix @@ -1,13 +1,10 @@ -{ - config, - lib, - ... -}: -with lib; let +{ config, lib, ... }: +with lib; +let cfg = config.nixfiles.modules.zathura; -in { - options.nixfiles.modules.zathura.enable = - mkEnableOption "Zathura PDF reader"; +in +{ + options.nixfiles.modules.zathura.enable = mkEnableOption "Zathura PDF reader"; config = mkIf cfg.enable { hm.programs.zathura = { |