Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7ae62c
commit b5818b5
Showing
9 changed files
with
424 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,10 @@ | ||
let | ||
sources = import ./nix/sources.nix { inherit pkgs; }; | ||
plutus-sources = import sources.plutus {}; | ||
pkgs = plutus-sources.pkgs; | ||
packages = import ./nix; | ||
inherit (packages) pkgs plutus-starter sources; | ||
project = plutus-starter.haskell.project; | ||
in | ||
{ | ||
inherit (plutus-sources) pkgs; | ||
inherit (plutus-sources) plutus; | ||
inherit pkgs sources plutus-starter; | ||
|
||
haskellNixProject = pkgs.haskell-nix.project { | ||
# 'cleanGit' cleans a source directory based on the files known by git | ||
src = pkgs.haskell-nix.haskellLib.cleanGit { | ||
name = "plutus-starter"; | ||
src = ./.; | ||
}; | ||
# Specify the GHC version to use. | ||
compiler-nix-name = "ghc810420210212"; # Should use the same version as in `https://github.com/input-output-hk/plutus/blob/master/nix/pkgs/haskell/default.nix | ||
|
||
sha256map = { | ||
"https://github.com/Quid2/flat.git"."95e5d7488451e43062ca84d5376b3adcc465f1cd" = "06l31x3y93rjpryvlxnpsyq2zyxvb0z6lik6yq2fvh36i5zwvwa3"; | ||
"https://github.com/input-output-hk/plutus.git"."514f059a7aabc4b03ca80343d29cf0736f9ea498" = "0l848y4y6yqva1xfcv05dyhb6hhvlmnjcign4dwmf1cgy0kyz4v5"; | ||
"https://github.com/shmish111/purescript-bridge.git"."6a92d7853ea514be8b70bab5e72077bf5a510596" = "13j64vv116in3c204qsl1v0ajphac9fqvsjp7x3zzfr7n7g61drb"; | ||
"https://github.com/shmish111/servant-purescript.git"."a76104490499aa72d40c2790d10e9383e0dbde63" = "11nxxmi5bw66va7psvrgrw7b7n85fvqgfp58yva99w3v9q3a50v9"; | ||
"https://github.com/input-output-hk/cardano-crypto.git"."f73079303f663e028288f9f4a9e08bcca39a923e" = "1n87i15x54s0cjkh3nsxs4r1x016cdw1fypwmr68936n3xxsjn6q"; | ||
"https://github.com/input-output-hk/cardano-base"."4251c0bb6e4f443f00231d28f5f70d42876da055" = "02a61ymvx054pcdcgvg5qj9kpybiajg993nr22iqiya196jmgciv"; | ||
"https://github.com/input-output-hk/cardano-prelude"."ee4e7b547a991876e6b05ba542f4e62909f4a571" = "0dg6ihgrn5mgqp95c4f11l6kh9k3y75lwfqf47hdp554w7wyvaw6"; | ||
"https://github.com/input-output-hk/ouroboros-network"."6cb9052bde39472a0555d19ade8a42da63d3e904" = "0rz4acz15wda6yfc7nls6g94gcwg2an5zibv0irkxk297n76gkmg"; | ||
"https://github.com/input-output-hk/iohk-monitoring-framework"."34abfb7f4f5610cabb45396e0496472446a0b2ca" = "1fdc0a02ipa385dnwa6r6jyc8jlg537i12hflfglkhjs2b7i92gs"; | ||
"https://github.com/input-output-hk/cardano-ledger-specs"."097890495cbb0e8b62106bcd090a5721c3f4b36f" = "0i3y9n0rsyarvhfqzzzjccqnjgwb9fbmbs6b7vj40afjhimf5hcj"; | ||
"https://github.com/input-output-hk/goblins"."cde90a2b27f79187ca8310b6549331e59595e7ba" = "17c88rbva3iw82yg9srlxjv2ia5wjb9cyqw44hik565f5v9svnyg"; | ||
}; | ||
|
||
modules = [ | ||
{ | ||
packages = { | ||
eventful-sql-common = { | ||
# This is needed so evenful-sql-common will build with a newer version of persistent. | ||
ghcOptions = [ "-XDerivingStrategies -XStandaloneDeriving -XUndecidableInstances -XDataKinds -XFlexibleInstances -XMultiParamTypeClasses" ]; | ||
doHaddock = false; | ||
}; | ||
|
||
# Broken due to haddock errors. Refer to https://github.com/input-output-hk/plutus/blob/master/nix/pkgs/haskell/haskell.nix | ||
plutus-ledger.doHaddock = false; | ||
plutus-use-cases.doHaddock = false; | ||
}; | ||
} | ||
]; | ||
}; | ||
inherit project; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
let | ||
sources = import (import ./sources.nix { inherit pkgs; }).plutus {}; | ||
pkgs = sources.pkgs; | ||
|
||
plutus-starter = import ./pkgs { inherit pkgs sources; }; | ||
|
||
in | ||
{ | ||
inherit pkgs plutus-starter sources; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
{ pkgs }: | ||
|
||
let | ||
# Generic nixpkgs, use *only* for lib functions that are stable across versions | ||
lib = pkgs.lib; | ||
in | ||
rec { | ||
# Borrowed from https://github.com/cachix/ghcide-nix/pull/4/files#diff-70bfff902f4dec33e545cac10ee5844d | ||
# Tweaked to use builtins.mapAttrs instead of needing the one from nixpkgs lib | ||
/* | ||
dimension: name -> attrs -> function -> attrs | ||
where | ||
function: keyText -> value -> attrsOf package | ||
WARNING: Attribute names must not contain periods ("."). | ||
See https://github.com/NixOS/nix/issues/3088 | ||
NOTE: The dimension name will be picked up by agent and web ui soon. | ||
Specifies a dimension of the build matrix. For example | ||
dimension "Example" { | ||
withP = { p = true; } | ||
withoutP = { p = false; } | ||
} (key: # either "withP" or "withoutP" | ||
{ p }: # either p = true or p = false | ||
myProject p | ||
) | ||
evaluates roughly to | ||
{ | ||
withP = myProject true; | ||
withoutP = myProject false; | ||
} | ||
Use nested calls for multiple dimensions. | ||
Example: | ||
dimension "System" { | ||
"x86_64-linux" = {}; | ||
# ... | ||
}: (system: {}: | ||
dimension "Nixpkgs release" ( | ||
{ | ||
"nixpkgs-19_03".nixpkgs = someSource | ||
} // optionalAttrs (system != "...") { | ||
"nixpkgs-unstable".nixpkgs = someOtherSource | ||
} | ||
) (_key: { nixpkgs }: | ||
myProject system nixpkgs | ||
) | ||
) | ||
evaluates roughly to | ||
{ | ||
x86_64-linux.nixpkgs-19_03 = myProject "x86_64-linux" someSource; | ||
x86_64-linux.nixpkgs-unstable = myProject "x86_64-linux" someOtherSource; | ||
... | ||
} | ||
If you need to make references across attributes, you can do so by binding | ||
the result. Wherever you write | ||
dimension "My dimension" {} (key: value: f1 key value) | ||
You can also write | ||
let | ||
myDimension = dimension "My dimension" {} (key: value: f2 key value myDimension) | ||
in | ||
myDimension | ||
This example builds a single test runner to reuse across releases: | ||
let | ||
overlay = | ||
testRunnerPkgs: self: super: { | ||
# ... | ||
}; | ||
myProject = | ||
{ nixpkgs, | ||
pkgs ? import nixpkgs { overlays = [ overlay ]; }, | ||
testRunnerPkgs ? pkgs | ||
}: pkgs; | ||
in | ||
let | ||
latest = "nixpkgs-19_03"; | ||
releases = | ||
dimension "Nixpkgs release" | ||
{ | ||
nixpkgs-18_09.nixpkgs = someSource | ||
nixpkgs-19_03.nixpkgs = someOtherSource | ||
} | ||
(_key: { nixpkgs }: | ||
myProject { | ||
inherit nixpkgs; | ||
testRunnerPkgs = releases."${latest}"; | ||
} | ||
); | ||
in releases; | ||
*/ | ||
dimension = name: attrs: f: | ||
builtins.mapAttrs | ||
(k: v: | ||
let o = f k v; | ||
in o // { recurseForDerivations = o.recurseForDerivations or true; } | ||
) | ||
attrs | ||
// { meta.dimension.name = name; }; | ||
|
||
/* | ||
Takes an attribute set and returns all the paths to derivations within it, i.e. | ||
derivationPaths { a = { b = <drv>; }; c = <drv>; } == [ "a.b" "c" ] | ||
This can be used with 'attrByPath' or the 'constitutents' of an aggregate Hydra job. | ||
*/ | ||
derivationPaths = | ||
let | ||
names = x: lib.filter (n: n != "recurseForDerivations" && n != "meta") (builtins.attrNames x); | ||
go = nameSections: attrs: | ||
builtins.concatMap | ||
(n: | ||
let | ||
v = builtins.getAttr n attrs; | ||
newNameSections = nameSections ++ [ n ]; | ||
in | ||
if pkgs.lib.isDerivation v | ||
then [ (builtins.concatStringsSep "." newNameSections) ] | ||
else if builtins.isAttrs v | ||
then go newNameSections v | ||
else [ ] | ||
) | ||
(names attrs); | ||
in | ||
go [ ]; | ||
|
||
# Creates an aggregate job with the given name from every derivation in the attribute set. | ||
derivationAggregate = name: attrs: pkgs.releaseTools.aggregate { | ||
inherit name; | ||
constituents = derivationPaths attrs; | ||
}; | ||
|
||
# A filter for removing packages that aren't supported on the current platform | ||
# according to 'meta.platforms'. | ||
platformFilterGeneric = pkgs: system: | ||
# This needs to use the correct nixpkgs version so all the systems line up | ||
let | ||
lib = pkgs.lib; | ||
platform = lib.systems.elaborate { inherit system; }; | ||
# Can't just default to [] for platforms, since no meta.platforms | ||
# means "all platforms" not "no platforms" | ||
in | ||
drv: | ||
if drv ? meta && drv.meta ? platforms then | ||
lib.any (lib.meta.platformMatch platform) drv.meta.platforms | ||
else true; | ||
|
||
# Hydra doesn't like these attributes hanging around in "jobsets": it thinks they're jobs! | ||
stripAttrsForHydra = filterAttrsOnlyRecursive (n: _: n != "recurseForDerivations" && n != "dimension"); | ||
|
||
# Keep derivations and attrsets with 'recurseForDerivations'. This ensures that we match the | ||
# derivations that Hercules will see, and prevents Hydra from trying to pick up all sorts of bad stuff | ||
# (like attrsets that contain themselves!). | ||
filterDerivations = filterAttrsOnlyRecursive (n: attrs: lib.isDerivation attrs || attrs.recurseForDerivations or false); | ||
|
||
# A version of 'filterAttrsRecursive' that doesn't recurse into derivations. This prevents us from going into an infinite | ||
# loop with the 'out' attribute on derivations. | ||
# TODO: Surely this shouldn't be necessary. I think normal 'filterAttrsRecursive' will effectively cause infinite loops | ||
# if you keep derivations and your predicate forces the value of the attribute, as this then triggers a loop on the | ||
# 'out' attribute. Weird. | ||
filterAttrsOnlyRecursive = pred: set: | ||
lib.listToAttrs ( | ||
lib.concatMap | ||
(name: | ||
let v = set.${name}; in | ||
if pred name v then [ | ||
(lib.nameValuePair name ( | ||
if builtins.isAttrs v && !lib.isDerivation v then filterAttrsOnlyRecursive pred v | ||
else v | ||
)) | ||
] else [ ] | ||
) | ||
(builtins.attrNames set) | ||
); | ||
|
||
# Takes an array of systems and returns a `name: system` AttrSet | ||
# filterSystems :: [ string ] -> AttrSet | ||
filterSystems = systems: lib.filterAttrs (_: v: builtins.elem v systems) { | ||
linux = "x86_64-linux"; | ||
darwin = "x86_64-darwin"; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ pkgs | ||
, sources | ||
}: | ||
let | ||
inherit (pkgs) stdenv; | ||
|
||
gitignore-nix = pkgs.callPackage sources."gitignore.nix" { }; | ||
|
||
haskell = pkgs.callPackage ./haskell { | ||
inherit gitignore-nix; | ||
}; | ||
|
||
hlint = sources.plutus.hlint; | ||
|
||
cabal-install = sources.plutus.cabal-install; | ||
|
||
stylish-haskell = sources.plutus.stylish-haskell; | ||
|
||
haskell-language-server = sources.plutus.haskell-language-server; | ||
|
||
in | ||
{ | ||
inherit haskell hlint cabal-install stylish-haskell haskell-language-server; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ haskell-nix | ||
, gitignore-nix | ||
}: | ||
let | ||
# The compiler that we are using. We are using a patched version so we need to specify it explicitly. | ||
# This version has the experimental core interface files patch, and a fix for unboxed tuples in | ||
# GHCi, which helps with HLS. | ||
compiler-nix-name = "ghc810420210212"; # Should use the same version as in `https://github.com/input-output-hk/plutus/blob/master/nix/pkgs/haskell/default.nix | ||
|
||
# The haskell project created by haskell-nix.cabalProject' | ||
project = import ./haskell.nix { | ||
inherit haskell-nix compiler-nix-name gitignore-nix; | ||
}; | ||
|
||
# All the packages defined by our project, including dependencies | ||
packages = project.hsPkgs; | ||
|
||
# Just the packages in the project | ||
projectPackages = haskell-nix.haskellLib.selectProjectPackages packages; | ||
|
||
in | ||
rec { | ||
inherit project projectPackages packages; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
############################################################################ | ||
# Builds Haskell packages with Haskell.nix | ||
############################################################################ | ||
{ haskell-nix | ||
, gitignore-nix | ||
, compiler-nix-name | ||
}: | ||
|
||
let | ||
project = haskell-nix.project { | ||
# 'cleanGit' cleans a source directory based on the files known by git | ||
src = haskell-nix.haskellLib.cleanGit { | ||
name = "plutus-starter"; | ||
src = ../../../.; | ||
}; | ||
|
||
inherit compiler-nix-name; | ||
|
||
sha256map = { | ||
"https://github.com/Quid2/flat.git"."95e5d7488451e43062ca84d5376b3adcc465f1cd" = "06l31x3y93rjpryvlxnpsyq2zyxvb0z6lik6yq2fvh36i5zwvwa3"; | ||
"https://github.com/input-output-hk/plutus.git"."514f059a7aabc4b03ca80343d29cf0736f9ea498" = "0l848y4y6yqva1xfcv05dyhb6hhvlmnjcign4dwmf1cgy0kyz4v5"; | ||
"https://github.com/shmish111/purescript-bridge.git"."6a92d7853ea514be8b70bab5e72077bf5a510596" = "13j64vv116in3c204qsl1v0ajphac9fqvsjp7x3zzfr7n7g61drb"; | ||
"https://github.com/shmish111/servant-purescript.git"."a76104490499aa72d40c2790d10e9383e0dbde63" = "11nxxmi5bw66va7psvrgrw7b7n85fvqgfp58yva99w3v9q3a50v9"; | ||
"https://github.com/input-output-hk/cardano-crypto.git"."f73079303f663e028288f9f4a9e08bcca39a923e" = "1n87i15x54s0cjkh3nsxs4r1x016cdw1fypwmr68936n3xxsjn6q"; | ||
"https://github.com/input-output-hk/cardano-base"."4251c0bb6e4f443f00231d28f5f70d42876da055" = "02a61ymvx054pcdcgvg5qj9kpybiajg993nr22iqiya196jmgciv"; | ||
"https://github.com/input-output-hk/cardano-prelude"."ee4e7b547a991876e6b05ba542f4e62909f4a571" = "0dg6ihgrn5mgqp95c4f11l6kh9k3y75lwfqf47hdp554w7wyvaw6"; | ||
"https://github.com/input-output-hk/ouroboros-network"."6cb9052bde39472a0555d19ade8a42da63d3e904" = "0rz4acz15wda6yfc7nls6g94gcwg2an5zibv0irkxk297n76gkmg"; | ||
"https://github.com/input-output-hk/iohk-monitoring-framework"."34abfb7f4f5610cabb45396e0496472446a0b2ca" = "1fdc0a02ipa385dnwa6r6jyc8jlg537i12hflfglkhjs2b7i92gs"; | ||
"https://github.com/input-output-hk/cardano-ledger-specs"."097890495cbb0e8b62106bcd090a5721c3f4b36f" = "0i3y9n0rsyarvhfqzzzjccqnjgwb9fbmbs6b7vj40afjhimf5hcj"; | ||
"https://github.com/input-output-hk/goblins"."cde90a2b27f79187ca8310b6549331e59595e7ba" = "17c88rbva3iw82yg9srlxjv2ia5wjb9cyqw44hik565f5v9svnyg"; | ||
}; | ||
|
||
modules = [ | ||
{ | ||
packages = { | ||
eventful-sql-common = { | ||
# This is needed so evenful-sql-common will build with a newer version of persistent. | ||
ghcOptions = [ "-XDerivingStrategies -XStandaloneDeriving -XUndecidableInstances -XDataKinds -XFlexibleInstances -XMultiParamTypeClasses" ]; | ||
doHaddock = false; | ||
}; | ||
|
||
# Broken due to haddock errors. Refer to https://github.com/input-output-hk/plutus/blob/master/nix/pkgs/haskell/haskell.nix | ||
plutus-ledger.doHaddock = false; | ||
plutus-use-cases.doHaddock = false; | ||
}; | ||
} | ||
]; | ||
}; | ||
in | ||
project | ||
|
Oops, something went wrong.