aboutsummaryrefslogtreecommitdiff
path: root/perl/lib
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-09-17 10:42:51 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-09-17 10:42:51 +0200
commitc9f51e87057652db0013289a95deffba495b35e7 (patch)
treecfa5f88a6d8da6bf602ff9390a1546a37b8280a6 /perl/lib
parent787469c7b66aec12ab6847e7db2cdc8aef5c325e (diff)
Remove corepkgs/config.nix
This isn't used anywhere except in the configure script of the Perl bindings. I've changed the latter to use the C++ API's Settings object at runtime.
Diffstat (limited to 'perl/lib')
-rw-r--r--perl/lib/Nix/Config.pm.in10
-rw-r--r--perl/lib/Nix/Store.pm60
-rw-r--r--perl/lib/Nix/Store.xs10
3 files changed, 15 insertions, 65 deletions
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 8546f6307..599921151 100644
--- a/perl/lib/Nix/Store.xs
+++ b/perl/lib/Nix/Store.xs
@@ -351,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)));