hercules-ci-cnix-store 0.1.0.0 → 0.1.1.0
raw patch · 4 files changed
+67/−1 lines, 4 files
Files
- CHANGELOG.md +7/−0
- hercules-ci-cnix-store.cabal +2/−1
- src/Hercules/CNix/Store.hs +17/−0
- src/Hercules/CNix/Util.hs +41/−0
CHANGELOG.md view
@@ -5,6 +5,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## 0.1.1.0 - 2021-04-21++### Added++ - Functions for retrieving the Nix daemon protocol versions+ - Functions for interacting with the interrupt handler+ ## 0.1.0.0 - 2021-03-05 ### Added
hercules-ci-cnix-store.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.4 name: hercules-ci-cnix-store-version: 0.1.0.0+version: 0.1.1.0 synopsis: Haskell bindings for Nix's libstore category: Nix homepage: https://docs.hercules-ci.com@@ -44,6 +44,7 @@ import: cxx-opts exposed-modules: Hercules.CNix+ Hercules.CNix.Util Hercules.CNix.Store.Context Hercules.CNix.Store include-dirs:
src/Hercules/CNix/Store.hs view
@@ -55,6 +55,8 @@ C.include "<nix/globals.hh>" +C.include "<nix/worker-protocol.hh>"+ C.include "hercules-ci-cnix/store.hxx" C.using "namespace nix"@@ -106,6 +108,21 @@ [C.block| const char* { std::string uri = (*$(refStore* store))->getUri(); return strdup(uri.c_str());+ } |]++getStoreProtocolVersion :: Store -> IO Int+getStoreProtocolVersion (Store store) =+ fromIntegral+ <$> [C.throwBlock| int {+ Store &store = **$(refStore* store);+ return store.getProtocol();+ } |]++getClientProtocolVersion :: IO Int+getClientProtocolVersion =+ fromIntegral+ <$> [C.throwBlock| int {+ return PROTOCOL_VERSION; } |] ensurePath :: Store -> ByteString -> IO ()
+ src/Hercules/CNix/Util.hs view
@@ -0,0 +1,41 @@+{-# LANGUAGE BlockArguments #-}+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TemplateHaskell #-}++-- | Functions calling Nix's libutil+module Hercules.CNix.Util+ ( setInterruptThrown,+ triggerInterrupt,+ )+where++import Hercules.CNix.Store.Context+ ( context,+ )+import qualified Language.C.Inline.Cpp as C+import qualified Language.C.Inline.Cpp.Exceptions as C+import Protolude+import Prelude ()++C.context context++C.include "<nix/config.h>"++C.include "<nix/affinity.hh>"++C.include "<nix/util.hh>"++C.using "namespace nix"++setInterruptThrown :: IO ()+setInterruptThrown =+ [C.throwBlock| void {+ nix::setInterruptThrown();+ } |]++triggerInterrupt :: IO ()+triggerInterrupt =+ [C.throwBlock| void {+ nix::triggerInterrupt();+ } |]