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 a65b67d commit 14e5485
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 9 deletions.
3 changes: 2 additions & 1 deletion default.nix
@@ -1,3 +1,4 @@
{ git-source-repository-overrides ? [ ] }:
########################################################################
# default.nix -- The top-level nix build file for plutus-starter.
#
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion 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; };
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion nix/pkgs/default.nix
Expand Up @@ -2,14 +2,15 @@
, sources
, plutus
, haskell-nix
, git-source-repository-overrides ? [ ]
}:
let
gitignore-nix = pkgs.callPackage plutus."gitignore.nix" { };

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;
};
Expand Down
3 changes: 2 additions & 1 deletion nix/pkgs/haskell/default.nix
Expand Up @@ -4,6 +4,7 @@
, sources
, compiler-nix-name
, libsodium-vrf
, git-source-repository-overrides ? [ ]
}:
let
# The Hackage index-state from cabal.project
Expand All @@ -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
Expand Down
31 changes: 28 additions & 3 deletions nix/pkgs/haskell/haskell.nix
Expand Up @@ -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";
Expand All @@ -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";
Expand All @@ -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 = [
{
Expand All @@ -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
2 changes: 1 addition & 1 deletion release.nix
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion shell.nix
@@ -1,6 +1,6 @@
{ pure ? false }:
let
packages = import ./.;
packages = import ./. { };
inherit (packages) pkgs plutus-starter;
inherit (plutus-starter) haskell;

Expand Down

0 comments on commit 14e5485

Please sign in to comment.