11

I work under NixOS, and I love it so far.

For my coding projects, I'm trying to achieve separate development environments. So for example for my Scala/node.js project, I have written default.nix for nix-shell :

with import <nixpkgs> {}; {
    tarifs2Env = stdenv.mkDerivation {
        name = "webapp";
        buildInputs = with pkgs; [ 
            sbt 
            nodejs
            nodePackages.gulp
        ];

        shellHook = ''
        '';
    };
}

So far so good. Now I would like to add a database, posgtres for example. Is there a way to add a service to a nix-shell?

KaC
  • 613
  • 6
  • 14

1 Answers1

7

I think https://github.com/chrisfarms/nixos-shell should do exactly what you're after. I've not used it myself but as I understand it works by taking a configuration.nix that describes the service(s) that you want then builds the config in an ephemeral NixOS container and drops you into a shell in the container.

brocking
  • 821
  • 6
  • 9
  • I didn't know it, looks great! Thanks. – KaC Sep 26 '16 at 13:29
  • 2
    No activity after 3 years, but I would propose that nix-shell represents a very minimal form of isolation focusing on just filesystem paths of dependencies (it may not actually use chroot to do this), while a nix container (or variants of this) starts to isolate OS resources (most of the time you only need the former, and in the case of apps, you need the latter). It should be possible for a nix-shell to build a container and drop you into that container. One possibility is to integrate into Docker. – CMCDragonkai Jul 12 '17 at 10:20