Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
argo
argonix
Commits
d25ab860
Commit
d25ab860
authored
Feb 16, 2019
by
Valentin Reis
Browse files
Argonix typo/style fixes.
parent
80723214
Pipeline
#5335
passed with stage
in 18 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/Argonix.hs
View file @
d25ab860
...
...
@@ -183,11 +183,12 @@ setupNodeOS sa = do
empty
export
"XDG_CACHE_HOME"
$
lineToText
cachedir
nodeos_config
<-
single
$
inproc
"nix-build"
(
fmap
pack
(
nixArguments
"containers"
sa
))
empty
printf
s
"
Will copy built argo_nodeos_config to /tmp/.
Checking filesystem attributes
.
"
printf
s
"Checking filesystem attributes
in /tmp
\n
"
checkFsAttributes
"/tmp"
printf
s
"Copying argo_nodeos_config."
shell
(
format
(
"cp "
%
s
%
" /tmp/argo_nodeos_config"
)
(
lineToText
nodeos_config
))
empty
printf
s
"Trying to sudo chown and chmod argo_nodeos_config"
printf
s
"Copying argo_nodeos_config to /tmp
\n
"
shell
"sudo rm -rf /tmp/argo_nodeos_config"
empty
shell
(
format
(
"cp "
%
s
%
"/bin/argo_nodeos_config /tmp/argo_nodeos_config"
)
(
lineToText
nodeos_config
))
empty
printf
s
"Trying to sudo chown and chmod argo_nodeos_config
\n
"
shell
"sudo chown root:root /tmp/argo_nodeos_config"
empty
>>=
\
case
ExitSuccess
->
printf
s
"Chowned argo_nodeos_config to root:root.
\n
"
...
...
@@ -207,6 +208,7 @@ nixArguments target StackArgs {..} = [unpack argopkgs, "-A", target] ++ concat
nixbuild
::
String
->
StackArgs
->
IO
()
nixbuild
target
sa
@
StackArgs
{
..
}
=
sh
$
do
view
$
single
$
inshell
"echo $SUDO"
empty
setupNodeOS
sa
let
arglist
=
(
(
nixArguments
target
sa
)
++
[
"--pure"
...
...
@@ -221,107 +223,107 @@ nixbuild target sa@StackArgs {..} = sh $ do
liftIO
$
executeFile
"nix-build"
True
arglist
Nothing
nixshell
::
IO
()
nixshell
=
sh
$
do
StackArgs
{
..
}
<-
liftIO
$
execParser
opts
nixshell
=
sh
$
do
undefined
{-
StackArgs {..} <- liftIO $ execParser opts
-}
-- building nixArguments (pure stuff) and shellArguments (impure stuff)
let
nixArguments
=
[
"-A"
,
if
enableApps
then
"expe"
else
"test"
]
++
concat
[
[
"--arg"
,
longform
<>
"-src"
,
encodeString
p
]
|
(
longform
,
p
)
<-
overrides
]
sudo
<-
which
"sudo"
>>=
\
case
(
Just
sudo
)
->
printf
(
"Found sudo at "
%
fp
%
"
\n
"
)
sudo
>>
return
sudo
Nothing
->
die
"sudo not in $PATH."
export
"SUDO"
$
pack
$
encodeString
sudo
let
shellArguments
=
[
unpack
argopkgs
]
++
[
"--keep"
,
"SUDO"
,
"--pure"
,
"--allow-new-privileges"
,
"--option"
,
"build-extra-sandbox-paths"
,
encodeString
(
directory
sudo
)
]
++
nixArguments
++
(
case
run
of
Just
cmd
->
[
"--run"
,
unpack
(
"
\"
exec "
<>
cmd
<>
"
\"
"
)]
Nothing
->
[]
)
{-
-- building nixArguments (pure stuff) and shellArguments (impure stuff)
-}
{-
let nixArguments = ["-A", if enableApps then "expe" else "test"] ++ concat
-}
{-
[ ["--arg", longform <> "-src", encodeString p]
-}
{-
| (longform, p) <- overrides
-}
{-]-}
{-
sudo <- which "sudo" >>= \case
-}
{-
(Just sudo) -> printf ("Found sudo at " % fp % "\n") sudo >> return sudo
-}
{-
Nothing -> die "sudo not in $PATH."
-}
{-
export "SUDO" $ pack $ encodeString sudo
-}
{-
let shellArguments =
-}
{-
[unpack argopkgs]
-}
{-
++ [ "--keep"
-}
{-
, "SUDO"
-}
{-
, "--pure"
-}
{-
, "--allow-new-privileges"
-}
{-
, "--option"
-}
{-
, "build-extra-sandbox-paths"
-}
{-
, encodeString (directory sudo)
-}
{-]-}
{-
++ nixArguments
-}
{-
++ (case run of
-}
{-
Just cmd -> ["--run", unpack ("\"exec " <> cmd <> "\"")]
-}
{-
Nothing -> []
-}
{-)-}
cachedir
<-
single
$
inproc
"mktemp"
[
"-d"
,
"--suffix=nixcache"
,
"/tmp/deletable-nix-cache-XXXX"
]
empty
export
"XDG_CACHE_HOME"
$
lineToText
cachedir
case
targetMachine
of
Nothing
->
do
printf
s
"Running nix-shell with the following arguments:
\n
"
liftIO
$
print
shellArguments
liftIO
$
executeFile
"nix-shell"
True
shellArguments
Nothing
Just
host
->
do
export
"NIX_SSHOPTS"
"source .profile; source .bash_profile;"
printf
s
"argonix: creating a derivation in the local store:
\n
"
{-
cachedir <- single $ inproc
-}
{-
"mktemp"
-}
{-
["-d", "--suffix=nixcache", "/tmp/deletable-nix-cache-XXXX"]
-}
{-
empty
-}
{-
export "XDG_CACHE_HOME" $ lineToText cachedir
-}
{-
case targetMachine of
-}
{-
Nothing -> do
-}
{-
printf s "Running nix-shell with the following arguments: \n"
-}
{-
liftIO $ print shellArguments
-}
{-
liftIO $ executeFile "nix-shell" True shellArguments Nothing
-}
{-
Just host -> do
-}
{-
export "NIX_SSHOPTS" "source .profile; source .bash_profile;"
-}
{-
printf s "argonix: creating a derivation in the local store:\n"
-}
drv
<-
single
$
inproc
"nix-instantiate"
([
"--quiet"
,
argopkgs
,
"-A"
,
"test"
]
++
fmap
pack
nixArguments
)
empty
{-
drv <- single $ inproc
-}
{-
"nix-instantiate"
-}
{-
(["--quiet", argopkgs, "-A", "test"] ++ fmap pack nixArguments)
-}
{-
empty
-}
printf
(
s
%
"
\n
"
)
$
lineToText
drv
{-
printf (s % "\n") $ lineToText drv
-}
if
remoteBuild
then
do
printf
s
"argonix: copying the derivation's closure (without build output).
\n
"
proc
"nix-copy-closure"
[
"--to"
,
host
,
lineToText
drv
]
empty
else
do
printf
s
"argonix: building the derivation's output:
\n
"
proc
"nix-store"
[
"--realize"
,
lineToText
drv
,
"--quiet"
]
empty
{-
if remoteBuild
-}
{-
then do
-}
{-
printf
-}
{-s-}
{-
"argonix: copying the derivation's closure (without build output).\n"
-}
{-
proc "nix-copy-closure" ["--to", host, lineToText drv] empty
-}
{-
else do
-}
{-
printf s "argonix: building the derivation's output:\n"
-}
{-
proc "nix-store" ["--realize", lineToText drv, "--quiet"] empty
-}
printf
s
"argonix: copying the derivation's closure (with build output).
\n
"
proc
"nix-copy-closure"
[
"--include-outputs"
,
"--to"
,
host
,
lineToText
drv
]
empty
{-
printf
-}
{-s-}
{-
"argonix: copying the derivation's closure (with build output).\n"
-}
{-
proc "nix-copy-closure"
-}
{-
["--include-outputs", "--to", host, lineToText drv]
-}
{-
empty
-}
case
run
of
Just
cmd
->
do
_
<-
proc
"ssh"
[
"-t"
,
host
,
"source .profile; source .bash_profile; SUDO=$(which sudo) exec nix-shell --keep SUDO --pure --allow-new-privileges --option build-extra-sandbox-paths $(which sudo | xargs dirname) "
<>
lineToText
drv
<>
" --run "
<>
"
\"
"
<>
cmd
<>
"
\"
"
]
empty
Prelude
.
mapM_
(
\
r
->
proc
"scp"
[
"-r"
,
host
<>
":"
<>
r
,
fromMaybe
"."
retreiveAs
]
empty
)
retreive
Nothing
->
liftIO
$
executeFile
"ssh"
True
[
"-t"
,
unpack
host
,
unpack
(
"source .profile; source .bash_profile; SUDO=$(which sudo) exec nix-shell --keep SUDO --pure --allow-new-privileges --option build-extra-sandbox-paths $(which sudo | xargs dirname) "
<>
lineToText
drv
)
]
Nothing
where
opts
=
info
(
executorParser
<**>
helper
)
(
fullDesc
<>
progDesc
"Argo environment provisioning/deployment/execution."
<>
header
"argonix"
)
{-
case run of
-}
{-
Just cmd -> do
-}
{-
_ <- proc
-}
{-
"ssh"
-}
{-
[ "-t"
-}
{-
, host
-}
{-
, "source .profile; source .bash_profile; SUDO=$(which sudo) exec nix-shell --keep SUDO --pure --allow-new-privileges --option build-extra-sandbox-paths $(which sudo | xargs dirname) "
-}
{-
<> lineToText drv
-}
{-
<> " --run "
-}
{-
<> "\""
-}
{-
<> cmd
-}
{-
<> "\""
-}
{-]-}
{-
empty
-}
{-
Prelude.mapM_
-}
{-
(\r -> proc "scp"
-}
{-
["-r", host <> ":" <> r, fromMaybe "." retreiveAs]
-}
{-
empty
-}
{-)-}
{-
retreive
-}
{-
Nothing -> liftIO $ executeFile
-}
{-
"ssh"
-}
{-
True
-}
{-
[ "-t"
-}
{-
, unpack host
-}
{-
, unpack
-}
{-
("source .profile; source .bash_profile; SUDO=$(which sudo) exec nix-shell --keep SUDO --pure --allow-new-privileges --option build-extra-sandbox-paths $(which sudo | xargs dirname) "
-}
{-
<> lineToText drv
-}
{-)-}
{-]-}
{-
Nothing
-}
{-
where
-}
{-
opts = info
-}
{-
(executorParser <**> helper)
-}
{-
( fullDesc
-}
{-
<> progDesc "Argo environment provisioning/deployment/execution."
-}
{-
<> header "argonix"
-}
{-)-}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment