From 988a90039ec70bce7283b5e7dc3d4b8fa094c08d Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 31 May 2024 05:51:51 +0300 Subject: [PATCH] warp-cli fix + yazi + some app settings --- flake.lock | 35 +++++++++++---- flake.nix | 2 + home/home.nix | 4 +- pkgs/apps.nix | 1 + pkgs/helix/default.nix | 1 + pkgs/hyprland/hypr/default.nix | 5 --- pkgs/hyprland/hypr/hyprland.conf | 3 +- pkgs/socks.nix | 43 +++++++++++++------ pkgs/yazi/default.nix | 74 ++++++++++++++++++++++++++++++++ 9 files changed, 138 insertions(+), 30 deletions(-) create mode 100644 pkgs/yazi/default.nix diff --git a/flake.lock b/flake.lock index 46154db..e9c6d4c 100644 --- a/flake.lock +++ b/flake.lock @@ -70,11 +70,11 @@ ] }, "locked": { - "lastModified": 1716035127, - "narHash": "sha256-qqxeTHGDvCcer1QEGlu81MmRfbkNHBqCD9Ue7S2yHBE=", + "lastModified": 1717067691, + "narHash": "sha256-WEOgDjuEs2r/5YSlFTVrACdNdL7kLACEAV2U/G0Q1Yk=", "owner": "nix-community", "repo": "flake-firefox-nightly", - "rev": "ee25f2df1923145abee8aa8096f9b45065b535fb", + "rev": "bfb1041c5c92ab530b1b026762a5fa56af5d7a4c", "type": "github" }, "original": { @@ -495,11 +495,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1715515815, - "narHash": "sha256-yaLScMHNFCH6SbB0HSA/8DWDgK0PyOhCXoFTdHlWkhk=", + "lastModified": 1716725378, + "narHash": "sha256-bNTVDAVBLFSSTU+q54cJnntmFKBi+F/D8sSqlZwBGiM=", "owner": "nix-community", "repo": "lib-aggregate", - "rev": "09883ca828e8cfaacdb09e29190a7b84ad1d9925", + "rev": "dbc9130fe1455e0f6ee4d8f5f799f9be551f866b", "type": "github" }, "original": { @@ -563,11 +563,11 @@ }, "nixpkgs-lib": { "locked": { - "lastModified": 1715474941, - "narHash": "sha256-CNCqCGOHdxuiVnVkhTpp2WcqSSmSfeQjubhDOcgwGjU=", + "lastModified": 1716684580, + "narHash": "sha256-sIbMJWJr4hl2PWd9/iWlh89QfVzBn1NJ3u5RjeZADuM=", "owner": "nix-community", "repo": "nixpkgs.lib", - "rev": "58e03b95f65dfdca21979a081aa62db0eed6b1d8", + "rev": "d0d27192931680482081aa1c38389da2af84a651", "type": "github" }, "original": { @@ -640,6 +640,22 @@ "type": "github" } }, + "nixpkgs2305": { + "locked": { + "lastModified": 1704290814, + "narHash": "sha256-LWvKHp7kGxk/GEtlrGYV68qIvPHkU9iToomNFGagixU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "70bdadeb94ffc8806c0570eb5c2695ad29f0e421", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1715534503, @@ -785,6 +801,7 @@ "nixpkgs-stable": "nixpkgs-stable", "nixpkgs-unstable": "nixpkgs-unstable", "nixpkgs2105": "nixpkgs2105", + "nixpkgs2305": "nixpkgs2305", "nixvim": "nixvim", "secrets": "secrets", "shwewo": "shwewo" diff --git a/flake.nix b/flake.nix index dab9c4d..ad6bff5 100644 --- a/flake.nix +++ b/flake.nix @@ -6,6 +6,8 @@ nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-23.11"; nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs2105.url = "github:NixOS/nixpkgs/nixos-21.05"; + nixpkgs2305.url = "github:NixOS/nixpkgs/nixos-23.05"; + home-manager.url = "github:nix-community/home-manager"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; diff --git a/home/home.nix b/home/home.nix index 475ed7d..b9889cd 100644 --- a/home/home.nix +++ b/home/home.nix @@ -6,6 +6,7 @@ imports = [ ./theme.nix ../pkgs/helix + ../pkgs/yazi ]; #services.blueman-applet.enable = true; @@ -13,7 +14,6 @@ programs.vscode = { enable = true; package = pkgs.vscode; - extensions = with pkgs.vscode-extensions; [ matklad.rust-analyzer jnoortheen.nix-ide @@ -143,7 +143,7 @@ background_opacity = "0.8"; remember_window_size = "no"; hide_window_decorations = "yes"; - remote_control_password = "kitty-notification-password-fish ls"; + remote_control_password = "kitty-notification-password-fish ls, kitty-password-scripts ls set-tab-* resize-* send-text"; allow_remote_control = "password"; font_family= "FiraCode"; font_features = "FiraCode +ss01 +ss02 +ss06 +ss08 +cv14 +cv03 +tnum"; diff --git a/pkgs/apps.nix b/pkgs/apps.nix index 6efdcd4..9e51d0b 100644 --- a/pkgs/apps.nix +++ b/pkgs/apps.nix @@ -31,6 +31,7 @@ in { #]; users.users.delta.packages = (with pkgs; [ + gitleaks git #chromium wl-clipboard diff --git a/pkgs/helix/default.nix b/pkgs/helix/default.nix index 90b35a4..4dd602c 100644 --- a/pkgs/helix/default.nix +++ b/pkgs/helix/default.nix @@ -37,6 +37,7 @@ space.q = ":q"; esc = [ "collapse_selection" "keep_primary_selection" ]; C-f = [":new" ":insert-output lf -selection-path=/dev/stdout" "split_selection_on_newline" "goto_file" "goto_last_modification" "goto_last_modified_file" ":buffer-close!" ":redraw"]; + # C-d = [":new" ":insert-output /home/delta/scripts/temp/yazi-choser.sh -selection-path=/dev/stdout" "split_selection_on_newline" "goto_file" "goto_last_modification" "goto_last_modified_file" ":buffer-close!" ":redraw"]; }; }; diff --git a/pkgs/hyprland/hypr/default.nix b/pkgs/hyprland/hypr/default.nix index 2070cc7..d3feea1 100644 --- a/pkgs/hyprland/hypr/default.nix +++ b/pkgs/hyprland/hypr/default.nix @@ -50,10 +50,5 @@ # "https://github.com/zakk4223/hyprland-easymotion" # ]; }; - # home.activation = { - # unlink_hyprland = lib.hm.dag.entryAfter ["onFilesChange"] '' - # unlink /home/delta/.config/hypr/hyprland.conf - # ''; - # }; }; } \ No newline at end of file diff --git a/pkgs/hyprland/hypr/hyprland.conf b/pkgs/hyprland/hypr/hyprland.conf index dc86f52..eca1924 100644 --- a/pkgs/hyprland/hypr/hyprland.conf +++ b/pkgs/hyprland/hypr/hyprland.conf @@ -7,7 +7,7 @@ # monitor=eDP-1,2944x1840@60,auto,1.333333 # monitor=eDP-1,preferred,auto,1.6 -monitor=eDP-1,preferred,auto,2 +monitor=eDP-1,preferred,auto,1.333333 #monitor=eDP-1,preferred,auto,1.066667 #source = ~/.config/hypr/monitors.conf @@ -217,6 +217,7 @@ gestures { #windowrule = float, ^(kitty)$ windowrule = float,^(pavucontrol)$ windowrule = float,^(blueman-manager)$ +windowrule = float,^(.blueman-manager-wrapped)$ windowrule = float,^(nm-connection-editor)$ #windowrule = float,^(chromium)$ windowrule = float,^(thunar)$ diff --git a/pkgs/socks.nix b/pkgs/socks.nix index 3de55ec..368bc33 100644 --- a/pkgs/socks.nix +++ b/pkgs/socks.nix @@ -1,5 +1,6 @@ { pkgs, lib, inputs, ... }: let + nixpkgs2305 = import inputs.nixpkgs2305 { system = "${pkgs.system}"; config = { allowUnfree = true; }; }; socksBuilder = attrs: { inherit (attrs) name; @@ -33,12 +34,10 @@ let }; }; - # IP of the proxies is 192.168.150.2 - - socksed = [ # gost port 4780 direct proxy - { name = "singbox-aus"; script = "sing-box run -c /run/secrets/singbox-aus"; } # port 4000 - { name = "socks-warp"; script = "wireproxy -c /etc/wireguard/warp0.conf"; } # port 3333 - { name = "socks-novpn"; script = "gost -L socks5://192.168.150.2:3334"; } # port 3334 + socksed = [ # IP of the proxies is 192.168.150.2 + { name = "singbox-aus"; script = "sing-box run -c /run/secrets/singbox-aus";} # port 4000 + { name = "socks-warp"; script = "wireproxy -c /etc/wireguard/cproxy.conf"; } # port 3333 + { name = "socks-novpn"; script = "gost -L socks5://192.168.150.2:3334"; } # port 3334 ]; delete_rules = pkgs.writeScriptBin "delete_rules" '' @@ -167,17 +166,17 @@ in { StateDirectory = "cloudflare-warp"; RuntimeDirectory = "cloudflare-warp"; LogsDirectory = "cloudflare-warp"; - ExecStart = "${pkgs.cloudflare-warp}/bin/warp-svc"; + ExecStart = "${nixpkgs2305.cloudflare-warp}/bin/warp-svc"; }; postStart = '' while true; do set -e - status=$(${pkgs.cloudflare-warp}/bin/warp-cli status || true) + status=$(${nixpkgs2305.cloudflare-warp}/bin/warp-cli status || true) set +e if [[ "$status" != *"Unable to connect to CloudflareWARP daemon"* ]]; then - ${pkgs.cloudflare-warp}/bin/warp-cli set-custom-endpoint 162.159.193.1:2408 + ${nixpkgs2305.cloudflare-warp}/bin/warp-cli set-custom-endpoint 162.159.193.1:2408 exit 0 fi sleep 1 @@ -188,18 +187,36 @@ in { tor.wantedBy = lib.mkForce []; }; - users.users.delta.packages = [ - (pkgs.writeScriptBin "nyx" ''sudo -u tor -g tor ${inputs.nixpkgs2105.legacyPackages."x86_64-linux".nyx}/bin/nyx $@'') + environment.systemPackages = [ + (pkgs.writeScriptBin "warp-cli" "${nixpkgs2305.cloudflare-warp}/bin/warp-cli $@") + (pkgs.writeScriptBin "nyx" ''sudo -u tor -g tor ${inputs.nixpkgs2105.legacyPackages."${pkgs.system}".nyx}/bin/nyx $@'') + (pkgs.writeScriptBin "tor-warp" '' + if [[ "$1" == "start" ]]; then + echo "Starting..." + warp-cli set-mode proxy + warp-cli set-proxy-port 4000 + sudo systemctl start tor + elif [[ "$1" == "stop" ]]; then + echo "Stopping..." + warp-cli set-mode warp + sudo systemctl stop tor + else + echo "Error: specify start or stop" + fi + '') ]; services.tor = { enable = true; client = { enable = true; - socksListenAddress = 9063; + socksListenAddress = 9050; }; settings = { - Socks5Proxy = "192.168.150.2:3333"; + # UseBridges = true; + # ClientTransportPlugin = "snowflake exec ${pkgs.snowflake}/bin/client"; + # Bridge = "snowflake 192.0.2.3:80 2B280B23E1107BB62ABFC40DDCC8824814F80A72 fingerprint=2B280B23E1107BB62ABFC40DDCC8824814F80A72 url=https://snowflake-broker.torproject.net.global.prod.fastly.net/ fronts=www.shazam.com,www.cosmopolitan.com,www.esquire.com ice=stun:stun.l.google.com:19302,stun:stun.antisip.com:3478,stun:stun.bluesip.net:3478,stun:stun.dus.net:3478,stun:stun.epygi.com:3478,stun:stun.sonetel.com:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.voys.nl:3478 utls-imitate=hellorandomizedalpn"; + Socks5Proxy = "localhost:4000"; # requires setting warp-svc to proxy mode: warp-cli set-mode proxy && warp-cli set-proxy-port 4000 ControlPort = 9051; CookieAuthentication = true; }; diff --git a/pkgs/yazi/default.nix b/pkgs/yazi/default.nix new file mode 100644 index 0000000..3b859c5 --- /dev/null +++ b/pkgs/yazi/default.nix @@ -0,0 +1,74 @@ +{ pkgs, lib, ... }: + +{ + programs.yazi = { + enable = true; + # enableFishIntegration = true; + }; + home.file.".config/yazi/yazi.toml".text = '' + [[manager.prepend_keymap]] + on = [ "l" ] + run = "plugin --sync smart-enter" + desc = "Enter the child directory, or open the file" + [[manager.prepend_keymap]] + on = [ "p" ] + run = "plugin --sync smart-paste" + desc = "Paste into the hovered directory or CWD" + [[manager.prepend_keymap]] + on = [ "" ] + run = 'shell "$SHELL" --block --confirm' + desc = "Open shell here" + [[manager.prepend_keymap]] + on = [ "T" ] + run = "plugin --sync max-preview" + + ''; + home.file.".config/yazi/plugins/smart-enter.yazi/init.lua".text = '' + return { + entry = function() + local h = cx.active.current.hovered + ya.manager_emit(h and h.cha.is_dir and "enter" or "open", { hovered = true }) + end, + } + ''; + home.file.".config/yazi/plugins/smart-paste.yazi/init.lua".text = '' + return { + entry = function() + local h = cx.active.current.hovered + if h and h.cha.is_dir then + ya.manager_emit("enter", {}) + ya.manager_emit("paste", {}) + ya.manager_emit("leave", {}) + else + ya.manager_emit("paste", {}) + end + end, + } + ''; + home.file.".config/yazi/plugins/max-preview.yazi/init.lua".text = '' + local function entry(st) + if st.old then + Manager.layout, st.old = st.old, nil + else + st.old = Manager.layout + Manager.layout = function(self, area) + self.area = area + + return ui.Layout() + :direction(ui.Layout.HORIZONTAL) + :constraints({ + ui.Constraint.Percentage(0), + ui.Constraint.Percentage(0), + ui.Constraint.Percentage(100), + }) + :split(area) + end + end + ya.app_emit("resize", {}) + end + + return { entry = entry } + ''; + + +}