From 14c4b916bae4218cffd45328a3345e0e43e6974f Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Sat, 29 Aug 2015 21:11:08 +0000 Subject: [PATCH 1/2] Add more languages --- nix-script.hs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/nix-script.hs b/nix-script.hs index 767cbba..b30e71e 100755 --- a/nix-script.hs +++ b/nix-script.hs @@ -25,14 +25,14 @@ import qualified Data.Text as Text -- | Information about a languages data LangDef = LangDef - { name :: String -- ^ Name of this language + { name :: String -- ^ Name of this language , deps :: [Text] -> [Text] -- ^ Convert langunage-specific dependencies to nix packages , run :: FilePath -> (String, [String]) -- ^ Command to run the given file as script , repl :: FilePath -> (String, [String]) -- ^ Command to load the given file in an interpreter } languages :: [LangDef] -languages = [haskell, shell] +languages = [haskell, python, javascript, perl, shell] haskell :: LangDef haskell = LangDef "haskell" d r i where @@ -41,6 +41,27 @@ haskell = LangDef "haskell" d r i where r script = ("runhaskell" , [script]) i script = ("ghci" , [script]) +python :: LangDef +python = LangDef "python" d r i where + d pkgs = return $ + Text.unwords (map ("pythonPackages." <>) pkgs) + r script = ("python" , [script]) + i script = ("python" , ["-i", script]) + +javascript :: LangDef +javascript = LangDef "javascript" d r i where + d pkgs = return $ + Text.unwords (map ("nodePackages." <>) pkgs) + r script = ("node" , [script]) + i script = ("node" , []) + +perl :: LangDef +perl = LangDef "perl" d r i where + d pkgs = return $ + Text.unwords (map ("perlPackages." <>) pkgs) + r script = ("perl" , [script]) + i script = ("perl" , ["-d", script]) + shell :: LangDef shell = LangDef "shell" (extraPackages ++) r i where r script = ("bash", [script]) From 2ca72ad03dfad8ede47b22229d2d97203925f7e9 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Sun, 30 Aug 2015 14:01:30 +0000 Subject: [PATCH 2/2] Fix dependecies definitions --- nix-script.hs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/nix-script.hs b/nix-script.hs index b30e71e..3bf3afd 100755 --- a/nix-script.hs +++ b/nix-script.hs @@ -43,22 +43,19 @@ haskell = LangDef "haskell" d r i where python :: LangDef python = LangDef "python" d r i where - d pkgs = return $ - Text.unwords (map ("pythonPackages." <>) pkgs) + d pkgs = "python" : map ("pythonPackages." <>) pkgs r script = ("python" , [script]) i script = ("python" , ["-i", script]) javascript :: LangDef javascript = LangDef "javascript" d r i where - d pkgs = return $ - Text.unwords (map ("nodePackages." <>) pkgs) + d pkgs = "node" : map ("nodePackages." <>) pkgs r script = ("node" , [script]) i script = ("node" , []) perl :: LangDef perl = LangDef "perl" d r i where - d pkgs = return $ - Text.unwords (map ("perlPackages." <>) pkgs) + d pkgs = "perl" : map ("perlPackages." <>) pkgs r script = ("perl" , [script]) i script = ("perl" , ["-d", script])