From 67b82386d8ad8ae3eea5083bd22809f6192d92a8 Mon Sep 17 00:00:00 2001 From: Azat Bahawi Date: Thu, 23 Nov 2023 04:20:34 +0300 Subject: 2023-11-23 --- flake.lock | 54 +++--- modules/common/bat.nix | 36 ++-- modules/common/common/shell/default.nix | 266 ++++++++++++++--------------- modules/common/common/shell/functions.bash | 18 +- modules/common/emacs/default.nix | 48 ++++-- modules/common/git.nix | 16 +- modules/common/mpv.nix | 252 +++++++++++++-------------- modules/common/nmap.nix | 16 +- modules/common/profiles/dev/containers.nix | 97 +++++------ modules/darwin/common/nix.nix | 2 - modules/nixos/common/nix.nix | 6 +- modules/nixos/docker.nix | 9 +- modules/nixos/mpv.nix | 160 ++++++++--------- modules/nixos/podman.nix | 54 +++--- overlay.nix | 4 +- 15 files changed, 492 insertions(+), 546 deletions(-) diff --git a/flake.lock b/flake.lock index 578e1fd..b306f68 100644 --- a/flake.lock +++ b/flake.lock @@ -266,11 +266,11 @@ ] }, "locked": { - "lastModified": 1700118404, - "narHash": "sha256-XkqpZpVoy1FV7UbiLkP+fQxxv/6KnwLYkFEHgE8z2IQ=", + "lastModified": 1700553346, + "narHash": "sha256-kW7uWsCv/lxuA824Ng6EYD9hlVYRyjuFn0xBbYltAeQ=", "owner": "nix-community", "repo": "home-manager", - "rev": "c1a033122df8a3c74fda3780c83a104a7d60873c", + "rev": "1aabb0a31b25ad83cfaa37c3fe29053417cd9a0f", "type": "github" }, "original": { @@ -309,11 +309,11 @@ ] }, "locked": { - "lastModified": 1700183996, - "narHash": "sha256-Xsl9ycyzeEDMeGKw3hfNhPX/yffpGJ1VQNqpChU6qh4=", + "lastModified": 1700529763, + "narHash": "sha256-O3BcD/xmO1BPP87wuntpBiADOH1QEbSS3/A//2HrN74=", "owner": "Infinidoge", "repo": "nix-minecraft", - "rev": "dd3ca2f4efdde2940f3f15c61bf4f1c09c3d73d5", + "rev": "6e99ae61a7e8271343ab5bad736070cd098aca2b", "type": "github" }, "original": { @@ -336,11 +336,11 @@ ] }, "locked": { - "lastModified": 1700183987, - "narHash": "sha256-lea3Wog1Lmwj8HQT9znmB3LrYErJkTMJm79AcXRdc4Q=", + "lastModified": 1700616109, + "narHash": "sha256-RtcYmcqzS1sWAw4q85YiOxEsPL4yo0EhGJIUatExh1A=", "owner": "nix-community", "repo": "nix-vscode-extensions", - "rev": "4fd6ede6a7f997bab3210856335d7d34fbb70011", + "rev": "744feda10f39afb587354bb98d04415662b57236", "type": "github" }, "original": { @@ -352,11 +352,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1699997707, - "narHash": "sha256-ugb+1TGoOqqiy3axyEZpfF6T4DQUGjfWZ3Htry1EfvI=", + "lastModified": 1700559156, + "narHash": "sha256-gL4epO/qf+wo30JjC3g+b5Bs8UrpxzkhNBBsUYxpw2g=", "owner": "NixOS", "repo": "nixos-hardware", - "rev": "5689f3ebf899f644a1aabe8774d4f37eb2f6c2f9", + "rev": "c3abafb01cd7045dba522af29b625bd1e170c2fb", "type": "github" }, "original": { @@ -368,11 +368,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1700108881, - "narHash": "sha256-+Lqybl8kj0+nD/IlAWPPG/RDTa47gff9nbei0u7BntE=", + "lastModified": 1700538105, + "narHash": "sha256-uZhOCmwv8VupEmPZm3erbr9XXmyg7K67Ul3+Rx2XMe0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "7414e9ee0b3e9903c24d3379f577a417f0aae5f1", + "rev": "51a01a7e5515b469886c120e38db325c96694c2f", "type": "github" }, "original": { @@ -384,11 +384,11 @@ }, "nixpkgs-master": { "locked": { - "lastModified": 1700232347, - "narHash": "sha256-QzG9ZKl29Pa+drx3Cbfwtpl1+9DvPL1X2cLPb3zLuy0=", + "lastModified": 1700692803, + "narHash": "sha256-ZmLkPHlPWhfRUqlHcX6oDICqiDOWga674DMjyv+k7fM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "139ccb05544a8460ec48bee1f9d84e17604d8a46", + "rev": "e4baad1ea299fc9488bc10d0b506389b9ed7c3f2", "type": "github" }, "original": { @@ -400,11 +400,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1700200546, - "narHash": "sha256-KK9uSx+qaoyF8VZDq4pED72AW4qTTwkL1lm0AN3ibFA=", + "lastModified": 1700682076, + "narHash": "sha256-+v5Q0qDioOXNuih+mmiwpyw8vdFy6WG13tzozG5TWxc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2af91613c61e71b278ee156099f9390447490e43", + "rev": "ee5ddacfab29812b32b5ea8c1dacdadfdf264475", "type": "github" }, "original": { @@ -428,11 +428,11 @@ ] }, "locked": { - "lastModified": 1700219833, - "narHash": "sha256-AkLpEg7nj0KUPb4pl7XIX1TbwePgC03hiBpMANlgBY0=", + "lastModified": 1700659845, + "narHash": "sha256-nU3fHWd/YKPtnJ+PVqtooVNlFtkSQIfrsq14wyufUXA=", "owner": "nix-community", "repo": "nixvim", - "rev": "1b44fe37a1c05bd00d9c727c1756461b9f1a967b", + "rev": "796e7391cec5134fd36951d275e7a0809e2107c8", "type": "github" }, "original": { @@ -478,11 +478,11 @@ }, "nur": { "locked": { - "lastModified": 1700232428, - "narHash": "sha256-2rik7MsvQGHc31RByhEzSEvdBCWqgsIOyB2VVKonKPg=", + "lastModified": 1700692941, + "narHash": "sha256-kthn0TMnP/EmfO4ujKYwXdzzFXqKmf3jdzQt7lRONaA=", "owner": "nix-community", "repo": "NUR", - "rev": "2347935c4aa0262ff3c2854e628c412228070fad", + "rev": "9e74bf0dc3167149e484519440359a347c5b68f4", "type": "github" }, "original": { diff --git a/modules/common/bat.nix b/modules/common/bat.nix index 7f78a59..d95f709 100644 --- a/modules/common/bat.nix +++ b/modules/common/bat.nix @@ -6,32 +6,22 @@ with lib; let cfg = config.nixfiles.modules.bat; in { - options.nixfiles.modules.bat.enable = - mkEnableOption "bat, an alternative to cat"; + options.nixfiles.modules.bat.enable = mkEnableOption "bat, an alternative to cat"; config = mkIf cfg.enable { - hm.programs = { - bat = { - enable = true; - config = { - style = "plain"; - tabs = "4"; - theme = "base16"; - wrap = "never"; - }; - }; - - bash = { - shellAliases = { - baj = "bat --language=json --tabs 2"; - bay = "bat --language=yaml --tabs 2"; - bas = "bat --language=syslog"; - }; + nixfiles.modules.common.shell.aliases = { + baj = "bat --language=json --tabs 2"; + bay = "bat --language=yaml --tabs 2"; + bas = "bat --language=syslog"; + }; - initExtra = mkAfter '' - _complete_alias bay _bat bat - _complete_alias baj _bat bat - ''; + hm.programs.bat = { + enable = true; + config = { + style = "plain"; + tabs = "4"; + theme = "base16"; + wrap = "never"; }; }; }; diff --git a/modules/common/common/shell/default.nix b/modules/common/common/shell/default.nix index b05b279..b50459d 100644 --- a/modules/common/common/shell/default.nix +++ b/modules/common/common/shell/default.nix @@ -1,150 +1,148 @@ { + config, lib, pkgs, - pkgsStable, this, ... }: -with lib; { - hm = { - programs = { - bash = { - enable = true; - - shellOptions = [ - "autocd" - "cdspell" - "checkjobs" - "checkwinsize" - "dirspell" - "extglob" - "globstar" - "histappend" - "histreedit" - "histverify" - ]; - - profileExtra = '' - export _PROFILE_SOURCED=1 - ''; - - initExtra = '' - set -o notify - - # 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 - - ${readFile ./functions.bash} - - # https://github.com/garabik/grc?tab=readme-ov-file#bash - GRC_ALIASES=true - source ${pkgs.grc}/etc/profile.d/grc.sh +with lib; let + cfg = config.nixfiles.modules.common.shell; +in { + options.nixfiles.modules.common.shell.aliases = mkOption { + description = "An attribute set of shell aliases."; + type = with types; attrsOf str; + default = {}; + }; - # https://github.com/akermu/emacs-libvterm?tab=readme-ov-file#shell-side-configuration - vterm_printf() { - if [ -n "$TMUX" ] && ([ "''${TERM%%-*}" = "tmux" ] || [ "''${TERM%%-*}" = "screen" ]); then - printf "\ePtmux;\e\e]%s\007\e\\" "$1" - elif [ "''${TERM%%-*}" = "screen" ]; then - printf "\eP\e]%s\007\e\\" "$1" - else - printf "\e]%s\e\\" "$1" + config = { + hm = { + 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 - } - - # This makes sure we always source these tweaks for both interactive - # and login sessions. - if [ -z "$_PROFILE_SOURCED" ] && [ -f "$HOME/.profile" ]; then - source "$HOME/.profile" - fi - ''; - - shellAliases = - listToAttrs - (map - ({ - name, - value, - }: - nameValuePair name (with pkgs; let - pkg = - if this.isHeadful - then - # FIXME Update this to 9.3 when patches[1] become available - # - # [1]: https://github.com/jarun/advcpmv - (pkgsStable.coreutils.overrideAttrs (_: _: { - patches = [ - (fetchpatch { - url = "https://raw.githubusercontent.com/jarun/advcpmv/ea268d870b475edd5960dcd55d5378abc9705958/advcpmv-0.9-9.1.patch"; - hash = "sha256-d+SRT/R4xmfHLAdOr7m4R3WFiW64P5ZH6iqDvErYCyg="; - }) - ]; - })) - else coreutils; - in "${pkg}/bin/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"); - historyControl = ["erasedups" "ignoredups" "ignorespace"]; + source "${./functions.bash}" + + 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 + ''; + + shellOptions = [ + "autocd" + "cdspell" + "checkjobs" + "checkwinsize" + "dirspell" + "extglob" + "globstar" + "histappend" + "histreedit" + "histverify" + ]; + + historyControl = [ + "erasedups" + "ignoredups" + "ignorespace" + ]; + + 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.3.patch"; + hash = "sha256-I25F7uHESUsMDZFYTv8/56eR8QwelIPpABRXTgvszQI="; + }) + ]; + })) + 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")) + // cfg.aliases; + }; + + command-not-found.enable = false; + + dircolors.enable = true; }; - command-not-found.enable = false; - - dircolors.enable = true; + home.packages = with pkgs; [grc]; }; - home.packages = with pkgs; [grc]; - }; - - environment = { - etc."grc.conf".source = "${pkgs.grc}/etc/grc.conf"; + environment = { + etc."grc.conf".source = "${pkgs.grc}/etc/grc.conf"; - systemPackages = with pkgs; [ - bash-completion - bc - gawk - hr - moreutils - pv - ]; + systemPackages = with pkgs; [ + bc + gawk + hr + moreutils + pv + ]; + }; }; } diff --git a/modules/common/common/shell/functions.bash b/modules/common/common/shell/functions.bash index c18104f..d947d0f 100644 --- a/modules/common/common/shell/functions.bash +++ b/modules/common/common/shell/functions.bash @@ -1,30 +1,16 @@ -_complete_alias() { - local alias_name=$1 - local base_function=$2 - local function_name=_alias_$alias_name - shift 2 - eval "$function_name() { - COMP_WORDS=( ${*@Q} \"\${COMP_WORDS[@]:1}\" ) - (( COMP_CWORD += $# - 1 )) - _completion_loader $1 - $base_function - }" - complete -F "$function_name" "$alias_name" -} - function where() { local s s="$(type -P "$1")" realpath "$s" } -_complete_alias where _complete complete +complete -F _command where function what() { local s s="$(where "$1")" printf "%s\n" "${s%/*/*}" } -_complete_alias what _complete complete +complete -F _command what function cat() { if (($# == 1)) && [[ -d $1 ]]; then diff --git a/modules/common/emacs/default.nix b/modules/common/emacs/default.nix index fe2618d..3db4393 100644 --- a/modules/common/emacs/default.nix +++ b/modules/common/emacs/default.nix @@ -222,23 +222,37 @@ in { }; }; - programs.emacs = { - enable = true; - package = - (pkgs.emacs29.override (finalAttrs: { - stdenv = with pkgs; - useMoldLinker - (withCFlags ["-O3"] - (impureUseNativeOptimizations finalAttrs.stdenv)); - })) - .overrideAttrs (_: final: { - configureFlags = - final.configureFlags - ++ [ - "--without-mailutils" - "--without-pop" - ]; - }); + programs = { + emacs = { + enable = true; + package = + (pkgs.emacs29.override (finalAttrs: { + stdenv = pkgs.useMoldLinker finalAttrs.stdenv; + })) + .overrideAttrs (_: final: { + configureFlags = + (final.configureFlags or []) + ++ [ + "--without-mailutils" + "--without-pop" + ]; + }); + }; + + bash.initExtra = mkAfter '' + # https://github.com/akermu/emacs-libvterm + if [[ "$INSIDE_EMACS" = vterm ]] && [[ -n "$EMACS_VTERM_PATH" ]] && [[ -f "$EMACS_VTERM_PATH/etc/emacs-vterm-bash.sh" ]]; then + source "$EMACS_VTERM_PATH/etc/emacs-vterm-bash.sh" + + message() { + vterm_cmd message "%s" "$*" + } + + find-file() { + vterm_cmd find-file "$(realpath "''${@:-.}")" + } + fi + ''; }; }; }; diff --git a/modules/common/git.nix b/modules/common/git.nix index aa157ed..fbd7ec7 100644 --- a/modules/common/git.nix +++ b/modules/common/git.nix @@ -31,6 +31,11 @@ in { }; }; + nixfiles.modules.common.shell.aliases = { + gl = "glab"; + ht = "hut"; + }; + hm = { home.packages = with pkgs; [ git-extras @@ -149,17 +154,6 @@ in { enable = true; settings.git_protocol = "ssh"; }; - - bash = { - shellAliases = { - gl = "glab"; - ht = "hut"; - }; - initExtra = mkAfter '' - _complete_alias gl __start_glab glab - _complete_alias ht __start_hut hut - ''; - }; }; }; }; diff --git a/modules/common/mpv.nix b/modules/common/mpv.nix index 37fbe4c..596d163 100644 --- a/modules/common/mpv.nix +++ b/modules/common/mpv.nix @@ -10,143 +10,133 @@ in { options.nixfiles.modules.mpv.enable = mkEnableOption "mpv"; config = mkIf cfg.enable { - hm.programs = { - mpv = { - enable = true; - - package = with pkgs; - wrapMpv mpv-unwrapped { - scripts = with mpvScripts; [ - autoload - sponsorblock - ]; - }; - - bindings = { - "RIGHT" = "seek 10"; - "LEFT" = "seek -10"; - "UP" = "seek 60"; - "DOWN" = "seek -60"; - - "Shift+RIGHT" = "no-osd seek 1 exact"; - "Shift+LEFT" = "no-osd seek -1 exact"; - "Shift+UP" = "no-osd seek 5 exact"; - "Shift+DOWN" = "no-osd seek -5 exact"; - - "Alt+h" = "add sub-delay +1"; - "Alt+l" = "add sub-delay -1"; - - "Alt+k" = "add sub-scale +0.1"; - "Alt+j" = "add sub-scale -0.1"; - - "B" = ''cycle-values background "#000000" "#ffffff"''; + hm.programs.mpv = { + enable = true; + + package = with pkgs; + wrapMpv mpv-unwrapped { + scripts = with mpvScripts; [ + autoload + sponsorblock + ]; }; - profiles = { - "protocol.http".force-window = "immediate"; - "protocol.https".profile = "protocol.http"; - - "extension.gif" = { - cache = false; - loop-file = true; - }; - "extension.png" = { - profile = "extension.gif"; - video-aspect-override = 0; - }; - "extension.jpeg".profile = "extension.png"; - "extension.jpg".profile = "extension.png"; - }; + bindings = { + "RIGHT" = "seek 10"; + "LEFT" = "seek -10"; + "UP" = "seek 60"; + "DOWN" = "seek -60"; - 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=''; - }; + "Shift+RIGHT" = "no-osd seek 1 exact"; + "Shift+LEFT" = "no-osd seek -1 exact"; + "Shift+UP" = "no-osd seek 5 exact"; + "Shift+DOWN" = "no-osd seek -5 exact"; + + "Alt+h" = "add sub-delay +1"; + "Alt+l" = "add sub-delay -1"; + + "Alt+k" = "add sub-scale +0.1"; + "Alt+j" = "add sub-scale -0.1"; + + "B" = ''cycle-values background "#000000" "#ffffff"''; }; - bash = { - shellAliases.cam = "mpv av://v4l2:/dev/video0"; + profiles = { + "protocol.http".force-window = "immediate"; + "protocol.https".profile = "protocol.http"; + + "extension.gif" = { + cache = false; + loop-file = true; + }; + "extension.png" = { + profile = "extension.gif"; + video-aspect-override = 0; + }; + "extension.jpeg".profile = "extension.png"; + "extension.jpg".profile = "extension.png"; + }; - initExtra = mkAfter '' - _complete_alias cam _mpv mpv - ''; + 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 ba06af3..6c6192c 100644 --- a/modules/common/nmap.nix +++ b/modules/common/nmap.nix @@ -11,6 +11,11 @@ in { options.nixfiles.modules.nmap.enable = mkEnableOption "Nmap"; config = mkIf cfg.enable { + nixfiles.modules.common.shell.aliases = { + nmap-vulners = "nmap -sV --script=vulners/vulners.nse"; + nmap-vulscan = "nmap -sV --script=vulscan/vulscan.nse"; + }; + hm = { home = { file = { @@ -25,17 +30,6 @@ in { ''; }; - programs.bash = { - shellAliases = { - nmap-vulners = "nmap -sV --script=vulners/vulners.nse"; - nmap-vulscan = "nmap -sV --script=vulscan/vulscan.nse"; - }; - initExtra = mkAfter '' - _complete_alias nmap-vulners _nmap nmap - _complete_alias nmap-vulscan _nmap nmap - ''; - }; - systemd.user = { services.update-nmap-vulscan-lists = { Service = { diff --git a/modules/common/profiles/dev/containers.nix b/modules/common/profiles/dev/containers.nix index 6e9346a..027c685 100644 --- a/modules/common/profiles/dev/containers.nix +++ b/modules/common/profiles/dev/containers.nix @@ -14,63 +14,52 @@ in { }; config = mkIf cfg.enable { - hm = { - home = { - sessionVariables = { - MINIKUBE_IN_STYLE = "false"; - WERF_DEV = "true"; - WERF_INSECURE_REGISTRY = "true"; - WERF_LOG_DEBUG = "true"; - WERF_LOG_PRETTY = "false"; - WERF_LOG_VERBOSE = "true"; - WERF_SYNCHRONIZATION = ":local"; - WERF_TELEMETRY = "false"; - }; + nixfiles.modules.common.shell.aliases = { + b = "buildah"; + h = "helm"; + k = "kubectl"; + kns = "kubens"; + ktx = "kubectx"; + }; - packages = with pkgs; [ - argocd - chart-testing - clusterctl - cmctl - datree - istioctl - k9s - kubeconform - kubectl - kubectl-doctor - kubectl-images - kubectl-tree - kubectx - kubelogin-oidc - kubent - kubernetes-helm - kubeseal - kubespy - minikube - skaffold - skopeo - stern - telepresence2 - werf - ]; + hm.home = { + sessionVariables = { + MINIKUBE_IN_STYLE = "false"; + WERF_DEV = "true"; + WERF_INSECURE_REGISTRY = "true"; + WERF_LOG_DEBUG = "true"; + WERF_LOG_PRETTY = "false"; + WERF_LOG_VERBOSE = "true"; + WERF_SYNCHRONIZATION = ":local"; + WERF_TELEMETRY = "false"; }; - programs.bash = { - shellAliases = { - b = "buildah"; - h = "helm"; - k = "kubectl"; - kns = "kubens"; - ktx = "kubectx"; - }; - initExtra = mkAfter '' - _complete_alias b _buildah buildah - _complete_alias h __start_helm helm - _complete_alias k __start_kubectl kubectl - _complete_alias kns _kube_namespaces kubens - _complete_alias ktx _kube_contexts kubectx - ''; - }; + packages = with pkgs; [ + argocd + chart-testing + clusterctl + cmctl + datree + istioctl + k9s + kubeconform + kubectl + kubectl-doctor + kubectl-images + kubectl-tree + kubectx + kubelogin-oidc + kubent + kubernetes-helm + kubeseal + kubespy + minikube + skaffold + skopeo + stern + telepresence2 + werf + ]; }; }; } diff --git a/modules/darwin/common/nix.nix b/modules/darwin/common/nix.nix index 0d216aa..10aeb03 100644 --- a/modules/darwin/common/nix.nix +++ b/modules/darwin/common/nix.nix @@ -11,8 +11,6 @@ with lib; { settings.extra-platforms = optionalString (this.system == "aarch64-darwin") '' x86_64-darwin aarch64-darwin ''; - - settings.trusted-users = ["@admin"]; }; services.nix-daemon.enable = true; diff --git a/modules/nixos/common/nix.nix b/modules/nixos/common/nix.nix index 0caf265..e21cc5c 100644 --- a/modules/nixos/common/nix.nix +++ b/modules/nixos/common/nix.nix @@ -2,6 +2,7 @@ config, inputs, lib, + this, ... }: with lib; let @@ -14,7 +15,10 @@ in { }; config = { - nix.settings.trusted-users = ["@wheel"]; + nix = mkIf this.isHeadless { + daemonCPUSchedPolicy = "idle"; + daemonIOSchedClass = "idle"; + }; nixpkgs.config.allowUnfreePredicate = p: elem (getName p) cfg.allowedUnfreePackages; diff --git a/modules/nixos/docker.nix b/modules/nixos/docker.nix index 31c0dda..3b38ff1 100644 --- a/modules/nixos/docker.nix +++ b/modules/nixos/docker.nix @@ -18,6 +18,8 @@ in { } ]; + nixfiles.modules.common.shell.aliases.d = "docker"; + secrets.containers-auth = { file = "${inputs.self}/secrets/containers-auth"; path = "${config.my.home}/.docker/config.json"; @@ -30,12 +32,5 @@ in { environment.systemPackages = with pkgs; [docker-compose]; my.extraGroups = ["docker"]; - - hm.programs.bash = { - shellAliases.d = "docker"; - initExtra = mkAfter '' - _complete_alias d _docker docker - ''; - }; }; } diff --git a/modules/nixos/mpv.nix b/modules/nixos/mpv.nix index efe1729..a2b73fa 100644 --- a/modules/nixos/mpv.nix +++ b/modules/nixos/mpv.nix @@ -7,83 +7,87 @@ with lib; let cfg = config.nixfiles.modules.mpv; in { config = mkIf cfg.enable { - nixfiles.modules.common.xdg.defaultApplications.mpv = let - audio = [ - "audio/aac" - "audio/ac3" - "audio/basic" - "audio/flac" - "audio/midi" - "audio/mp4" - "audio/mpeg" - "audio/ogg" - "audio/opus" - "audio/vnd.dts" - "audio/vnd.dts.hd" - "audio/webm" - "audio/x-adpcm" - "audio/x-aifc" - "audio/x-aiff" - "audio/x-ape" - "audio/x-flac+ogg" - "audio/x-m4b" - "audio/x-m4r" - "audio/x-matroska" - "audio/x-mpegurl" - "audio/x-musepack" - "audio/x-opus+ogg" - "audio/x-speex" - "audio/x-speex+ogg" - "audio/x-vorbis+ogg" - "audio/x-wav" - "audio/x-wavpack" - "x-content/audio-cdda" - "x-content/audio-dvd" - ]; - video = [ - "video/3gpp" - "video/3gpp2" - "video/mkv" - "video/mp2t" - "video/mp4" - "video/mpeg" - "video/ogg" - "video/quicktime" - "video/vnd.mpegurl" - "video/vnd.radgamettools.bink" - "video/vnd.radgamettools.smacker" - "video/wavelet" - "video/webm" - "video/x-matroska" - "video/x-matroska-3d" - "video/x-mjpeg" - "video/x-msvideo" - "video/x-ogm+ogg" - "video/x-theora+ogg" - "x-content/video-bluray" - "x-content/video-dvd" - "x-content/video-hddvd" - "x-content/video-svcd" - "x-content/video-vcd" - ]; - image = [ - "image/avif" - "image/bmp" - "image/gif" - "image/jp2" - "image/jpeg" - "image/jpg" - "image/jpm" - "image/jpx" - "image/jxl" - "image/png" - "image/tiff" - "image/vnd.microsoft.icon" - "image/webp" - "image/webp" - "image/x-tga" - ]; - in - audio ++ video ++ image; + nixfiles.modules.common = { + shell.aliases.cam = "mpv av://v4l2:/dev/video0"; + + xdg.defaultApplications.mpv = let + audio = [ + "audio/aac" + "audio/ac3" + "audio/basic" + "audio/flac" + "audio/midi" + "audio/mp4" + "audio/mpeg" + "audio/ogg" + "audio/opus" + "audio/vnd.dts" + "audio/vnd.dts.hd" + "audio/webm" + "audio/x-adpcm" + "audio/x-aifc" + "audio/x-aiff" + "audio/x-ape" + "audio/x-flac+ogg" + "audio/x-m4b" + "audio/x-m4r" + "audio/x-matroska" + "audio/x-mpegurl" + "audio/x-musepack" + "audio/x-opus+ogg" + "audio/x-speex" + "audio/x-speex+ogg" + "audio/x-vorbis+ogg" + "audio/x-wav" + "audio/x-wavpack" + "x-content/audio-cdda" + "x-content/audio-dvd" + ]; + video = [ + "video/3gpp" + "video/3gpp2" + "video/mkv" + "video/mp2t" + "video/mp4" + "video/mpeg" + "video/ogg" + "video/quicktime" + "video/vnd.mpegurl" + "video/vnd.radgamettools.bink" + "video/vnd.radgamettools.smacker" + "video/wavelet" + "video/webm" + "video/x-matroska" + "video/x-matroska-3d" + "video/x-mjpeg" + "video/x-msvideo" + "video/x-ogm+ogg" + "video/x-theora+ogg" + "x-content/video-bluray" + "x-content/video-dvd" + "x-content/video-hddvd" + "x-content/video-svcd" + "x-content/video-vcd" + ]; + image = [ + "image/avif" + "image/bmp" + "image/gif" + "image/jp2" + "image/jpeg" + "image/jpg" + "image/jpm" + "image/jpx" + "image/jxl" + "image/png" + "image/tiff" + "image/vnd.microsoft.icon" + "image/webp" + "image/webp" + "image/x-tga" + ]; + in + audio ++ video ++ image; + }; }; } diff --git a/modules/nixos/podman.nix b/modules/nixos/podman.nix index 0f6db48..f6ee6bf 100644 --- a/modules/nixos/podman.nix +++ b/modules/nixos/podman.nix @@ -18,6 +18,8 @@ in { } ]; + nixfiles.modules.common.shell.aliases.p = "podman"; + secrets.containers-auth = { file = "${inputs.self}/secrets/containers-auth"; path = "${config.dirs.config}/containers/auth.json"; @@ -31,38 +33,26 @@ in { my.extraGroups = ["podman"]; - hm = { - xdg.configFile = { - # This removes a really annoying registry search. 100% of the time I - # would need to look up stuff from the Docker and not Quay! - "containers/registries.conf".text = '' - [registries.search] - registries = ["docker.io"] - ''; - - # As for plain OverlayFS in Podman over ZFS[1]... I guess we are waiting - # for Podman to catch up now. - # - # [1]: https://github.com/openzfs/zfs/pull/14070#issuecomment-1309116666 - "containers/storage.conf".text = optionalString config.boot.zfs.enabled '' - [storage] - driver = "overlay" - - [storage.options] - mount_program = "${getExe' pkgs.fuse-overlayfs "fuse-overlayfs"}" - mountopt = "noatime,nodev,nosuid" - ''; - }; - - programs.bash = { - shellAliases = { - podman = "grc -es ${getExe' pkgs.podman "podman"}"; - p = "podman"; - }; - initExtra = mkAfter '' - _complete_alias p __start_podman podman - ''; - }; + hm.xdg.configFile = { + # This removes a really annoying registry search. 100% of the time I + # would need to look up stuff from the Docker and not Quay! + "containers/registries.conf".text = '' + [registries.search] + registries = ["docker.io"] + ''; + + # As for plain OverlayFS in Podman over ZFS[1]... I guess we are waiting + # for Podman to catch up now. + # + # [1]: https://github.com/openzfs/zfs/pull/14070#issuecomment-1309116666 + "containers/storage.conf".text = optionalString config.boot.zfs.enabled '' + [storage] + driver = "overlay" + + [storage.options] + mount_program = "${getExe' pkgs.fuse-overlayfs "fuse-overlayfs"}" + mountopt = "noatime,nodev,nosuid" + ''; }; }; } diff --git a/overlay.nix b/overlay.nix index 5314ab2..74e0746 100644 --- a/overlay.nix +++ b/overlay.nix @@ -51,7 +51,7 @@ final: prev: { prismlauncher-unwrapped = (prev.prismlauncher-unwrapped.override (finalAttrs: { - stdenv = final.useMoldLinker (final.impureUseNativeOptimizations finalAttrs.stdenv); + stdenv = final.useMoldLinker finalAttrs.stdenv; })) .overrideAttrs (_: super: { patches = @@ -63,7 +63,7 @@ final: prev: { telegram-desktop = (prev.telegram-desktop.override (finalAttrs: { - stdenv = final.useMoldLinker (final.impureUseNativeOptimizations finalAttrs.stdenv); + stdenv = final.useMoldLinker finalAttrs.stdenv; })) .overrideAttrs (_: super: { patches = -- cgit v1.2.3