diff --git a/.builds/cache-alacritty-fork.yml b/.builds/cache-alacritty-fork.yml new file mode 100644 index 00000000..e623b362 --- /dev/null +++ b/.builds/cache-alacritty-fork.yml @@ -0,0 +1,22 @@ +image: nixos/unstable + +packages: + - nixos.nixUnstable + - nixos.cachix + +environment: + NIX_CONFIG: "experimental-features = nix-command flakes" + +secrets: + - f2907d38-97b4-4e7d-9fb9-57b3fb0135af + +tasks: +- auth_cachix: | + cat ~/.cachix_token | cachix authtoken --stdin + cachix use misterio +- build: | + cd nix-config + # Build alacritty with ligatures + nix --log-format raw build .#packages.x86_64-linux.alacritty-ligatures +- cache: | + nix path-info nix-config/result/ -r | cachix push misterio diff --git a/flake.nix b/flake.nix index 367b695e..799e2365 100644 --- a/flake.nix +++ b/flake.nix @@ -170,6 +170,7 @@ in { packages.generated-gtk-themes = pkgs.callPackage ./pkgs/generated-gtk-themes { inherit nix-colors; }; + packages.alacritty-ligatures = pkgs.alacritty-ligatures; devShell = pkgs.mkShell { buildInputs = with pkgs; [ nixUnstable nixfmt rnix-lsp hm ]; diff --git a/overlays/default.nix b/overlays/default.nix index 8079c955..3ed09ebd 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -21,13 +21,6 @@ final: prev: { }; }; - # Link kitty to xterm (to fix crappy drun behaviour) - kitty = prev.kitty.overrideAttrs (oldAttrs: rec { - postInstall = (oldAttrs.postInstall or " ") + '' - ln -s $out/bin/kitty $out/bin/xterm - ''; - }); - # Update openrgb openrgb = prev.openrgb.overrideAttrs (oldAttrs: rec { buildInputs = (oldAttrs.buildInputs or [ ]) ++ [ prev.mbedtls ]; diff --git a/pkgs/alacritty-ligatures/default.nix b/pkgs/alacritty-ligatures/default.nix new file mode 100644 index 00000000..96bfcda8 --- /dev/null +++ b/pkgs/alacritty-ligatures/default.nix @@ -0,0 +1,116 @@ +{ stdenv +, lib +, fetchFromGitHub +, fetchpatch +, rustPlatform + +, cmake +, gzip +, installShellFiles +, makeWrapper +, ncurses +, pkg-config +, python3 + +, expat +, fontconfig +, freetype +, libGL +, libX11 +, libXcursor +, libXi +, libXrandr +, libXxf86vm +, libxcb +, libxkbcommon +, wayland +, xdg-utils +, zlib +}: +let + rpathLibs = [ + expat + fontconfig + freetype + libGL + libX11 + libXcursor + libXi + libXrandr + libXxf86vm + libxcb + ] ++ lib.optionals stdenv.isLinux [ + libxkbcommon + wayland + zlib + ]; +in +rustPlatform.buildRustPackage rec { + pname = "alacritty"; + version = "master"; + + src = fetchFromGitHub { + owner = "fee1-dead"; + repo = pname; + rev = "77e6d029d9e0ce980c71abf793d50a9a5f4e1564"; + sha256 = "sha256-h4XG9jJofjHs1l1hfcDkTVFocZ0k9Co2eTv36hV6FpU="; + }; + + cargoSha256 = "sha256-hHAlNxHvsKzqpOfnEmvAaMsrQynRXTLjdjGrUjFxAz0="; + + nativeBuildInputs = [ + cmake + gzip + installShellFiles + makeWrapper + ncurses + pkg-config + python3 + ]; + + buildInputs = rpathLibs; + + outputs = [ "out" "terminfo" ]; + + postPatch = '' + substituteInPlace alacritty/src/config/ui_config.rs \ + --replace xdg-open ${xdg-utils}/bin/xdg-open + ''; + + + # TODO find out why tests fail + doCheck = false; + + postInstall = '' + install -D extra/linux/Alacritty.desktop -t $out/share/applications/ + install -D extra/linux/io.alacritty.Alacritty.appdata.xml -t $out/share/appdata/ + install -D extra/logo/compat/alacritty-term.svg $out/share/icons/hicolor/scalable/apps/Alacritty.svg + # patchelf generates an ELF that binutils' "strip" doesn't like: + # strip: not enough room for program headers, try linking with -N + # As a workaround, strip manually before running patchelf. + strip -S $out/bin/alacritty + patchelf --set-rpath "${lib.makeLibraryPath rpathLibs}" $out/bin/alacritty + '' + '' + installShellCompletion --zsh extra/completions/_alacritty + installShellCompletion --bash extra/completions/alacritty.bash + installShellCompletion --fish extra/completions/alacritty.fish + install -dm 755 "$out/share/man/man1" + gzip -c extra/alacritty.man > "$out/share/man/man1/alacritty.1.gz" + install -Dm 644 alacritty.yml $out/share/doc/alacritty.yml + install -dm 755 "$terminfo/share/terminfo/a/" + tic -xe alacritty,alacritty-direct -o "$terminfo/share/terminfo" extra/alacritty.info + mkdir -p $out/nix-support + echo "$terminfo" >> $out/nix-support/propagated-user-env-packages + ''; + + dontPatchELF = true; + + meta = with lib; { + description = "A cross-platform, GPU-accelerated terminal emulator"; + homepage = "https://github.com/alacritty/alacritty"; + license = licenses.asl20; + maintainers = with maintainers; [ Br1ght0ne mic92 ma27 ]; + platforms = platforms.unix; + changelog = "https://github.com/alacritty/alacritty/blob/v${version}/CHANGELOG.md"; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index c8f6c98a..b346892e 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,26 +1,30 @@ { pkgs }: { - amdgpu-clocks = pkgs.callPackage ../pkgs/amdgpu-clocks { }; - preferredplayer = pkgs.callPackage ../pkgs/preferredplayer { }; - rgbdaemon = pkgs.callPackage ../pkgs/rgbdaemon { }; - sistemer-bot = pkgs.callPackage ../pkgs/sistemer-bot { }; - soundwire = pkgs.libsForQt5.callPackage ../pkgs/soundwire { }; - wallpapers = pkgs.callPackage ../pkgs/wallpapers { }; - zenity-askpass = pkgs.callPackage ../pkgs/zenity-askpass { }; + amdgpu-clocks = pkgs.callPackage ./amdgpu-clocks { }; + preferredplayer = pkgs.callPackage ./preferredplayer { }; + rgbdaemon = pkgs.callPackage ./rgbdaemon { }; + sistemer-bot = pkgs.callPackage ./sistemer-bot { }; + soundwire = pkgs.libsForQt5.callPackage ./soundwire { }; + wallpapers = pkgs.callPackage ./wallpapers { }; + zenity-askpass = pkgs.callPackage ./zenity-askpass { }; - setscheme = pkgs.callPackage ../pkgs/setscheme { }; - setwallpaper = pkgs.callPackage ../pkgs/setwallpaper { }; + setscheme = pkgs.callPackage ./setscheme { }; + setwallpaper = pkgs.callPackage ./setwallpaper { }; - setscheme-wofi = pkgs.callPackage ../pkgs/setscheme-wofi { + setscheme-wofi = pkgs.callPackage ./setscheme-wofi { inherit (pkgs.gnome) zenity; }; - setwallpaper-wofi = pkgs.callPackage ../pkgs/setwallpaper-wofi { + setwallpaper-wofi = pkgs.callPackage ./setwallpaper-wofi { inherit (pkgs.gnome) zenity; }; + shellcolord = pkgs.callPackage ./shellcolord { }; + # Experimental papermc version - papermc-experimental = pkgs.callPackage ../pkgs/papermc-experimental { }; + papermc-experimental = pkgs.callPackage ./papermc-experimental { }; - pass-wofi = pkgs.callPackage ../pkgs/pass-wofi { + pass-wofi = pkgs.callPackage ./pass-wofi { pass = pkgs.pass.withExtensions (exts: [ exts.pass-otp ]); }; + + alacritty-ligatures = pkgs.callPackage ./alacritty-ligatures { }; } diff --git a/pkgs/generated-gtk-themes/default.nix b/pkgs/generated-gtk-themes/default.nix index 2e4d34bb..a06add99 100644 --- a/pkgs/generated-gtk-themes/default.nix +++ b/pkgs/generated-gtk-themes/default.nix @@ -1,3 +1,4 @@ +# This "package" is not used in my install, this file is meant for building through the flake on CI (for caching gtk themes). { pkgs, nix-colors }: with nix-colors.lib { inherit pkgs; }; diff --git a/pkgs/shellcolord/default.nix b/pkgs/shellcolord/default.nix new file mode 100644 index 00000000..b84d1fa1 --- /dev/null +++ b/pkgs/shellcolord/default.nix @@ -0,0 +1,24 @@ +{ lib, stdenv, fetchFromSourcehut }: + +with lib; + +stdenv.mkDerivation rec { + name = "shellcolord"; + version = "0.1"; + src = fetchFromSourcehut { + owner = "~misterio"; + repo = name; + rev = "250cb20b9d931092ddd9ccf1f66d52aaf72b71b7"; + sha256 = "sha256-eL+4ikdTiwoMB/gu1CTYTL+V2tnVDo03Mwh4a9nuT38="; + }; + + makeFlags = [ "PREFIX=$(out)" ]; + + meta = { + description = "A daemon that themes your shell remotely"; + homepage = "https://git.sr.ht/~misterio/${name}"; + license = licenses.unlicense; + platforms = platforms.all; + maintainers = with maintainers; [ misterio77 ]; + }; +} diff --git a/users/misterio/features/cli/fish.nix b/users/misterio/features/cli/fish.nix index b7988bb3..66f6fba5 100644 --- a/users/misterio/features/cli/fish.nix +++ b/users/misterio/features/cli/fish.nix @@ -1,136 +1,40 @@ { pkgs, config, lib, ... }: -let - colors = config.colorscheme.colors; - get_red = color: builtins.substring 0 2 color; - get_green = color: builtins.substring 2 2 color; - get_blue = color: builtins.substring 4 2 color; - split-colors = lib.mapAttrs (name: color: "${get_red color}/${get_green color}/${get_blue color}") colors; - - base16-shell = pkgs.writeShellScriptBin "base16-shell" '' - #!/bin/sh - # base16-shell (https://github.com/chriskempson/base16-shell) - # Base16 Shell template by Chris Kempson (http://chriskempson.com) - # {{scheme-name}} scheme by {{scheme-author}} - - color00="${split-colors.base00}" # Base 00 - Black - color01="${split-colors.base08}" # Base 08 - Red - color02="${split-colors.base0B}" # Base 0B - Green - color03="${split-colors.base0A}" # Base 0A - Yellow - color04="${split-colors.base0D}" # Base 0D - Blue - color05="${split-colors.base0E}" # Base 0E - Magenta - color06="${split-colors.base0C}" # Base 0C - Cyan - color07="${split-colors.base05}" # Base 05 - White - color08="${split-colors.base03}" # Base 03 - Bright Black - color09=$color01 # Base 08 - Bright Red - color10=$color02 # Base 0B - Bright Green - color11=$color03 # Base 0A - Bright Yellow - color12=$color04 # Base 0D - Bright Blue - color13=$color05 # Base 0E - Bright Magenta - color14=$color06 # Base 0C - Bright Cyan - color15="${split-colors.base07}" # Base 07 - Bright White - color16="${split-colors.base09}" # Base 09 - color17="${split-colors.base0F}" # Base 0F - color18="${split-colors.base01}" # Base 01 - color19="${split-colors.base02}" # Base 02 - color20="${split-colors.base04}" # Base 04 - color21="${split-colors.base06}" # Base 06 - color_foreground="${split-colors.base05}" # Base 05 - color_background="${split-colors.base00}" # Base 00 - - if [ -n "$TMUX" ]; then - # Tell tmux to pass the escape sequences through - # (Source: http://permalink.gmane.org/gmane.comp.terminal-emulators.tmux.user/1324) - put_template() { printf '\033Ptmux;\033\033]4;%d;rgb:%s\033\033\\\033\\' $@; } - put_template_var() { printf '\033Ptmux;\033\033]%d;rgb:%s\033\033\\\033\\' $@; } - put_template_custom() { printf '\033Ptmux;\033\033]%s%s\033\033\\\033\\' $@; } - elif [ "''${TERM%%[-.]*}" = "screen" ]; then - # GNU screen (screen, screen-256color, screen-256color-bce) - put_template() { printf '\033P\033]4;%d;rgb:%s\007\033\\' $@; } - put_template_var() { printf '\033P\033]%d;rgb:%s\007\033\\' $@; } - put_template_custom() { printf '\033P\033]%s%s\007\033\\' $@; } - elif [ "''${TERM%%-*}" = "linux" ]; then - put_template() { [ $1 -lt 16 ] && printf "\e]P%x%s" $1 $(echo $2 | sed 's/\///g'); } - put_template_var() { true; } - put_template_custom() { true; } - else - put_template() { printf '\033]4;%d;rgb:%s\033\\' $@; } - put_template_var() { printf '\033]%d;rgb:%s\033\\' $@; } - put_template_custom() { printf '\033]%s%s\033\\' $@; } - fi - - # 16 color space - put_template 0 $color00 - put_template 1 $color01 - put_template 2 $color02 - put_template 3 $color03 - put_template 4 $color04 - put_template 5 $color05 - put_template 6 $color06 - put_template 7 $color07 - put_template 8 $color08 - put_template 9 $color09 - put_template 10 $color10 - put_template 11 $color11 - put_template 12 $color12 - put_template 13 $color13 - put_template 14 $color14 - put_template 15 $color15 - - # 256 color space - put_template 16 $color16 - put_template 17 $color17 - put_template 18 $color18 - put_template 19 $color19 - put_template 20 $color20 - put_template 21 $color21 - - # foreground / background / cursor color - put_template_var 10 $color_foreground - if [ "$BASE16_SHELL_SET_BACKGROUND" != false ]; then - put_template_var 11 $color_background - if [ "''${TERM%%-*}" = "rxvt" ]; then - put_template_var 708 $color_background # internal border (rxvt) - fi - fi - put_template_custom 12 ";7" # cursor (reverse video) - ''; -in { - home.packages = [ base16-shell ]; programs.fish = { enable = true; shellAbbrs = { ls = "exa"; top = "btm"; + jqless = "jq -C | less -r"; + snrs = "sudo nixos-rebuild switch --flake /dotfiles"; nrs = "nixos-rebuild switch --flake /dotfiles"; hms = "home-manager switch --flake /dotfiles"; + v = "nvim"; vi = "nvim"; vim = "nvim"; m = "neomutt"; mutt = "neomutt"; + s = "base16-shell"; }; shellAliases = { - miningclock = "sudo USER_STATES_PATH=/etc/default/amdgpu-custom-state amdgpu-clocks"; - gamingclock = "sudo USER_STATES_PATH=/etc/default/amdgpu-gaming-state amdgpu-clocks"; - # SSH with kitty terminfo - kssh = "kitty +kitten ssh"; # Get ip getip = "curl ifconfig.me"; - # Clear screen and scrollbackbuffer - clear = "clear && printf '\\033[2J\\033[3J\\033[1;1H'"; }; functions = { fish_greeting = "${pkgs.fortune}/bin/fortune -s"; wh = "readlink -f (which $argv)"; - ssh = '' - command ssh $argv - base16-shell - ''; + ssh = let shellcolor = "${pkgs.shellcolord}/bin/shellcolor"; in + '' + ${shellcolor} disable $fish_pid + command ssh $argv + ${shellcolor} enable $fish_pid + ${shellcolor} apply $fish_pid + ''; }; interactiveShellInit = # Use vim bindings and cursors @@ -170,12 +74,33 @@ in set -U fish_pager_color_prefix 'white' '--bold' '--underline' set -U fish_pager_color_progress 'brwhite' '--background=cyan' '' + - # Activate base16-shell if connected via SSH + # Start shellcolor daemon '' - if test -n "$SSH_CONNECTION" - ${base16-shell}/bin/base16-shell - end + ${pkgs.shellcolord}/bin/shellcolord $fish_pid & ''; }; + xdg.configFile."shellcolor.conf" = { + text = let colors = config.colorscheme.colors; in '' + base00=${colors.base00} + base01=${colors.base01} + base02=${colors.base02} + base03=${colors.base03} + base04=${colors.base04} + base05=${colors.base05} + base06=${colors.base06} + base07=${colors.base07} + base08=${colors.base08} + base09=${colors.base09} + base0A=${colors.base0A} + base0B=${colors.base0B} + base0C=${colors.base0C} + base0D=${colors.base0D} + base0E=${colors.base0E} + base0F=${colors.base0F} + ''; + onChange = '' + timeout 1 ${pkgs.shellcolord}/bin/shellcolor apply || true + ''; + }; } diff --git a/users/misterio/features/cli/ranger.nix b/users/misterio/features/cli/ranger.nix index 0fd771f0..8be7354f 100644 --- a/users/misterio/features/cli/ranger.nix +++ b/users/misterio/features/cli/ranger.nix @@ -2,8 +2,4 @@ { home.packages = with pkgs; [ ranger ]; - xdg.configFile."ranger/rc.conf".text = '' - set preview_images true - set preview_images_method kitty - ''; } diff --git a/users/misterio/features/cli/starship.nix b/users/misterio/features/cli/starship.nix index 8ff20188..bbebf744 100644 --- a/users/misterio/features/cli/starship.nix +++ b/users/misterio/features/cli/starship.nix @@ -14,6 +14,7 @@ hostname = { ssh_only = false; format = "[@$hostname]($style)"; + style = "bold green"; }; directory = { }; character = { diff --git a/users/misterio/features/desktop-sway/alacritty.nix b/users/misterio/features/desktop-sway/alacritty.nix new file mode 100644 index 00000000..1ecaaba3 --- /dev/null +++ b/users/misterio/features/desktop-sway/alacritty.nix @@ -0,0 +1,32 @@ +{ config, pkgs, ... }: + +let colors = config.colorscheme.colors; +in { + home.sessionVariables = { + TERMINAL = "alacritty"; + }; + programs.alacritty = { + enable = true; + package = pkgs.alacritty-ligatures; + settings = { + live_config_reload = false; + font = { + size = 12.0; + normal.family = "FiraCode Nerd Font"; + }; + window = { + padding = { + x = 24; + y = 26; + }; + dynamic_title = true; + }; + colors = { + primary = { + background = "#${colors.base00}"; + foreground = "#${colors.base05}"; + }; + }; + }; + }; +} diff --git a/users/misterio/features/desktop-sway/default.nix b/users/misterio/features/desktop-sway/default.nix index 1ae909ff..4c606fab 100644 --- a/users/misterio/features/desktop-sway/default.nix +++ b/users/misterio/features/desktop-sway/default.nix @@ -1,13 +1,13 @@ { pkgs, ... }: { imports = [ + ./alacritty.nix ./discord.nix ./element.nix ./fira.nix ./firefox.nix ./gtk.nix ./kdeconnect.nix - ./kitty.nix ./mako.nix ./obs.nix ./qt.nix diff --git a/users/misterio/features/desktop-sway/kitty.nix b/users/misterio/features/desktop-sway/kitty.nix deleted file mode 100644 index 268c9bbc..00000000 --- a/users/misterio/features/desktop-sway/kitty.nix +++ /dev/null @@ -1,54 +0,0 @@ -{ config, pkgs, ... }: - -let colors = config.colorscheme.colors; -in { - home.sessionVariables = { - TERMINAL = "kitty"; - }; - programs.kitty = { - enable = true; - font = { - package = pkgs.nerdfonts.override { fonts = [ "FiraCode" ]; }; - name = "FiraCode"; - size = 12; - }; - settings = { - window_padding_width = 15; - foreground = "#${colors.base05}"; - background = "#${colors.base00}"; - selection_background = "#${colors.base05}"; - selection_foreground = "#${colors.base00}"; - url_color = "#${colors.base04}"; - cursor = "#${colors.base05}"; - active_border_color = "#${colors.base03}"; - inactive_border_color = "#${colors.base01}"; - active_tab_background = "#${colors.base00}"; - active_tab_foreground = "#${colors.base05}"; - inactive_tab_background = "#${colors.base01}"; - inactive_tab_foreground = "#${colors.base04}"; - tab_bar_background = "#${colors.base01}"; - color0 = "#${colors.base00}"; - color1 = "#${colors.base08}"; - color2 = "#${colors.base0B}"; - color3 = "#${colors.base0A}"; - color4 = "#${colors.base0D}"; - color5 = "#${colors.base0E}"; - color6 = "#${colors.base0C}"; - color7 = "#${colors.base05}"; - color8 = "#${colors.base03}"; - color9 = "#${colors.base08}"; - color10 = "#${colors.base0B}"; - color11 = "#${colors.base0A}"; - color12 = "#${colors.base0D}"; - color13 = "#${colors.base0E}"; - color14 = "#${colors.base0C}"; - color15 = "#${colors.base07}"; - color16 = "#${colors.base09}"; - color17 = "#${colors.base0F}"; - color18 = "#${colors.base01}"; - color19 = "#${colors.base02}"; - color20 = "#${colors.base04}"; - color21 = "#${colors.base06}"; - }; - }; -} diff --git a/users/misterio/features/desktop-sway/sway.nix b/users/misterio/features/desktop-sway/sway.nix index d0fc4cdd..c85aa57d 100644 --- a/users/misterio/features/desktop-sway/sway.nix +++ b/users/misterio/features/desktop-sway/sway.nix @@ -19,7 +19,7 @@ let amfora = "${pkgs.amfora}/bin/amfora"; discocss = "${pkgs.discocss}/bin/discocss"; grimshot = "${pkgs.sway-contrib.grimshot}/bin/grimshot"; - kitty = "${pkgs.kitty}/bin/kitty"; + alacritty = "${config.programs.alacritty.package}/bin/alacritty"; light = "${pkgs.light}/bin/light"; makoctl = "${pkgs.mako}/bin/makoctl"; neomutt = "${pkgs.neomutt}/bin/neomutt"; @@ -54,7 +54,7 @@ rec { systemdIntegration = true; wrapperFeatures.gtk = true; config = rec { - terminal = "${kitty}"; + terminal = "${alacritty}"; menu = "${wofi} -D run-always_parse_args=true -k /dev/null -i -e -S run -t ${terminal}"; fonts = { diff --git a/users/misterio/features/desktop-sway/waybar.nix b/users/misterio/features/desktop-sway/waybar.nix index ae9922b7..15c223d0 100644 --- a/users/misterio/features/desktop-sway/waybar.nix +++ b/users/misterio/features/desktop-sway/waybar.nix @@ -79,7 +79,7 @@ in { exec = '' echo " ($(find ~/Mail/*/INBOX/new -type f | wc -l))" ''; - on-click = "${pkgs.kitty}/bin/kitty -e ${pkgs.neomutt}/bin/neomutt"; + on-click = "${config.programs.alacritty.package}/bin/alacritty -e ${pkgs.neomutt}/bin/neomutt"; interval = 2; }; "custom/gpg-agent" = lib.mkIf (builtins.elem "trusted" features) {