Skip to content

Commit

Permalink
Enable overriding source-repository-packages from Nix.
Browse files Browse the repository at this point in the history
This will be used for CI
  • Loading branch information
shlevy committed Jan 17, 2022
1 parent a308592 commit 4de6777
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
4 changes: 3 additions & 1 deletion default.nix
Expand Up @@ -17,13 +17,15 @@
stackage = sources.stackage-nix;
};
}
, packages ? import ./nix { inherit system sources crossSystem config sourcesOverride haskellNix checkMaterialization enableHaskellProfiling; }
, packages ? import ./nix { inherit system sources crossSystem config sourcesOverride haskellNix checkMaterialization enableHaskellProfiling git-source-repository-overrides; }
# An explicit git rev to use, passed when we are in Hydra
# Whether to check that the pinned shas for haskell.nix are correct. We want this to be
# false, generally, since it does more work, but we set it to true in the CI
, checkMaterialization ? false
# Whether to build our Haskell packages (and their dependencies) with profiling enabled.
, enableHaskellProfiling ? false
, git-source-repository-overrides ? [ ]
# see pkgs/nix/haskell/haskell.nix for explanation
}:
let
inherit (packages) pkgs marlowe sources;
Expand Down
3 changes: 2 additions & 1 deletion nix/default.nix
Expand Up @@ -7,6 +7,7 @@
, haskellNix
, checkMaterialization ? false
, enableHaskellProfiling ? false
, git-source-repository-overrides ? [ ]
}:
let
ownOverlays =
Expand Down Expand Up @@ -39,7 +40,7 @@ let
config = haskellNix.nixpkgsArgs.config // config;
};

marlowe = import ./pkgs { inherit pkgs checkMaterialization enableHaskellProfiling sources; };
marlowe = import ./pkgs { inherit pkgs checkMaterialization enableHaskellProfiling sources git-source-repository-overrides; };

in
{
Expand Down
2 changes: 2 additions & 0 deletions nix/pkgs/default.nix
Expand Up @@ -4,6 +4,7 @@
, config ? { allowUnfreePredicate = (import ../lib/unfree.nix).unfreePredicate; }
, sources
, enableHaskellProfiling
, git-source-repository-overrides ? [ ]
}:
let
inherit (pkgs) stdenv;
Expand All @@ -14,6 +15,7 @@ let
haskell = pkgs.callPackage ./haskell {
inherit gitignore-nix sources;
inherit checkMaterialization enableHaskellProfiling;
inherit git-source-repository-overrides;
inherit (sources) actus-tests;

# This ensures that the utility scripts produced in here will run on the current system, not
Expand Down
2 changes: 2 additions & 0 deletions nix/pkgs/haskell/default.nix
Expand Up @@ -12,6 +12,7 @@
, z3
, enableHaskellProfiling
, actus-tests
, git-source-repository-overrides ? [ ]
}:
let
# The Hackage index-state from cabal.project
Expand Down Expand Up @@ -42,6 +43,7 @@ let
inherit enableHaskellProfiling;
inherit deferPluginErrors;
inherit actus-tests;
inherit git-source-repository-overrides;
};
project = baseProject { deferPluginErrors = false; };
# The same as above, but this time with we defer plugin errors so that we
Expand Down
26 changes: 23 additions & 3 deletions nix/pkgs/haskell/haskell.nix
Expand Up @@ -15,6 +15,14 @@
# it. If set to true, we will also build the haddocks for those packages.
, deferPluginErrors
, actus-tests
, git-source-repository-overrides ? [ ]
# Override source-repository-package entries in cabal (useful for CI)
# List of attribute sets:
# location
# tag
# sha256
# subdir (optional list of strings)

}:
let
r-packages = with rPackages; [ R tidyverse dplyr stringr MASS plotly shiny shinyjs purrr ];
Expand All @@ -35,7 +43,8 @@ let
# At the moment, we only need one but conceivably we might need one for darwin in future.
# See https://github.com/input-output-hk/nix-tools/issues/97
materialized =
if pkgs.stdenv.hostPlatform.isLinux then ./materialized-linux
if git-source-repository-overrides != [ ] then null
else if pkgs.stdenv.hostPlatform.isLinux then ./materialized-linux
else if pkgs.stdenv.hostPlatform.isDarwin then ./materialized-darwin
else if pkgs.stdenv.hostPlatform.isWindows then ./materialized-windows
else builtins.error "Don't have materialized files for this platform";
Expand All @@ -61,11 +70,22 @@ let
"https://github.com/input-output-hk/plutus"."3f089ccf0ca746b399c99afe51e063b0640af547" = "1nx8xmdgwmnsla4qg4k67f5md8vm3p1p9i25ndalrqdg40z90486";
"https://github.com/input-output-hk/plutus-apps"."404af7ac3e27ebcb218c05f79d9a70ca966407c9" = "00pv5ds99lf6lmws3a3ipsn9amg56ayc9b0wqki2gky464dm6gzr";
"https://github.com/j-mueller/cardano-wallet"."6be73ab852c0592713dfe78218856d4a8a0ee69e" = "0rx5hvmbdv5dwb4qq39vyhisj0v75j21jbiivn3s3q9za6m6x1p4";
};
} // (builtins.listToAttrs (map (sro: { name = sro.location; value = { ${sro.tag} = sro.sha256; }; }) git-source-repository-overrides));
# Configuration settings needed for cabal configure to work when cross compiling
# for windows. We can't use `modules` for these as `modules` are only applied
# after cabal has been configured.
cabalProjectLocal = lib.optionalString pkgs.stdenv.hostPlatform.isWindows ''
cabalProjectLocal = (builtins.concatStringsSep "\n" (map
(sro: ''
source-repository-package
type: git
location: ${sro.location}
tag: ${sro.tag}
'' + lib.optionalString (sro ? subdir) ''
subdir:
${builtins.concatStringsSep "\n " sro.subdir}
-- comment here for proper Nix string indentation
'')
git-source-repository-overrides)) + lib.optionalString pkgs.stdenv.hostPlatform.isWindows ''
-- When cross compiling for windows we don't have a `ghc` package, so use
-- the `plutus-ghc-stub` package instead.
package plutus-tx-plugin
Expand Down

0 comments on commit 4de6777

Please sign in to comment.