packages feed

hercules-ci-cnix-store 0.2.0.0 → 0.2.0.1

raw patch · 3 files changed

+102/−1 lines, 3 files

Files

CHANGELOG.md view
@@ -5,6 +5,12 @@  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## 0.2.0.1 - 2021-06-16++### Fixed++ - Missing file in sdist+ ## 0.2.0.0 - 2021-06-16  ### Added
+ compat-2.3/include/nix-compat.hh view
@@ -0,0 +1,92 @@+#pragma once+#include <nix/store-api.hh>+#include <nix/derivation-output.hh>+#include <nix/derivations.hh>+#include <nix/path-compat.hh>++// derivations.cc++inline void validatePath(std::string_view s) {+    if (s.size() == 0 || s[0] != '/')+        throw nix::FormatError("bad path '%1%' in derivation", s);+}++inline compat::nix::DerivationOutput parseDerivationOutput(const nix::Store & store, std::string drvName,+    std::string pathS, std::string hashAlgo, std::string hash)+{+    if (hashAlgo != "") {+        auto method = nix::FileIngestionMethod::Flat;+        if (std::string(hashAlgo, 0, 2) == "r:") {+            method = nix::FileIngestionMethod::Recursive;+            hashAlgo = hashAlgo.substr(2);+        }+        const auto hashType = nix::parseHashType(hashAlgo);+        if (hash != "") {+            validatePath(pathS);+            return compat::nix::DerivationOutput {+                .output = nix::DerivationOutputCAFixed {+                    .drvName = drvName,+                    .hash = nix::FixedOutputHash {+                        .method = std::move(method),+                        .hash = nix::Hash(hash, hashType),+                    },+                },+            };+        } else {+            throw nix::Error("ca-derivations not supported in Nix 2.3");+        }+    } else {+        if (pathS == "") {+            return compat::nix::DerivationOutput {+                .output = nix::DerivationOutputDeferred { }+            };+        }+        validatePath(pathS);+        return compat::nix::DerivationOutput {+            .output = nix::DerivationOutputInputAddressed {+                .path = parseStorePath(store, pathS),+            }+        };+    }+}++inline compat::nix::DerivationOutput compatDerivationOutput(nix::Store &store, std::string drvName, nix::DerivationOutput &o) {+  return parseDerivationOutput(store, drvName, o.path, o.hashAlgo, o.hash);+}++inline void compatComputeFSClosure(nix::Store &store, nix::StorePathSet &pathSet, nix::StorePathSet &closurePaths, bool flipDirection = false, bool includeOutputs = false, bool includeDerivers = false) {+  nix::PathSet simpleClosurePaths;+  store.computeFSClosure(compatPathSet(store, pathSet), simpleClosurePaths, flipDirection, includeOutputs, includeDerivers);+  for (auto sp : simpleClosurePaths) {+    closurePaths.insert(parseStorePath(store, sp));+  }+}++inline nix::StorePathSet parseStorePathSet(const nix::Store &store, const nix::PathSet &pathSet) {+  nix::StorePathSet r;+  for (auto sp : pathSet) {+    // TODO merge?+    r.insert(parseStorePath(store, sp));+  }+  return r;+}+#define parseStorePathSet23(store, pathSet) parseStorePathSet(store, pathSet)++inline std::optional<nix::StorePath> parseOptionalStorePath(const nix::Store &store, const nix::Path path) {+  if (path != "unknown-deriver" && path != "")+    return parseStorePath(store, path);+  return {};+}+#define parseOptionalStorePath23(store, path) parseOptionalStorePath(store, path)++#define toDerivedPaths24(x) (x)++namespace nix {+  StorePathWithOutputs parsePathWithOutputs(const Store &store, const std::string & s);+}++// util.hh++// C++17 std::visit boilerplate+template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; };+template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
hercules-ci-cnix-store.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.4  name:           hercules-ci-cnix-store-version:        0.2.0.0+version:        0.2.0.1 synopsis:       Haskell bindings for Nix's libstore category:       Nix homepage:       https://docs.hercules-ci.com@@ -14,6 +14,9 @@ extra-source-files:     CHANGELOG.md     test/data/*.drv+    compat-2.3/include/*.hh+    compat-2.3/include/nix/*.hh+    compat-2.4/include/*.hh  source-repository head   type: git