chruby: allow for specifying Rubies to use
This allows the user to specify an attrset of Rubies to use with chruby by overriding the default of ~/.rubies with a path to a symlink tree.
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
{ stdenv, lib, fetchFromGitHub }:
|
||||
{ stdenv, lib, fetchFromGitHub, runCommand, rubies ? null }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
let
|
||||
rubiesEnv = runCommand "chruby-env" { preferLocalBuild = true; } ''
|
||||
mkdir $out
|
||||
${lib.concatStrings
|
||||
(lib.mapAttrsToList (name: path: "ln -s ${path} $out/${name}\n") rubies)}
|
||||
'';
|
||||
|
||||
in stdenv.mkDerivation rec {
|
||||
name = "chruby";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
@@ -10,7 +17,15 @@ stdenv.mkDerivation rec {
|
||||
sha256 = "1iq9milnnj3189yw02hkly2pnnh4g0vn2fxq6dfx90kldjwpwxq5";
|
||||
};
|
||||
|
||||
phases = [ "unpackPhase" "installPhase" "fixupPhase" ];
|
||||
phases = [ "unpackPhase" "patchPhase" "installPhase" "fixupPhase" ];
|
||||
|
||||
patches = lib.optionalString (rubies != null) [
|
||||
./env.patch
|
||||
];
|
||||
|
||||
postPatch = lib.optionalString (rubies != null) ''
|
||||
substituteInPlace share/chruby/chruby.sh --replace "@rubiesEnv@" ${rubiesEnv}
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
|
||||
Reference in New Issue
Block a user