From 88721031e68f379b778cf54768ec69ff2978a0d5 Mon Sep 17 00:00:00 2001 From: Ilya Savitsky Date: Wed, 26 Nov 2025 16:15:58 +0000 Subject: [PATCH] fix: fix the nix module `try` installed with the home manager module failed because it references /usr/bin/ruby which is absent on nixos. This fix removes the calls to ruby that broke nixos installations, as well as patching the shebang at the beginning --- flake.nix | 9 +++++---- try.rb | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index 81bf2e1..78a7b1e 100644 --- a/flake.nix +++ b/flake.nix @@ -69,15 +69,16 @@ version = "0.1.0"; src = inputs.self; - nativeBuildInputs = [ pkgs.makeBinaryWrapper ]; + + postPatch = '' + substituteInPlace try.rb \ + --replace-fail '#!/usr/bin/env ruby' '#!${ruby}/bin/ruby' + ''; installPhase = '' mkdir -p $out/bin cp try.rb $out/bin/try chmod +x $out/bin/try - - wrapProgram $out/bin/try \ - --prefix PATH : ${ruby}/bin ''; meta = with pkgs.lib; { diff --git a/try.rb b/try.rb index 4aedf58..fcc9d94 100755 --- a/try.rb +++ b/try.rb @@ -1118,7 +1118,7 @@ def cmd_init!(args, tries_path) bash_or_zsh_script = <<~SHELL try() { local out - out=$(/usr/bin/env ruby '#{script_path}' exec#{path_arg} "$@" 2>/dev/tty) + out=$('#{script_path}' exec#{path_arg} "$@" 2>/dev/tty) if [ $? -eq 0 ]; then eval "$out" else @@ -1129,7 +1129,7 @@ def cmd_init!(args, tries_path) fish_script = <<~SHELL function try - set -l out (/usr/bin/env ruby '#{script_path}' exec#{path_arg} $argv 2>/dev/tty | string collect) + set -l out ('#{script_path}' exec#{path_arg} $argv 2>/dev/tty | string collect) if test $status -eq 0 eval $out else