Packaging shell scripts

#1

Hi!

I’d love to package https://github.com/mkropat/jumpapp for NixOS, which is a simple bash script which relies on a single external utility, wmctrl. What is the nix was to handle this? Should I use makeWrapper or should I try to patch the source code of the script with the correct executable? Are there some nice examples I can use?

0 Likes

#2

I’d vote for patching. But looks like in this case patching is easy:

let
  pkgs = import <nixpkgs> {};
in pkgs.runCommand "jumpapp" {
    buildInputs = with pkgs; [ xdotool wmctrl xorg.xprop nettools ];
} ''
  mkdir -p $out/bin
  cp ${./jumpapp} $out/bin/jumpapp
  sed -i "2 i export PATH=$PATH" $out/bin/jumpapp
''

So running jumpapp script is exactly the same, what you get when running in nix-shell --pure. You can make it less pure (and reduce closure size) with following patch:

  sed -i "2 i export PATH=$_PATH:\$PATH" $out/bin/jumpapp
1 Like

#3

Thanks! Send a PR: https://github.com/NixOS/nixpkgs/pull/57893

0 Likes