Commit 8d77c521 authored by Valentin Reis's avatar Valentin Reis

Initial commit

parents
Pipeline #5105 passed with stage
in 1 minute and 17 seconds
### `argonix`
This is a test environment manager/remote deployment tool for Argo. It provides
a documented way to use various nix tools. It should be provisioned using
[argopkgs](https://xgitlab.cels.anl.gov/argo/argopkgs).
#### Usage
```{.bash}
argonix --help
```
Output:
```{.txt pipe="sh"}
argonix --help
```
### Hacking
- see `default.nix`
- edit `.README.md` in place of README.md and run ./shake.hs as a pre-commit hook.
eJzsPGlv4zqSf8UQZj9NZOs-snjAOrGTeDqxPbbT6W4sIFA3dVAyKeta7H9fUJIdX0mnk36YmZ08oLvlukgWWcUiq_j-hxkumEsGYOaCGS6Mm9nCWA0Xt-PVDrikX6T5OkJT4NVi9rQcUxHrzGQumOtr5pLxLKv5PKTvoLP72eLm9uqWuWRsxwWbKPvP7t8tdjVePDCXDC7zjC3TuAFPbya3xvJufH_PXDIDBMsByRLsDLCkpnJal7IQi0iUcttbp6GM87UXc7EgxawJiM9KfYlNBXFgQjSgACry2zfap7_-tf0-6moDHl09Lo3leLmczKYG_R6ORovxkipkg2B5CUySYWBlfwyyOB3Y5oawX_28ulIfrmf-hbeB9h-uxruCoumqaGmOzskmsDXd0XXZkl1OEQBtZbz8sprNtw0xl0yZOTj-axknCNg32KE0k8V4-tV4Gq6u78a0fedvJakxPyvq4d-Hsytxs0LrmXszV_GknuBxcEUcFlQiuB3FMf6-kGwDTG6MgMtdY_jEFt-ehsNcX4Jk5V4tBNZlb35MPXPmKNHScX7cb8Sr4Uzjs_p-9TT8kS8f4LjyHrT5hDi67isOb7qJbRQ3s3Usf6_l7G_hRphp3zZkRIy7K6LDxfS7pM2e5nq1Jvx99AV-Wfl3Gx8_zb5Ol3dqMX6ERJNX8Reu_pZ8t2b1Dyuvv7vz8qYYDg2DlTaP36fNuJfz--F35pK55JgLZjyarGZ0reX0x8NwQheDi53_crGzKfsuXa-3o4fXNHk7fjDmw9Xd4SrSdMXPoxiTtMYlVxOUliIqU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iy2vHRbVeG9pOVRwWWtveTbu6ozndxh365ex1J17XRcDXcdezZJBGn5qUdCdBPEVBB7eLIrnggSJqwFgFXs1GUpmwMYwekaVdNdHmmsrRDvDI5b5mWVyfkp1PRjfR2MR6vxovdiLfllW1xqedndszaIANdMpKyLB6nq8nDLnd3bGyUZDkeNvuLA7J90G6dJtijAh3bIWGWpIMRJGkEqgeAgOfgwfKAr32v2j0rPfsIcp-uMT3-CPjmdgmBCTpuevV9Tj1CyW_Ffl1N6dBV5oIxDleIVAVrYvkur6V1aaYgtART0TQSEh3ovBezNsQOylmhz6t9bnvUHbRQKu40p_mZivzMj3ymIj9TkZ-m9v_c1D5TkZ-pyM9U5Gcq8h-zf9Hg0xivrp9LFGfTbUFhi_ixvBtPvxrtPd9oh5pOvs2WxnK8MsbTr5PFbPownq72uc0NjOwJSjcZYS6ZXq_3Lp_3ca53ecnehzxk78POpPdRR9L7kBPpvduB9N7rPHrvtd3eh-y2906b3S5wB_-m_5HTtvDeuYmARy2GuWBsJyVXtJXmr3OwOU5S4IHMOcauAPac7CzwHM9dQjL65xRyjrqVc9zEPvSEK7n2HSvc_pi0q30P1q3_uQ-Iw1wyjuUnvb8gkMHcuXp2JL2_7HmV3n9vOE50en9JNhlzwSAQU85X3xI1ZEcyf8-x-x_kp5gLho7-cAl-6LlVK7FTTKvZlE4K_XkwSRdMupvkQ3UeoKZn9M1cME37v8l0SGY7KD8UpqfQBakqp6GpQze21z4H6dHRs8S1qBGFbZnY5gFlIwNDKxs56bZ_zb0ac8m0Dy47uv_9vwAAAP__WNx9LQ==
use_nix
.argo_nodeos_config_exit_message
dist
_output
result
.shake
*.log
*/build
*/new-build
*/dist
*/new-dist
*/result
_output
*/_output
stages:
- build
argonix.build:
stage: build
script:
- nix-build -A argonix
tags:
- integration
# ~/.tmuxinator/sample.yml
name: argonix
#root: ./.
windows:
- editor:
layout: even-horizontal
panes:
-
- ghcid
- git:
layout: even-horizontal
panes:
- trackit -t . -c "git log --graph --all --color --oneline --decorate"
- trackit -t . -c "git status"
Copyright (c) 2018 Valentin Reis
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
### `argonix`
This is a test environment manager/remote deployment tool for Argo. It
provides a documented way to use various nix tools. It should be
provisioned using
[argopkgs](https://xgitlab.cels.anl.gov/argo/argopkgs).
#### Usage
``` {.bash}
argonix --help
```
Output:
``` {.txt}
argonix
Usage: argonix [-v|--verbose] [--target_machine USER@HOST] [--argotk PATH]
[--argopkgs PATH] [--nrm PATH] [--containers PATH]
[--libnrm PATH] [--amg PATH] [--lammps PATH] [--qmcpack PATH]
[--stream PATH] [--run COMMAND]
Argo test environment manager. This uses various nix tools to provision a
local or remote environment with source overrides.
Available options:
-v,--verbose Enable verbose mode
--target_machine USER@HOST
Target machine. defaults to localhost via forking.
--argotk PATH argotk source folder override.
--argopkgs PATH argopkgs source folder override.
--nrm PATH nrm source folder override.
--containers PATH containers source folder override.
--libnrm PATH libnrm source folder override.
--amg PATH amg source folder override.
--lammps PATH lammps source folder override.
--qmcpack PATH qmcpack source folder override.
--stream PATH stream source folder override.
--run COMMAND Command to run the environment instead of an
interactive shell
-h,--help Show this help text
```
### Hacking
- see `default.nix`
- edit `.README.md` in place of README.md and run ./shake.hs as a
pre-commit hook.
name: argonix
version: 0.1.0.0
license: MIT
license-file: LICENSE
author: Valentin Reis
maintainer: fre@freux.fr
build-type: Simple
extra-source-files: ChangeLog.md
cabal-version: >=1.10
executable argonix
main-is: argonix.hs
build-depends:
base,
turtle,
data-default,
optparse-applicative,
unix,
text,
system-filepath
hs-source-dirs: src
default-language: Haskell2010
ghc-options:
-threaded
-Wall
-Wincomplete-uni-patterns
-Wincomplete-record-updates
-Wmissing-home-modules
-Widentities
-Wredundant-constraints
-Wcpp-undef
-fwarn-tabs
-fwarn-unused-imports
-fwarn-missing-signatures
-fwarn-name-shadowing
-fprint-potential-instances
-Wmissing-export-list
-fwarn-incomplete-patterns
{
"fetch": {
"args": {
"fetchSubmodules": false,
"rev": "cf88d28ef7ee77956b87e0edc587f3ca96a8b4a7",
"sha256": "0gvr8nxppyddjzwbwww3gz09f224h1s1cnxidacbi1mhr4x7l4l6",
"url": "https://xgitlab.cels.anl.gov/argo/argopkgs.git"
},
"fn": "fetchgit"
},
"rev": "refs/heads/master",
"type": "fetchgit",
"url": "https://xgitlab.cels.anl.gov/argo/argopkgs.git"
}
\ No newline at end of file
{
hostPkgs ? import <nixpkgs> {},
pkgs ? import (hostPkgs.nix-update-source.fetch ./argopkgs.json).src {},
}:
let
filterHdevTools = builtins.filterSource (path: type: baseNameOf path != ".hdevtools.sock");
hpkgs = pkgs.haskellPackages.override {
overrides = self: super: rec {
argonix = self.callCabal2nix "argonix" (filterHdevTools ./.) {};
};
};
devHPackages = with hpkgs; [
pkgs.tmuxinator
cabal-install
apply-refact
hdevtools
hindent
hlint
shake
brittany
ghcid
];
in rec
{
argonix = hpkgs.argonix.overrideAttrs (old:{
installPhase = old.installPhase + ''
mkdir $out/share/
MANIFESTS=/tmp $out/bin/argonix --bash-completion-script argonix > $out/share/argonix.sh
'';
});
hack = hpkgs.shellFor {
packages = p: with p; [ argonix ];
withHoogle = true;
buildInputs = devHPackages;
};
preCommit = pkgs.mkShell {
name = "shake";
MANIFESTS = "/tmp";
buildInputs = [
(pkgs.haskellPackages.ghcWithPackages (p: with p; [
argonix
shake
(pkgs.haskell.lib.doJailbreak panpipe)
]))
];
};
}
#! /usr/bin/env nix-shell
#! nix-shell default.nix -i runhaskell -A preCommit
import Development.Shake
import Development.Shake.FilePath
import Control.Monad
main = shakeArgs shakeOptions $ do
phony "clean" $ do
removeFilesAfter "." ["README.md"]
want ["README.md"]
"README.md" %> \out -> do
let template = ".README.md"
need [template , "src/argonix.hs" ]
(Stdout panpipe) <- cmd "which panpipe"
cmd_ "pandoc --filter"
[take (length panpipe - 1) panpipe, template, "-o", out]
(import ./default.nix {}).hack
{-# language RecordWildCards #-}
{-# language ApplicativeDo #-}
{-# language OverloadedStrings #-}
module Main where
import Data.Default
import Turtle hiding ( header
, arguments
)
import Options.Applicative
import Data.Maybe
import Prelude hiding ( FilePath )
import Data.Text ( pack )
import System.Posix.Process
data StackArgs = StackArgs
{ verbosity :: Verbosity
, targetMachine :: Maybe String
, run :: Maybe String
, 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. defaults to localhost via forking."
)
overrides <- catMaybes <$> truc
run <- optional $ strOption
(long "run" <> metavar "COMMAND" <> help
"Command to run the environment instead of an interactive shell"
)
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 longform = do
parsed <- optional $ strOption
(long longform <> metavar "PATH" <> help
(longform <> " source folder override.")
)
pure $ mapT longform parsed
mapT :: String -> Maybe FilePath -> Maybe (String, FilePath)
mapT longform thePath = case thePath of
Nothing -> Nothing
Just p -> Just (longform, p)
main :: IO ()
main = sh $ do
a@StackArgs {..} <- liftIO $ execParser opts
let arguments = argumentsBuilder a
case targetMachine of
Nothing -> liftIO $ executeFile "nix-shell" True arguments Nothing
Just host -> do
printf s "argonix.hs: creating a derivation in the local store:\n"
drv <- single $ inproc
"nix-instantiate"
(["default.nix", "--quiet"] ++ map pack arguments)
empty
printf (s % "\n") $ lineToText drv
printf s "argonix.hs: building the derivation's output:\n"
proc "nix-store" ["--realize", lineToText drv, "--quiet"] empty
printf s "argonix.hs: copying the derivation's closure.\n"
proc "nix-copy-closure"
["--include-outputs", "--to", pack host, lineToText drv]
empty
liftIO $ executeFile
"ssh"
True
["-t", host, "source .profile; source .bash_profile; nix-shell $drv"]
Nothing
where
argumentsBuilder :: StackArgs -> [String]
argumentsBuilder StackArgs {..} =
["-A", "test"]
++ concat
[ ["--arg", longform <> "-src", encodeString p]
| (longform, p) <- overrides
]
++ (case run of
Just cmd -> ["--run", cmd]
Nothing -> []
)
opts = info
(executorParser <**> helper)
( fullDesc
<> progDesc
"Argo test environment manager. This uses various nix tools to provision a local or remote environment with source overrides."
<> header "argonix"
)
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