aboutsummaryrefslogtreecommitdiff
path: root/perl
diff options
context:
space:
mode:
Diffstat (limited to 'perl')
-rw-r--r--perl/Makefile2
-rw-r--r--perl/configure.ac13
-rw-r--r--perl/lib/Nix/Config.pm.in10
-rw-r--r--perl/lib/Nix/Store.pm60
-rw-r--r--perl/lib/Nix/Store.xs26
5 files changed, 27 insertions, 84 deletions
diff --git a/perl/Makefile b/perl/Makefile
index 7ddb0cf69..259ed7dc3 100644
--- a/perl/Makefile
+++ b/perl/Makefile
@@ -1,6 +1,6 @@
makefiles = local.mk
-GLOBAL_CXXFLAGS += -g -Wall
+GLOBAL_CXXFLAGS += -g -Wall -std=c++17
-include Makefile.config
diff --git a/perl/configure.ac b/perl/configure.ac
index c3769e142..255744afd 100644
--- a/perl/configure.ac
+++ b/perl/configure.ac
@@ -70,19 +70,6 @@ PKG_CHECK_MODULES([NIX], [nix-store])
NEED_PROG([NIX], [nix])
-# Get nix configure values
-export NIX_REMOTE=daemon
-nixbindir=$("$NIX" --experimental-features nix-command eval --raw -f '<nix/config.nix>' nixBinDir)
-nixlibexecdir=$("$NIX" --experimental-features nix-command eval --raw -f '<nix/config.nix>' nixLibexecDir)
-nixlocalstatedir=$("$NIX" --experimental-features nix-command eval --raw -f '<nix/config.nix>' nixLocalstateDir)
-nixsysconfdir=$("$NIX" --experimental-features nix-command eval --raw -f '<nix/config.nix>' nixSysconfDir)
-nixstoredir=$("$NIX" --experimental-features nix-command eval --raw -f '<nix/config.nix>' nixStoreDir)
-AC_SUBST(nixbindir)
-AC_SUBST(nixlibexecdir)
-AC_SUBST(nixlocalstatedir)
-AC_SUBST(nixsysconfdir)
-AC_SUBST(nixstoredir)
-
# Expand all variables in config.status.
test "$prefix" = NONE && prefix=$ac_default_prefix
test "$exec_prefix" = NONE && exec_prefix='${prefix}'
diff --git a/perl/lib/Nix/Config.pm.in b/perl/lib/Nix/Config.pm.in
index bc1749e60..f7c6f2484 100644
--- a/perl/lib/Nix/Config.pm.in
+++ b/perl/lib/Nix/Config.pm.in
@@ -4,14 +4,8 @@ use MIME::Base64;
$version = "@PACKAGE_VERSION@";
-$binDir = $ENV{"NIX_BIN_DIR"} || "@nixbindir@";
-$libexecDir = $ENV{"NIX_LIBEXEC_DIR"} || "@nixlibexecdir@";
-$stateDir = $ENV{"NIX_STATE_DIR"} || "@nixlocalstatedir@/nix";
-$logDir = $ENV{"NIX_LOG_DIR"} || "@nixlocalstatedir@/log/nix";
-$confDir = $ENV{"NIX_CONF_DIR"} || "@nixsysconfdir@/nix";
-$storeDir = $ENV{"NIX_STORE_DIR"} || "@nixstoredir@";
-
-$useBindings = 1;
+$binDir = Nix::Store::getBinDir;
+$storeDir = Nix::Store::getStoreDir;
%config = ();
diff --git a/perl/lib/Nix/Store.pm b/perl/lib/Nix/Store.pm
index d226264d4..179f1dc90 100644
--- a/perl/lib/Nix/Store.pm
+++ b/perl/lib/Nix/Store.pm
@@ -2,7 +2,6 @@ package Nix::Store;
use strict;
use warnings;
-use Nix::Config;
require Exporter;
@@ -22,6 +21,7 @@ our @EXPORT = qw(
addToStore makeFixedOutputPath
derivationFromPath
addTempRoot
+ getBinDir getStoreDir
);
our $VERSION = '0.15';
@@ -34,62 +34,8 @@ sub backtick {
return $res;
}
-if ($Nix::Config::useBindings) {
- require XSLoader;
- XSLoader::load('Nix::Store', $VERSION);
-} else {
-
- # Provide slow fallbacks of some functions on platforms that don't
- # support the Perl bindings.
-
- use File::Temp;
- use Fcntl qw/F_SETFD/;
-
- *hashFile = sub {
- my ($algo, $base32, $path) = @_;
- my $res = backtick("$Nix::Config::binDir/nix-hash", "--flat", $path, "--type", $algo, $base32 ? "--base32" : ());
- chomp $res;
- return $res;
- };
-
- *hashPath = sub {
- my ($algo, $base32, $path) = @_;
- my $res = backtick("$Nix::Config::binDir/nix-hash", $path, "--type", $algo, $base32 ? "--base32" : ());
- chomp $res;
- return $res;
- };
-
- *hashString = sub {
- my ($algo, $base32, $s) = @_;
- my $fh = File::Temp->new();
- print $fh $s;
- my $res = backtick("$Nix::Config::binDir/nix-hash", $fh->filename, "--type", $algo, $base32 ? "--base32" : ());
- chomp $res;
- return $res;
- };
-
- *addToStore = sub {
- my ($srcPath, $recursive, $algo) = @_;
- die "not implemented" if $recursive || $algo ne "sha256";
- my $res = backtick("$Nix::Config::binDir/nix-store", "--add", $srcPath);
- chomp $res;
- return $res;
- };
-
- *isValidPath = sub {
- my ($path) = @_;
- my $res = backtick("$Nix::Config::binDir/nix-store", "--check-validity", "--print-invalid", $path);
- chomp $res;
- return $res ne $path;
- };
-
- *queryPathHash = sub {
- my ($path) = @_;
- my $res = backtick("$Nix::Config::binDir/nix-store", "--query", "--hash", $path);
- chomp $res;
- return $res;
- };
-}
+require XSLoader;
+XSLoader::load('Nix::Store', $VERSION);
1;
__END__
diff --git a/perl/lib/Nix/Store.xs b/perl/lib/Nix/Store.xs
index 945ed49c7..599921151 100644
--- a/perl/lib/Nix/Store.xs
+++ b/perl/lib/Nix/Store.xs
@@ -182,7 +182,7 @@ void importPaths(int fd, int dontCheckSigs)
PPCODE:
try {
FdSource source(fd);
- store()->importPaths(source, nullptr, dontCheckSigs ? NoCheckSigs : CheckSigs);
+ store()->importPaths(source, dontCheckSigs ? NoCheckSigs : CheckSigs);
} catch (Error & e) {
croak("%s", e.what());
}
@@ -224,7 +224,7 @@ SV * hashString(char * algo, int base32, char * s)
SV * convertHash(char * algo, char * s, int toBase32)
PPCODE:
try {
- Hash h(s, parseHashType(algo));
+ auto h = Hash::parseAny(s, parseHashType(algo));
string s = h.to_string(toBase32 ? Base32 : Base16, false);
XPUSHs(sv_2mortal(newSVpv(s.c_str(), 0)));
} catch (Error & e) {
@@ -285,7 +285,7 @@ SV * addToStore(char * srcPath, int recursive, char * algo)
SV * makeFixedOutputPath(int recursive, char * algo, char * hash, char * name)
PPCODE:
try {
- Hash h(hash, parseHashType(algo));
+ auto h = Hash::parseAny(hash, parseHashType(algo));
auto method = recursive ? FileIngestionMethod::Recursive : FileIngestionMethod::Flat;
auto path = store()->makeFixedOutputPath(method, h, name);
XPUSHs(sv_2mortal(newSVpv(store()->printStorePath(path).c_str(), 0)));
@@ -303,8 +303,14 @@ SV * derivationFromPath(char * drvPath)
hash = newHV();
HV * outputs = newHV();
- for (auto & i : drv.outputs)
- hv_store(outputs, i.first.c_str(), i.first.size(), newSVpv(store()->printStorePath(i.second.path).c_str(), 0), 0);
+ for (auto & i : drv.outputsAndOptPaths(*store())) {
+ hv_store(
+ outputs, i.first.c_str(), i.first.size(),
+ !i.second.second
+ ? newSV(0) /* null value */
+ : newSVpv(store()->printStorePath(*i.second.second).c_str(), 0),
+ 0);
+ }
hv_stores(hash, "outputs", newRV((SV *) outputs));
AV * inputDrvs = newAV();
@@ -345,3 +351,13 @@ void addTempRoot(char * storePath)
} catch (Error & e) {
croak("%s", e.what());
}
+
+
+SV * getBinDir()
+ PPCODE:
+ XPUSHs(sv_2mortal(newSVpv(settings.nixBinDir.c_str(), 0)));
+
+
+SV * getStoreDir()
+ PPCODE:
+ XPUSHs(sv_2mortal(newSVpv(settings.nixStore.c_str(), 0)));