prefix aliases for pijul: pj cl https://nest.pijul.com/jorsn/pj
{ pkgs ? import <nixpkgs> {} }:

pkgs.lib.flip pkgs.callPackage {} (

  { lib, stdenv, writeShellScript, runtimeShell
  , coreutils, gnused
  , pijul
  }:

  stdenv.mkDerivation {
    pname = "pj";
    version = lib.fileContents ./version;

    src = builtins.filterSource (path: type: baseNameOf path == "pj") ./.;

    builder = pkgs.writeShellScript "pj-builder" ''
      PATH=${coreutils}/bin:$PATH
      mkdir -p $out/bin
      echo '#!${runtimeShell}' > $out/bin/pj
      echo 'export PATH=${lib.makeBinPath [ coreutils gnused pijul ]}''${PATH:+:}$PATH' >> $out/bin/pj
      cat $src/pj >> $out/bin/pj
      chmod 555 $out/bin/pj
    '';

    meta = with lib; {
      description = "prefix aliases for pijul";
      homepage = "https://nest.pijul.org/jorsn/pj";
      license = licenses.gpl2Plus;
      platforms = pijul.meta.platforms;
      maintainers = [ maintainers.jorsn ];
    };
  }

)