diff --git a/README.md b/README.md index db794fc..2c1b3eb 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Usage To use `nix-script`, you need to add a header to your file. Here is an example for a haskell file `example.hs`: ```haskell -#!nix-script +#!/usr/bin/env nix-script #!> haskell #! haskell | text lens optparse-applicative #! shell | nix nix-prefetch-scripts diff --git a/example.hs b/example.hs new file mode 100755 index 0000000..a2a06bd --- /dev/null +++ b/example.hs @@ -0,0 +1,8 @@ +#!/usr/bin/env nix-script +#!> haskell +#! haskell | text lens optparse-applicative +#! shell | nix nix-prefetch-scripts + +main :: IO () +main = do + putStrLn "It works!" diff --git a/nix-script.hs b/nix-script.hs old mode 100644 new mode 100755 index 8b8e4f9..767cbba --- a/nix-script.hs +++ b/nix-script.hs @@ -1,4 +1,4 @@ -#!nix-bang +#!/usr/bin/env nix-script #!> haskell #! haskell | text lens #! shell | nix @@ -37,8 +37,7 @@ languages = [haskell, shell] haskell :: LangDef haskell = LangDef "haskell" d r i where d pkgs = return $ - "haskellPackages.ghcWithPackages (hs: with hs; [" <> Text.unwords (map mkPkg pkgs) <> "])" - mkPkg = Text.concat . over (_tail.mapped._head) toUpper . Text.splitOn "-" + "haskellPackages.ghcWithPackages (hs: with hs; [" <> Text.unwords pkgs <> "])" r script = ("runhaskell" , [script]) i script = ("ghci" , [script])