Skip to content

Commit

Permalink
Existing shell.nix didn't work for me.
Browse files Browse the repository at this point in the history
  • Loading branch information
nyarly committed Jan 7, 2018
1 parent 7504f73 commit 090b7df
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 13 deletions.
8 changes: 8 additions & 0 deletions Rakefile
@@ -0,0 +1,8 @@
require 'rake/testtask'

Rake::TestTask.new do |t|
t.pattern = 'test/*.rb'
t.warning = false
end

task :default => :test
43 changes: 30 additions & 13 deletions shell.nix
@@ -1,19 +1,36 @@
with (import <nixpkgs> {});
let
ruby = pkgs.ruby_2_4_1;
bundler = pkgs.bundler.override { inherit ruby; };
gems = bundlerEnv {
minitest = buildRubyGem {
inherit ruby;
name = "bundix-gems";
gemdir = ./.;
gemName = "minitest";
type = "gem";
version = "5.10.1";
sha256 = "1yk2m8sp0p5m1niawa3ncg157a4i0594cg7z91rzjxv963rzrwab";
gemPath = [];
};

rake = buildRubyGem {
inherit ruby;
gemName = "rake";
type = "gem";
version = "12.0.0";
sha256 = "01j8fc9bqjnrsxbppncai05h43315vmz9fwg28qdsgcjw9ck1d7n";
gemPath = [];
};
in
stdenv.mkDerivation {
name = "bundix-shell";
buildInputs = [
bundler
(lowPrio gems)
ruby
postgresql96
];
stdenv.mkDerivation {
name = "bundix";
src = ./.;
phases = "installPhase";
installPhase = ''
mkdir -p $out
makeWrapper $src/bin/bundix $out/bin/bundix \
--prefix PATH : "${nix.out}/bin" \
--prefix PATH : "${nix-prefetch-git.out}/bin" \
--set GEM_PATH "${bundler}/${bundler.ruby.gemPath}"
'';

nativeBuildInputs = [makeWrapper];

buildInputs = [bundler ruby minitest rake nix-prefetch-scripts];
}
34 changes: 34 additions & 0 deletions test/commandline.rb
@@ -0,0 +1,34 @@
require 'minitest/autorun'
require 'bundix/commandline'

class CommandLineTest < Minitest::Test
def setup
@cli = Bundix::CommandLine.new
@options = {
project: "test-project",
ruby: "test-ruby",
gemfile: "test-gemfile",
lockfile: "test-lockfile",
gemset: "test-gemset",
}
end

def test_shell_nix
assert_equal(@cli.shell_nix_string(@options), <<SHELLNIX)
with (import <nixpkgs> {});
let
env = bundlerEnv {
name = "test-project-bundler-env";
inherit test-ruby;
gemfile = ./test-gemfile;
lockfile = ./test-lockfile;
gemset = ./test-gemset;
};
in stdenv.mkDerivation {
name = "test-project";
buildInputs = [ env ];
}
SHELLNIX

end
end

0 comments on commit 090b7df

Please sign in to comment.