mirror of
https://github.com/bennofs/nix-script
synced 2025-01-09 20:34:20 +01:00
Add shell mode with nix-scripts
This commit is contained in:
parent
b28f58eeee
commit
c631038ee0
@ -5,7 +5,10 @@ pkgs.stdenv.mkDerivation {
|
||||
src = ./nix-script.hs;
|
||||
phases = [ "buildPhase" "installPhase" "fixupPhase" ];
|
||||
buildPhase = ''mkdir -p $out/bin; ghc -O2 $src -o $out/bin/nix-script -odir $TMP'';
|
||||
installPhase = ''ln -s $out/bin/nix-script $out/bin/nix-scripti'';
|
||||
installPhase = ''
|
||||
ln -s $out/bin/nix-script $out/bin/nix-scripti
|
||||
ln -s $out/bin/nix-script $out/bin/nix-scripts
|
||||
'';
|
||||
buildInputs = [ (pkgs.haskellPackages.ghcWithPackages (hs: with hs; [posix-escape])) ];
|
||||
meta = {
|
||||
homepage = https://github.com/bennofs/nix-script;
|
||||
|
@ -146,9 +146,12 @@ main = do
|
||||
pkgs = concatMap parseHeader deps
|
||||
language = dropWhile isSpace identifier
|
||||
interactive = last progName == 'i'
|
||||
shell = last progName == 's'
|
||||
interpreter = makeInter language interactive file
|
||||
|
||||
cmd <- makeCmd interpreter args <$> makeEnv env
|
||||
callProcess "nix-shell" ("--pure" : "--command" : cmd : "-p" : pkgs)
|
||||
if shell
|
||||
then callProcess "nix-shell" ("-p" : pkgs)
|
||||
else callProcess "nix-shell" ("--pure" : "--run" : cmd : "-p" : pkgs)
|
||||
|
||||
_ -> fail "missing or invalid header"
|
Loading…
Reference in New Issue
Block a user