Skip to content

A bunch of fixes to sync with deps #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
packageRoot: [ hnix-store-core, hnix-store-remote ]
packageRoot: [ hnix-store-remote ]
ghc: [ "8.10", "8.4" ]
defaults:
run:
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/Core-Cabal-Linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: "Hackage, Cabal, Linux"

on:
pull_request:
push:
branches:
- master
schedule:
- cron: "45 02 * * *"

env:
cabalConfig: --enable-tests --disable-optimization --enable-deterministic

jobs:

build10:
name: "GHC"
runs-on: ubuntu-latest
strategy:
matrix:
# Separation between Core & Store workflows made deliberately, so when one fixes Core, CI does not falls because of the Hackage Core Remote builds with.
# Also singleton also use is deliberate, it allows to reference the value in the further configuration & also leaves a name in the CI & preserves matrix flexibility for the future.
packageRoot: [ hnix-store-core ]
ghc: [ "8.10", "8.4" ]
defaults:
run:
working-directory: "./${{ matrix.packageRoot }}"
steps:

- name: "Git checkout"
uses: actions/checkout@v2
with:
submodules: recursive

- name: "Haskell env setup"
id: HaskEnvSetup
uses: haskell/actions/setup@v1
with:
ghc-version: ${{ matrix.ghc }}

- name: "Repository update"
run: cabal v2-update

- name: "Install additional system packages"
run: sudo apt install libsodium-dev

# NOTE: Freeze is for the caching
- name: "Configuration freeze"
run: cabal v2-freeze $cabalConfig

- name: "Hack: Copy freeze file to the root dir"
run: cp -a cabal.project.freeze ../cabal.project.freeze

- name: "Configuring GitHub cache"
uses: actions/cache@v2
with:
path: |
${{ steps.HaskEnvSetup.outputs.cabal-store }}
dist-newstyle
key: ${{ matrix.packageRoot }}-${{ runner.os }}-Cabal-${{ matrix.ghc }}-${{ hashFiles( 'cabal.project.freeze' ) }}
restore-keys: ${{ matrix.packageRoot }}-${{ runner.os }}-Cabal-${{ matrix.ghc }}-

- name: "Build"
run: cabal v2-build $cabalConfig

- name: "Tests"
run: cabal v2-test $cabalConfig

- name: "Source distribution file"
if: ${{ matrix.ghc == '8.10' }}
run: cabal v2-sdist
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ env:

jobs:

# 2021-03-12: NOTE: Please, enable uncommented working code when `remote` builds on macOS.
build10:
name: "GHC"
runs-on: macos-latest
strategy:
matrix:
packageRoot: [ hnix-store-core ]
# packageRoot: [ hnix-store-core, hnix-store-remote ]
defaults:
run:
working-directory: "./${{ matrix.packageRoot }}"
Expand All @@ -43,16 +41,6 @@ jobs:
- name: "Install additional system packages"
run: cabal v2-install tasty-discover

# # Still required for Remote
# - name: "Install Nix"
# uses: cachix/install-nix-action@v12
# if: matrix.packageRoot == 'hnix-store-remote'

# # Remote: Enabling testsuite, because it requires networking in the default Nix environment.
# - name: "Project-specific Cabal configuration"
# if: matrix.packageRoot == 'hnix-store-remote'
# run: echo "cabalConfig=$cabalConfig -f io-testsuite" >> $GITHUB_ENV

# NOTE: Freeze is for the caching
- name: "Configuration freeze"
run: cabal v2-freeze $cabalConfig
Expand Down
1 change: 1 addition & 0 deletions hnix-store-core/hnix-store-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ test-suite format-tests
, process
, tasty
, tasty-golden
, hspec
, tasty-hspec
, tasty-hunit
, tasty-quickcheck
Expand Down
12 changes: 11 additions & 1 deletion hnix-store-core/src/System/Nix/Internal/Signature.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Description : Nix-relevant interfaces to NaCl signatures.
-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE CPP #-}

module System.Nix.Internal.Signature where

Expand All @@ -11,16 +12,25 @@ import qualified Data.ByteString as Bytes
import Data.Coerce ( coerce )
import Crypto.Saltine.Core.Sign ( PublicKey )
import Crypto.Saltine.Class ( IsEncoding(..) )
import qualified Crypto.Saltine.Internal.ByteSizes as NaClSizes

-- 2021-05-30: NOTE: Please, clean-up these overloads in ~2022
#if MIN_VERSION_saltine(0,2,0)
import qualified Crypto.Saltine.Internal.Sign as NaClSizes
#else
import qualified Crypto.Saltine.Internal.ByteSizes as NaClSizes
#endif

-- | A NaCl signature.
newtype Signature = Signature ByteString
deriving (Eq, Ord)

instance IsEncoding Signature where
decode s
#if MIN_VERSION_saltine(0,2,0)
| Bytes.length s == NaClSizes.sign_bytes = Just $ Signature s
#else
| Bytes.length s == NaClSizes.sign = Just $ Signature s
#endif
| otherwise = Nothing
encode = coerce

Expand Down
17 changes: 9 additions & 8 deletions hnix-store-core/tests/Derivation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,26 @@ import System.Nix.Derivation ( parseDerivation
, buildDerivation
)

import qualified Data.Attoparsec.Text.Lazy
import qualified Data.Attoparsec.Text
import qualified Data.Text.IO
import qualified Data.Text.Lazy
import qualified Data.Text.Lazy.Builder

processDerivation :: FilePath -> FilePath -> IO ()
processDerivation source dest = do
contents <- Data.Text.IO.readFile source
case
Data.Attoparsec.Text.Lazy.parseOnly
(parseDerivation "/nix/store")
contents
of
Left e -> error e
Right drv ->
either
fail
(\ drv ->
Data.Text.IO.writeFile dest
. Data.Text.Lazy.toStrict
. Data.Text.Lazy.Builder.toLazyText
$ buildDerivation drv
)
(Data.Attoparsec.Text.parseOnly
(parseDerivation "/nix/store")
contents
)

test_derivation :: TestTree
test_derivation =
Expand Down
2 changes: 1 addition & 1 deletion hnix-store-core/tests/Hash.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import qualified Data.ByteString.Base64.Lazy as B64
import qualified Data.ByteString.Lazy as BSL
import Data.Text (Text)

import Test.Tasty.Hspec
import Test.Hspec
import Test.Tasty.QuickCheck

import System.Nix.Hash
Expand Down
2 changes: 1 addition & 1 deletion hnix-store-core/tests/NarFormat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import qualified System.IO.Temp as Temp
import qualified System.Posix.Process as Unix
import qualified System.Process as P
import Test.Tasty as T
import Test.Tasty.Hspec
import Test.Hspec
import qualified Test.Tasty.HUnit as HU
import Test.Tasty.QuickCheck
import qualified Text.Printf as Printf
Expand Down
6 changes: 3 additions & 3 deletions hnix-store-core/tests/StorePath.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

module StorePath where

import qualified Data.Attoparsec.Text.Lazy
import qualified Data.Attoparsec.Text

import Test.Tasty.QuickCheck

Expand All @@ -24,8 +24,8 @@ prop_storePathRoundtrip' x =

prop_storePathRoundtripParser :: NixLike -> NixLike -> Property
prop_storePathRoundtripParser (_ :: NixLike) = \(NixLike x) ->
(Data.Attoparsec.Text.Lazy.parseOnly (pathParser $ storePathRoot x) $ storePathToText x) === Right x
(Data.Attoparsec.Text.parseOnly (pathParser $ storePathRoot x) $ storePathToText x) === Right x

prop_storePathRoundtripParser' :: StorePath -> Property
prop_storePathRoundtripParser' x =
(Data.Attoparsec.Text.Lazy.parseOnly (pathParser $ storePathRoot x) $ storePathToText x) === Right x
(Data.Attoparsec.Text.parseOnly (pathParser $ storePathRoot x) $ storePathToText x) === Right x