stack
allows one to define git repositories as packages using the stack.yaml
file. Is it possible to do something like the following, directly via command-line:
stack install --resolver=lts-12.1 [email protected]:saurabhnanda/some-repo.git
Use-case: Install a command-line tool that I have written during a docker
build process. I want to avoid cloning the repo and then building it. Is there a short-hand for this?
EDIT
New solution
Right after submitting the answer I thought of a separate solution.
You can create a custom custom-snapshot.yaml
file in your repository that extends some existing snapshot, such as lts-15.3 for example. Add your package to it in a similar way you would add it to the stack.yaml
.
And the point to it when installing the tool:
$ stack install --resolver https://raw.githubusercontent.com/saurabhnanda/my-cool-tool/master/custom-snapshot.yaml my-cool-tool
or even shorter:
$ stack install --resolver github:saurabhnanda/my-cool-tool:custom-snapshot.yaml my-cool-tool
Disclaimer - I have not tried it, but in theory it should work.
Old solution
I don't think you can do it at cli without stack.yaml
So two options are:
stack new
add your repository to the stack.yaml
stack.yaml
, location of which can be found programmatically:$ stack path --config-location
/home/saurabhnanda/.stack/global-project/stack.yaml
and add this to extra-deps
:
- github: saurabhnanda/some-repo
commit: master
subdirs:
- my-cool-tool
After that running stack install my-cool-tool
should work as normal.
I don't think it would be too hard too write up a Haskell script that could do one of those two solutions for you and host as a gist that can be curl
ed and executed on demand with stack
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With