mirror of
https://github.com/haskell-nix/hnix-store.git
synced 2024-09-11 18:05:56 +03:00
remote: add build-derivation executable
This commit is contained in:
parent
edace0445c
commit
2e9ab694fa
@ -20,4 +20,4 @@ package hnix-store-nar
|
||||
flags: +bounded_memory
|
||||
|
||||
package hnix-store-remote
|
||||
flags: +build-readme +io-testsuite
|
||||
flags: +build-derivation +build-readme +io-testsuite
|
||||
|
41
hnix-store-remote/app/BuildDerivation.hs
Normal file
41
hnix-store-remote/app/BuildDerivation.hs
Normal file
@ -0,0 +1,41 @@
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
module Main where
|
||||
|
||||
import Data.Default.Class (Default(def))
|
||||
import Data.Text (Text)
|
||||
import System.Nix.Derivation (Derivation)
|
||||
import System.Nix.StorePath (StorePath)
|
||||
|
||||
import qualified Data.Text
|
||||
import qualified Data.Text.IO
|
||||
import qualified Data.Attoparsec.Text
|
||||
import qualified System.Environment
|
||||
import qualified System.Nix.Build
|
||||
import qualified System.Nix.Derivation
|
||||
import qualified System.Nix.StorePath
|
||||
import qualified System.Nix.Store.Remote
|
||||
|
||||
parseDerivation :: FilePath -> IO (Derivation StorePath Text)
|
||||
parseDerivation source = do
|
||||
contents <- Data.Text.IO.readFile source
|
||||
case Data.Attoparsec.Text.parseOnly
|
||||
(System.Nix.Derivation.parseDerivation def) contents of
|
||||
Left e -> error e
|
||||
Right drv -> pure drv
|
||||
|
||||
main :: IO ()
|
||||
main = System.Environment.getArgs >>= \case
|
||||
[filename] -> do
|
||||
case System.Nix.StorePath.parsePathFromText def (Data.Text.pack filename) of
|
||||
Left e -> error $ show e
|
||||
Right p -> do
|
||||
d <- parseDerivation filename
|
||||
out <-
|
||||
System.Nix.Store.Remote.runStore
|
||||
$ System.Nix.Store.Remote.buildDerivation
|
||||
p
|
||||
d
|
||||
System.Nix.Build.BuildMode_Normal
|
||||
print out
|
||||
_ -> error "No input derivation file"
|
||||
|
@ -56,6 +56,12 @@ flag io-testsuite
|
||||
Enable testsuite, which requires external
|
||||
binaries and Linux namespace support.
|
||||
|
||||
flag build-derivation
|
||||
default:
|
||||
False
|
||||
description:
|
||||
Build build-derivation executable
|
||||
|
||||
flag build-readme
|
||||
default:
|
||||
False
|
||||
@ -111,6 +117,21 @@ library
|
||||
hs-source-dirs: src
|
||||
ghc-options: -Wall
|
||||
|
||||
executable build-derivation
|
||||
if !flag(build-derivation)
|
||||
buildable: False
|
||||
build-depends:
|
||||
base >=4.12 && <5
|
||||
, attoparsec
|
||||
, hnix-store-core
|
||||
, hnix-store-remote
|
||||
, data-default-class
|
||||
, text
|
||||
default-language: Haskell2010
|
||||
main-is: BuildDerivation.hs
|
||||
hs-source-dirs: app
|
||||
ghc-options: -Wall -threaded -rtsopts "-with-rtsopts -N"
|
||||
|
||||
executable remote-readme
|
||||
if !flag(build-readme)
|
||||
buildable: False
|
||||
|
Loading…
Reference in New Issue
Block a user