Skip to content

Instantly share code, notes, and snippets.

@icetan
Created May 7, 2019 11:40
Show Gist options
  • Save icetan/4adc045581fe67f90c953091aadb8ad9 to your computer and use it in GitHub Desktop.
Save icetan/4adc045581fe67f90c953091aadb8ad9 to your computer and use it in GitHub Desktop.

Nix a Practical Introduction

Pros

  • builds the same independent of user environment (not on platform)
  • clean user env, no need to clutter your PATH with every persivable build tool
  • no clashing versions, becaus each build has it's own environment, multiple versions of the same dependency won't clash
  • coherent and declaritive way to define builds
  • cachable build outputs
  • reference any file via HTTP or GIT
  • re-use between repos
  • high level of control, model dependencies and build flows
  • garbage collection of unused dependencies

Cons

  • steep learning curve
  • many ways to solve the same problem

Layered approach

  • layer 1: write bash scripts and other programs
  • layer 2: wrap in nix derivations for reproducablilty
  • layer 3: package for deployment and distripution in images

What does it replace?

What doesn't it replace?

Where can we use it?

File dependencies and pre-processing (compiling etc.)

  • when we have source code that needs compiling
  • when we need to manage dependencies

Other use cases

  • containarazation
    • create docker images from Nix derivations
  • deployment
    • use NixOps to deploy services and link them together
  • continuous Integration
    • run Nix derivations for testing and publish releases with build cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment