Skip to content

Commit

Permalink
nix: convert flake to use haskell.nix
Browse files Browse the repository at this point in the history
Co-authored-by: Jean-Baptiste Giraudeau <jean-baptiste.giraudeau@iohk.io>
  • Loading branch information
craigem and jbgi committed Apr 28, 2021
1 parent fecdb3b commit b3260b3
Show file tree
Hide file tree
Showing 24 changed files with 387 additions and 459 deletions.
3 changes: 0 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# GitHub Linguist annotations.

# Hide niv boilerplate
nix/sources.nix linguist-generated=true
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ tags
# For now require that users generate their own hie.yaml
hie.yaml

# Ignore local modification of nix config files
/custom-config.nix
/workbench-config.nix
/supported-systems.nix

# Ignore Visual Studio code configuration
.vscode/tasks.json

Expand Down
1 change: 1 addition & 0 deletions custom-config.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ }
46 changes: 7 additions & 39 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# allows to cutomize haskellNix (ghc and profiling, see ./nix/haskell.nix)
, config ? {}
# override scripts with custom configuration
, customConfig ? {}
, customConfig ? import ./custom-config.nix
# allows to override dependencies of the project without modifications,
# eg. to test build against local checkout of nixpkgs and iohk-nix:
# nix build -f default.nix cardano-node --arg sourcesOverride '{
# iohk-nix = ../iohk-nix;
# }'
, sourcesOverride ? {}
# pinned version of nixpkgs augmented with overlays (iohk-nix and our packages).
, pkgs ? import ./nix/default.nix { inherit system crossSystem config sourcesOverride gitrev; }
, pkgs ? import ./nix/default.nix { inherit system crossSystem config customConfig sourcesOverride gitrev; }
# Git sha1 hash, to be passed when not building from a git work tree.
, gitrev ? null
}:
Expand All @@ -22,52 +22,20 @@ let
# the Haskell.nix package set, reduced to local packages.
(selectProjectPackages cardanoNodeHaskellPackages);

scripts = callPackage ./nix/scripts.nix { inherit customConfig; };
# NixOS tests run a proxy and validate it listens
nixosTests = recRecurseIntoAttrs (import ./nix/nixos/tests {
inherit pkgs;
});

dockerImage = let
defaultConfig = rec {
stateDir = "/data";
dbPrefix = "db";
socketPath = "/ipc/node.socket";
};
customConfig' = defaultConfig // customConfig;
in pkgs.callPackage ./nix/docker.nix {
inherit (packages) cardano-node cardano-cli;
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-node cardano-node-profiled cardano-node-eventlogged
cardano-cli db-converter cardano-ping
scripts nixosTests environments dockerImage mkCluster bech32;
scripts environments dockerImage submitApiDockerImage mkCluster bech32;

nixosTests = recRecurseIntoAttrs nixosTests;

# so that eval time gc roots are cached (nix-tools stuff)
inherit (cardanoNodeHaskellPackages) roots;
inherit (cardanoNodeProject) roots plan-nix;

inherit (haskellPackages.cardano-node.identifier) version;

inherit (haskellPackages.cardano-node.project) plan-nix;

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

# `tests` are the test suites which have been built.
tests = collectComponents' "tests" haskellPackages;
Expand Down
58 changes: 33 additions & 25 deletions flake.lock

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

Loading

0 comments on commit b3260b3

Please sign in to comment.