Skip to content

Commit 59e08d4

Browse files
authored
Merge pull request #59 from sorki/storepath
Remote store
2 parents cbe0c49 + dff7527 commit 59e08d4

30 files changed

+1521
-235
lines changed

hnix-store-core/ChangeLog.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
# Revision history for hnix-store-core
22

3+
## (unreleased) 0.3.0.0 -- 2020-XY-ZV
4+
5+
* `StorePath` type changed to simple variant without type level
6+
symbolic store path root.
7+
* Added `makeFixedOutputPath` to `System.Nix.ReadonlyStore`
8+
* Added `decodeBase16` and `decodeBase32` to `System.Nix.Hash`
9+
* `System.Nix.StorePath` module now provides
10+
* `storePathToFilePath` and `storePathToText` helpers
11+
* `storePathToNarInfo` for converting paths to `narinfo` URLs
12+
* `parsePath` function
13+
* `pathParser` Attoparsec parser
14+
* Added `System.Nix.Build` module
15+
* Added `System.Nix.Derivation` module
16+
* Removed `System.Nix.Util` module, moved to `hnix-store-remote`
17+
318
## 0.2.0.0 -- 2020-03-12
419

520
Removed `System.Nix.Store`. We may reintroduce it later when multiple backends
621
exist and we can tell what common effects they should share.
722

8-
## 0.1.0.0 -- YYYY-mm-dd
23+
## 0.1.0.0 -- 2019-03-18
924

1025
* First version.

hnix-store-core/hnix-store-core.cabal

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ license-file: LICENSE
1111
author: Shea Levy
1212
maintainer: [email protected]
1313
copyright: 2018 Shea Levy
14-
category: System
14+
category: Nix
1515
build-type: Simple
1616
extra-source-files: ChangeLog.md, README.md
1717
cabal-version: >=1.10
1818

1919
library
2020
exposed-modules: System.Nix.Base32
21+
, System.Nix.Build
22+
, System.Nix.Derivation
2123
, System.Nix.Hash
2224
, System.Nix.Internal.Base32
2325
, System.Nix.Internal.Hash
@@ -28,8 +30,8 @@ library
2830
, System.Nix.Signature
2931
, System.Nix.StorePath
3032
, System.Nix.StorePathMetadata
31-
, System.Nix.Util
3233
build-depends: base >=4.10 && <5
34+
, attoparsec
3335
, base16-bytestring
3436
, bytestring
3537
, binary
@@ -42,8 +44,7 @@ library
4244
, filepath
4345
, hashable
4446
, mtl
45-
, regex-base
46-
, regex-tdfa >= 1.3.1.0
47+
, nix-derivation >= 1.1.1 && <2
4748
, saltine
4849
, time
4950
, text
@@ -65,22 +66,27 @@ test-suite format-tests
6566
main-is: Driver.hs
6667
other-modules:
6768
Arbitrary
69+
Derivation
6870
NarFormat
6971
Hash
72+
StorePath
7073
hs-source-dirs:
7174
tests
7275
build-depends:
7376
hnix-store-core
77+
, attoparsec
7478
, base
7579
, base16-bytestring
7680
, base64-bytestring
7781
, binary
7882
, bytestring
7983
, containers
84+
, filepath
8085
, directory
8186
, process
8287
, tasty
8388
, tasty-discover
89+
, tasty-golden
8490
, tasty-hspec
8591
, tasty-hunit
8692
, tasty-quickcheck
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{-# LANGUAGE RecordWildCards #-}
2+
{-|
3+
Description : Build related types
4+
Maintainer : srk <[email protected]>
5+
|-}
6+
module System.Nix.Build (
7+
BuildMode(..)
8+
, BuildStatus(..)
9+
, BuildResult(..)
10+
, buildSuccess
11+
) where
12+
13+
import Data.Time (UTCTime)
14+
import Data.Text (Text)
15+
import Data.HashSet (HashSet)
16+
17+
-- keep the order of these Enums to match enums from reference implementations
18+
-- src/libstore/store-api.hh
19+
data BuildMode = Normal | Repair | Check
20+
deriving (Eq, Ord, Enum, Show)
21+
22+
data BuildStatus =
23+
Built
24+
| Substituted
25+
| AlreadyValid
26+
| PermanentFailure
27+
| InputRejected
28+
| OutputRejected
29+
| TransientFailure -- possibly transient
30+
| CachedFailure -- no longer used
31+
| TimedOut
32+
| MiscFailure
33+
| DependencyFailed
34+
| LogLimitExceeded
35+
| NotDeterministic
36+
deriving (Eq, Ord, Enum, Show)
37+
38+
39+
-- | Result of the build
40+
data BuildResult = BuildResult
41+
{ -- | build status, MiscFailure should be default
42+
status :: !BuildStatus
43+
, -- | possible build error message
44+
errorMessage :: !(Maybe Text)
45+
, -- | How many times this build was performed
46+
timesBuilt :: !Integer
47+
, -- | If timesBuilt > 1, whether some builds did not produce the same result
48+
isNonDeterministic :: !Bool
49+
, -- Start time of this build
50+
startTime :: !UTCTime
51+
, -- Stop time of this build
52+
stopTime :: !UTCTime
53+
} deriving (Eq, Ord, Show)
54+
55+
buildSuccess BuildResult{..} = status == Built || status == Substituted || status == AlreadyValid
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
3+
module System.Nix.Derivation (
4+
parseDerivation
5+
, buildDerivation
6+
) where
7+
8+
import Data.Attoparsec.Text.Lazy (Parser)
9+
import Data.ByteString (ByteString)
10+
import Data.Text (Text)
11+
import Data.Text.Lazy.Builder (Builder)
12+
import Nix.Derivation (Derivation)
13+
import System.Nix.StorePath (StorePath, pathParser)
14+
15+
import qualified Data.ByteString.Char8
16+
import qualified Data.Text
17+
import qualified Data.Text.Lazy.Builder
18+
import qualified Data.Attoparsec.Text.Lazy
19+
20+
import qualified Nix.Derivation
21+
import qualified System.Nix.StorePath
22+
23+
parseDerivation :: FilePath -> Parser (Derivation StorePath Text)
24+
parseDerivation expectedRoot =
25+
Nix.Derivation.parseDerivationWith
26+
("\"" *> System.Nix.StorePath.pathParser expectedRoot <* "\"")
27+
Nix.Derivation.textParser
28+
29+
buildDerivation :: Derivation StorePath Text -> Builder
30+
buildDerivation derivation =
31+
Nix.Derivation.buildDerivationWith
32+
(string . Data.Text.pack . show)
33+
string
34+
derivation
35+
where
36+
string = Data.Text.Lazy.Builder.fromText . Data.Text.pack . show

0 commit comments

Comments
 (0)