Giter Club home page Giter Club logo

nix-rehash's Introduction

========== 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"
    , lib ? (import <nixpkgs> {}).lib
    , nix-rehash ? import <nix-rehash> }:
      with lib;
    
    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 :)

Alternative using nix-shell:

  • set buildInputs = [ services.config.supervisord.bin ];
  • run nix-shell
  • use supervisord and supervisorctl as you wish

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>
    , lib ? (import <nixpkgs> {}).lib
    , name ? "myProject"
    , nix-rehash ? import <nix-rehash> }:
      with 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-container-start

  • 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-container-stop

nix-rehash's People

Contributors

offlinehacker avatar zefhemel avatar seitz avatar wmertens avatar

Watchers

 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.