Commit 318c571d authored by Vaibhav Sagar's avatar Vaibhav Sagar Committed by GitHub

Merge pull request #768 from gibiansky/reduce-nix-rebuilds

release.nix: split out sources to reduce rebuilds
parents 46460e0e 6b329d3d
...@@ -2,14 +2,22 @@ ...@@ -2,14 +2,22 @@
let let
inherit (builtins) any elem filterSource listToAttrs; inherit (builtins) any elem filterSource listToAttrs;
lib = nixpkgs.lib;
cleanSource = name: type: let cleanSource = name: type: let
baseName = baseNameOf (toString name); baseName = baseNameOf (toString name);
lib = nixpkgs.lib;
in lib.cleanSourceFilter name type && !( in lib.cleanSourceFilter name type && !(
(type == "directory" && (elem baseName [ ".stack-work" "dist"])) || (type == "directory" && (elem baseName [ ".stack-work" "dist"])) ||
any (lib.flip lib.hasSuffix baseName) [ ".hi" ".ipynb" ".nix" ".sock" ".yaml" ".yml" ] any (lib.flip lib.hasSuffix baseName) [ ".hi" ".ipynb" ".nix" ".sock" ".yaml" ".yml" ]
); );
src = filterSource cleanSource ./.; ihaskellSourceFilter = src: name: type: let
relPath = lib.removePrefix (toString src + "/") (toString name);
in cleanSource name type && ( any (lib.flip lib.hasPrefix relPath) [
"src" "main" "html" "Setup.hs" "ihaskell.cabal" "LICENSE"
]);
ihaskell-src = filterSource (ihaskellSourceFilter ./.) ./.;
ipython-kernel-src = filterSource cleanSource ./ipython-kernel;
ghc-parser-src = filterSource cleanSource ./ghc-parser;
ihaskell-display-src = filterSource cleanSource ./ihaskell-display;
plot = nixpkgs.fetchFromGitHub { plot = nixpkgs.fetchFromGitHub {
owner = "amcphail"; owner = "amcphail";
repo = "plot"; repo = "plot";
...@@ -18,7 +26,7 @@ let ...@@ -18,7 +26,7 @@ let
}; };
displays = self: builtins.listToAttrs ( displays = self: builtins.listToAttrs (
map map
(display: { name = display; value = self.callCabal2nix display "${src}/ihaskell-display/${display}" {}; }) (display: { name = display; value = self.callCabal2nix display "${ihaskell-display-src}/${display}" {}; })
[ [
"ihaskell-aeson" "ihaskell-aeson"
"ihaskell-blaze" "ihaskell-blaze"
...@@ -36,7 +44,7 @@ let ...@@ -36,7 +44,7 @@ let
haskellPackages = nixpkgs.haskell.packages.ghc821.override { haskellPackages = nixpkgs.haskell.packages.ghc821.override {
overrides = self: super: rec { overrides = self: super: rec {
ihaskell = nixpkgs.haskell.lib.overrideCabal ( ihaskell = nixpkgs.haskell.lib.overrideCabal (
self.callCabal2nix "ihaskell" src {}) (_drv: { self.callCabal2nix "ihaskell" ihaskell-src {}) (_drv: {
postPatch = let postPatch = let
# Nix-built IHaskell expects to load a *.dyn_o file instead of *.o, # Nix-built IHaskell expects to load a *.dyn_o file instead of *.o,
# see https://github.com/gibiansky/IHaskell/issues/728 # see https://github.com/gibiansky/IHaskell/issues/728
...@@ -67,8 +75,8 @@ let ...@@ -67,8 +75,8 @@ let
export GHC_PACKAGE_PATH=$PWD/dist/package.conf.inplace/:$GHC_PACKAGE_PATH export GHC_PACKAGE_PATH=$PWD/dist/package.conf.inplace/:$GHC_PACKAGE_PATH
''; '';
}); });
ghc-parser = self.callCabal2nix "ghc-parser" "${src}/ghc-parser" {}; ghc-parser = self.callCabal2nix "ghc-parser" ghc-parser-src {};
ipython-kernel = self.callCabal2nix "ghc-parser" "${src}/ipython-kernel" {}; ipython-kernel = self.callCabal2nix "ipython-kernel" ipython-kernel-src {};
shelly = nixpkgs.haskell.lib.doJailbreak super.shelly; shelly = nixpkgs.haskell.lib.doJailbreak super.shelly;
plot = self.callCabal2nix "plot" plot { inherit cairo pango; }; plot = self.callCabal2nix "plot" plot { inherit cairo pango; };
......
...@@ -2,17 +2,25 @@ ...@@ -2,17 +2,25 @@
let let
inherit (builtins) any elem filterSource listToAttrs; inherit (builtins) any elem filterSource listToAttrs;
lib = nixpkgs.lib;
cleanSource = name: type: let cleanSource = name: type: let
baseName = baseNameOf (toString name); baseName = baseNameOf (toString name);
lib = nixpkgs.lib;
in lib.cleanSourceFilter name type && !( in lib.cleanSourceFilter name type && !(
(type == "directory" && (elem baseName [ ".stack-work" "dist"])) || (type == "directory" && (elem baseName [ ".stack-work" "dist"])) ||
any (lib.flip lib.hasSuffix baseName) [ ".hi" ".ipynb" ".nix" ".sock" ".yaml" ".yml" ] any (lib.flip lib.hasSuffix baseName) [ ".hi" ".ipynb" ".nix" ".sock" ".yaml" ".yml" ]
); );
src = filterSource cleanSource ./.; ihaskellSourceFilter = src: name: type: let
relPath = lib.removePrefix (toString src + "/") (toString name);
in cleanSource name type && ( any (lib.flip lib.hasPrefix relPath) [
"src" "main" "html" "Setup.hs" "ihaskell.cabal" "LICENSE"
]);
ihaskell-src = filterSource (ihaskellSourceFilter ./.) ./.;
ipython-kernel-src = filterSource cleanSource ./ipython-kernel;
ghc-parser-src = filterSource cleanSource ./ghc-parser;
ihaskell-display-src = filterSource cleanSource ./ihaskell-display;
displays = self: listToAttrs ( displays = self: listToAttrs (
map map
(display: { name = display; value = self.callCabal2nix display "${src}/ihaskell-display/${display}" {}; }) (display: { name = display; value = self.callCabal2nix display "${ihaskell-display-src}/${display}" {}; })
[ [
"ihaskell-aeson" "ihaskell-aeson"
"ihaskell-blaze" "ihaskell-blaze"
...@@ -31,7 +39,7 @@ let ...@@ -31,7 +39,7 @@ let
haskellPackages = nixpkgs.haskellPackages.override { haskellPackages = nixpkgs.haskellPackages.override {
overrides = self: super: { overrides = self: super: {
ihaskell = nixpkgs.haskell.lib.overrideCabal ( ihaskell = nixpkgs.haskell.lib.overrideCabal (
self.callCabal2nix "ihaskell" src {}) (_drv: { self.callCabal2nix "ihaskell" ihaskell-src {}) (_drv: {
postPatch = let postPatch = let
# Nix-built IHaskell expects to load a *.dyn_o file instead of *.o, # Nix-built IHaskell expects to load a *.dyn_o file instead of *.o,
# see https://github.com/gibiansky/IHaskell/issues/728 # see https://github.com/gibiansky/IHaskell/issues/728
...@@ -62,8 +70,8 @@ let ...@@ -62,8 +70,8 @@ let
export GHC_PACKAGE_PATH=$PWD/dist/package.conf.inplace/:$GHC_PACKAGE_PATH export GHC_PACKAGE_PATH=$PWD/dist/package.conf.inplace/:$GHC_PACKAGE_PATH
''; '';
}); });
ghc-parser = self.callCabal2nix "ghc-parser" "${src}/ghc-parser" {}; ghc-parser = self.callCabal2nix "ghc-parser" ghc-parser-src {};
ipython-kernel = self.callCabal2nix "ipython-kernel" "${src}/ipython-kernel" {}; ipython-kernel = self.callCabal2nix "ipython-kernel" ipython-kernel-src {};
} // displays self; } // displays self;
}; };
ihaskell = haskellPackages.ihaskell; ihaskell = haskellPackages.ihaskell;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment