Is there a way to install an Haskell executable as a dependency? - haskell

I found myself writing Haskell commands based upon other commands provided by other Haskell packages, but i could not find a way to install an executable as a dependency.
As far as i could see, Cabal and Stack provide ways for a package to depend on a library, but not on an executable.
If i want to build upon the functionality already provided by another executable, the only way i know is to ask the users to install that other package as well. That also means that i cannot assume the executable is there or its version is the right one.
So is there a way for an Haskell package to depend on an executable provided by another package?

Related

How do I build Nim library packages

I've created a nimble library package as per the documentation. When I try to build it using nimble build I get the following error.
Error: Nothing to build. Did you specify a module to build using the bin key in your .nimble file?
I can do this and it does fix the error but according to the documentation adding the bin key to the .nimble file turns my package into a binary package.
Other things I have tried:
Use nimble install: This does not appear to verify that my code will actually compile and will happily install anything to the local package directory (I added a C# class to my .nim file, for example, and it was successfully installed).
Use nimble c: This works but I have to pass in the path to the nim file I want to compile and the binDir entry in the .nimble file is ignored resulting in the output being placed in the same directory as the file being built. This complicates the development cycle because I have to manually clean up after the compiler.
Use the compiler directly. This is pretty much the same as the previous option with the same flaws.
I guess I could also create a separate .nim file and import my library after it is installed but this is a big overhead for just wanting to verify that a package in the early stages of development will actually compile.
I just want to be able to verify that the source code in my library package is syntactically correct and will compile. How is this meant to be done for library packages?
From your provided link to the nimble package manager documentation I have the feeling that
https://github.com/nim-lang/nimble#tests
is what you are looking for. But I have never used the test command, so I am not sure. I do my test manually still, I read the nimble docs maybe 4 years ago and can not really remember. And currently there is much package manager related work going on, I heard there is a new, alternative package manager called nimph, and from a forum thread I think I read something that nimble is going to change and improve also. Maybe you should consider subscribing to the Nim forum, that is the place where the bright Nim devs are. Well, at least a few of them.

How do I use stack to install locally authored Haskell modules for global usage?

I have a locally authored Haskell project, which produces both:
a binary executable, and
several new Haskell modules, which I'd like made accessible to my other, Haskell based, executables.
After:
stack build
stack install
I'm finding that:
the binary executable (#1, above) runs just fine from any directory.
But, the new Haskell modules (#2, above) are only found when I'm running from within my project directory! (That is, for any executable other than #1, above.)
I need to be able to find the new modules from anywhere.
How can I achieve this?
Each stack project is in its own sandbox, so the compiled modules can only be used within that project. Compiled dependencies (which come from a stackage snapshot) sometimes get shared between projects.
Note that you can list a relative path in the packages list, and point to this package. It will get built again, but it can be directly used in another project this way. Why the extra building? Stack has a different model of projects than cabal-install - it does not allow mutations to the package DB to affect how your other projects build.
One option for sharing such a package is to have it in a git repo and use https://docs.haskellstack.org/en/stable/custom_snapshot/ , but that stuff is still a bit new.

Is it possible to compile a portable executible on Linux based on yum or rpm?

Usually one rpm depends on many other packages or libs. This is not easy for massive deployment without internet access.
Since yum can automatically resolve dependencies. Is it possible to build a portable executable? So that we can copy it to other machines with the same OS.
If you want a known collection of RPMs to install, yum offers a downloadonly plugin. With that, you should be able to collect all the associated RPMs in one shot to install what you wanted on a disconnected machine.
The general way to build a binary without runtime library dependencies is to build it to be static, ie. using the -static argument to gcc, which links in static versions of the libraries required such that they're included in the resulting executable. This doesn't bundle in any data file dependencies or external executables (ie. libexec-style helpers), but simpler applications often don't need them.
For more complex needs (where data files are involved, or elements of the dependency chain can't be linked in for one reason or another), consider using AppImageKit -- which bundles an application and its dependency chain into a runnable ISO. See docs/links at PortableLinuxApps.org.
In neither of these cases does rpm or yum have anything to do with it. It's certainly possible to build an RPM that packages static executables, but that's a matter of changing the %build section of the spec file such that it passes -static to gcc, not of doing anything RPM-specific.
To be clear, by the way -- there are compelling reasons why we don't use static libraries all the time!
Using shared libraries means that applying a security update to a library only means replacing the library itself, not recompiling all applications using it.
Using shared libraries is more memory-efficient, since the single shared copy of the library in memory can be used by multiple applications.
Using shared libraries means your executables don't need to include full copies of all the libraries they use, making them much smaller.

is it possible to stack cabal sandboxes?

Is it possible to "stack" cabal sandboxes or specify a "package.d" search path?
I'd like to install frequently used packages into a common sandbox that projects can use but don't update.
There is a world-file parameter in the cabal.sandbox.config file, but I couldn't find any reference to it in the Cabal source.
I believe world-file refers to an optional function by which cabal-install will maintain a plaintext list of packages requested for install, perhaps modeled on Gentoo's /var/lib/portage/world and similar systems. Cabal doesn't use that file for anything.
Your proposed "nested sandboxes" might cause the same problems as global or per-user installations: various packages would have to have a consistent set of dependencies.
It's possible to share a single sandbox between projects with the --sandbox=DIR parameter to cabal sandbox.

Bundling an scons based source

We are using SCons for all our build need, and we would like to distribute a library in open source.
Now most softwares uses ./configure, make and make install as build mechanism, we were wondering how we should bundle our library.
We have the following solutions:
Just bundle like the way it is, requiring scons to build.
Add a dummy configure and makefile that just call scons.
Add autoconf and a makefile.
How it is perceived to get a software requiring python and scons to build?
I think it depends largely on your target audience (ie, users who can easily install scons if they don't have it, or ones who can't), but if you are distributing source at all then presumably your users are happy compiling things, and they can install scons too (and python if for some obscene reason they don't have it already)
Also, if you are worried about people not being able to build it, you should probably be distributing a binary package anyway.
If your library is cross-platform and can be compiled on Windows too, then using scons is the right choice.
Another option would be to include the scons-local version in the package. This reduces the dependencies to just python.

Resources