about summary refs log tree commit diff
path: root/perl
diff options
context:
space:
mode:
Diffstat (limited to 'perl')
-rw-r--r--perl/Makefile.am1
-rw-r--r--perl/lib/Nix/Store.pm2
-rw-r--r--perl/lib/Nix/Store.xs41
3 files changed, 33 insertions, 11 deletions
diff --git a/perl/Makefile.am b/perl/Makefile.am
index e6a5f9b5e71c..eded469f924b 100644
--- a/perl/Makefile.am
+++ b/perl/Makefile.am
@@ -5,6 +5,7 @@ perllibdir = $(libdir)/perl5/site_perl/$(perlversion)/$(perlarchname)
 PERL_MODULES = lib/Nix/Store.pm lib/Nix/Manifest.pm lib/Nix/GeneratePatches.pm lib/Nix/SSH.pm lib/Nix/Config.pm.in
 
 all: $(PERL_MODULES:.in=)
+	ln -sfn $(abs_builddir)/.libs/libNixStore.so lib/Store.so
 
 install-exec-local: $(PERL_MODULES:.in=)
 	$(INSTALL) -d $(DESTDIR)$(perllibdir)/Nix
diff --git a/perl/lib/Nix/Store.pm b/perl/lib/Nix/Store.pm
index af69debedaf2..bef6e7460ca7 100644
--- a/perl/lib/Nix/Store.pm
+++ b/perl/lib/Nix/Store.pm
@@ -12,7 +12,7 @@ our %EXPORT_TAGS = ( 'all' => [ qw( ) ] );
 
 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
 
-our @EXPORT = qw( );
+our @EXPORT = qw(isValidPath topoSortPaths computeFSClosure followLinksToStorePath);
 
 our $VERSION = '0.15';
 
diff --git a/perl/lib/Nix/Store.xs b/perl/lib/Nix/Store.xs
index dd5cffdbb7b3..af71ad955c4f 100644
--- a/perl/lib/Nix/Store.xs
+++ b/perl/lib/Nix/Store.xs
@@ -39,8 +39,7 @@ void init()
         doInit();
 
 
-int isValidPath(path)
-        char * path
+int isValidPath(char * path)
     CODE:
         try {
             doInit();
@@ -52,8 +51,7 @@ int isValidPath(path)
         RETVAL
 
 
-SV * queryReferences(path)
-        char * path
+SV * queryReferences(char * path)
     PPCODE:
         try {
             doInit();
@@ -66,8 +64,7 @@ SV * queryReferences(path)
         }
 
 
-SV * queryPathHash(path)
-        char * path
+SV * queryPathHash(char * path)
     PPCODE:
         try {
             doInit();
@@ -79,8 +76,7 @@ SV * queryPathHash(path)
         }
 
 
-SV * queryDeriver(path)
-        char * path
+SV * queryDeriver(char * path)
     PPCODE:
         try {
             doInit();
@@ -92,8 +88,7 @@ SV * queryDeriver(path)
         }
 
 
-SV * queryPathInfo(path)
-        char * path
+SV * queryPathInfo(char * path)
     PPCODE:
         try {
             doInit();
@@ -127,3 +122,29 @@ SV * computeFSClosure(int flipDirection, int includeOutputs, ...)
         } catch (Error & e) {
             croak(e.what());
         }
+
+
+SV * topoSortPaths(...)
+    PPCODE:
+        try {
+            doInit();
+            PathSet paths;
+            for (int n = 0; n < items; ++n) paths.insert(SvPV_nolen(ST(n)));
+            Paths sorted = topoSortPaths(*store, paths);
+            for (Paths::iterator i = sorted.begin(); i != sorted.end(); ++i)
+                XPUSHs(sv_2mortal(newSVpv(i->c_str(), 0)));
+        } catch (Error & e) {
+            croak(e.what());
+        }
+
+
+SV * followLinksToStorePath(char * path)
+    CODE:
+        try {
+            doInit();
+            RETVAL = newSVpv(followLinksToStorePath(path).c_str(), 0);
+        } catch (Error & e) {
+            croak(e.what());
+        }
+    OUTPUT:
+        RETVAL