Skip to content

Instantly share code, notes, and snippets.

@mbbx6spp
Created November 15, 2018 21:41
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbbx6spp/fdf48aac530fddbbff872f39429d4619 to your computer and use it in GitHub Desktop.
Save mbbx6spp/fdf48aac530fddbbff872f39429d4619 to your computer and use it in GitHub Desktop.
Quick notes on what worked to package a frontend yarn JS project and how to update gems in an existing Ruby project using bundix for Nix based configuration.

Random Nix Project Packaging (yarn2nix, bundix -l)

Setting up a nodejs project via yarn2nix in Nix for existing project

  • nix-shell -p yarn yarn2nix nodejs
  • copied the Nix skeleton files in place (./z/etc/lib/{version,nixpkgs}.nix ./z/etc/overlays/default.nix)
  • generated package.nix using yarn2nix
  • add these Nix expressions in the root
# shell.nix
{ pkgs ? import ./z/etc/lib/nixpkgs.nix }:
let
  pkg = import ./. {
    inherit (pkgs) mkYarnPackage;
  };
in pkgs.mkShell {
  buildInputs = with pkgs; [
    nodejs
    yarn
    yarn2nix
    python
    pkg
  ];
}
# default.nix
{ mkYarnPackage }:
mkYarnPackage {
  name = "dailykos-frontend";
  src = ./.;
  packageJson = ./package.json;
  yarnLock = ./yarn.lock;
  yarnNix = ./package.nix;
}

Adding gems to an existing Ruby project for Nix environment

  • Edited Gemfile to add gem to appropriate group
  • bundix -l
  • You might need to add the group to the groups attribute of the bundlerEnv
  • Profit!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment