Nix development utils that will blow up your mind
Go to file
2014-05-23 19:18:46 +02:00
nix-services services: add mongodb and logstash 2014-04-26 08:32:28 +02:00
container.nix container: fix updating scripts 2014-05-23 19:18:46 +02:00
default.nix fix nix file name 2014-04-07 23:49:58 +02:00
README.md README: fix typo 2014-03-23 18:57:56 +01:00

========== nix-rehash

Nix development utils that will blow up your mind

reService - fullstack@dev

reService takes your nixos config of services and creates user-enabled supervisord config that you can use for development or deployment on non nixos systems. Having deterministic fullstack in development has never been more awesome.

  • Create default.nix

    { pkgs ? import <nixpkgs> {}
    , projectName ? "myProject"
    , nix-rehash ? import <nix-rehash> }:
      with pkgs.lib;
      with pkgs;
    
    let
      services = nix-rehash.reService {
        name = "${projectName}";
        configuration = let servicePrefix = "/tmp/${projectName}/services"; in [
          ({ config, pkgs, ...}: {
            services.postgresql.enable = true;
            services.postgresql.package = pkgs.postgresql92;
            services.postgresql.dataDir = "${servicePrefix}/postgresql";
          })
        ];
      };
    in myEnvFun {
      name = projectName;
      buildInputs = [ services ];
    }
    
  • install nix-env -f default.nix -i

  • load environemnt load-env-myProject

  • start services myProject-start-services, control services myProject-control-services, stop services myProject-stop-services

Now build this with hydra and pass the environment around :)

reContain - heroku@home

reContain makes nixos enabled installable container that can auto-update itself. Now you can build container on hydra and auto update it on host machine. Staging or deployments have never been easier :)

  • Create default.nix

    { pkgs ? import <nixpkgs>
    , name ? "myProject"
    , nix-rehash ? import <nix-rehash> }:
      with pkgs.lib;
      with pkgs;
    
    {
      container = nix-rehash.reContain {
        inherit name;
        configuration = [{
        services.openssh.enable = true;
        services.openssh.ports = [ 25 ];
        users.extraUsers.root.openssh.authorizedKeys.keys = [ (builtins.readFile ./id_rsa.pub) ];
        }];
      };
    }
    
  • do nix-env [-f default.nix] -i myProject-container or build with hydra and add a channel

  • start container: sudo myProject-start-container

  • ssh to container: ssh localhost -p 25

  • enable auto updates with cron:

    * * * * * nix-env -i myProject-container && sudo $HOME/.nix-profile/bin/myProject-update-container
    
  • stop container: sudo myProject-stop-container