diff --git a/default.nix b/default.nix index f72ea93..3431a13 100644 --- a/default.nix +++ b/default.nix @@ -1,15 +1,22 @@ -{ - pkgs ? (import {}), - ruby ? pkgs.ruby_2_6, - bundler ? (pkgs.bundler.override { inherit ruby; }), - nix ? pkgs.nix, - nix-prefetch-git ? pkgs.nix-prefetch-git, +{ pkgs ? (import {}) +, ruby ? pkgs.ruby_2_6 +, bundler ? (pkgs.bundler.override { inherit ruby; }) +, nix ? pkgs.nix +, nix-prefetch-git ? pkgs.nix-prefetch-git +, rake ? pkgs.rubyPackages.rake +, minitest ? pkgs.rubyPackages.minitest +, nix-prefetch-scripts ? pkgs.nix-prefetch-scripts }: -pkgs.stdenv.mkDerivation rec { +let + srcWithout = rootPath: ignoredPaths: + let + ignoreStrings = map (path: toString path ) ignoredPaths; + in + builtins.filterSource (path: type: (builtins.all (i: i != path) ignoreStrings)) rootPath; +in pkgs.stdenv.mkDerivation rec { version = "2.5.0"; name = "bundix"; - src = ./.; - phases = "installPhase"; + src = srcWithout ./. [ ./.git ./tmp ./result ]; installPhase = '' mkdir -p $out makeWrapper $src/bin/bundix $out/bin/bundix \ @@ -22,6 +29,19 @@ pkgs.stdenv.mkDerivation rec { nativeBuildInputs = [ pkgs.makeWrapper ]; buildInputs = [ ruby bundler ]; + checkInputs = [ + rake + minitest + + nix-prefetch-scripts + nix + ]; + + doCheck = true; + checkPhase = '' + NIX_STATE_DIR=$TMPDIR/var HOME=$TMPDIR rake test + ''; + meta = { inherit version; description = "Creates Nix packages from Gemfiles"; diff --git a/shell.nix b/shell.nix deleted file mode 100644 index c4272fd..0000000 --- a/shell.nix +++ /dev/null @@ -1,44 +0,0 @@ -with (import {}); -with builtins; - -let - minitest = buildRubyGem { - inherit ruby; - gemName = "minitest"; - type = "gem"; - version = "5.10.1"; - source.sha256 = "1yk2m8sp0p5m1niawa3ncg157a4i0594cg7z91rzjxv963rzrwab"; - gemPath = []; - }; - - rake = buildRubyGem { - inherit ruby; - gemName = "rake"; - type = "gem"; - version = "12.0.0"; - source.sha256 = "01j8fc9bqjnrsxbppncai05h43315vmz9fwg28qdsgcjw9ck1d7n"; - gemPath = []; - }; - - srcWithout = rootPath: ignoredPaths: - let - ignoreStrings = map (path: toString path ) ignoredPaths; - in - filterSource (path: type: (all (i: i != path) ignoreStrings)) rootPath; -in - stdenv.mkDerivation { - name = "bundix"; - src = srcWithout ./. [ ./.git ./tmp ./result ]; - 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]; -}