mirror of
https://github.com/bennofs/nix-script
synced 2025-01-10 12:54:20 +01:00
Fix deps in passthrough mode
This commit is contained in:
parent
2ca72ad03d
commit
ff48133d0f
@ -23,7 +23,8 @@ import Data.Monoid
|
|||||||
|
|
||||||
import qualified Data.Text as Text
|
import qualified Data.Text as Text
|
||||||
|
|
||||||
-- | Information about a languages
|
|
||||||
|
-- | Information about a language
|
||||||
data LangDef = LangDef
|
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
|
, deps :: [Text] -> [Text] -- ^ Convert langunage-specific dependencies to nix packages
|
||||||
@ -31,12 +32,17 @@ data LangDef = LangDef
|
|||||||
, repl :: FilePath -> (String, [String]) -- ^ Command to load the given file in an interpreter
|
, repl :: FilePath -> (String, [String]) -- ^ Command to load the given file in an interpreter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
basePackages :: [Text]
|
||||||
|
basePackages = ["coreutils", "utillinux"]
|
||||||
|
|
||||||
|
|
||||||
languages :: [LangDef]
|
languages :: [LangDef]
|
||||||
languages = [haskell, python, javascript, perl, shell]
|
languages = [haskell, python, javascript, perl, shell]
|
||||||
|
|
||||||
haskell :: LangDef
|
haskell :: LangDef
|
||||||
haskell = LangDef "haskell" d r i where
|
haskell = LangDef "haskell" d r i where
|
||||||
d pkgs = return $
|
d pkgs = pure $
|
||||||
"haskellPackages.ghcWithPackages (hs: with hs; [" <> Text.unwords pkgs <> "])"
|
"haskellPackages.ghcWithPackages (hs: with hs; [" <> Text.unwords pkgs <> "])"
|
||||||
r script = ("runhaskell" , [script])
|
r script = ("runhaskell" , [script])
|
||||||
i script = ("ghci" , [script])
|
i script = ("ghci" , [script])
|
||||||
@ -60,15 +66,22 @@ perl = LangDef "perl" d r i where
|
|||||||
i script = ("perl" , ["-d", script])
|
i script = ("perl" , ["-d", script])
|
||||||
|
|
||||||
shell :: LangDef
|
shell :: LangDef
|
||||||
shell = LangDef "shell" (extraPackages ++) r i where
|
shell = LangDef "shell" d r i where
|
||||||
|
d = mappend ("bash" : basePackages)
|
||||||
r script = ("bash", [script])
|
r script = ("bash", [script])
|
||||||
i _ = ("bash", [])
|
i _ = ("bash", [])
|
||||||
extraPackages = ["bash", "coreutils", "utillinux", "gitAndTools.hub", "git"]
|
|
||||||
|
passthrough :: String -> LangDef
|
||||||
|
passthrough name = LangDef name d r i where
|
||||||
|
d = mappend basePackages
|
||||||
|
r script = (name, [script])
|
||||||
|
i _ = (name, [])
|
||||||
|
|
||||||
|
|
||||||
lookupLangDef :: String -> IO LangDef
|
lookupLangDef :: String -> IO LangDef
|
||||||
lookupLangDef n
|
lookupLangDef n
|
||||||
| Just def <- find ((n ==) . name) languages = return def
|
| Just def <- find ((n ==) . name) languages = return def
|
||||||
| otherwise = fail $ "Unknown language: " ++ n
|
| otherwise = return (passthrough n)
|
||||||
|
|
||||||
makeDeps :: String -> [String] -> IO [String]
|
makeDeps :: String -> [String] -> IO [String]
|
||||||
makeDeps lang ds = lookupLangDef lang <&> \def ->
|
makeDeps lang ds = lookupLangDef lang <&> \def ->
|
||||||
|
Loading…
Reference in New Issue
Block a user