nix-build nix-generate-from-cpan:表达式不计算为推导
nix-build nix-generate-from-cpan: expression does not evaluate to a derivation
我正在尝试使用 nix-generate-from-cspan to install sqitch
来自 nix-generate-from-cpan App::Sqitch DBD::Pg
,我制作了这个文件:
{buildPerlModule, fetchurl}:
buildPerlModule rec {
name = "App-Sqitch-0.9995";
src = fetchurl {
url = "mirror://cpan/authors/id/D/DW/DWHEELER/${name}.tar.gz";
sha256 = "c29b4610ce43bd43ecfa39188f4cbb00b38c390136fcdd9984142efd99eba292";
};
buildInputs = [ CaptureTiny ModuleBuild TestDeep TestDir TestException TestFile TestFileContents TestMockModule TestNoWarnings ];
propagatedBuildInputs = [ Clone ConfigGitLike DBI DateTime DateTimeTimeZone DevelStackTrace EncodeLocale FileHomeDir HashMerge IOPager IPCRun3 IPCSystemSimple ListMoreUtils Moo PathClass PerlIOutf8_strict StringFormatter StringShellQuote SubExporter TemplateTiny Throwable TryTiny TypeTiny URI URIdb libintlperl namespaceautoclean self."if" ];
meta = {
homepage = http://sqitch.org/;
description = "Sane database change management";
license = stdenv.lib.licenses.mit;
};
}
但是 运行 nix-build -E 'with import <nixpkgs> { }; callPackage ./sqitch.nix'
给出了这个错误:
expression does not evaluate to a derivation (or a set or list of those)
为了调试,我尝试了 nix-instantiate --eval --expr 'with import <nixpkgs> { }; callPackage ./sqitch.nix'
,结果是:
<LAMBDA>
所以我尝试了 nix-build -E 'with import <nixpkgs> { }; callPackage callPackage ./sqitch.nix'
但它仍然给出相同的错误,并且 nix-instantiate --eval --expr 'with import <nixpkgs> { }; callPackage callPackage ./sqitch.nix'
给出:
{ __functor = <CODE>; override = <CODE>; overrideDerivation = <CODE>; }
这对我帮助不大。
简答
buildPerlModule
的结果将用作 mkDerivation
参数中的 src
。
长答案
原来sqitch
已经是nixpkgs的一部分了,它的定义是这样的:
{ name, stdenv, perl, makeWrapper, sqitchModule, databaseModule }:
stdenv.mkDerivation {
name = "${name}-${sqitchModule.version}";
buildInputs = [ perl makeWrapper sqitchModule databaseModule ];
src = sqitchModule;
dontBuild = true;
installPhase = ''
mkdir -p $out/bin
for d in bin/sqitch etc lib share ; do
ln -s ${sqitchModule}/$d $out/$d
done
'';
dontStrip = true;
postFixup = "wrapProgram $out/bin/sqitch --prefix PERL5LIB : $PERL5LIB";
meta = {
platforms = stdenv.lib.platforms.unix;
};
}
sqitchPg = callPackage ../development/tools/misc/sqitch {
name = "sqitch-pg";
databaseModule = perlPackages.DBDPg;
sqitchModule = perlPackages.AppSqitch;
};
https://github.com/NixOS/nixpkgs/blob/56904d7c423f2b13b37fbd29f39bbb4b52bc7824/pkgs/top-level/perl-packages.nix#L281-L305(这是nix-generate-from-cpan App::Sqitch
的输出)
AppSqitch = buildPerlModule rec {
version = "0.9994";
name = "App-Sqitch-${version}";
src = fetchurl {
url = "mirror://cpan/authors/id/D/DW/DWHEELER/${name}.tar.gz";
sha256 = "0in602z40s50fdlmws4g0a1pb8p7yn0wx8jgsacz26a4i1q7gpi4";
};
buildInputs = [
CaptureTiny PathClass TestDeep TestDir TestException
TestFile TestFileContents TestMockModule TestNoWarnings
];
propagatedBuildInputs = [
Clone ConfigGitLike DBI DateTime
DevelStackTrace EncodeLocale FileHomeDir HashMerge IOPager IPCRun3
IPCSystemSimple ListMoreUtils Moo PathClass PerlIOutf8_strict StringFormatter
StringShellQuote SubExporter TemplateTiny Throwable TryTiny TypeTiny URI
URIdb libintlperl namespaceautoclean
];
doCheck = false; # Can't find home directory.
meta = {
homepage = http://sqitch.org/;
description = "Sane database change management";
license = stdenv.lib.licenses.mit;
};
};
DBDPg = import ../development/perl-modules/DBD-Pg {
inherit stdenv fetchurl buildPerlPackage DBI;
inherit (pkgs) postgresql;
};
https://github.com/NixOS/nixpkgs/blob/56904d7c423f2b13b37fbd29f39bbb4b52bc7824/pkgs/development/perl-modules/DBD-Pg/default.nix(看起来像 nix-generate-from-cpan DBD::Pg
的输出,但不完全一样)
{ stdenv, fetchurl, buildPerlPackage, DBI, postgresql }:
buildPerlPackage rec {
name = "DBD-Pg-3.5.3";
src = fetchurl {
url = "mirror://cpan/authors/id/T/TU/TURNSTEP/${name}.tar.gz";
sha256 = "03m9w1cd0yyrbqwkwcl92j1cpmasmm69f3hwvcrlfsi5fnwsk63y";
};
buildInputs = [ postgresql ];
propagatedBuildInputs = [ DBI ];
makeMakerFlags = "POSTGRES_HOME=${postgresql}";
meta = {
homepage = http://search.cpan.org/dist/DBD-Pg/;
description = "DBI PostgreSQL interface";
license = with stdenv.lib.licenses; [ artistic1 gpl1Plus ];
platforms = stdenv.lib.platforms.unix;
};
}
这就是它的用途。
注意:正如我刚刚在问题评论中指出的那样,我也忘记在 callPackage
之后添加 {}
,这解释了我得到的奇怪类型。
我正在尝试使用 nix-generate-from-cspan to install sqitch
来自 nix-generate-from-cpan App::Sqitch DBD::Pg
,我制作了这个文件:
{buildPerlModule, fetchurl}:
buildPerlModule rec {
name = "App-Sqitch-0.9995";
src = fetchurl {
url = "mirror://cpan/authors/id/D/DW/DWHEELER/${name}.tar.gz";
sha256 = "c29b4610ce43bd43ecfa39188f4cbb00b38c390136fcdd9984142efd99eba292";
};
buildInputs = [ CaptureTiny ModuleBuild TestDeep TestDir TestException TestFile TestFileContents TestMockModule TestNoWarnings ];
propagatedBuildInputs = [ Clone ConfigGitLike DBI DateTime DateTimeTimeZone DevelStackTrace EncodeLocale FileHomeDir HashMerge IOPager IPCRun3 IPCSystemSimple ListMoreUtils Moo PathClass PerlIOutf8_strict StringFormatter StringShellQuote SubExporter TemplateTiny Throwable TryTiny TypeTiny URI URIdb libintlperl namespaceautoclean self."if" ];
meta = {
homepage = http://sqitch.org/;
description = "Sane database change management";
license = stdenv.lib.licenses.mit;
};
}
但是 运行 nix-build -E 'with import <nixpkgs> { }; callPackage ./sqitch.nix'
给出了这个错误:
expression does not evaluate to a derivation (or a set or list of those)
为了调试,我尝试了 nix-instantiate --eval --expr 'with import <nixpkgs> { }; callPackage ./sqitch.nix'
,结果是:
<LAMBDA>
所以我尝试了 nix-build -E 'with import <nixpkgs> { }; callPackage callPackage ./sqitch.nix'
但它仍然给出相同的错误,并且 nix-instantiate --eval --expr 'with import <nixpkgs> { }; callPackage callPackage ./sqitch.nix'
给出:
{ __functor = <CODE>; override = <CODE>; overrideDerivation = <CODE>; }
这对我帮助不大。
简答
buildPerlModule
的结果将用作 mkDerivation
参数中的 src
。
长答案
原来sqitch
已经是nixpkgs的一部分了,它的定义是这样的:
{ name, stdenv, perl, makeWrapper, sqitchModule, databaseModule }:
stdenv.mkDerivation {
name = "${name}-${sqitchModule.version}";
buildInputs = [ perl makeWrapper sqitchModule databaseModule ];
src = sqitchModule;
dontBuild = true;
installPhase = ''
mkdir -p $out/bin
for d in bin/sqitch etc lib share ; do
ln -s ${sqitchModule}/$d $out/$d
done
'';
dontStrip = true;
postFixup = "wrapProgram $out/bin/sqitch --prefix PERL5LIB : $PERL5LIB";
meta = {
platforms = stdenv.lib.platforms.unix;
};
}
sqitchPg = callPackage ../development/tools/misc/sqitch {
name = "sqitch-pg";
databaseModule = perlPackages.DBDPg;
sqitchModule = perlPackages.AppSqitch;
};
https://github.com/NixOS/nixpkgs/blob/56904d7c423f2b13b37fbd29f39bbb4b52bc7824/pkgs/top-level/perl-packages.nix#L281-L305(这是nix-generate-from-cpan App::Sqitch
的输出)
AppSqitch = buildPerlModule rec {
version = "0.9994";
name = "App-Sqitch-${version}";
src = fetchurl {
url = "mirror://cpan/authors/id/D/DW/DWHEELER/${name}.tar.gz";
sha256 = "0in602z40s50fdlmws4g0a1pb8p7yn0wx8jgsacz26a4i1q7gpi4";
};
buildInputs = [
CaptureTiny PathClass TestDeep TestDir TestException
TestFile TestFileContents TestMockModule TestNoWarnings
];
propagatedBuildInputs = [
Clone ConfigGitLike DBI DateTime
DevelStackTrace EncodeLocale FileHomeDir HashMerge IOPager IPCRun3
IPCSystemSimple ListMoreUtils Moo PathClass PerlIOutf8_strict StringFormatter
StringShellQuote SubExporter TemplateTiny Throwable TryTiny TypeTiny URI
URIdb libintlperl namespaceautoclean
];
doCheck = false; # Can't find home directory.
meta = {
homepage = http://sqitch.org/;
description = "Sane database change management";
license = stdenv.lib.licenses.mit;
};
};
DBDPg = import ../development/perl-modules/DBD-Pg {
inherit stdenv fetchurl buildPerlPackage DBI;
inherit (pkgs) postgresql;
};
https://github.com/NixOS/nixpkgs/blob/56904d7c423f2b13b37fbd29f39bbb4b52bc7824/pkgs/development/perl-modules/DBD-Pg/default.nix(看起来像 nix-generate-from-cpan DBD::Pg
的输出,但不完全一样)
{ stdenv, fetchurl, buildPerlPackage, DBI, postgresql }:
buildPerlPackage rec {
name = "DBD-Pg-3.5.3";
src = fetchurl {
url = "mirror://cpan/authors/id/T/TU/TURNSTEP/${name}.tar.gz";
sha256 = "03m9w1cd0yyrbqwkwcl92j1cpmasmm69f3hwvcrlfsi5fnwsk63y";
};
buildInputs = [ postgresql ];
propagatedBuildInputs = [ DBI ];
makeMakerFlags = "POSTGRES_HOME=${postgresql}";
meta = {
homepage = http://search.cpan.org/dist/DBD-Pg/;
description = "DBI PostgreSQL interface";
license = with stdenv.lib.licenses; [ artistic1 gpl1Plus ];
platforms = stdenv.lib.platforms.unix;
};
}
这就是它的用途。
注意:正如我刚刚在问题评论中指出的那样,我也忘记在 callPackage
之后添加 {}
,这解释了我得到的奇怪类型。