GithubHelp home page GithubHelp logo

soraismus / nixos-shell Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chrisfarms/nixos-shell

0.0 3.0 0.0 157 KB

spawn ephemeral development environments in containers. Like nix-shell only more so!

Nix 4.16% Go 95.84%

nixos-shell's Introduction

nixos-shell

A tool for reproducable development environments described as NixOS modules.

It fits somewhere between nix-shell and nixos-rebuild build-vm.

Why

It solves the same problem as things like virtualenv, RVM and tools like Vagrant: The issue of quickly being able to enter an environment with all the dependecies you need for working on your application without polluting your environment.

How

You add a configuration.nix file to each of your applications. Then when you want to work on an application you navigate to your project and boot a container:

$ cd my-awesome-project
$ sudo nixos-shell
[10.0.2.12:/src]$ echo "I'm in a container"

A container is built as defined in your project's configuration.nix, spawned, and you are logged in via SSH. The container has a private networking namespace so you can start multiple containers with clashing ports.

You can access things running in the container from the host via the ip address advertised in the bash prompt.

Your application dir (the path on the host where you ran nixos-shell) is bind mounted to /src inside the container. This is analgous to the /vagrant synced folder in vagrant.

Install

$ git clone https://github.com/chrisfarms/nixos-shell.git
$ cd nixos-shell
$ nix-env -i -f default.nix

If you want your containers to be able to connect to the internet you will need to setup NAT on your host by adding something like the following to your config:

networking.nat = {
	enable = true;
	externalInterface = "eth0";
	internalInterfaces = [ "ve-+" ];                                                                                            
};

FAQ

####What's a configuration.nix file See the NixOS manual.

####Isn't this just nix-shell? No. nix-shell will drop you into a chroot, with any required build dependencies, but won't handle dependent services. nixos-shell will drop you into a containter which is closer to booting a virtual machine with everything you need.

####Isn't this just nixos-container? Not quite. nixos-shell builds on tops of nixos-container to spawn a temporary environment. That is, it sets up your environment, gets you logged in, then takes care of tearing it up and tidying up after you when you log out.

nixos-shell's People

Contributors

chrisfarms avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.