Skip to content
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

derivationStrict #554

Merged
merged 9 commits into from
Jan 1, 2021
Prev Previous commit
Next Next commit
use & support recent hnix-store master == 0.4
M  default.nix
M  hnix.cabal
M  src/Nix/Effects/Derivation.hs

default.nix: fx overlay call
  • Loading branch information
Anton-Latukha committed Dec 31, 2020
commit 1927b424e68560bd07f2c9bedf78590756a2459a
29 changes: 20 additions & 9 deletions default.nix
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@
# , nixos-20.03 # Last stable release, gets almost no updates to recipes, gets only required backports
# ...
# }
, rev ? "24eb3f87fc610f18de7076aee7c5a84ac5591e3e"
, rev ? "8ba15f6383c74e981d8038fa19cc77ed0c53ba22"

, pkgs ?
if builtins.compareVersions builtins.nixVersion "2.0" < 0
@@ -125,16 +125,16 @@ let
then getDefaultGHC
else compiler;

# 2020-05-23: NOTE: Currently HNix-store needs no overlay
# hnix-store-src = pkgs.fetchFromGitHub {
# owner = "haskell-nix";
# repo = "hnix-store";
# rev = "0.2.0.0";
# sha256 = "1qf5rn43d46vgqqgmwqdkjh78rfg6bcp4kypq3z7mx46sdpzvb78";
# };
# 2020-12-31: NOTE: Remove after `hnix-store 0.4` arrives into Nixpkgs
hnix-store-src = pkgs.fetchFromGitHub {
owner = "haskell-nix";
repo = "hnix-store";
rev = "fd09d29b8bef4904058f033d693e7d928a4a92dc";
sha256 = "0fxig1ckzknm5g19jzg7rrcpz7ssn4iiv9bs9hff9gfy3ciq4zrs";
};

overlay = pkgs.lib.foldr pkgs.lib.composeExtensions (_: _: {}) [
# (import "${hnix-store-src}/overlay.nix")
(import "${hnix-store-src}/overlay.nix" pkgs pkgs.haskell.lib)
(self: super:
pkgs.lib.optionalAttrs withHoogle {
ghc = super.ghc // { withPackages = super.ghc.withHoogle; };
@@ -223,6 +223,17 @@ let
root = packageRoot;

overrides = self: super: {
# 2020-12-07 We really want cryptohash-sha512, but it conflicts with
# recent versions of base, for seemingly no valid reason.
# As the update is slow to happen, just jailbreak here
# See https://github.com/haskell-hvr/cryptohash-sha512/pull/3
# and https://github.com/haskell-hvr/cryptohash-sha512/pull/5
cryptohash-sha512 = pkgs.haskell.lib.unmarkBroken ( pkgs.haskell.lib.doJailbreak super.cryptohash-sha512 );

# 2020-12-07 hnix-store-remote fails when trying to connect to a real hnix daemon.
# probably due to nix sandbox restrictions.
hnix-store-remote = pkgs.haskell.lib.dontCheck super.hnix-store-remote;

# 2020-08-04 hnix uses custom LayoutOptions and therefore is
# likely to be affected by the change in the ribbon width
# calculation in prettyprinter-1.7.0.
4 changes: 2 additions & 2 deletions hnix.cabal
Original file line number Diff line number Diff line change
@@ -402,8 +402,8 @@ library
, gitrev >= 1.1.0 && < 1.4
, hashable >= 1.2.5 && < 1.4
, hashing >= 0.1.0 && < 0.2
, hnix-store-core >= 0.3.0 && < 0.4
, hnix-store-remote >= 0.2.0 && < 0.3
, hnix-store-core >= 0.4.0 && < 0.5
, hnix-store-remote >= 0.4.0 && < 0.5
, http-client >= 0.5.14 && < 0.6 || >= 0.6.4 && < 0.7
, http-client-tls >= 0.3.5 && < 0.4
, http-types >= 0.12.2 && < 0.13
8 changes: 4 additions & 4 deletions src/Nix/Effects/Derivation.hs
Original file line number Diff line number Diff line change
@@ -112,7 +112,7 @@ hashDerivationModulo (Derivation {
$ "fixed:out"
<> (if hashMode == Recursive then ":r" else "")
<> ":" <> (Store.algoName @hashType)
<> ":" <> (Store.encodeBase16 digest)
<> ":" <> (Store.encodeInBase Store.Base16 digest)
<> ":" <> path
outputsList -> throwError $ ErrorCall $ "This is weird. A fixed output drv should only have one output named 'out'. Got " ++ show outputsList
hashDerivationModulo drv@(Derivation {inputs = (inputSrcs, inputDrvs)}) = do
@@ -122,7 +122,7 @@ hashDerivationModulo drv@(Derivation {inputs = (inputSrcs, inputDrvs)}) = do
Just hash -> return (hash, outs)
Nothing -> do
drv' <- readDerivation $ Text.unpack path
hash <- Store.encodeBase16 <$> hashDerivationModulo drv'
hash <- Store.encodeInBase Store.Base16 <$> hashDerivationModulo drv'
return (hash, outs)
)
return $ Store.hash @'Store.SHA256 $ Text.encodeUtf8 $ unparseDrv (drv {inputs = (inputSrcs, inputsModulo)})
@@ -135,7 +135,7 @@ unparseDrv (Derivation {..}) = Text.append "Derive" $ parens
case mFixed of
Nothing -> parens [s outputName, s outputPath, s "", s ""]
Just (Store.SomeDigest (digest :: Store.Digest hashType)) ->
parens [s outputName, s outputPath, s $ prefix <> Store.algoName @hashType, s $ Store.encodeBase16 digest]
parens [s outputName, s outputPath, s $ prefix <> Store.algoName @hashType, s $ Store.encodeInBase Store.Base16 digest]
)
, -- inputDrvs
list $ flip map (Map.toList $ snd inputs) (\(path, outs) ->
@@ -257,7 +257,7 @@ defaultDerivationStrict = fromValue @(AttrSet (NValue t f m)) >=> \s -> do
drvPath <- pathToText <$> writeDerivation drv'

-- Memoize here, as it may be our last chance in case of readonly stores.
drvHash <- Store.encodeBase16 <$> hashDerivationModulo drv'
drvHash <- Store.encodeInBase Store.Base16 <$> hashDerivationModulo drv'
modify (\(a, b) -> (a, MS.insert drvPath drvHash b))

let outputsWithContext = Map.mapWithKey (\out path -> principledMakeNixStringWithSingletonContext path (StringContext drvPath (DerivationOutput out))) (outputs drv')