Skip to content

Commit

Permalink
Switch to hercules-ci/gitignore.nix for a cool 2x eval speedup
Browse files Browse the repository at this point in the history
I do remember this being problematic before, switching to the more
maintained project immediately gave us a 2x eval speedup...
  • Loading branch information
michaelpj committed Dec 3, 2020
1 parent 02da396 commit af5df4a
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 36 deletions.
9 changes: 4 additions & 5 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,21 @@ rec {
inherit pkgs plutus plutusMusl;

inherit (plutus) web-ghc;
inherit (plutus.lib) buildNodeModules;

inherit (haskell.packages.plutus-scb.components.exes)
plutus-game
plutus-currency
plutus-atomic-swap
plutus-pay-to-wallet;

webCommon = pkgs.callPackage ./web-common { };
webCommon = pkgs.callPackage ./web-common { inherit (plutus.lib) gitignore-nix; };

plutus-playground = pkgs.recurseIntoAttrs rec {
tutorial = docs.site;
haddock = plutus.plutus-haddock-combined;

inherit (pkgs.callPackage ./plutus-playground-client {
inherit (plutus.lib) buildPursPackage buildNodeModules;
inherit (plutus.lib) buildPursPackage buildNodeModules gitignore-nix;
inherit set-git-rev haskell webCommon;
}) client server-invoker generated-purescript;
};
Expand All @@ -53,7 +52,7 @@ rec {
tutorial = docs.marlowe-tutorial;

inherit (pkgs.callPackage ./marlowe-playground-client {
inherit (plutus.lib) buildPursPackage buildNodeModules;
inherit (plutus.lib) buildPursPackage buildNodeModules gitignore-nix;
inherit set-git-rev haskell webCommon;
}) client server-invoker generated-purescript;
};
Expand All @@ -71,7 +70,7 @@ rec {
};

plutus-scb = pkgs.callPackage ./plutus-scb-client {
inherit (plutus.lib) buildPursPackage buildNodeModules;
inherit (plutus.lib) buildPursPackage buildNodeModules gitignore-nix;
inherit set-git-rev haskell webCommon;
};

Expand Down
4 changes: 2 additions & 2 deletions marlowe-playground-client/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, nix-gitignore, set-git-rev, haskell, webCommon, buildPursPackage, buildNodeModules }:
{ pkgs, gitignore-nix, set-git-rev, haskell, webCommon, buildPursPackage, buildNodeModules }:
let
playground-exe = set-git-rev haskell.packages.marlowe-playground-server.components.exes.marlowe-playground-server;

Expand Down Expand Up @@ -27,7 +27,7 @@ let
'';

