Skip to content
forked from ydlr/mix2nix

Generate a set of nix derivations from a mix.lock file.

License

Notifications You must be signed in to change notification settings

code-supply/mix2nix

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mix2nix

Generate a set of nix derivations from a mix.lock file.

Overview

Mix2nix is a commandline utility to create a set of nix package definitions based on the contents of a mix.lock file. It makes it a little easier to manage Elixir dependencies with nix.

To understand where it fits in with other tools used to package Elixir libraries and releases for Nix, please read the Packaging BEAM Applications section of the Nixpkgs Manual.

Usage

Generate an expession set

Generate an expression set and save it to a file:

$ mix2nix > deps.nix

You can also specify a path to your mix.lock file:

$ mix2nix /path/to/mix.lock > deps.nix

Using generated expressions in your project

You can import your generated package set into your own package definition like any other function. An example default.nix could look something like:

{ pkgs ? import <nixpkgs> {} }:

with pkgs; with beamPackages;

let
  deps = import ./deps.nix { inherit lib beamPackages; };
in
buildMix rec {
  name = "example-package";
  src = ./.;
  version = "0.0.0";

  beamDeps = [
    deps.package1
    deps.package2
  ];
}

If you are packaging your application as a release:

{ pkgs ? import <nixpkgs> {} }:

with pkgs; with beamPackages;

mixRelease {
  pname = "example-release";
  src = ./.;
  version = "0.0.0";

  mixNixDeps = import ./deps.nix { inherit lib beamPackage; };
}

Overriding package definitions

You can override any package by passing in an overrides attribute:

let
  deps = import ./deps.nix { inherit lib beamPackages; overrides = overrideDeps; };

  overrideDeps = (self: super: {
    package1 = super.package1.override {
      enableDebugInfo = true;
      compilePorts = true;
    };
  };
in
...

Dependencies from outside of Hex.pm Repository

Currently, only public packages from Hex.pm are supported. If you have any dependencies from git, private repositories, or local sources, you will need to manually specify those.

Build and Install

To create a development environment:

$ nix-shell

To build without adding to global environment:

$ nix-build

To install in your environment:

$ nix-env -f ./ -i

About

Generate a set of nix derivations from a mix.lock file.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Elixir 71.8%
  • Nix 27.7%
  • Makefile 0.5%