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?
Description. The command nix-shell will build the dependencies of the specified derivation, but not the derivation itself. It will then start an interactive shell in which all environment variables defined by the derivation path have been set to their corresponding values, and the script $stdenv/setup has been sourced.
Nix evaluation can be slow sometimes, but installation is generally relatively fast, since everything in Nix is fully parallelizable. It's generally several times faster than apt, for installs that involve multiple large downloads, for example, and historically it's also faster than pacman.
Derivations are the building blocks of a Nix system, from a file system view point. The Nix language is used to describe such derivations.
The command nix-env is used to manipulate Nix user environments. User environments are sets of software packages available to a user at some point in time. In other words, they are a synthesised view of the programs available in the Nix store.
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.
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