Commit e2aafd1a authored by Valentin Reis's avatar Valentin Reis

Adding argonix draft.

parent 37ab60ff
Pipeline #5102 passed with stage
in 13 seconds
#! /usr/bin/env nix-shell
#! nix-shell default.nix -i runhaskell -A executor
{-# language RecordWildCards #-}
{-# language TupleSections #-}
{-# language ApplicativeDo #-}
{-# language OverloadedStrings #-}
module Argotest where
import Data.Default
import Turtle hiding ( header )
import Options.Applicative
import Data.Maybe
import Prelude hiding ( FilePath )
import System.IO ( withFile )
import Debug.Trace
import Filesystem.Path ( (</>) )
import Control.Concurrent.Async
import System.Console.ANSI
import System.Console.ANSI.Types ( Color )
import System.Posix.Signals
import System.Posix.Process
data StackArgs = StackArgs
{ verbosity :: Verbosity
, targetMachine :: Maybe FilePath
, run :: Maybe FilePath
, overrides :: [(String, FilePath)]
} deriving (Show)
data Verbosity = Verbose | Normal deriving (Show)
instance Default StackArgs where
def = StackArgs
{ verbosity = Normal,
run = Nothing,
targetMachine = Nothing,
overrides = []
}
executorParser :: Parser StackArgs
executorParser = do
verbosity <- flag
Normal
Verbose
(long "verbose" <> short 'v' <> help "Enable verbose mode")
targetMachine <- optional $ strOption
(long "target_machine" <> metavar "USER@HOST" <> help
"Target machine to run on"
)
overrides <- catMaybes <$> truc
run <- optional $ strOption
(long "run" <> metavar "COMMAND" <> help
"Command to run once in the environment"
)
pure StackArgs {..}
where
truc :: Parser [Maybe (String, FilePath)]
truc = traverse optSrc [ "argotk", "argopkgs", "nrm", "containers", "libnrm", "amg", "lammps", "qmcpack", "stream" ]
optSrc :: String -> Parser (Maybe (String, FilePath))
optSrc l = do
parsed <- optional $ strOption (long l <> metavar "PATH" <> help (l <> " source folder override."))
pure $ mapT l parsed
mapT :: String -> Maybe FilePath -> Maybe (String, FilePath)
mapT l thePath = case thePath of
Nothing -> Nothing
Just p -> Just (l,p)
main :: IO ()
main = sh $ do
a@StackArgs {..} <- liftIO $ execParser opts
let arguments = ["-A", "test"]
liftIO $ executeFile "nix-shell" True (["-A", "test"] ++ (concat [ ["--arg", (l <> "-src") , encodeString p] | (l,p) <- overrides])) Nothing
where
opts = info
(executorParser <**> helper)
(fullDesc <> progDesc "Test environment builder for argo. This is a lightweight wrapper around various nix commands." <> header
"argonix"
)
......@@ -13,7 +13,19 @@ in
stream-src ? argopkgs.applications.nrm.stream.src,
dgemm_randomwalk-src ? argopkgs.applications.nrm.dgemm_randomwalk.src,
}:
rec {
let
devInputs = with argopkgs.haskellPackages; with argopkgs; [
sysstat jq
];
devHPackages = with argopkgs.haskellPackages; [
hdevtools hlint brittany ghcid
];
addHackEnv = package : package.overrideAttrs (old: {
buildInputs = old.buildInputs ++ devInputs ++ devHPackages;
});
in rec {
argotk = argopkgs.argotk.overrideAttrs (old: {src = argotk-src;} );
nrm = argopkgs.nodelevel.nrm.overrideAttrs (old: {src = nrm-src;} );
libnrm = argopkgs.nodelevel.libnrm.overrideAttrs (old: {src = libnrm-src;} );
......@@ -54,7 +66,7 @@ in
}
);
preCommit = argopkgs.mkShell {
preCommit = addHackEnv ( argopkgs.mkShell {
name = "shake";
buildInputs = [
(argopkgs.haskellPackages.ghcWithPackages (p: with p; [
......@@ -62,15 +74,17 @@ in
(argopkgs.haskell.lib.doJailbreak panpipe)
]))
];
};
});
remoteShellExecutor = argopkgs.mkShell {
executor = argopkgs.mkShell {
name = "shake";
buildInputs = [
(argopkgs.haskellPackages.ghcWithPackages (p: with p; [
argotk
turtle data-default optparse-generic
turtle data-default optparse-generic unix
]))
];
};
executor-hack = addHackEnv executor;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment