Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
horizon-devtools
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
package-sets
horizon-devtools
Commits
d6adbc7c
Commit
d6adbc7c
authored
2 years ago
by
Daniel Firth
Browse files
Options
Downloads
Patches
Plain Diff
apps.procex: init with simple commands
parent
f7a7a95b
Branches
Branches containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
flake.nix
+6
-0
6 additions, 0 deletions
flake.nix
shell/ShellRC.hs
+52
-0
52 additions, 0 deletions
shell/ShellRC.hs
shell/default.nix
+64
-0
64 additions, 0 deletions
shell/default.nix
with
122 additions
and
0 deletions
flake.nix
+
6
−
0
View file @
d6adbc7c
...
@@ -78,6 +78,7 @@
...
@@ -78,6 +78,7 @@
program
=
"
${
run-impure-tests
}
/bin/run-impure-tests"
;
program
=
"
${
run-impure-tests
}
/bin/run-impure-tests"
;
};
};
procex
=
import
./shell/default.nix
{
haskellPackages
=
horizon-platform-prev
.
legacyPackages
.
${
system
};
inherit
(
pkgs
)
runCommand
writeShellScriptBin
;
};
in
in
{
{
...
@@ -90,6 +91,11 @@
...
@@ -90,6 +91,11 @@
program
=
"
${
horizon-gen-gitlab-ci
}
/bin/gen-gitlab-ci"
;
program
=
"
${
horizon-gen-gitlab-ci
}
/bin/gen-gitlab-ci"
;
};
};
procex
=
{
type
=
"app"
;
program
=
"
${
procex
}
/bin/procex-shell"
;
};
run-impure-tests
=
run-impure-tests-app
;
run-impure-tests
=
run-impure-tests-app
;
};
};
...
...
This diff is collapsed.
Click to expand it.
shell/ShellRC.hs
0 → 100644
+
52
−
0
View file @
d6adbc7c
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# OPTIONS_GHC -Wno-missing-signatures #-}
{-# OPTIONS_GHC -Wno-unused-imports #-}
module
ShellRC
where
import
qualified
Control.Lens
as
L
import
qualified
Data.Aeson
as
A
import
qualified
Data.Aeson.Key
as
A
import
qualified
Data.Aeson.KeyMap
as
A
import
qualified
Data.Aeson.Lens
as
L
import
qualified
Data.ByteString.Lazy
as
B
import
Data.ByteString.Lazy.UTF8
as
BLU
import
qualified
Data.ByteString.Lazy.UTF8
as
BU
import
qualified
Data.Map
as
Map
import
Data.Text
(
Text
)
import
qualified
Data.Text
as
T
import
qualified
Data.Text.Encoding
as
T
import
qualified
Data.Yaml
as
Y
import
qualified
Data.Yaml.Pretty
as
Y
import
Network.HTTP.Simple
import
Path
import
Procex.Prelude
import
Procex.Shell
hiding
(
promptFunction
)
import
System.Directory
import
System.Environment
promptFunction
::
[
String
]
->
Int
->
IO
String
promptFunction
_modules
_line
=
do
d
<-
getEnv
"PWD"
setCurrentDirectory
d
pure
$
d
<>
": "
_init
::
IO
()
_init
=
do
initInteractive
getEnv
"REALHOME"
>>=
setEnv
"HOME"
-- Set by the script that launches GHCi
hackagePkg
::
Text
->
IO
A
.
Value
hackagePkg
x
=
do
k
<-
parseRequest
$
"http://hackage.haskell.org/package/"
<>
T
.
unpack
x
getResponseBody
<$>
httpJSON
k
hackagePkgLatest
::
Text
->
IO
Text
hackagePkgLatest
x
=
Prelude
.
last
.
Map
.
keys
.
A
.
toMapText
.
L
.
view
L
.
_Object
<$>
hackagePkg
x
runAllFeedback
::
IO
()
runAllFeedback
=
do
(
x
::
Either
Y
.
ParseException
A
.
Value
)
<-
Y
.
decodeFileEither
"feedback.yaml"
t
<-
getEnv
"TERM"
let
y
=
Map
.
keys
.
A
.
toMapText
.
L
.
view
(
L
.
_Right
.
L
.
_Object
.
L
.
ix
"loops"
.
L
.
_Object
)
$
x
mapM_
(
captureLazyNoThrow
.
mq
t
"--command"
"nix"
"run"
"github:NorfairKing/feedback"
"--"
.
T
.
unpack
)
y
This diff is collapsed.
Click to expand it.
shell/default.nix
0 → 100644
+
64
−
0
View file @
d6adbc7c
{
haskellPackages
,
writeShellScriptBin
,
runCommand
}:
let
shellrcSrcPath
=
./.
;
shellrcModule
=
"ShellRC"
;
shellrcSrc
=
shellrcSrcPath
;
shellrcModulePath
=
builtins
.
replaceStrings
[
"."
]
[
"/"
]
shellrcModule
+
".hs"
;
ghc
=
haskellPackages
.
ghcWithPackages
(
p
:
with
p
;
[
bytestring
containers
dhall
http-conduit
lens
lens-aeson
path
procex
text
yaml
]);
args
=
builtins
.
concatStringsSep
" "
[
"-XDataKinds"
"-XExtendedDefaultRules"
"-XGHC2021"
"-XOverloadedStrings"
"-XOverloadedLabels"
"-Wall"
"-Wno-type-defaults"
];
shellrc
=
runCommand
"shellrc"
{
}
''
cp
${
shellrcSrc
}
--no-preserve=all -rT $out
${
ghc
}
/bin/ghc -c -dynamic --make -i"$out"
${
args
}
$out/
${
shellrcModulePath
}
''
;
init
=
runCommand
"ghci-init"
{
}
''
cat > $out <<END
:set +m -interactive-print Text.Pretty.Simple.pPrint
:l
${
shellrcModule
}
import Procex.Shell.Labels
:set prompt-function promptFunction
_init
END
grep -E '^import .*$' <
${
shellrcSrc
}
/
${
shellrcModulePath
}
>> $out
''
;
in
(
writeShellScriptBin
"procex-shell"
''
home="$HOME/.local/share/ghci-shell"
mkdir -p "$home"
exec env GHCRTS="-c" HOME="$home" REALHOME="$HOME"
${
ghc
}
/bin/ghci
${
args
}
-ignore-dot-ghci -i -i
${
shellrc
}
-ghci-script
${
init
}
"$@"
''
)
.
overrideAttrs
(
old
:
old
//
{
passthru
=
{
shellPath
=
"/bin/procex-shell"
;
};
})
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment