使用最新版本时,请确保Nix Dev Environment中的Ruby版本 [英] Ensure Ruby version in Nix Dev Environment when using latest version
问题描述
当前,Nix中默认的最新Ruby是2.2.2-p0。当我运行 nix-env -qaP ruby
时,它将返回一个列表,该列表表示可通过 nixpkgs.ruby $ c $访问此Ruby版本。 c>。我希望这个Ruby链接将更改为与最新的受支持的ruby版本保持最新。我没有可选的nixpkgs.ruby_2_2_2来确保我的红宝石版本。
Currently, the default and latest Ruby in Nix is 2.2.2-p0. When I run nix-env -qaP ruby
it returns a list, which says that this ruby version is accessed via nixpkgs.ruby
. I expect that this Ruby link will change to stay up-to-date with the latest supported ruby version. There is no optional nixpkgs.ruby_2_2_2 for me to use to ensure my ruby version.
查看位于 https://github.com/NixOS/nixpkgs/blob/master/pkgs /development/interpreters/ruby/ruby-2.2.2.nix ,但是我看到他们在该脚本中指定了修订版本。
Looking at the .nix definition file at https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/interpreters/ruby/ruby-2.2.2.nix, however, I see that they specify the revision in that script.
所以我我想知道,当我在我的Nix表达式的 buildInputs
中列出它以创建开发时,是否可以指定我想要的Nix包的修订版本?环境(将通过 nix-shell。
访问)?还是我还有其他方法可以确保将ruby 2.2.2-p0用于安装,而不仅仅是可能会更改的最新Ruby?
So I'm wondering, is there some way for me to specify the revision of the Nix package that I want when I'm listing it in the buildInputs
of my Nix expression for creating the development environment (which will be accessed via nix-shell .
)? Or is there something else that I might do that would enable me to ensure that ruby 2.2.2-p0 is used for the installation, and not just the latest Ruby, which might change?
当前脚本:
let
pkgs = import <nixpkgs> {};
in with pkgs; {
rubyEnv = stdenv.mkDerivation rec {
name = "ruby-env";
version = "0.1";
src = ./.;
buildInputs = [
stdenv
ruby
bundler_HEAD
];
};
}
我没有在 http://nixos.org/nix/manual/#chap-writing-nix-expressions
推荐答案
我没有可用于确保我的$ b $的可选nixpkgs.ruby_2_2_2 b红宝石版本。
There is no optional nixpkgs.ruby_2_2_2 for me to use to ensure my ruby version.
实际上nixpkgs中有 ruby_2_2_2
: p>
Actually there is a ruby_2_2_2
in nixpkgs:
$ nix-env -qaP ruby
nixos.ruby_1_8 ruby-1.8.7-p374
nixos.ruby_1_9 ruby-1.9.3-p551
nixos.ruby_2_0 ruby-2.0.0-p645
nixos.ruby_2_1_0 ruby-2.1.0-p0
nixos.ruby_2_1_1 ruby-2.1.1-p0
nixos.ruby_2_1_2 ruby-2.1.2-p353
nixos.ruby_2_1_3 ruby-2.1.3-p0
nixos.ruby_2_1 ruby-2.1.6-p0
nixos.ruby_2_2_0 ruby-2.2.0-p0
nixos.ruby ruby-2.2.2-p0
nixos.bundler_HEAD ruby-2.2.2-p0-bundler-2015-01-11
通过查看 ruby包,您可以看到当前的默认ruby只是ruby 2.2的别名:
By looking at the definition of ruby package in the index, you can see that the current default ruby is just an alias to ruby 2.2:
ruby = ruby_2_2;
这又是ruby 2.2.2的别名:
that is in turn an alias to ruby 2.2.2:
ruby_2_2 = ruby_2_2_2;
要在nix表达式中将ruby软件包覆盖为特定的ruby版本,请 overridePackages
:
To override the ruby package to a specific ruby version in a nix expression, overridePackages
can be used:
let
nixpkgs = import <nixpkgs> {};
pkgs = nixpkgs.overridePackages (self: super: {
ruby = nixpkgs.ruby_2_2_2;
});
in with pkgs;
{
rubyEnv = stdenv.mkDerivation rec {
name = "ruby-env";
version = "0.1";
src = ./.;
buildInputs = [
stdenv
ruby
bundler
];
};
}
这篇关于使用最新版本时,请确保Nix Dev Environment中的Ruby版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!