Merge pull request #42 from awakesecurity/gabriel/latest_hnix

Build against latest `hnix`
This commit is contained in:
Gabriel Gonzalez 2019-03-25 10:22:19 -07:00 committed by GitHub
commit b0c77ea043
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 212 additions and 261 deletions

View File

@ -1,13 +1,13 @@
{ mkDerivation, aeson, aeson-pretty, ansi-wl-pprint, async, base
, bytestring, concurrentoutput, containers, cryptonite, data-fix
, deepseq, directory, exceptions, filepath, foldl, hnix
, http-client, http-types, lens, lens-aeson, lifted-base, memory
{ mkDerivation, aeson, aeson-pretty, async, base, bytestring
, concurrentoutput, containers, cryptonite, data-fix, deepseq
, directory, exceptions, filepath, foldl, hnix, http-client
, http-types, lens, lens-aeson, lifted-base, megaparsec, memory
, mtl, neat-interpolation, network, network-uri, nix-paths
, optional-args, optparse-applicative, optparse-generic, pooled-io
, pureMD5, scientific, stdenv, tar, tasty, tasty-golden
, tasty-hunit, tasty-quickcheck, tasty-smallcheck, temporary, text
, time, transformers, turtle, unordered-containers, uri-bytestring
, vector, wreq, zlib
, prettyprinter, pureMD5, scientific, stdenv, tar, tasty
, tasty-golden, tasty-hunit, tasty-quickcheck, tasty-smallcheck
, temporary, text, time, transformers, turtle, unordered-containers
, uri-bytestring, vector, word8, wreq, zlib
}:
mkDerivation {
pname = "hocker";
@ -15,23 +15,25 @@ mkDerivation {
src = ./.;
isLibrary = true;
isExecutable = true;
enableSeparateDataOutput = true;
libraryHaskellDepends = [
aeson aeson-pretty ansi-wl-pprint async base bytestring
concurrentoutput containers cryptonite data-fix deepseq directory
exceptions filepath foldl hnix http-client http-types lens
lens-aeson lifted-base memory mtl neat-interpolation network
aeson aeson-pretty async base bytestring concurrentoutput
containers cryptonite data-fix deepseq directory exceptions
filepath foldl hnix http-client http-types lens lens-aeson
lifted-base megaparsec memory mtl neat-interpolation network
network-uri nix-paths optparse-applicative optparse-generic
pooled-io pureMD5 scientific tar temporary text time transformers
turtle unordered-containers uri-bytestring vector wreq zlib
pooled-io prettyprinter pureMD5 scientific tar temporary text time
transformers turtle unordered-containers uri-bytestring vector wreq
zlib
];
executableHaskellDepends = [
base bytestring cryptonite data-fix filepath hnix lens mtl network
optional-args optparse-applicative optparse-generic temporary text
];
testHaskellDepends = [
aeson ansi-wl-pprint base bytestring containers cryptonite mtl
network network-uri tasty tasty-golden tasty-hunit tasty-quickcheck
tasty-smallcheck text unordered-containers
aeson base bytestring containers cryptonite mtl network network-uri
prettyprinter tasty tasty-golden tasty-hunit tasty-quickcheck
tasty-smallcheck text unordered-containers word8
];
homepage = "https://github.com/awakesecurity/hocker#readme";
description = "Interact with the docker registry and generate nix build instructions";

View File

@ -68,7 +68,6 @@ library
base >= 4.9 && < 5,
aeson >= 1.0.0.0,
aeson-pretty >= 0.8,
ansi-wl-pprint >= 0.6.7.3,
async >= 2.0.0.0 && < 2.3,
bytestring >= 0.10,
concurrentoutput >= 0.2,
@ -80,13 +79,13 @@ library
exceptions >= 0.8,
filepath >= 1.4,
foldl >= 1.0,
hnix >= 0.3.4,
hnix >= 0.5.2,
http-client >= 0.4,
http-types >= 0.9.1,
lens >= 4.0,
lens-aeson >= 1.0,
lifted-base >= 0.2.3.8,
megaparsec >= 6.0.0,
megaparsec >= 7.0.0,
memory >= 0.11,
mtl >= 2.2,
neat-interpolation >= 0.3.2,
@ -94,6 +93,7 @@ library
network-uri >= 2.6,
optparse-applicative >= 0.13,
optparse-generic >= 1.2.0,
prettyprinter >= 1.1.1,
pooled-io >= 0.0.2,
pureMD5 >= 2.1,
scientific >= 0.3,
@ -202,7 +202,7 @@ executable docker2nix
bytestring >= 0.10,
data-fix >= 0.0.3,
filepath >= 1.4,
hnix >= 0.3.4,
hnix >= 0.5.2,
hocker,
lens >= 4.0,
mtl >= 2.2,
@ -226,7 +226,6 @@ test-suite hocker-tests
build-depends:
base >= 4.9 && < 5,
aeson >= 0.9.0.1,
ansi-wl-pprint >= 0.6.7.3,
bytestring >= 0.10,
containers >= 0.5,
cryptonite >= 0.13,
@ -234,6 +233,7 @@ test-suite hocker-tests
mtl >= 2.2,
network >= 2.6,
network-uri >= 2.6,
prettyprinter >= 1.1.1,
tasty >= 0.11,
tasty-golden >= 2.3,
tasty-hunit >= 0.9,

View File

@ -1,9 +0,0 @@
let
fetchNixpkgs = import ./fetchNixpkgs.nix;
in
fetchNixpkgs {
rev = "3389f23412877913b9d22a58dfb241684653d7e9";
sha256 = "1zf05a90d29bpl7j56y20r3kmrl4xkvg7gsfi55n6bb2r0xp2ma5";
outputSha256 = "0wgm7sk9fca38a50hrsqwz6q79z35gqgb9nw80xz7pfdr4jy9pf8";
}

8
nix/18_09.nix Normal file
View File

@ -0,0 +1,8 @@
let
fetchNixpkgs = import ./fetchNixpkgs.nix;
in
fetchNixpkgs {
rev = "f5689d5d6b9be626e8528cb63e2f2cf8f9a0c87e";
sha256 = "101f0nnk6i25x9nxviy4by1mpxbdplq81hssvvgi8x54yvh8m3rq";
}

View File

@ -1,11 +0,0 @@
{ mkDerivation, base, deepseq, stdenv }:
mkDerivation {
pname = "Only";
version = "0.1";
sha256 = "0rdj3a629fk2vp121jq8mf2smkblrz5w3cxhlsyx6my2x29s2ymb";
revision = "1";
editedCabalFile = "f92f5da97e647451f1ee7f5bf44914fb75062d08ccd3f36b2000d649c63d13aa";
libraryHaskellDepends = [ base deepseq ];
description = "The 1-tuple type or single-value \"collection\"";
license = stdenv.lib.licenses.bsd3;
}

View File

@ -1,56 +1,48 @@
{ rev # The Git revision of nixpkgs to fetch
, sha256 # The SHA256 of the downloaded data
, outputSha256 ? null # The SHA256 output hash
, sha256 # The SHA256 hash of the unpacked archive
, system ? builtins.currentSystem # This is overridable if necessary
}:
with {
ifThenElse = { bool, thenValue, elseValue }: (
if bool then thenValue else elseValue);
};
if (0 <= builtins.compareVersions builtins.nixVersion "1.12")
ifThenElse {
bool = (0 <= builtins.compareVersions builtins.nixVersion "1.12");
# In Nix 1.12, we can just give a `sha256` to `builtins.fetchTarball`.
then (
builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
inherit sha256;
})
# In Nix 1.12, we can just give a `sha256` to `builtins.fetchTarball`.
thenValue = (
builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
sha256 = outputSha256;
});
# This hack should at least work for Nix 1.11
else (
(rec {
tarball = import <nix/fetchurl.nix> {
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
sha256 = null;
};
# This hack should at least work for Nix 1.11
elseValue = (
(rec {
tarball = import <nix/fetchurl.nix> {
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
inherit sha256;
};
builtin-paths = import <nix/config.nix>;
builtin-paths = import <nix/config.nix>;
script = builtins.toFile "nixpkgs-unpacker" ''
"$coreutils/mkdir" "$out"
cd "$out"
"$gzip" --decompress < "$tarball" | "$tar" -x --strip-components=1
'';
script = builtins.toFile "nixpkgs-unpacker" ''
"$coreutils/mkdir" "$out"
cd "$out"
"$gzip" --decompress < "$tarball" | "$tar" -x --strip-components=1
'';
nixpkgs = builtins.derivation ({
name = "nixpkgs-${builtins.substring 0 6 rev}";
nixpkgs = builtins.derivation ({
name = "nixpkgs-${builtins.substring 0 6 rev}";
builder = builtins.storePath builtin-paths.shell;
builder = builtins.storePath builtin-paths.shell;
args = [ script ];
args = [ script ];
inherit tarball system;
inherit tarball system;
tar = builtins.storePath builtin-paths.tar;
gzip = builtins.storePath builtin-paths.gzip;
coreutils = builtins.storePath builtin-paths.coreutils;
} // (if null == outputSha256 then { } else {
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = outputSha256;
}));
}).nixpkgs);
}
tar = builtins.storePath builtin-paths.tar;
gzip = builtins.storePath builtin-paths.gzip;
coreutils = builtins.storePath builtin-paths.coreutils;
} // (if null == sha256 then { } else {
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = sha256;
}));
}).nixpkgs)

66
nix/hnix.nix Normal file
View File

@ -0,0 +1,66 @@
{ mkDerivation, aeson, array, base, base16-bytestring, binary
, bytestring, containers, criterion, cryptohash-md5
, cryptohash-sha1, cryptohash-sha256, cryptohash-sha512, data-fix
, deepseq, dependent-sum, deriving-compat, Diff, directory
, exceptions, fetchgit, filepath, free, generic-random, Glob
, hashable, hashing, haskeline, hedgehog, hspec-discover
, http-client, http-client-tls, http-types, interpolate
, lens-family, lens-family-core, lens-family-th, logict, megaparsec
, monadlist, mtl, optparse-applicative, parser-combinators
, pretty-show, prettyprinter, process, ref-tf, regex-tdfa
, regex-tdfa-text, repline, scientific, semigroups, serialise
, split, stdenv, syb, tasty, tasty-hedgehog, tasty-hunit
, tasty-quickcheck, tasty-th, template-haskell, text, these, time
, transformers, unix, unordered-containers, vector, xml
}:
mkDerivation {
pname = "hnix";
version = "0.5.2";
src = fetchgit {
url = "https://github.com/haskell-nix/hnix.git";
sha256 = "0qaknj75bkrgalyvdjz3xwi2n6f2kisq4cpk7cr5198wcy0fn20w";
rev = "9b161172a55a70556410e3124e227468fe51dda3";
fetchSubmodules = true;
};
isLibrary = true;
isExecutable = true;
libraryHaskellDepends = [
aeson array base base16-bytestring binary bytestring containers
cryptohash-md5 cryptohash-sha1 cryptohash-sha256 cryptohash-sha512
data-fix deepseq dependent-sum deriving-compat directory exceptions
filepath free hashable hashing haskeline http-client
http-client-tls http-types interpolate lens-family lens-family-core
lens-family-th logict megaparsec monadlist mtl optparse-applicative
parser-combinators pretty-show prettyprinter process ref-tf
regex-tdfa regex-tdfa-text scientific semigroups serialise split
syb template-haskell text these time transformers unix
unordered-containers vector xml
];
executableHaskellDepends = [
aeson base base16-bytestring bytestring containers cryptohash-md5
cryptohash-sha1 cryptohash-sha256 cryptohash-sha512 data-fix
deepseq exceptions filepath hashing haskeline mtl
optparse-applicative pretty-show prettyprinter repline serialise
template-haskell text time transformers unordered-containers
];
testHaskellDepends = [
base base16-bytestring bytestring containers cryptohash-md5
cryptohash-sha1 cryptohash-sha256 cryptohash-sha512 data-fix
deepseq dependent-sum Diff directory exceptions filepath
generic-random Glob hashing hedgehog interpolate megaparsec mtl
optparse-applicative pretty-show prettyprinter process serialise
split tasty tasty-hedgehog tasty-hunit tasty-quickcheck tasty-th
template-haskell text time transformers unix unordered-containers
];
testToolDepends = [ hspec-discover ];
benchmarkHaskellDepends = [
base base16-bytestring bytestring containers criterion
cryptohash-md5 cryptohash-sha1 cryptohash-sha256 cryptohash-sha512
data-fix deepseq exceptions filepath hashing mtl
optparse-applicative serialise template-haskell text time
transformers unordered-containers
];
homepage = "https://github.com/haskell-nix/hnix#readme";
description = "Haskell implementation of the Nix language";
license = stdenv.lib.licenses.bsd3;
}

View File

@ -1,19 +0,0 @@
{ mkDerivation, base, bytestring, case-insensitive, connection
, cryptonite, data-default-class, exceptions, hspec, http-client
, http-types, memory, network, stdenv, tls, transformers
}:
mkDerivation {
pname = "http-client-tls";
version = "0.3.3";
sha256 = "0r50h7lhrwmxcmiq5nw1rxnpda3k6mhz4jsd86m56ymai5lnf77c";
libraryHaskellDepends = [
base bytestring case-insensitive connection cryptonite
data-default-class exceptions http-client http-types memory network
tls transformers
];
testHaskellDepends = [ base hspec http-client http-types ];
doCheck = false;
homepage = "https://github.com/snoyberg/http-client";
description = "http-client backend using the connection package and tls library";
license = stdenv.lib.licenses.mit;
}

View File

@ -1,27 +0,0 @@
{ mkDerivation, array, async, base, base64-bytestring
, blaze-builder, bytestring, case-insensitive, containers, cookie
, deepseq, directory, exceptions, filepath, ghc-prim, hspec
, http-types, mime-types, monad-control, network, network-uri
, random, stdenv, streaming-commons, text, time, transformers, zlib
}:
mkDerivation {
pname = "http-client";
version = "0.5.6.1";
sha256 = "1v9bdb8dkhb5g6jl9azk86ig7ia8xh9arr64n7s8r94fp0vl6c1c";
libraryHaskellDepends = [
array base base64-bytestring blaze-builder bytestring
case-insensitive containers cookie deepseq exceptions filepath
ghc-prim http-types mime-types network network-uri random
streaming-commons text time transformers
];
testHaskellDepends = [
async base base64-bytestring blaze-builder bytestring
case-insensitive containers deepseq directory hspec http-types
monad-control network network-uri streaming-commons text time
transformers zlib
];
doCheck = false;
homepage = "https://github.com/snoyberg/http-client";
description = "An HTTP client engine";
license = stdenv.lib.licenses.mit;
}

25
nix/megaparsec.nix Normal file
View File

@ -0,0 +1,25 @@
{ mkDerivation, base, bytestring, case-insensitive, containers
, criterion, deepseq, hspec, hspec-expectations, mtl
, parser-combinators, QuickCheck, scientific, stdenv, text
, transformers, weigh
}:
mkDerivation {
pname = "megaparsec";
version = "7.0.4";
sha256 = "325ba5cee8cdef91e351fb2db0b38562f8345b0bcdfed97045671357501de8c1";
libraryHaskellDepends = [
base bytestring case-insensitive containers deepseq mtl
parser-combinators scientific text transformers
];
testHaskellDepends = [
base bytestring case-insensitive containers hspec
hspec-expectations mtl parser-combinators QuickCheck scientific
text transformers
];
benchmarkHaskellDepends = [
base containers criterion deepseq text weigh
];
homepage = "https://github.com/mrkkrp/megaparsec";
description = "Monadic parser combinators";
license = stdenv.lib.licenses.bsd2;
}

View File

@ -0,0 +1,15 @@
{ mkDerivation, base, base-prelude, HTF, megaparsec, stdenv
, template-haskell, text
}:
mkDerivation {
pname = "neat-interpolation";
version = "0.3.2.4";
sha256 = "de7370d938ffd8c7b52d732f4f088387ed8216cf9767d818e99b7ec827931752";
libraryHaskellDepends = [
base base-prelude megaparsec template-haskell text
];
testHaskellDepends = [ base-prelude HTF ];
homepage = "https://github.com/nikita-volkov/neat-interpolation";
description = "A quasiquoter for neat and simple multiline text interpolation";
license = stdenv.lib.licenses.mit;
}

View File

@ -1,11 +0,0 @@
{ mkDerivation, base, nix, process, stdenv }:
mkDerivation {
pname = "nix-paths";
version = "1.0.1";
sha256 = "1y09wl1ihxmc9p926g595f70pdcsx78r3q5n5rna23lpq8xicdxb";
libraryHaskellDepends = [ base process ];
libraryToolDepends = [ nix ];
homepage = "https://github.com/peti/nix-paths";
description = "Knowledge of Nix's installation directories";
license = stdenv.lib.licenses.bsd3;
}

View File

@ -1,15 +0,0 @@
{ mkDerivation, ansi-wl-pprint, base, bytestring, process
, QuickCheck, stdenv, transformers, transformers-compat
}:
mkDerivation {
pname = "optparse-applicative";
version = "0.14.0.0";
sha256 = "06iwp1qsq0gjhnhxwyhdhldwvhlgcik6lx5jxpbb40fispyk4nxm";
libraryHaskellDepends = [
ansi-wl-pprint base process transformers transformers-compat
];
testHaskellDepends = [ base bytestring QuickCheck ];
homepage = "https://github.com/pcapriotti/optparse-applicative";
description = "Utilities and combinators for parsing command line options";
license = stdenv.lib.licenses.bsd3;
}

View File

@ -1,15 +0,0 @@
{ mkDerivation, base, bytestring, Only, optparse-applicative
, semigroups, stdenv, system-filepath, text, time, transformers
, void
}:
mkDerivation {
pname = "optparse-generic";
version = "1.2.3";
sha256 = "1wxzpj4xj3bafg3piarwsr69xxzp75fdglx9c3spbahl1aq9wzgk";
libraryHaskellDepends = [
base bytestring Only optparse-applicative semigroups
system-filepath text time transformers void
];
description = "Auto-generate a command-line parser for your datatype";
license = stdenv.lib.licenses.bsd3;
}

View File

@ -1,21 +0,0 @@
{ mkDerivation, ansi-wl-pprint, async, base, bytestring, clock
, containers, criterion, directory, doctest, foldl, hostname
, managed, optional-args, optparse-applicative, process, semigroups
, stdenv, stm, system-fileio, system-filepath, temporary, text
, time, transformers, unix, unix-compat
}:
mkDerivation {
pname = "turtle";
version = "1.4.5";
sha256 = "082svk0bcf1vvqrzfmb6r5rridgch0c15423fwcb57cfc8xzm8kx";
libraryHaskellDepends = [
ansi-wl-pprint async base bytestring clock containers directory
foldl hostname managed optional-args optparse-applicative process
semigroups stm system-fileio system-filepath temporary text time
transformers unix unix-compat
];
testHaskellDepends = [ base doctest system-filepath temporary ];
benchmarkHaskellDepends = [ base criterion text ];
description = "Shell programming, Haskell-style";
license = stdenv.lib.licenses.bsd3;
}

View File

@ -1,34 +0,0 @@
{ mkDerivation, aeson, aeson-pretty, attoparsec, authenticate-oauth
, base, base16-bytestring, base64-bytestring, byteable, bytestring
, case-insensitive, containers, cryptohash, directory, doctest
, exceptions, filepath, ghc-prim, hashable, http-client
, http-client-tls, http-types, HUnit, lens, lens-aeson, mime-types
, network-info, psqueues, QuickCheck, snap-core, snap-server
, stdenv, template-haskell, temporary, test-framework
, test-framework-hunit, test-framework-quickcheck2, text, time
, time-locale-compat, transformers, unix-compat
, unordered-containers, uuid, vector
}:
mkDerivation {
pname = "wreq";
version = "0.5.0.1";
sha256 = "138n138rczs5xb7pr25b5a2ajhhxph7vfrh02x71w2alh2xr4akc";
libraryHaskellDepends = [
aeson attoparsec authenticate-oauth base base16-bytestring byteable
bytestring case-insensitive containers cryptohash exceptions
ghc-prim hashable http-client http-client-tls http-types lens
lens-aeson mime-types psqueues template-haskell text time
time-locale-compat unordered-containers
];
testHaskellDepends = [
aeson aeson-pretty base base64-bytestring bytestring
case-insensitive containers directory doctest filepath hashable
http-client http-types HUnit lens lens-aeson network-info
QuickCheck snap-core snap-server temporary test-framework
test-framework-hunit test-framework-quickcheck2 text time
transformers unix-compat unordered-containers uuid vector
];
homepage = "http://www.serpentine.com/wreq";
description = "An easy-to-use HTTP client library";
license = stdenv.lib.licenses.bsd3;
}

View File

@ -7,29 +7,22 @@ let
haskellPackages = oldPkgs.haskellPackages.override {
overrides = haskellPackagesNew: haskellPackagesOld: {
optparse-applicative =
hnix =
newPkgs.haskell.lib.dontCheck
(haskellPackagesNew.callPackage ./nix/optparse-applicative.nix { });
(haskellPackagesNew.callPackage ./nix/hnix.nix { });
optparse-generic =
haskellPackagesNew.callPackage ./nix/optparse-generic.nix { };
hocker = haskellPackagesNew.callPackage ./default.nix { };
turtle =
haskellPackagesNew.callPackage ./nix/turtle.nix { };
megaparsec = haskellPackagesNew.callPackage ./nix/megaparsec.nix { };
nix-paths =
haskellPackagesNew.callPackage ./nix/nix-paths.nix { };
hocker =
haskellPackagesNew.callPackage ./default.nix { };
neat-interpolation = haskellPackagesNew.callPackage ./nix/neat-interpolation.nix { };
};
};
})
];
nixpkgs = import ./nix/17_09.nix;
nixpkgs = import ./nix/18_09.nix;
pkgs = import nixpkgs { inherit config overlays; };

View File

@ -115,8 +115,6 @@ generate dim@HockerImageMeta{..} = runExceptT $
pluckedConfigDigest = Hocker.Lib.stripHashId $ manifestJSON ^. key "config" . key "digest" . _String
pluckedLayerDigests = Hocker.Lib.stripHashId <$> pluckLayersFrom manifestJSON
{-| Generate a top-level Nix Expression AST from a 'HockerImageMeta'
record, a config digest, and a list of layer digests.
@ -162,7 +160,8 @@ generateFetchDockerExpr dim@HockerImageMeta{..} configDigest layerDigests = do
[ ("fetchDockerConfig", Nothing)
, ("fetchDockerLayer", Nothing)
, ("fetchdocker", Nothing)
]
] -- List keys in sorted order so that we do not care
-- whether hnix sorts keys or preserves this order.
#if MIN_VERSION_hnix(0,5,0)
False -- not variadic
#endif
@ -175,7 +174,8 @@ mkFetchDocker :: HockerImageMeta -> NExpr -> NExpr -> Either HockerException NEx
mkFetchDocker HockerImageMeta{..} fetchconfig fetchlayers = do
registry <- Bifunctor.first mkHockerException serializedRegistry
pure
(mkApp (mkSym constFetchdocker)
(mkSym constFetchdocker
@@
(recAttrsE
[ ("name", mkStr $ fromMaybe imageName altImageName)
, ("registry", mkStr registry)
@ -201,7 +201,7 @@ mkFetchDocker HockerImageMeta{..} fetchconfig fetchlayers = do
-- the output expression.
mkFetchDockerConfig :: Binding NExpr -> Base32Digest -> NExpr
mkFetchDockerConfig inherits (Base32Digest digest) =
mkApp (mkSym constFetchDockerConfig)
mkSym constFetchDockerConfig @@
(Fix $ NSet [ inherits, "sha256" $= (mkStr digest) ])
-- | Generate a list of Nix expression ASTs representing
@ -228,9 +228,9 @@ mkFetchDockerLayers inherits layerDigests =
where
mkLayerId i = Text.pack $ "layer" <> show i
mkFetchLayer (i, ((Base16Digest d16), (Base32Digest d32))) =
(mkLayerId i) $= mkApp (mkSym constFetchDockerLayer)
(mkLayerId i) $= (mkSym constFetchDockerLayer @@
(Fix $ NSet
[ inherits
, "layerDigest" $= (mkStr d16) -- Required in order to perform a registry request
, "sha256" $= (mkStr d32) -- Required by Nix for fixed output derivations
])
]))

View File

@ -31,6 +31,10 @@ import Data.Coerce
import Data.Semigroup ((<>))
import Data.Text (Text)
import qualified Data.Text as Text
import Data.Text.Prettyprint.Doc (LayoutOptions(..),
PageWidth(..), SimpleDocStream)
import qualified Data.Text.Prettyprint.Doc
import qualified Data.Text.Prettyprint.Doc.Render.Text
import Data.Text.Encoding (encodeUtf8)
import qualified Network.Wreq as Wreq
import Nix.Expr (NExpr)
@ -39,9 +43,7 @@ import System.Directory (findExecutable)
import System.Environment (getProgName)
import System.Exit as Exit
import System.FilePath.Posix as File
import Text.PrettyPrint.ANSI.Leijen as Text.PrettyPrint (SimpleDoc,
displayS,
renderPretty)
import qualified System.IO
import URI.ByteString
import Data.Docker.Image.Types
@ -169,13 +171,19 @@ splitRepository :: ImageName -> (RepoNamePart, ImageNamePart)
splitRepository (ImageName (Text.pack -> n)) = over _2 Text.tail $ Text.break (=='/') n
-- | Given a nix expression AST, produce a pretty printer document.
renderNixExpr :: NExpr -> Text.PrettyPrint.SimpleDoc
renderNixExpr = renderPretty 0.4 120 . prettyNix
renderNixExpr :: NExpr -> SimpleDocStream ann
renderNixExpr =
Data.Text.Prettyprint.Doc.layoutSmart layoutOptions . prettyNix
where
layoutOptions = LayoutOptions { layoutPageWidth = AvailablePerLine 120 0.4 }
-- | Print a nix expression AST using the 'renderNixExpr' pretty
-- printing renderer.
pprintNixExpr :: NExpr -> IO ()
pprintNixExpr expr = Prelude.putStrLn (displayS (renderNixExpr expr) "")
pprintNixExpr expr =
Data.Text.Prettyprint.Doc.Render.Text.renderIO System.IO.stdout stream
where
stream = renderNixExpr expr
-- | Given an executable's name, try to find it in the PATH.
findExec :: (MonadIO m, Except.MonadError HockerException m)

View File

@ -19,6 +19,7 @@ import Data.ByteString as BS
import Data.ByteString.Lazy.Char8 as C8L
import Data.Either (either)
import qualified Data.Text as Text
import qualified Data.Text.Prettyprint.Doc.Render.String
import Data.Word8 as W8
import Network.URI
@ -26,7 +27,6 @@ import Test.Tasty
import Test.Tasty.Golden
import Test.Tasty.Golden.Advanced (goldenTest)
import Test.Tasty.HUnit
import Text.PrettyPrint.ANSI.Leijen as Text.PrettyPrint (displayS)
import Text.Printf (printf)
import Data.Docker.Image.Types
@ -105,7 +105,9 @@ generateFetchDockerNix = do
, altImageName = Nothing
}
let display = Data.Text.Prettyprint.Doc.Render.String.renderString
either
(Hocker.Lib.die . Text.pack . show)
(return . C8L.pack . (flip displayS "") . Hocker.Lib.renderNixExpr)
(return . C8L.pack . display . Hocker.Lib.renderNixExpr)
nixExpression

View File

@ -1,5 +1,7 @@
{ fetchDockerConfig, fetchDockerLayer, fetchdocker }:
fetchdocker rec {
{ fetchDockerConfig
, fetchDockerLayer
, fetchdocker }:
fetchdocker rec {
name = "debian";
registry = "https://registry-1.docker.io/v2/";
repository = "library";
@ -8,12 +10,12 @@ fetchdocker rec {
imageConfig = fetchDockerConfig {
inherit tag registry repository imageName;
sha256 = "1rwinmvfc8jxn54y7qnj82acrc97y7xcnn22zaz67y76n4wbwjh5";
};
};
imageLayers = let
layer0 = fetchDockerLayer {
inherit registry repository imageName;
layerDigest = "cd0a524342efac6edff500c17e625735bbe479c926439b263bbe3c8518a0849c";
sha256 = "1744l0c8ag5y7ck9nhr6r5wy9frmaxi7xh80ypgnxb7g891m42nd";
};
in [ layer0 ];
}
};
in [ layer0 ];
}