diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-07-30 16:14:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-30 16:14:03 +0200 |
commit | 2b67cb7b8c8ac7953f7e341d760bdb3c021fe765 (patch) | |
tree | d3cc3bd584680fea247f71331be2087623c229bf | |
parent | 48e35585a6f23b05647cef12bcc85eeab3ae1d59 (diff) | |
parent | c15e121e322ee5bca1d96d59cc0b693e5bd9d0bf (diff) |
Merge pull request #5072 from NixOS/ca/queryRealisation-perl
Expose a perl method to query a derivation
-rw-r--r-- | perl/lib/Nix/Store.pm | 1 | ||||
-rw-r--r-- | perl/lib/Nix/Store.xs | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/perl/lib/Nix/Store.pm b/perl/lib/Nix/Store.pm index 179f1dc90..3e4bbee0a 100644 --- a/perl/lib/Nix/Store.pm +++ b/perl/lib/Nix/Store.pm @@ -22,6 +22,7 @@ our @EXPORT = qw( derivationFromPath addTempRoot getBinDir getStoreDir + queryRawRealisation ); our $VERSION = '0.15'; diff --git a/perl/lib/Nix/Store.xs b/perl/lib/Nix/Store.xs index ad9042a2a..edbf12f7c 100644 --- a/perl/lib/Nix/Store.xs +++ b/perl/lib/Nix/Store.xs @@ -15,6 +15,7 @@ #include "crypto.hh" #include <sodium.h> +#include <nlohmann/json.hpp> using namespace nix; @@ -120,6 +121,18 @@ SV * queryPathInfo(char * path, int base32) croak("%s", e.what()); } +SV * queryRawRealisation(char * outputId) + PPCODE: + try { + auto realisation = store()->queryRealisation(DrvOutput::parse(outputId)); + if (realisation) + XPUSHs(sv_2mortal(newSVpv(realisation->toJSON().dump().c_str(), 0))); + else + XPUSHs(sv_2mortal(newSVpv("", 0))); + } catch (Error & e) { + croak("%s", e.what()); + } + SV * queryPathFromHashPart(char * hashPart) PPCODE: |