Skip to content

Instantly share code, notes, and snippets.

@cleverca22
Forked from emptyflask/default.nix
Last active June 3, 2019 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cleverca22/31bed88a5e903d55a040eb068c8c93bb to your computer and use it in GitHub Desktop.
Save cleverca22/31bed88a5e903d55a040eb068c8c93bb to your computer and use it in GitHub Desktop.
# in rails project
with (import <nixpkgs> {});
let
rubyenv = bundlerEnv {
name = "cart-env";
# Setup for ruby gems using bundix generated gemset.nix
inherit ruby_2_6;
gemfile = ./Gemfile;
lockfile = ./Gemfile.lock;
gemset = ./gemset.nix;
# Bundler groups available in this environment
groups = ["default" "development" "test" "toolbox"];
};
in {
inherit rubyenv;
wrapper = writeScript "wrapper" ''
#!/bin/sh
exec ${rubyenv}/bin/bundle exec foreman start -p 5001
'';
cart = stdenv.mkDerivation {
name = "cart";
version = "0.0.1";
buildInputs = [
git
# Ruby deps
ruby_2_6.devEnv
bundler
bundix
# Rails deps
clang
libxml2
libxslt
nodejs
openssl
postgresql_10
readline
zlib
];
shellHook = ''
export LIBXML2_DIR=${pkgs.libxml2}
export LIBXSLT_DIR=${pkgs.libxslt}
'';
};
}
# home-manager config
{
systemd.user.services.cart = {
Unit = {
Description = "Cart";
};
Service = {
WorkingDirectory = "/home/jon/dev/cart";
ExecStart = "${(import ./default.nix).wrapper}";
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment