diff --git a/default.nix b/default.nix index 7bbd156..3f9416e 100644 --- a/default.nix +++ b/default.nix @@ -1,3 +1,4 @@ +{ git-source-repository-overrides ? [ ] }: ######################################################################## # default.nix -- The top-level nix build file for plutus-starter. # @@ -22,7 +23,7 @@ let # haskell-language-server # } # } - packages = import ./nix; + packages = import ./nix { inherit git-source-repository-overrides; }; inherit (packages) pkgs plutus-starter; project = plutus-starter.haskell.project; diff --git a/nix/default.nix b/nix/default.nix index f85920d..031ef72 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -1,3 +1,4 @@ +{ git-source-repository-overrides ? [ ] }: let # Pratically, the only needed dependency is the plutus repository. sources = import ./sources.nix { inherit pkgs; }; @@ -11,7 +12,7 @@ let haskell-nix = pkgs.haskell-nix; plutus-starter = import ./pkgs { - inherit pkgs haskell-nix sources plutus; + inherit pkgs haskell-nix sources plutus git-source-repository-overrides; }; in diff --git a/nix/pkgs/default.nix b/nix/pkgs/default.nix index 9818ca3..1a2bdbc 100644 --- a/nix/pkgs/default.nix +++ b/nix/pkgs/default.nix @@ -2,6 +2,7 @@ , sources , plutus , haskell-nix +, git-source-repository-overrides ? [ ] }: let gitignore-nix = pkgs.callPackage plutus."gitignore.nix" { }; @@ -9,7 +10,7 @@ let compiler-nix-name = plutus.plutus-apps.haskell.compiler-nix-name; haskell = pkgs.callPackage ./haskell { - inherit gitignore-nix sources haskell-nix; + inherit gitignore-nix sources haskell-nix git-source-repository-overrides; inherit compiler-nix-name; # Use the same GHC version as plutus inherit (pkgs) libsodium-vrf; }; diff --git a/nix/pkgs/haskell/default.nix b/nix/pkgs/haskell/default.nix index aa36c8b..a973b40 100644 --- a/nix/pkgs/haskell/default.nix +++ b/nix/pkgs/haskell/default.nix @@ -4,6 +4,7 @@ , sources , compiler-nix-name , libsodium-vrf +, git-source-repository-overrides ? [ ] }: let # The Hackage index-state from cabal.project @@ -22,7 +23,7 @@ let # The haskell project created by haskell-nix.cabalProject' project = import ./haskell.nix { - inherit lib haskell-nix compiler-nix-name gitignore-nix libsodium-vrf; + inherit lib haskell-nix compiler-nix-name gitignore-nix libsodium-vrf git-source-repository-overrides; }; # All the packages defined by our project, including dependencies diff --git a/nix/pkgs/haskell/haskell.nix b/nix/pkgs/haskell/haskell.nix index 8232f38..a996c33 100644 --- a/nix/pkgs/haskell/haskell.nix +++ b/nix/pkgs/haskell/haskell.nix @@ -6,10 +6,19 @@ , compiler-nix-name , lib , libsodium-vrf +, git-source-repository-overrides ? [ ] + # Override source-repository-package entries in cabal (useful for CI). + # Note that this will override any cabal.project.local you have, if set. + # + # Type: List of attribute sets: + # location + # tag + # sha256 + # subdir (optional list of strings) }: let - project = haskell-nix.project { + project = haskell-nix.project ({ # 'cleanGit' cleans a source directory based on the files known by git src = haskell-nix.haskellLib.cleanGit { name = "plutus-starter"; @@ -18,6 +27,8 @@ let inherit compiler-nix-name; + # If using materialization, be sure to disable it when git-source-repository-overrides is set or it won't take effect. + sha256map = { "https://github.com/input-output-hk/plutus-apps.git"."plutus-starter-devcontainer/v1.0.14" = "0j3hphj4b21vwdj900233d67qsaj91mppwsx1vv0ichnmnw2bmir"; "https://github.com/Quid2/flat.git"."ee59880f47ab835dbd73bea0847dab7869fc20d8" = "1lrzknw765pz2j97nvv9ip3l1mcpf2zr4n56hwlz0rk7wq7ls4cm"; @@ -37,7 +48,10 @@ let "https://github.com/input-output-hk/cardano-wallet"."ae7569293e94241ef6829139ec02bd91abd069df" = "1mv1dhpkdj9ridm1fvq6jc85qs6zvbp172228rq72gyawjwrgvi6"; "https://github.com/input-output-hk/cardano-addresses"."d2f86caa085402a953920c6714a0de6a50b655ec" = "0p6jbnd7ky2yf7bwb1350k8880py8dgqg39k49q02a6ij4ld01ay"; "https://github.com/input-output-hk/plutus"."3f089ccf0ca746b399c99afe51e063b0640af547" = "1nx8xmdgwmnsla4qg4k67f5md8vm3p1p9i25ndalrqdg40z90486"; - }; + } // (builtins.listToAttrs (map (sro: { + name = sro.location; + value.${sro.tag} = sro.sha256; + }) git-source-repository-overrides)); modules = [ { @@ -52,6 +66,17 @@ let }; } ]; - }; + } // lib.optionalAttrs (git-source-repository-overrides != [ ]) { + 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); + }); in project diff --git a/release.nix b/release.nix index dc210b3..43807ad 100644 --- a/release.nix +++ b/release.nix @@ -3,7 +3,7 @@ # # Therefore, do not worry too much about the structure. let - packages = import ./.; + packages = import ./. { }; pkgs = packages.pkgs; haskellNix = pkgs.haskell-nix; diff --git a/shell.nix b/shell.nix index 1eb4811..27186a2 100644 --- a/shell.nix +++ b/shell.nix @@ -1,6 +1,6 @@ { pure ? false }: let - packages = import ./.; + packages = import ./. { }; inherit (packages) pkgs plutus-starter; inherit (plutus-starter) haskell;