From 4de67772ca90eab08cfdbc01306811694b85bf10 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Mon, 17 Jan 2022 07:20:38 -0500 Subject: [PATCH] Enable overriding source-repository-packages from Nix. This will be used for CI --- default.nix | 4 +++- nix/default.nix | 3 ++- nix/pkgs/default.nix | 2 ++ nix/pkgs/haskell/default.nix | 2 ++ nix/pkgs/haskell/haskell.nix | 26 +++++++++++++++++++++++--- 5 files changed, 32 insertions(+), 5 deletions(-) diff --git a/default.nix b/default.nix index d16d2c2563..d7faa657f5 100644 --- a/default.nix +++ b/default.nix @@ -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; diff --git a/nix/default.nix b/nix/default.nix index 7f6a6c4c50..3eca7dd247 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -7,6 +7,7 @@ , haskellNix , checkMaterialization ? false , enableHaskellProfiling ? false +, git-source-repository-overrides ? [ ] }: let ownOverlays = @@ -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 { diff --git a/nix/pkgs/default.nix b/nix/pkgs/default.nix index d324bf296c..8707d41554 100644 --- a/nix/pkgs/default.nix +++ b/nix/pkgs/default.nix @@ -4,6 +4,7 @@ , config ? { allowUnfreePredicate = (import ../lib/unfree.nix).unfreePredicate; } , sources , enableHaskellProfiling +, git-source-repository-overrides ? [ ] }: let inherit (pkgs) stdenv; @@ -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 diff --git a/nix/pkgs/haskell/default.nix b/nix/pkgs/haskell/default.nix index 3087b7bf93..0e542b0815 100644 --- a/nix/pkgs/haskell/default.nix +++ b/nix/pkgs/haskell/default.nix @@ -12,6 +12,7 @@ , z3 , enableHaskellProfiling , actus-tests +, git-source-repository-overrides ? [ ] }: let # The Hackage index-state from cabal.project @@ -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 diff --git a/nix/pkgs/haskell/haskell.nix b/nix/pkgs/haskell/haskell.nix index d006c2cfc7..febeb45747 100644 --- a/nix/pkgs/haskell/haskell.nix +++ b/nix/pkgs/haskell/haskell.nix @@ -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 ]; @@ -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"; @@ -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