Packaging shell scripts

Hi!

I’d love to package GitHub - mkropat/jumpapp: A run-or-raise application switcher for any X11 desktop 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?

3 Likes

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
2 Likes

Thanks! Send a PR: jumpapp: init at 1.0 by matklad · Pull Request #57893 · NixOS/nixpkgs · GitHub

Thank you for packaging! Google has this page as kind of first hit, thus I link the package here: NixOS Search

Maybe @matklad you have time to update. It seems that -N is missing in the options of NixOs’ jumpapp, whereas available in the public documentation.

I’ve stopped using jumpapp myself as since then KDE plasma gained this functionality built-in (if you pin an app, you get a shortcut to jump to it).

Updating the package in nixpkgs should be hard though — if you use jumpapp, sending a PR might be the easiest option to get the latest version.

1 Like