cabal sandbox v. global package db - haskell

When installing inside a cabal sandbox, cabal will still use packages from the global package db (in particular, packages which came from the Haskell Platform). This can lead to install conflicts. Is it possible to configure cabal to ignore the global package db?
I see the corresponding feature has been implemented in ghc itself, via a -no-global-package-db option (see https://ghc.haskell.org/trac/ghc/ticket/5977), and ghc-pkg will ignore the global package db if you do not pass it the --global flag. Is there a way to configure cabal similarly?
Also, there's a closed issue against cabal implying the opposite behavior (rebuilding everything instead of using packages from the installed Haskell Platform), so I'm not sure if this behavior has changed over time; see https://github.com/haskell/cabal/issues/1695

You should be able to pass cabal configure the --package-db flag, documented like so:
--package-db=DB Append the given package database to the
list of package databases used (to satisfy
dependencies and register into). May be a
specific file, 'global' or 'user'. The
initial list is ['global'], ['global',
'user'], or ['global', $sandbox],
depending on context. Use 'clear' to reset
the list to empty. See the user guide for
details.
So in particular, you can pass it clear and then pass it just the sandbox db.
This is all discussed in wonderful detail in the Storage and Interpretation of Cabalized Packages article.

Related

Packages that are not updated when running meteor

I alter some code in a package at
C:\Users\usr\AppData\Local\.meteor\packages\accounts-ui-unstyled\1.3.0\web.browser\login_buttons.js
The thing is , after I alter the code and run “meteor” in the command line the changes are not implemented, I even deleted the whole package mentioned before and run the app and it was like … nothing happened, it’s like the application have some sort of a cache of the packages that he doesn’t have to go to that path to get them , instead it uses what it had from it before.
Can anyone please explain this to me ? What’s happening here ?
The correct way of "changing" a package is to git clone the package from git (or otherwise retrieve it's source) into either a project internal /packages folder or a project external folder (requires environment variable METOER_PACKAGE_DIRS).
If the package is, as in your case, a Meteor internal package, you can also copy only the package into your project and even add it to your versioning.
In this package you then apply your changes. It will be used in favor of the atmosphere package.
A good practice is to also increment the package version, so it is known for everyone that a custom version is in use.
Why you should not change packages inside the users \Users\...\.meteor installation packages folder?
This is the path to packages, that will be used as defaults for every new meteor project you create. Deep changes can create deep damage to your projects since changing a package will apply to all dependent projects.
Think also about project specific customization. The above described method will allow this, too.

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

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?

Browsing a package in ghci

I have a project set up via stack and am importing a package dependency. I see that the package downloaded/installed successfully, so I had hoped that the REPL spawned by stack ghci would let me explore this package. To my surprise, there doesn't seem to be any sort of command for browsing a package. You can use :browse to look through a module, but I don't seem to have any way to see which modules are exposed by this package.
Is there any way to inspect a package in ghci? And if not, are there other ways to inspect a package? I know there are websites which provide documentation, but I want to ensure the information I'm seeing matches the actual version of the package which is installed.

How to gather the full config of a NixOS system?

I read a bit about NixOS and tried it these days, because I got the impression that it would let me configure a Linux with just one file.
When I used it, I installed a bunch of packages with nix-env, so they didn't end up in the configuration.nix, but I could simply uninstall them later and add them to the configuration.nix by hand. I there something like npm i -g <package> that would install this globally so it would end up in the configuration.nix and could simply be copied to another machine.
Also, I installed stuff like zsh and atom and they have an entirely different approach to configuration and customization (bashscript, javascript, less, etc).
Is there a way for Nix/NixOS to track the package-specific config too?
Does it already happen and I don't see it? Like the nix expression of the package knows where the package will store its config etc.
I mean, it's nice that I can add these packages to the main config and when using it at another PC I get the same software installed, but I still see myself writing rather much configs for the installed packages too.
If you want packages installed through configuration.nix, then the easiest way to accomplish that is to add them to the environment.systemPackages attribute. Packages listed in there will be available automatically to all users on the machine. As far as I know, there is no shell command available to automate the maintenance of that attribute, though. The only way to manage that list is by editing configuration.nix and manually adding the packages you'd like to have installed.
Nix does not manage package-specific configuration files. As you probably know, NixOS provides such a mechanism for files in /etc, but a similar mechanism to manage config files in $HOME etc. does not exist. The PR https://github.com/NixOS/nixpkgs/pull/9250 on Github contains a concrete proposal to add this capability to Nix, but it hasn't been merged yet because it requires some changes that are controversial.
Nix does not currently offer ways of managing user specific configuration or language specific package managers. AFAICT that's because it is a very complex and opinionated territory compared to generating configs for sshd etc.
There are however Nix-based projects providing solution to at least some parts of your question. For managing user configuration (zsh etc.), have a look at home manager.

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.

Resources