Skip to content

Instantly share code, notes, and snippets.

@Profpatsch
Last active September 19, 2019 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Profpatsch/8e169b4e384d865bd32ef68496f582d2 to your computer and use it in GitHub Desktop.
Save Profpatsch/8e169b4e384d865bd32ef68496f582d2 to your computer and use it in GitHub Desktop.
let
execlineb-with-builtins =
let eldir = "${pkgs.execline}/bin";
in pkgs.writeScriptBin "execlineb" ''
#!${eldir}/execlineb -s0
# appends the execlineb bin dir to PATH if not yet in PATH
${eldir}/define eldir ${eldir}
''${eldir}/ifelse
{
# since this is nix, we can grep for the execline drv hash in PATH
# to see whether it’s already in there
''${eldir}/pipeline
{ ${pkgs.coreutils}/bin/printenv PATH }
${pkgs.gnugrep}/bin/grep --quiet "${eldir}"
}
# it’s there already
{ ''${eldir}/execlineb $@ }
# not there yet, add it
''${eldir}/importas oldpath PATH
''${eldir}/export PATH "''${eldir}:''${oldpath}"
''${eldir}/execlineb $@
'';
in {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment