diff --git a/dhall-nix/formatting.nix b/dhall-nix/formatting.nix deleted file mode 100644 index cb124ce..0000000 --- a/dhall-nix/formatting.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ mkDerivation, array, base, bytestring, clock, ghc-prim, hspec -, integer-gmp, old-locale, scientific, stdenv, text, time -, transformers -}: -mkDerivation { - pname = "formatting"; - version = "6.3.1"; - sha256 = "56303c8dff977ef9eb66b67fc30eb079f867201558f5fe6b442ffa06561fd479"; - libraryHaskellDepends = [ - array base bytestring clock ghc-prim integer-gmp old-locale - scientific text time transformers - ]; - testHaskellDepends = [ base hspec ]; - description = "Combinator-based type-safe formatting (like printf() or FORMAT)"; - license = stdenv.lib.licenses.bsd3; -} diff --git a/dhall-nix/default.nix b/dhall-nix/nix/dhall-nix.nix similarity index 97% rename from dhall-nix/default.nix rename to dhall-nix/nix/dhall-nix.nix index 8998d32..366585e 100644 --- a/dhall-nix/default.nix +++ b/dhall-nix/nix/dhall-nix.nix @@ -5,7 +5,7 @@ mkDerivation { pname = "dhall-nix"; version = "1.1.3"; - src = ./.; + src = ./..; isLibrary = true; isExecutable = true; libraryHaskellDepends = [ diff --git a/dhall-nix/dhall.nix b/dhall-nix/nix/dhall.nix similarity index 100% rename from dhall-nix/dhall.nix rename to dhall-nix/nix/dhall.nix diff --git a/dhall-nix/nix/fetchNixpkgs.nix b/dhall-nix/nix/fetchNixpkgs.nix new file mode 100644 index 0000000..478c25d --- /dev/null +++ b/dhall-nix/nix/fetchNixpkgs.nix @@ -0,0 +1,49 @@ +{ rev # The Git revision of nixpkgs to fetch +, sha256 # The SHA256 of the downloaded data +, outputSha256 ? null # The SHA256 fixed-output hash +, system ? builtins.currentSystem # This is overridable if necessary +}: + +if (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"; + sha256 = outputSha256; + }) + +# This hack should at least work for Nix 1.11 +else ( + (rec { + tarball = import { + url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz"; + inherit sha256; + }; + + builtin-paths = import ; + + 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}"; + + builder = builtins.storePath builtin-paths.shell; + + args = [ script ]; + + 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) diff --git a/dhall-nix/prettyprinter.nix b/dhall-nix/prettyprinter.nix deleted file mode 100644 index 5180605..0000000 --- a/dhall-nix/prettyprinter.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ mkDerivation, ansi-wl-pprint, base, bytestring, containers -, criterion, deepseq, doctest, mtl, pgp-wordlist, QuickCheck -, random, stdenv, tasty, tasty-hunit, tasty-quickcheck -, template-haskell, text, transformers -}: -mkDerivation { - pname = "prettyprinter"; - version = "1.2.0.1"; - sha256 = "11397b182138efc8f7b09a70873093fb565d070e4c8f92cdde9e601bcd5a0566"; - isLibrary = true; - isExecutable = true; - libraryHaskellDepends = [ base text ]; - executableHaskellDepends = [ base template-haskell text ]; - testHaskellDepends = [ - base bytestring doctest pgp-wordlist tasty tasty-hunit - tasty-quickcheck text - ]; - benchmarkHaskellDepends = [ - ansi-wl-pprint base containers criterion deepseq mtl QuickCheck - random text transformers - ]; - homepage = "http://github.com/quchen/prettyprinter"; - description = "A modern, easy to use, well-documented, extensible prettyprinter"; - license = stdenv.lib.licenses.bsd2; -} diff --git a/dhall-nix/release.nix b/dhall-nix/release.nix index b33cb5f..f60d742 100644 --- a/dhall-nix/release.nix +++ b/dhall-nix/release.nix @@ -1,52 +1,38 @@ -# You can build this repository using Nix by running: -# -# $ nix-build -A dhall-nix release.nix -# -# You can also open up this repository inside of a Nix shell by running: -# -# $ nix-shell -A dhall-nix.env release.nix -# -# ... and then Nix will supply the correct Haskell development environment for -# you let + fetchNixpkgs = import ./nix/fetchNixpkgs.nix; + + nixpkgs = fetchNixpkgs { + rev = "804060ff9a79ceb0925fe9ef79ddbf564a225d47"; + + sha256 = "01pb6p07xawi60kshsxxq1bzn8a0y4s5jjqvhkwps4f5xjmmwav3"; + + outputSha256 = "0ga345hgw6v2kzyhvf5kw96hf60mx5pbd9c4qj5q4nan4lr7nkxn"; + }; + config = { packageOverrides = pkgs: { haskellPackages = pkgs.haskellPackages.override { overrides = haskellPackagesNew: haskellPackagesOld: { - dhall = haskellPackagesNew.callPackage ./dhall.nix { }; + dhall = haskellPackagesNew.callPackage ./nix/dhall.nix { }; dhall-nix = - pkgs.haskell.lib.justStaticExecutables - (haskellPackagesNew.callPackage ./default.nix { }); + pkgs.haskell.lib.failOnAllWarnings + (pkgs.haskell.lib.justStaticExecutables + (haskellPackagesNew.callPackage ./nix/dhall-nix.nix { }) + ); - prettyprinter = haskellPackagesNew.callPackage ./prettyprinter.nix { }; + formatting = haskellPackagesOld.formatting_6_3_0; - formatting = haskellPackagesNew.callPackage ./formatting.nix { }; + prettyprinter = haskellPackagesOld.prettyprinter_1_2_0_1; }; }; }; }; pkgs = - import { inherit config; }; + import nixpkgs { inherit config; }; - # Convert a Dhall expression (represented as a string) to the equivalent Nix - # expression - dhallToNix = code : - let - file = builtins.toFile "dhall-expr" code; - - drv = pkgs.stdenv.mkDerivation { - name = "dhall-expr-as-nix"; - - buildCommand = '' - dhall-to-nix <<< "${file}" > $out - ''; - - buildInputs = [ pkgs.haskellPackages.dhall-nix ]; - }; - in - import "${drv}"; + inherit (pkgs) dhallToNix; in { dhall-nix = pkgs.haskellPackages.dhall-nix;