mirror of
https://github.com/bennofs/nix-script
synced 2025-01-10 04:44:21 +01:00
fixes for haskellng + add example
This commit is contained in:
parent
45f2a37b67
commit
d28f2a06ea
@ -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`:
|
To use `nix-script`, you need to add a header to your file. Here is an example for a haskell file `example.hs`:
|
||||||
|
|
||||||
```haskell
|
```haskell
|
||||||
#!nix-script
|
#!/usr/bin/env nix-script
|
||||||
#!> haskell
|
#!> haskell
|
||||||
#! haskell | text lens optparse-applicative
|
#! haskell | text lens optparse-applicative
|
||||||
#! shell | nix nix-prefetch-scripts
|
#! shell | nix nix-prefetch-scripts
|
||||||
|
8
example.hs
Executable file
8
example.hs
Executable file
@ -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!"
|
5
nix-script.hs
Normal file → Executable file
5
nix-script.hs
Normal file → Executable file
@ -1,4 +1,4 @@
|
|||||||
#!nix-bang
|
#!/usr/bin/env nix-script
|
||||||
#!> haskell
|
#!> haskell
|
||||||
#! haskell | text lens
|
#! haskell | text lens
|
||||||
#! shell | nix
|
#! shell | nix
|
||||||
@ -37,8 +37,7 @@ languages = [haskell, shell]
|
|||||||
haskell :: LangDef
|
haskell :: LangDef
|
||||||
haskell = LangDef "haskell" d r i where
|
haskell = LangDef "haskell" d r i where
|
||||||
d pkgs = return $
|
d pkgs = return $
|
||||||
"haskellPackages.ghcWithPackages (hs: with hs; [" <> Text.unwords (map mkPkg pkgs) <> "])"
|
"haskellPackages.ghcWithPackages (hs: with hs; [" <> Text.unwords pkgs <> "])"
|
||||||
mkPkg = Text.concat . over (_tail.mapped._head) toUpper . Text.splitOn "-"
|
|
||||||
r script = ("runhaskell" , [script])
|
r script = ("runhaskell" , [script])
|
||||||
i script = ("ghci" , [script])
|
i script = ("ghci" , [script])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user