From 34238f66dac6c4590e23fd736baddb9dbc1e0010 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Sun, 22 Dec 2019 04:50:19 +0000 Subject: [PATCH] Flake: take dhall-lang as input --- flake.lock | 14 ++++++++++---- flake.nix | 8 ++++++-- nix/sdist.nix | 7 ++++--- nix/shared.nix | 30 ++++++++++++++++++++++-------- release.nix | 3 ++- 5 files changed, 44 insertions(+), 18 deletions(-) diff --git a/flake.lock b/flake.lock index 28c325d..b590996 100644 --- a/flake.lock +++ b/flake.lock @@ -1,16 +1,22 @@ { "inputs": { + "dhallLang": { + "inputs": {}, + "narHash": "sha256-8JaeNB0fOj09L1cQL8i+0eSuNvl9MbgiuFU5bc4Aeb0=", + "originalUrl": "git+https://github.com/dhall-lang/dhall-lang.git?ref=v12.0.0", + "url": "git+https://github.com/dhall-lang/dhall-lang.git?ref=v12.0.0&rev=9f248138f69ee5e22192dc3d0417d5c77b189e04" + }, "nixpkgs": { "inputs": {}, "narHash": "sha256-wJg4DA700SoQbEz61448sR6BgxRa1R92K3vvCV1g+HY=", - "originalUri": "git+https://github.com/nixos/nixpkgs.git?ref=18.09-beta&rev=1d4de0d552ae9aa66a5b8dee5fb0650a4372d148", - "uri": "git+https://github.com/nixos/nixpkgs.git?ref=18.09-beta&rev=1d4de0d552ae9aa66a5b8dee5fb0650a4372d148" + "originalUrl": "git+https://github.com/nixos/nixpkgs.git?ref=18.09-beta&rev=1d4de0d552ae9aa66a5b8dee5fb0650a4372d148", + "url": "git+https://github.com/nixos/nixpkgs.git?ref=18.09-beta&rev=1d4de0d552ae9aa66a5b8dee5fb0650a4372d148" }, "nixpkgsStaticLinux": { "inputs": {}, "narHash": "sha256-famU3pJZ4vkElV9qc71HmyRVSvcrAhfMZ0UJKpmmKP8=", - "originalUri": "git+https://github.com/nh2/nixpkgs.git?ref=static-haskell-nix-stack-dhall-working", - "uri": "git+https://github.com/nh2/nixpkgs.git?ref=static-haskell-nix-stack-dhall-working&rev=925aac04f4ca58aceb83beef18cb7dae0715421b" + "originalUrl": "git+https://github.com/nh2/nixpkgs.git?ref=static-haskell-nix-stack-dhall-working", + "url": "git+https://github.com/nh2/nixpkgs.git?ref=static-haskell-nix-stack-dhall-working&rev=925aac04f4ca58aceb83beef18cb7dae0715421b" } }, "version": 3 diff --git a/flake.nix b/flake.nix index e9b05b7..7e70ff5 100644 --- a/flake.nix +++ b/flake.nix @@ -14,11 +14,15 @@ "git+https://github.com/nh2/nixpkgs.git?ref=static-haskell-nix-stack-dhall-working"; flake = false; }; + dhallLang = { + uri = "git+https://github.com/dhall-lang/dhall-lang.git?ref=v12.0.0"; + flake = false; + }; }; - outputs = { self, nixpkgs, nixpkgsStaticLinux }: { + outputs = { self, nixpkgs, nixpkgsStaticLinux, dhallLang }: { hydraJobs.x86_64-linux = import ./release.nix { - inherit nixpkgs nixpkgsStaticLinux; + inherit nixpkgs nixpkgsStaticLinux dhallLang; system = "x86_64-linux"; }; packages.x86_64-linux = with self.hydraJobs.x86_64-linux; { diff --git a/nix/sdist.nix b/nix/sdist.nix index 2b52c15..d90665d 100644 --- a/nix/sdist.nix +++ b/nix/sdist.nix @@ -15,17 +15,18 @@ let || base == "index.html" ); - filteredSource = builtins.filterSource predicate src; + filteredSource = + if builtins.isPath src then builtins.filterSource predicate src else src; in runCommand "dhall-sdist" - ( { LANG = "en_US.UTF-8"; } + ( { inherit filteredSource; LANG = "en_US.UTF-8"; } // lib.optionalAttrs (stdenv.buildPlatform.libc == "glibc") { LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive"; } ) '' ${coreutils}/bin/mkdir $out - ${coreutils}/bin/cp --recursive ${filteredSource} src + ${coreutils}/bin/cp --recursive $filteredSource src cd src ${coreutils}/bin/chmod --recursive u+w . ${coreutils}/bin/mkdir dist diff --git a/nix/shared.nix b/nix/shared.nix index 91ca89b..1caca90 100644 --- a/nix/shared.nix +++ b/nix/shared.nix @@ -1,12 +1,13 @@ let pinned = import ./pinnedNixpkgs.nix; - + defaultCompiler = "ghc843"; in { nixpkgs ? pinned.nixpkgs , nixpkgsStaticLinux ? pinned.nixpkgsStaticLinux +, dhallLang ? null , compiler ? defaultCompiler , coverage ? false , system ? builtins.currentSystem @@ -205,13 +206,26 @@ let } ); - dhall = - applyCoverage - (haskellPackagesNew.callCabal2nix - "dhall" - (pkgsNew.sdist ../dhall) - { } - ); + dhall = let + src = if builtins.pathExists ../dhall/dhall-lang/Prelude then + ../dhall + else + let + predicate = path: type: + let base = baseNameOf path; + in !(pkgs.lib.hasSuffix ".nix" base + || base == "dist" + || base == "result" + || base == ".git" + || base == "index.html"); + filter = builtins.filterSource predicate; + in pkgs.runCommand "dhall-sdist-input" { } '' + mkdir -p $out/dhall-lang + cp --recursive ${filter ../dhall}/* $out + cp --recursive ${dhallLang}/* $out/dhall-lang + ''; + in applyCoverage + (haskellPackagesNew.callCabal2nix "dhall" (pkgsNew.sdist src) { }); dhall-no-http = pkgsNew.haskell.lib.appendConfigureFlag diff --git a/release.nix b/release.nix index 8426490..4cd078d 100644 --- a/release.nix +++ b/release.nix @@ -3,12 +3,13 @@ let pinned = import ./nix/pinnedNixpkgs.nix; in { src ? { rev = ""; } , nixpkgs ? pinned.nixpkgs , nixpkgsStaticLinux ? pinned.nixpkgsStaticLinux +, dhallLang ? null , system ? builtins.currentSystem }: let callShared = args: - import ./nix/shared.nix ({ inherit nixpkgs nixpkgsStaticLinux system; } // args); + import ./nix/shared.nix ({ inherit nixpkgs nixpkgsStaticLinux dhallLang system; } // args); shared_7_10_3 = callShared { compiler = "ghc7103"; };