Skip to content

Commit

Permalink
Expose a perl method to query a derivation
Browse files Browse the repository at this point in the history
Just doing a very stupid thing taking as argument a serialised drv
output and returning a serialised realisation.

This is needed for `nix-serve` to handle ca derivations
  • Loading branch information
thufschmitt committed Jul 30, 2021
1 parent 48e3558 commit c15e121
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions perl/lib/Nix/Store.pm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ our @EXPORT = qw(
derivationFromPath
addTempRoot
getBinDir getStoreDir
queryRawRealisation
);

our $VERSION = '0.15';
Expand Down
13 changes: 13 additions & 0 deletions perl/lib/Nix/Store.xs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "crypto.hh"

#include <sodium.h>
#include <nlohmann/json.hpp>


using namespace nix;
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit c15e121

Please sign in to comment.