This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

tools: refactor to use makeWrapper helper function

+125 -146
+2 -1
flake.nix
··· 178 178 }; 179 179 }; 180 180 flake.lib = import ./lib { inherit (nixpkgs) lib; }; 181 - flake.libWithPkgs = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed (system: 181 + flake.libWithPkgs = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed ( 182 + system: 182 183 import ./lib/pkgs.nix { 183 184 inherit (nixpkgs) lib; 184 185 pkgs = nixpkgs.legacyPackages.${system};
+1 -1
lib/default.nix
··· 1 - { lib, ... }: 1 + { ... }: 2 2 let 3 3 # Pure library functions that don't need pkgs 4 4 superlib = {
+9 -7
lib/make-wrapper.nix
··· 1 - { lib, superlib, pkgs, ... }: 1 + { lib, pkgs, ... }: 2 2 { 3 3 /** 4 4 Create a wrapped application that preserves all original outputs (man pages, completions, etc.) ··· 25 25 } 26 26 ``` 27 27 */ 28 - makeWrapper = package: args@{ 29 - runtimeInputs ? [], 30 - env ? {}, 31 - wrapper ? ''exec ${lib.getExe package} "$@"'' 32 - }: 28 + makeWrapper = 29 + package: 30 + { 31 + runtimeInputs ? [ ], 32 + env ? { }, 33 + wrapper ? ''exec ${lib.getExe package} "$@"'', 34 + }: 33 35 let 34 36 # Extract binary name from the exe path 35 37 exePath = lib.getExe package; ··· 51 53 package 52 54 ]; 53 55 }; 54 - } 56 + }
+1 -1
lib/pkgs.nix
··· 6 6 { 7 7 # Import functions that need pkgs 8 8 makeWrapper = (import ./make-wrapper.nix { inherit lib superlib pkgs; }).makeWrapper; 9 - } 9 + }
+5 -3
5pkgs/git-mcp/default.nix
··· 1 1 { pkgs, ... }: 2 2 let 3 - python = pkgs.python3.withPackages (ps: with ps; [ 4 - mcp 5 - ]); 3 + python = pkgs.python3.withPackages ( 4 + ps: with ps; [ 5 + mcp 6 + ] 7 + ); 6 8 in 7 9 pkgs.writeShellApplication { 8 10 name = "git-mcp";
+64 -73
tools/muchsync/flake-module.nix
··· 1 1 { self, ... }: 2 2 { 3 3 perSystem = 4 - { pkgs, lib, ... }: 5 4 { 6 - packages.muchsync = pkgs.symlinkJoin { 7 - name = "muchsync"; 8 - paths = [ 9 - (pkgs.writeShellApplication { 10 - name = "muchsync"; 11 - runtimeInputs = 12 - [ 13 - pkgs.muchsync 14 - pkgs.notmuch 15 - ] 16 - ++ lib.optionals pkgs.stdenv.isLinux [ 17 - pkgs.iputils 18 - ]; 19 - text = '' 20 - export NOTMUCH_CONFIG=${ 21 - pkgs.writeText "notmuch-config" self.packages.${pkgs.system}.mutt.passthru.notmuchConfig 22 - } 5 + pkgs, 6 + lib, 7 + system, 8 + ... 9 + }: 10 + { 11 + packages.muchsync = self.libWithPkgs.${system}.makeWrapper pkgs.muchsync { 12 + runtimeInputs = [ pkgs.notmuch ] ++ lib.optionals pkgs.stdenv.isLinux [ pkgs.iputils ]; 13 + env = { 14 + NOTMUCH_CONFIG = 15 + pkgs.writeText "notmuch-config" 16 + self.packages.${pkgs.system}.mutt.passthru.notmuchConfig; 17 + }; 18 + wrapper = '' 23 19 24 - set -efu 20 + # Create Maildir structure if it doesn't exist 21 + mkdir -p "$HOME/Maildir"/{cur,new,tmp} 25 22 26 - # Create Maildir structure if it doesn't exist 27 - mkdir -p "$HOME/Maildir"/{cur,new,tmp} 23 + # Check if a host is reachable 24 + check_host() { 25 + local host=$1 26 + ping -W2 -c1 "$host" >/dev/null 2>&1 27 + } 28 28 29 - # Check if a host is reachable 30 - check_host() { 31 - local host=$1 32 - ping -W2 -c1 "$host" >/dev/null 2>&1 33 - } 29 + # Smart host selection - try spora, nether, retiolum, then tor 30 + find_green_host() { 31 + if check_host green.s; then 32 + echo "green.s" 33 + elif check_host green.n; then 34 + echo "green.n" 35 + elif check_host green.r; then 36 + echo "green.r" 37 + else 38 + echo "tor" 39 + fi 40 + } 34 41 35 - # Smart host selection - try spora, nether, retiolum, then tor 36 - find_green_host() { 37 - if check_host green.s; then 38 - echo "green.s" 39 - elif check_host green.n; then 40 - echo "green.n" 41 - elif check_host green.r; then 42 - echo "green.r" 43 - else 44 - echo "tor" 45 - fi 46 - } 42 + # Check if arguments look like flags or a hostname 43 + has_hostname=false 44 + for arg in "$@"; do 45 + case "$arg" in 46 + -*) ;; # This is a flag 47 + *) has_hostname=true; break ;; # Found a non-flag argument 48 + esac 49 + done 47 50 48 - # Check if arguments look like flags or a hostname 49 - has_hostname=false 50 - for arg in "$@"; do 51 - case "$arg" in 52 - -*) ;; # This is a flag 53 - *) has_hostname=true; break ;; # Found a non-flag argument 54 - esac 55 - done 51 + # If only flags provided (or no args), do a sync with green host 52 + if [ "$has_hostname" = "false" ]; then 53 + host=$(find_green_host) 54 + echo "Syncing with $host..." >&2 56 55 57 - # If only flags provided (or no args), do a sync with green host 58 - if [ "$has_hostname" = "false" ]; then 59 - host=$(find_green_host) 60 - echo "Syncing with $host..." >&2 61 - 62 - if [ "$host" = "tor" ]; then 63 - # Build dependencies lazily 64 - echo "Building tornade..." >&2 65 - tornade_path=$(nix build --no-link --print-out-paths "${self}#tornade") 66 - clan_path=$(nix build --no-link --print-out-paths "${self}#clan-cli") 67 - 68 - # Get tor hostname using clan CLI 69 - tor_hostname=$(CLAN_DIR="${self}" "$clan_path/bin/clan" vars get green tor-ssh/tor-hostname) 70 - 71 - # Use muchsync with custom ssh command via tornade 72 - exec muchsync "$@" -s "$tornade_path/bin/tornade ssh" lass@"$tor_hostname" 73 - else 74 - exec muchsync "$@" lass@"$host" 75 - fi 76 - else 77 - # Pass through arguments to muchsync 78 - exec muchsync "$@" 79 - fi 80 - ''; 81 - }) 82 - pkgs.muchsync 83 - ]; 56 + if [ "$host" = "tor" ]; then 57 + # Build dependencies lazily 58 + echo "Building tornade..." >&2 59 + tornade_path=$(nix build --no-link --print-out-paths "${self}#tornade") 60 + clan_path=$(nix build --no-link --print-out-paths "${self}#clan-cli") 61 + 62 + # Get tor hostname using clan CLI 63 + tor_hostname=$(CLAN_DIR="${self}" "$clan_path/bin/clan" vars get green tor-ssh/tor-hostname) 64 + 65 + # Use muchsync with custom ssh command via tornade 66 + exec muchsync "$@" -s "$tornade_path/bin/tornade ssh" lass@"$tor_hostname" 67 + else 68 + exec muchsync "$@" lass@"$host" 69 + fi 70 + else 71 + # Pass through arguments to muchsync 72 + exec muchsync "$@" 73 + fi 74 + ''; 84 75 }; 85 76 }; 86 77 }
+11 -19
tools/pass/flake-module.nix
··· 1 1 { self, ... }: 2 2 { 3 3 perSystem = 4 - { pkgs, ... }: 4 + { pkgs, system, ... }: 5 + let 6 + passWithOtp = pkgs.pass.withExtensions (ext: [ ext.pass-otp ]); 7 + in 5 8 { 6 - packages.pass = pkgs.symlinkJoin { 7 - name = "pass"; 8 - paths = [ 9 - (pkgs.writeShellApplication { 10 - name = "pass"; 11 - runtimeInputs = [ 12 - (pkgs.pass.withExtensions (ext: [ ext.pass-otp ])) 13 - pkgs.gnupg 14 - ]; 15 - text = '' 16 - set -efu 17 - gpg --import ${self.keys.pgp.yubi.key} &>/dev/null 18 - echo '${self.keys.pgp.yubi.id}:6:' | gpg --import-ownertrust &>/dev/null 19 - pass "$@" 20 - ''; 21 - }) 22 - (pkgs.pass.withExtensions (ext: [ ext.pass-otp ])) 23 - ]; 9 + packages.pass = self.libWithPkgs.${system}.makeWrapper passWithOtp { 10 + runtimeInputs = [ pkgs.gnupg ]; 11 + wrapper = '' 12 + gpg --import ${self.keys.pgp.yubi.key} &>/dev/null 13 + echo '${self.keys.pgp.yubi.id}:6:' | gpg --import-ownertrust &>/dev/null 14 + exec ${pkgs.lib.getExe passWithOtp} "$@" 15 + ''; 24 16 }; 25 17 }; 26 18 }
+13 -17
tools/tmux/flake-module.nix
··· 1 - { ... }: 1 + { self, ... }: 2 2 { 3 3 perSystem = 4 - { pkgs, ... }: 4 + { pkgs, system, ... }: 5 5 let 6 6 tmuxConfigText = '' 7 7 set-option -g default-terminal screen-256color ··· 12 12 tmuxConfigFile = pkgs.writeText "tmux.conf" tmuxConfigText; 13 13 in 14 14 { 15 - packages.tmux = pkgs.symlinkJoin { 16 - name = "tmux"; 17 - paths = [ 18 - (pkgs.writeShellApplication { 19 - name = "tmux"; 20 - text = '' 21 - exec ${pkgs.tmux}/bin/tmux -f ${tmuxConfigFile} "$@" 22 - ''; 23 - }) 24 - pkgs.tmux 25 - ]; 26 - passthru = { 27 - tmuxConfig = tmuxConfigText; 28 - }; 29 - }; 15 + packages.tmux = 16 + (self.libWithPkgs.${system}.makeWrapper pkgs.tmux { 17 + wrapper = '' 18 + exec ${pkgs.lib.getExe pkgs.tmux} -f ${tmuxConfigFile} "$@" 19 + ''; 20 + }).overrideAttrs 21 + (old: { 22 + passthru = (old.passthru or { }) // { 23 + tmuxConfig = tmuxConfigText; 24 + }; 25 + }); 30 26 }; 31 27 }
+19 -24
tools/zsh/flake-module.nix
··· 237 237 ''; 238 238 in 239 239 { 240 - packages.zsh = pkgs.symlinkJoin { 241 - name = "zsh-with-config"; 242 - paths = [ 243 - (pkgs.writeShellApplication { 244 - name = "zsh"; 245 - runtimeInputs = with pkgs; [ 246 - tmux 247 - fzf 248 - direnv 249 - atuin 250 - nix-index 251 - self.packages.${pkgs.system}.name-generator 252 - ]; 253 - text = '' 254 - export ZDOTDIR=${pkgs.writeTextDir "/.zshrc" zshrc} 255 - exec ${pkgs.zsh}/bin/zsh "$@" 256 - ''; 257 - }) 258 - pkgs.zsh 259 - ]; 260 - passthru = { 261 - inherit zshrc; 262 - }; 263 - }; 240 + packages.zsh = 241 + (self.libWithPkgs.${pkgs.system}.makeWrapper pkgs.zsh { 242 + runtimeInputs = with pkgs; [ 243 + tmux 244 + fzf 245 + direnv 246 + atuin 247 + nix-index 248 + self.packages.${pkgs.system}.name-generator 249 + ]; 250 + env = { 251 + ZDOTDIR = pkgs.writeTextDir "/.zshrc" zshrc; 252 + }; 253 + }).overrideAttrs 254 + (old: { 255 + passthru = (old.passthru or { }) // { 256 + inherit zshrc; 257 + }; 258 + }); 264 259 }; 265 260 }