diff --git a/home/common/general.nix b/home/common/general.nix index 40eb2c5..dc95ada 100644 --- a/home/common/general.nix +++ b/home/common/general.nix @@ -1,6 +1,6 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: { - imports = [ ./options.nix ]; + imports = [ ./options.nix ./zsh.nix ]; manual.json.enable = true; services.gpg-agent = { enable = true; @@ -10,30 +10,82 @@ }; programs = { + atuin = { + enable = true; + settings = { + update_check = false; + }; + }; + nnn = let pluginSrc = "${pkgs.nnn.src}/plugins"; in { + enable = true; + package = (pkgs.nnn.override ({ withNerdIcons = true; })).overrideAttrs (oldAttrs: { + # no need to add makeWrapper to nativeBuildInputs as home-manager does it already + postInstall = + let nnnArchiveRegex = "\\.(${lib.strings.concatStringsSep "|" [ + "7z" "a" "ace" "alz" "arc" "arj" "bz" "bz2" "cab" "cpio" "deb" "gz" "jar" "lha" "lz" "lzh" "lzma" "lzo" "rar" "rpm" "rz" "t7z" "tar" "tbz" "tbz2" "tgz" "tlz" "txz" "tZ" "tzo" "war" "xpi" "xz" "Z" "zip" + ]})$"; in with lib; with strings; '' + wrapProgram $out/bin/nnn \ + --set GUI 1 \ + --set NNN_OPENER ${escapeShellArg "${pluginSrc}/nuke"} \ + --set NNN_ARCHIVE ${escapeShellArg nnnArchiveRegex} \ + --add-flags ${ + # -a: auto create fifo file + # -c: use NNN_OPENER + # -x: x server features + escapeShellArg "-a -c -x" + } + ''; + }); + extraPackages = with pkgs; [ + # utils + gnused mktemp fzf coreutils-full findutils xdg-utils git gnupg whois curl + file mediainfo unzip gnutar man rclone sshfs trash-cli + # drag & drop + xdragon + # xembed + tabbed + # for preview + exa bat + ffmpeg ffmpegthumbnailer nsxiv imagemagick + libarchive unzip gnutar atool + libreoffice poppler_utils fontpreview djvulibre + glow w3m + # for opening + p7zip unrar-wrapper zathura mpv odt2txt + ]; + plugins = { + src = pluginSrc; + mappings = { + p = "-preview-tui"; + P = "fzplug"; + D = "dragdrop"; + c = "-chksum"; + d = "-diffs"; + f = "fzopen"; + s = "suedit"; + x = "togglex"; + u = "umounttree"; + }; + }; + }; neomutt = { enable = true; sidebar.enable = true; vimKeys = true; }; home-manager.enable = true; + # i only use this as a login shell bash = { enable = true; }; - fish = { - enable = true; - interactiveShellInit = '' - ${pkgs.gnupg}/bin/gpg-connect-agent --quiet updatestartuptty /bye > /dev/null - ''; - shellInit = '' - set PATH ~/bin/:$PATH - ''; - shellAbbrs = { - }; - }; git = { enable = true; package = pkgs.gitAndTools.gitFull; delta.enable = true; + extraConfig = { + core.askPass = ""; + credential.helper = "${pkgs.gitAndTools.gitFull}/bin/git-credential-libsecret"; + }; }; ssh = { enable = true; diff --git a/home/common/gui.nix b/home/common/gui.nix index e301ea3..fe6e3f0 100644 --- a/home/common/gui.nix +++ b/home/common/gui.nix @@ -1,5 +1,6 @@ { config, pkgs, lib, ... }: { + imports = [ ./terminal.nix ]; home.sessionVariables."ALSOFT_CONF" = "${config.xdg.configHome}/.config/alsoft.conf"; xdg.configFile."alsoft.conf".text = '' [general] @@ -71,6 +72,8 @@ # "*fading" = 0; # "*fadeColor" = "#6b4d52"; }; + # home.file.".Xdefaults".source = /. + "/${config.home.homeDirectory}/.Xresources"; + home.file.".Xdefaults".source = config.home.file."${config.home.homeDirectory}/.Xresources".source; services.gammastep.enable = true; services.kdeconnect.enable = true; fonts.fontconfig.enable = true; diff --git a/home/common/i3-sway.nix b/home/common/i3-sway.nix index 12be2fd..dddf2d2 100644 --- a/home/common/i3-sway.nix +++ b/home/common/i3-sway.nix @@ -97,7 +97,6 @@ commonConfig = { inner = 10; }; menu = "${pkgs.bemenu}/bin/bemenu-run --no-overlap --prompt '>' --tb '#24101a' --tf '#ebbe5f' --fb '#24101a' --nb '#24101a70' --ab '#24101a70' --nf '#ebdadd' --af '#ebdadd' --hb '#394893' --hf '#e66e6e' --list 30 --prefix '*' --scrollbar autohide --fn 'Noto Sans Mono' --line-height 23 --sb '#394893' --sf '#ebdadd' --scb '#6b4d52' --scf '#e66e6e'"; - terminal = if config.useAlacritty then "${pkgs.alacritty}/bin/alacritty" else "${pkgs.urxvt}/bin/urxvt"; window.hideEdgeBorders = "smart"; workspaceAutoBackAndForth = true; }; @@ -130,6 +129,10 @@ in SDL_IM_MODULE = "fcitx"; XIM_SERVERS = "fcitx"; INPUT_METHOD = "fcitx"; + SUDO_ASKPASS = pkgs.writeScript "sudo-askpass" '' + #! ${pkgs.bash}/bin/bash + ${pkgs.libsecret}/bin/secret-tool lookup root password + ''; }; xdg.configFile."xdg-desktop-portal-wlr/config".source = (pkgs.formats.ini {}).generate "xdg-desktop-portal-wlr.ini" { screencast = { @@ -149,53 +152,10 @@ in defaultTimeout = 7500; font = "Noto Sans Mono 12"; }; - programs.alacritty = { - enable = lib.mkDefault config.useAlacritty; - settings = { - window.opacity = 0.75; - font.normal.family = "Noto Sans Mono"; - font.size = 16; - colors.primary.background = "#24101a"; - colors.primary.foreground = "#ebdadd"; - colors.normal = { - black = "#523b3f"; - red = "#e66e6e"; - green = "#8cbf73"; - yellow = "#ebbe5f"; - blue = "#5968b3"; - magenta = "#a64999"; - cyan = "#77c7c2"; - white = "#f0e4e6"; - }; - colors.bright = { - black = "#6b4d52"; - red = "#e66e6e"; - green = "#8cbf73"; - yellow = "#ebbe5f"; - blue = "#5968b3"; - magenta = "#a64999"; - cyan = "#77c7c2"; - white = "#f7f0f1"; - }; - }; - }; - # i use this instead of alacritty on old laptops - programs.urxvt = { - enable = lib.mkDefault (!config.useAlacritty); - keybindings = { - "Control-Alt-C" = "builtin-string:"; - "Control-Alt-V" = "builtin-string:"; - }; - extraConfig = { - depth = 32; - inheritPixmap = true; - }; - scroll.bar.enable = false; - fonts = [ "xft:Noto Sans Mono:pixelsize=16" "xft:Symbols Nerd Font Mono:pixelsize=16" ]; - }; xsession.windowManager.i3 = { config = let i3Config = { keybindings = genKeybindings options.xsession.windowManager.i3 {}; + terminal = config.terminalBinX; }; in i3Config // commonConfig // i3Config; }; home.file.".xinitrc".text = '' @@ -220,6 +180,7 @@ in wayland.windowManager.sway = { wrapperFeatures.gtk = true; config = let swayConfig = { + terminal = config.terminalBin; window.commands = [ { command = "floating enable; move workspace current"; criteria = { diff --git a/home/common/options.nix b/home/common/options.nix index a6895f2..f44d4f9 100644 --- a/home/common/options.nix +++ b/home/common/options.nix @@ -1,8 +1,52 @@ { lib, ... }: -{ - options.useAlacritty = lib.mkOption { - type = with lib.types; uniq bool; - description = "Use Alacritty"; - default = true; +with lib; { + options.terminals = mkOption { + type = with types; listOf str; + description = "terminal kinds (possible values are alacritty, urxvt, kitty, foot)"; + default = ["alacritty"]; + }; + options.terminalBin = mkOption { + type = types.str; + description = "Path to terminal binary (output)"; + }; + options.terminalBinX = mkOption { + type = types.str; + description = "Path to terminal binary for X server (output)"; + }; + options.colors = mkOption { + type = types.submodule { + options = { + base = mkOption { + type = with types; listOf str; + description = "16 theme colors"; + }; + foreground = mkOption { + type = types.str; + }; + background = mkOption { + type = types.str; + }; + # 0-1 + alpha = mkOption { + type = types.float; + description = "opacity (0.0-1.0)"; + }; + }; + }; + }; + options.termShell = mkOption { + type = types.submodule { + options = { + enable = mkOption { + type = types.bool; + default = false; + }; + path = mkOption { + type = types.str; + }; + }; + }; + default = {enable=false;}; + description = "Use a separate shell for gui terminal"; }; } diff --git a/home/common/terminal.nix b/home/common/terminal.nix new file mode 100644 index 0000000..544b18f --- /dev/null +++ b/home/common/terminal.nix @@ -0,0 +1,173 @@ +{ config, pkgs, lib, ... }: +let + supportTerminal = (term: builtins.elem term config.terminals); + getTerminalBin = (term: ({ + alacritty = "${pkgs.alacritty}/bin/alacritty"; + foot = "${pkgs.foot}/bin/footclient"; + kitty = "${pkgs.kitty}/bin/kitty"; + urxvt = "${pkgs.rxvt-unicode-emoji}/bin/urxvt"; + }).${term}); + color = builtins.elemAt config.colors.base; + hex = (x: if builtins.isFunction x then (y: "#" + (x y)) else ("#" + x)); + shell = lib.mkIf config.termShell.enable config.termShell.path; +in { + imports = [ ./options.nix ]; + terminalBin = getTerminalBin (builtins.head config.terminals); + terminalBinX = getTerminalBin (lib.lists.findFirst (term: term != "foot") null config.terminals); + colors = { + base = [ + "523b3f" + "e66e6e" + "8cbf73" + "ebbe5f" + "5968b3" + "a64999" + "77c7c2" + "f0e4e6" + "6b4d52" + "e66e6e" + "8cbf73" + "ebbe5f" + "5968b3" + "a64999" + "77c7c2" + "f7f0f1" + ]; + foreground = "ebdadd"; + background = "24101a"; + alpha = 0.75; + }; + programs.alacritty = { + enable = supportTerminal "alacritty"; + # https://github.com/alacritty/alacritty/blob/master/alacritty.yml + settings = { + window.opacity = config.colors.alpha; + font.normal.family = "Noto Sans Mono"; + font.size = 16; + shell.program = shell; + colors.primary.background = hex config.colors.background; + colors.primary.foreground = hex config.colors.foreground; + colors.normal = { + black = hex color 0; + red = hex color 1; + green = hex color 2; + yellow = hex color 3; + blue = hex color 4; + magenta = hex color 5; + cyan = hex color 6; + white = hex color 7; + }; + colors.bright = { + black = hex color 8; + red = hex color 9; + green = hex color 10; + yellow = hex color 11; + blue = hex color 12; + magenta = hex color 13; + cyan = hex color 14; + white = hex color 15; + }; + }; + }; + programs.urxvt = { + # default shell can't be changed... I can create a wrapper, but fuck that + enable = supportTerminal "urxvt"; + package = pkgs.rxvt-unicode-emoji; + keybindings = { + "Control-Alt-C" = "builtin-string:"; + "Control-Alt-V" = "builtin-string:"; + }; + extraConfig = { + depth = 32; + inheritPixmap = true; + }; + scroll.bar.enable = false; + fonts = [ "xft:Noto Sans Mono:size=16" "xft:Symbols Nerd Font Mono:size=16" ]; + }; + programs.foot = { + enable = supportTerminal "foot"; + server.enable = true; + # https://codeberg.org/dnkl/foot/src/branch/master/foot.ini + settings = { + main = { + font = "Noto Sans Mono:size=16,Noto Sans Mono CJK JP:size=16,Symbols Nerd Font Mono:size=16"; + dpi-aware = false; + notify = "${pkgs.libnotify}/bin/notify-send -a \${app-id} -i \${app-id} \${title} \${body}"; + inherit shell; + }; + url = { + launch = "${pkgs.xdg-utils}/bin/xdg-open \${url}"; + }; + colors = { + alpha = config.colors.alpha; + background = config.colors.background; + foreground = config.colors.foreground; + regular0 = color 0; + regular1 = color 1; + regular2 = color 2; + regular3 = color 3; + regular4 = color 4; + regular5 = color 5; + regular6 = color 6; + regular7 = color 7; + bright0 = color 8; + bright1 = color 9; + bright2 = color 10; + bright3 = color 11; + bright4 = color 12; + bright5 = color 13; + bright6 = color 14; + bright7 = color 15; + }; + }; + }; + programs.kitty = { + enable = supportTerminal "kitty"; + font.name = "Noto Sans Mono"; + font.size = 16; + settings = { + inherit shell; + symbol_map = "U+23FB-U+23FE,U+2665,U+26A1,U+2B58,U+E000-U+F8FF,U+F0000-U+FFFFF Symbols Nerd Font Mono"; + cursor = "none"; + open_url_with = "${pkgs.xdg-utils}/bin/xdg-open"; + focus_follows_mouse = true; + repaint_delay = 4; + foreground = hex config.colors.foreground; + background = hex config.colors.background; + background_opacity = builtins.toString config.colors.alpha; + color0 = hex color 0; + color1 = hex color 1; + color2 = hex color 2; + color3 = hex color 3; + color4 = hex color 4; + color5 = hex color 5; + color6 = hex color 6; + color7 = hex color 7; + color8 = hex color 8; + color9 = hex color 9; + color10 = hex color 10; + color11 = hex color 11; + color12 = hex color 12; + color13 = hex color 13; + color14 = hex color 14; + color15 = hex color 15; + allow_remote_control = "socket"; + listen_on = "unix:/tmp/kitty"; + enabled_layouts = "all"; + }; + }; + xdg.configFile."fontconfig/conf.d/10-kitty-fonts.conf".text = lib.mkIf ((supportTerminal "kitty") && (config.programs.kitty.font.name == "Noto Sans Mono")) '' + + + + + + Noto Sans Mono + + + 90 + + + + ''; +} diff --git a/home/common/zsh.nix b/home/common/zsh.nix new file mode 100644 index 0000000..a4eb384 --- /dev/null +++ b/home/common/zsh.nix @@ -0,0 +1,119 @@ +{ config, pkgs, lib, ... }: +{ + programs.zsh = { + enable = true; + # zsh-autosuggestions + enableAutosuggestions = true; + # zsh-syntax-highlighting + enableSyntaxHighlighting = true; + defaultKeymap = "viins"; + dotDir = ".config/zsh"; + history.ignoreDups = true; + history.path = "${config.xdg.dataHome}/zsh/zsh_history"; + shellAliases.s = "sudo -A"; + shellAliases.se = "sudo -AE"; + localVariables = { + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS = [ + # "os_icon" # os identifier + "dir" # current directory + "vcs" # git status + "prompt_char" # prompt symbol + ]; + POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS = [ + "status" # exit code of the last command + "command_execution_time" # duration of the last command + "background_jobs" # presence of background jobs + # "direnv" # direnv status (https://direnv.net/) + # "asdf" # asdf version manager (https://github.com/asdf-vm/asdf) + # "virtualenv" # python virtual environment (https://docs.python.org/3/library/venv.html) + # "anaconda" # conda environment (https://conda.io/) + # "pyenv" # python environment (https://github.com/pyenv/pyenv) + # "goenv" # go environment (https://github.com/syndbg/goenv) + # "nodenv" # node.js version from nodenv (https://github.com/nodenv/nodenv) + # "nvm" # node.js version from nvm (https://github.com/nvm-sh/nvm) + # "nodeenv" # node.js environment (https://github.com/ekalinin/nodeenv) + # "node_version" # node.js version + # "go_version" # go version (https://golang.org) + # "rust_version" # rustc version (https://www.rust-lang.org) + # "dotnet_version" # .NET version (https://dotnet.microsoft.com) + # "php_version" # php version (https://www.php.net/) + # "laravel_version" # laravel php framework version (https://laravel.com/) + # "java_version" # java version (https://www.java.com/) + # "package" # name@version from package.json (https://docs.npmjs.com/files/package.json) + # "rbenv" # ruby version from rbenv (https://github.com/rbenv/rbenv) + # "rvm" # ruby version from rvm (https://rvm.io) + # "fvm" # flutter version management (https://github.com/leoafarias/fvm) + # "luaenv" # lua version from luaenv (https://github.com/cehoffman/luaenv) + # "jenv" # java version from jenv (https://github.com/jenv/jenv) + # "plenv" # perl version from plenv (https://github.com/tokuhirom/plenv) + # "phpenv" # php version from phpenv (https://github.com/phpenv/phpenv) + # "scalaenv" # scala version from scalaenv (https://github.com/scalaenv/scalaenv) + # "haskell_stack" # haskell version from stack (https://haskellstack.org/) + # "kubecontext" # current kubernetes context (https://kubernetes.io/) + # "terraform" # terraform workspace (https://www.terraform.io) + # "terraform_version # terraform version (https://www.terraform.io) + # "aws" # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) + # "aws_eb_env" # aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) + # "azure" # azure account name (https://docs.microsoft.com/en-us/cli/azure) + # "gcloud" # google cloud cli account and project (https://cloud.google.com/) + # "google_app_cred" # google application credentials (https://cloud.google.com/docs/authentication/production) + # "toolbox" # toolbox name (https://github.com/containers/toolbox) + # "context" # user@hostname + # "nordvpn" # nordvpn connection status, linux only (https://nordvpn.com/) + # "ranger" # ranger shell (https://github.com/ranger/ranger) + "nnn" # nnn shell (https://github.com/jarun/nnn) + # "xplr" # xplr shell (https://github.com/sayanarijit/xplr) + "vim_shell" # vim shell indicator (:sh) + # "midnight_commander" # midnight commander shell (https://midnight-commander.org/) + "nix_shell" # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) + # "vi_mode" # vi mode (you don't need this if you've enabled prompt_char) + # "vpn_ip" # virtual private network indicator + # "load" # CPU load + # "disk_usage" # disk usage + # "ram" # free RAM + # "swap" # used swap + # "todo" # todo items (https://github.com/todotxt/todo.txt-cli) + # "timewarrior" # timewarrior tracking status (https://timewarrior.net/) + # "taskwarrior" # taskwarrior task count (https://taskwarrior.org/) + # "time" # current time + # "ip" # ip address and bandwidth usage for a specified network interface + # "public_ip" # public IP address + # "proxy" # system-wide http/https/ftp proxy + # "battery" # internal battery + # "wifi" # wifi speed + # "example" # example user-defined segment (see prompt_example function below) + ]; + POWERLEVEL9K_MODE = "nerdfont-complete"; + POWERLEVEL9K_ICON_PADDING = "none"; + POWERLEVEL9K_PROMPT_ADD_NEWLINE = "true"; + POWERLEVEL9K_TRANSIENT_PROMPT = "same-dir"; + POWERLEVEL9K_INSTANT_PROMPT = "verbose"; + POWERLEVEL9K_DIR_FOREGROUND = "254"; + POWERLEVEL9K_SHORTEN_STRATEGY = "truncate_to_unique"; + POWERLEVEL9K_DIR_ANCHOR_BOLD = "true"; + POWERLEVEL9K_SHORTEN_FOLDER_MARKER = "(.bzr|.citc|.git|.hg|.node-version|.python-version|.go-version|.ruby-version|.lua-version|.java-version|.perl-version|.php-version|.tool-version|.shorten_folder_marker|.svn|.terraform|CVS|Cargo.toml|composer.json|flake.nix|go.mod|package.json|stack.yaml)"; + # POWERLEVEL9K_PROMPT_CHAR_LEFT_LEFT_WHITESPACE = ""; + # POWERLEVEL9K_PROMPT_CHAR_LEFT_RIGHT_WHITESPACE = ""; + POWERLEVEL9K_STATUS_ERROR_FOREGROUND = "15"; + POWERLEVEL9K_STATUS_ERROR_SIGNAL_FOREGROUND = "15"; + POWERLEVEL9K_STATUS_ERROR_PIPE_FOREGROUND = "15"; + POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND = "0"; + POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND = "3"; + POWERLEVEL9K_NIX_SHELL_FOREGROUND = "15"; + SHELL = "zsh"; + }; + plugins = with pkgs; [ + { name = "zsh-vi-mode"; + src = zsh-vi-mode.src; } + { name = "fzf-tab"; + src = zsh-fzf-tab.src; } + { name = "nix-shell"; + src = zsh-nix-shell.src; } + { name = "powerlevel10k"; + src = zsh-powerlevel10k.src; + file = "powerlevel10k.zsh-theme"; } + { name = "you-should-use"; + src = zsh-you-should-use.src; } + ]; + }; +} diff --git a/home/hosts/nixmsi.nix b/home/hosts/nixmsi.nix index f4dba54..e50a767 100644 --- a/home/hosts/nixmsi.nix +++ b/home/hosts/nixmsi.nix @@ -11,6 +11,10 @@ home.stateVersion = "22.11"; home.username = "user"; home.homeDirectory = "/home/user"; + termShell = { + enable = true; + path = "${pkgs.zsh}/bin/zsh"; + }; xsession.windowManager.i3.enable = true; wayland.windowManager.sway.enable = true; nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ @@ -20,6 +24,7 @@ "steam-runtime" "steamcmd" ]; + terminals = ["kitty" "urxvt"]; home.packages = with pkgs; [ steam-run steam easyeffects diff --git a/system/hosts/nixmsi.nix b/system/hosts/nixmsi.nix index ee3892c..4d74484 100644 --- a/system/hosts/nixmsi.nix +++ b/system/hosts/nixmsi.nix @@ -1,6 +1,7 @@ { config, lib, pkgs, ... }: let - cryptroot = "/dev/disk/by-uuid/f4edc0df-b50b-42f6-94ed-1c8f88d6cdbb"; + cryptrootUuid = "f4edc0df-b50b-42f6-94ed-1c8f88d6cdbb"; + cryptroot = "/dev/disk/by-uuid/${cryptrootUuid}"; encPart = "/dev/disk/by-uuid/ce6ccdf0-7b6a-43ae-bfdf-10009a55041a"; efiPart = "/dev/disk/by-uuid/D77D-8CE0"; in { @@ -150,6 +151,19 @@ in { ### RANDOM PATCHES ### + # zsh + environment.pathsToLink = [ "/share/zsh" ]; + + # dedupe + + services.beesd = { + filesystems.cryptroot = { + spec = "UUID=${cryptrootUuid}"; + hashTableSizeMB = 128; + # extraOptions = [ ]; + }; + }; + # System76 scheduler (not actually a scheduler, just a renice daemon) for improved responsiveness services.dbus.packages = [ pkgs.system76-scheduler ];