nodeModules = buildNodeModules {
projectDir = nix-gitignore.gitignoreSource [ "/*.nix" "/*.md" ] ./.;
projectDir = gitignore-nix.gitignoreSource ./.;
packageJson = ./package.json;
packageLockJson = ./package-lock.json;
githubSourceHashMap = {
Expand Down
6 changes: 3 additions & 3 deletions nix/lib/purescript.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ stdenv
, nodejs
, easyPS
, nix-gitignore
, gitignore-nix
}:

{
Expand All @@ -21,8 +21,8 @@
, nodeModules
}:
let
# Cleans the source based on the patterns in ./.gitignore and the additionalIgnores
cleanSrcs = nix-gitignore.gitignoreSource [ "/*.adoc" "/*.nix" ] src;
# Cleans the source based on the patterns in gitignore files
cleanSrcs = gitignore-nix.gitignoreSource src;

in
stdenv.mkDerivation {
Expand Down
1 change: 0 additions & 1 deletion nix/overlays/nixpkgs-overrides.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
self: super: {
nix-gitignore = super.callPackage ((import ../sources.nix).nix-gitignore) { };
# We can *nearly* replace this with upstream nixpkgs, but unfortunately we also need a patch
# that hasn't been merged upstream yet. And you can't override the pieces of a 'bundlerApp'.
asciidoctor = super.callPackage ../pkgs/asciidoctor { };
Expand Down
8 changes: 6 additions & 2 deletions nix/pkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ let
sourcesOverride = { inherit (sources) nixpkgs; };
};

gitignore-nix = pkgs.callPackage sources."gitignore.nix" { };

# The git revision comes from `rev` if available (Hydra), otherwise
# it is read using IFD and git, which is avilable on local builds.
git-rev = if isNull rev then iohkNix.commitIdFromGitRepo ../../.git else rev;

# { index-state, project, projectPackages, packages, muslProject, muslPackages, extraPackages }
haskell = pkgs.callPackage ./haskell {
inherit gitignore-nix;
inherit plutusMusl;
inherit agdaWithStdlib checkMaterialization;
};
Expand Down Expand Up @@ -143,10 +146,11 @@ let

# Collect everything to be exported under `plutus.lib`: builders/functions/utils
lib = rec {
inherit gitignore-nix;
haddock-combine = pkgs.callPackage ../lib/haddock-combine.nix { inherit sphinxcontrib-haddock; };
latex = pkgs.callPackage ../lib/latex.nix { };
npmlock2nix = (pkgs.callPackage sources.npmlock2nix { });
buildPursPackage = pkgs.callPackage ../lib/purescript.nix { inherit easyPS;inherit (pkgs) nodejs; };
npmlock2nix = pkgs.callPackage sources.npmlock2nix { };
buildPursPackage = pkgs.callPackage ../lib/purescript.nix { inherit easyPS gitignore-nix;inherit (pkgs) nodejs; };
buildNodeModules = pkgs.callPackage ../lib/node_modules.nix ({
inherit npmlock2nix;
} // pkgs.lib.optionalAttrs (stdenv.isDarwin) {
Expand Down
7 changes: 4 additions & 3 deletions nix/pkgs/haskell/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
, haskell-nix
, buildPackages
, checkMaterialization
, nix-gitignore
, gitignore-nix
, R
, rPackages
, z3
Expand All @@ -29,7 +29,7 @@ let

# The haskell project created by haskell-nix.stackProject'
project = import ./haskell.nix {
inherit lib stdenv haskell-nix buildPackages nix-gitignore R rPackages z3;
inherit lib stdenv haskell-nix buildPackages gitignore-nix R rPackages z3;
inherit agdaWithStdlib checkMaterialization;
};

Expand All @@ -44,7 +44,8 @@ let

# The haskell project created by haskell-nix.stackProject' (musl version)
muslProject = import ./haskell.nix {
inherit (plutusMusl) lib stdenv haskell-nix buildPackages nix-gitignore R rPackages z3;
inherit (plutusMusl) lib stdenv haskell-nix buildPackages R rPackages z3;
inherit gitignore-nix;
inherit agdaWithStdlib checkMaterialization;
};

Expand Down
4 changes: 2 additions & 2 deletions nix/pkgs/haskell/haskell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
, haskell-nix
, agdaWithStdlib
, buildPackages
, nix-gitignore
, gitignore-nix
, checkMaterialization
, z3
, R
Expand All @@ -18,7 +18,7 @@ let
# This is incredibly difficult to get right, almost everything goes wrong, see https://github.com/input-output-hk/haskell.nix/issues/496
src = let root = ../../../.; in
haskell-nix.haskellLib.cleanSourceWith {
filter = nix-gitignore.gitignoreFilter (nix-gitignore.gitignoreCompileIgnore [ ../../../.gitignore ] root) root;
filter = gitignore-nix.gitignoreFilter root;
src = root;
# Otherwise this depends on the name in the parent directory, which reduces caching, and is
# particularly bad on Hercules, see https://github.com/hercules-ci/support/issues/40
Expand Down
26 changes: 13 additions & 13 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@
"url": "https://github.com/justinwoo/easy-purescript-nix/archive/7b1c1635e16c7f12065db2f8ec049030fcc63655.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"gitignore.nix": {
"branch": "master",
"builtin": false,
"description": "Nix function for filtering local git sources",
"homepage": "",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "c4662e662462e7bf3c2a968483478a665d00e717",
"sha256": "1npnx0h6bd0d7ql93ka7azhj40zgjp815fw2r6smg8ch9p7mzdlx",
"type": "tarball",
"url": "https://github.com/hercules-ci/gitignore.nix/archive/c4662e662462e7bf3c2a968483478a665d00e717.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"hackage.nix": {
"branch": "master",
"description": "Automatically generated Nix expressions for Hackage",
Expand Down Expand Up @@ -61,19 +74,6 @@
"url": "https://github.com/fzakaria/mvn2nix/archive/a4c9ec1cd6118e22a6a5e5fc04c30c406d0d80ea.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nix-gitignore": {
"branch": "master",
"builtin": false,
"description": "A nix expression that filters source based on a .gitignore file.",
"homepage": "",
"owner": "siers",
"repo": "nix-gitignore",
"rev": "a9609739209cef90e2e8eaa0b5b656721d3da63e",
"sha256": "1h7dgiy0kiyzsv0s2w5p6z5103k4s8wc6i793cwq1srk2kwdsrxm",
"type": "tarball",
"url": "https://github.com/siers/nix-gitignore/archive/a9609739209cef90e2e8eaa0b5b656721d3da63e.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "nixos-20.09",
"builtin": true,
Expand Down
4 changes: 2 additions & 2 deletions plutus-playground-client/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, nix-gitignore, set-git-rev, haskell, webCommon, buildPursPackage, buildNodeModules }:
{ pkgs, gitignore-nix, set-git-rev, haskell, webCommon, buildPursPackage, buildNodeModules }:
let
playground-exe = set-git-rev haskell.packages.plutus-playground-server.components.exes.plutus-playground-server;

Expand Down Expand Up @@ -28,7 +28,7 @@ let
'';

nodeModules = buildNodeModules {
projectDir = nix-gitignore.gitignoreSource [ "/*.nix" "/*.md" ] ./.;
projectDir = gitignore-nix.gitignoreSource ./.;
packageJson = ./package.json;
packageLockJson = ./package-lock.json;
};
Expand Down
4 changes: 2 additions & 2 deletions plutus-scb-client/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, nix-gitignore, set-git-rev, haskell, webCommon, buildPursPackage, buildNodeModules }:
{ pkgs, gitignore-nix, set-git-rev, haskell, webCommon, buildPursPackage, buildNodeModules }:
let
server-invoker = set-git-rev haskell.packages.plutus-scb.components.exes.plutus-scb;

Expand All @@ -9,7 +9,7 @@ let
'';

nodeModules = buildNodeModules {
projectDir = nix-gitignore.gitignoreSource [ "/*.nix" "/*.md" ] ./.;
projectDir = gitignore-nix.gitignoreSource ./.;
packageJson = ./package.json;
packageLockJson = ./package-lock.json;
};
Expand Down
2 changes: 1 addition & 1 deletion web-common/default.nix
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ lib, nix-gitignore }: nix-gitignore.gitignoreSource [ ] ./.
{ lib, gitignore-nix }: gitignore-nix.gitignoreSource ./.

0 comments on commit af5df4a

Please sign in to comment.