How to use Nix to setup a development environment?

前端 未结 1 1140
我寻月下人不归
我寻月下人不归 2021-02-14 00:38

Let\'s say I need PostgreSQL 9.6.3 and Ruby 2.3.1 and various other tools. I can\'t find a tutorial that explains what I need to do.

From the Nix manual, I seem to need

1条回答
  •  醉梦人生
    2021-02-14 01:14

    You can use nix-shell for this. It drops you into a shell configured to the given nix expression. Initially that expression could simply be along the lines of buildInputs = [ pkgs.ruby ]; and you can develop it from that. There are a number of helpful articles online written by nix users that give more examples of using nix-shell, like this one from garbas.si

    You may also find it useful to get a better idea of how nix packages work. There's a separate nixpkgs manual that covers in greater detail using nix to create package expressions. A quick skim of the 3rd section should be useful to give a bit more understanding. There's also a chapter on using nix with ruby bundler that might be useful for you. Again there are articles that give more examples of its use, such as one from stesie.github.io.

    If you need postgresql actually running in your environment nix won't manage that for you; its function is solely the building and management of packages, not their activation. You could simply activate postgres manually, use the nix-shell hook, or create some other integration with nix, but I think the most robust option is to make use of the Linux distribution that's built on top of Nix - NixOS. NixOS integrates with nix packages and manages the services provided by the packages. You could create a NixOS configuration with postgres active and your development environment present. This utility from github.com/chrisfarms may also be of interest.

    0 讨论(0)
提交回复
热议问题