Skip to content

Commit

Permalink
Merge #607
Browse files Browse the repository at this point in the history
607: nix flake support r=jbgi a=jbgi



Co-authored-by: Craige McWhirter <craige.mcwhirter@iohk.io>
  • Loading branch information
iohk-bors[bot] and craigem committed May 14, 2021
2 parents 6ba501a + 3034aba commit 74b120b
Show file tree
Hide file tree
Showing 17 changed files with 465 additions and 366 deletions.
14 changes: 10 additions & 4 deletions cabal.project
Expand Up @@ -56,8 +56,18 @@ package cardano-node
package ouroboros-consensus-cardano
tests: False


allow-newer:
monoidal-containers:aeson,
size-based:template-haskell

-- ---------------------------------------------------------

-- The two following one-liners will cut off / restore the remainder of this file (for nix-shell users):
-- when using the "cabal" wrapper script provided by nix-shell.
-- --------------------------- 8< --------------------------
-- Please do not put any `source-repository-package` clause above this line.

source-repository-package
type: git
location: https://github.com/input-output-hk/Win32-network
Expand Down Expand Up @@ -163,7 +173,3 @@ source-repository-package
typed-protocols
typed-protocols-examples
network-mux

allow-newer:
monoidal-containers:aeson,
size-based:template-haskell
3 changes: 3 additions & 0 deletions custom-config/default.nix
@@ -0,0 +1,3 @@
self: {
withHoogle = true;
}
8 changes: 8 additions & 0 deletions custom-config/flake.nix
@@ -0,0 +1,8 @@
{
outputs = {...}: {
# Example scripts customization:
#nixosModules.cardano-db-sync = {
# service.cardano-db-sync.postgres.port = 5433;
#}
};
}
63 changes: 9 additions & 54 deletions default.nix
Expand Up @@ -11,70 +11,25 @@
# }'
, sourcesOverride ? {}
# pinned version of nixpkgs augmented with overlays (iohk-nix and our packages).
, pkgs ? import ./nix { inherit system crossSystem config sourcesOverride gitrev; }
, gitrev ? pkgs.iohkNix.commitIdFromGitRepoOrZero ./.git
, pkgs ? import ./nix { inherit system crossSystem config sourcesOverride gitrev customConfig; }
, gitrev ? null
}:
with pkgs; with commonLib;
let
customConfig' = if customConfig ? services then customConfig else {
services.cardano-db-sync = customConfig;
};

haskellPackages = recRecurseIntoAttrs
# the Haskell.nix package set, reduced to local packages.
(selectProjectPackages cardanoDbSyncHaskellPackages);

scripts = callPackage ./nix/scripts.nix {
customConfig = customConfig';
};

rewrite-static = _: p: if (pkgs.stdenv.hostPlatform.isDarwin) then
pkgs.runCommandCC p.name {
nativeBuildInputs = [ pkgs.haskellBuildUtils.package pkgs.buildPackages.binutils pkgs.buildPackages.nix ];
} ''
cp -R ${p} $out
chmod -R +w $out
rewrite-libs $out/bin $out/bin/*
'' else if (pkgs.stdenv.hostPlatform.isMusl) then
pkgs.runCommandCC p.name { } ''
cp -R ${p} $out
chmod -R +w $out
$STRIP $out/bin/*
'' else p;

packages = {
inherit haskellPackages cardano-db-sync cardano-db-sync-extended cardano-node scripts;
inherit haskellPackages cardano-db-sync cardano-db-sync-extended cardano-node scripts dockerImage;

# so that eval time gc roots are cached (nix-tools stuff)
inherit (cardanoDbSyncHaskellPackages) roots;
inherit (haskellPackages.cardano-db-sync.project) plan-nix;
inherit (cardanoDbSyncProject) roots plan-nix;

inherit (haskellPackages.cardano-db-sync.identifier) version;

exes = mapAttrsRecursiveCond (as: !(isDerivation as)) rewrite-static (collectComponents' "exes" haskellPackages);

dockerImage = let
defaultConfig = rec {
services.cardano-db-sync = {
socketPath = lib.mkDefault ("/node-ipc/node.socket");
postgres.generatePGPASS = false;
};
};
customConfig'' = mkMerge [ defaultConfig customConfig' ];
in callPackage ./nix/docker.nix {
scripts = scripts.override {
customConfig = customConfig'';
};
extendedScripts = scripts.override {
customConfig = mkMerge [
customConfig''
{ services.cardano-db-sync = {
extended = true;
};
}
];
};
};
exes = mapAttrsRecursiveCond (as: !(isDerivation as)) rewriteStatic (collectComponents' "exes" haskellPackages);

# `tests` are the test suites which have been built.
tests = collectComponents' "tests" haskellPackages;
Expand All @@ -85,12 +40,12 @@ let
# `checks.tests` collect results of executing the tests:
tests = collectChecks haskellPackages;

hlint = callPackage iohkNix.tests.hlint {
src = ./. ;
hlint = callPackage hlintCheck {
inherit (pkgs.cardanoDbSyncProject.projectModule) src;
};

stylish-haskell = callPackage iohkNix.tests.stylish-haskell {
src = ./. ;
stylish-haskell = callPackage stylishHaskellCheck {
inherit (pkgs.cardanoDbSyncProject.projectModule) src;
};
};

Expand Down
149 changes: 149 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 74b120b

Please sign in to comment.