Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Nix flake #3221

Merged
merged 9 commits into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@
{ system ? builtins.currentSystem
, crossSystem ? null
, config ? { allowUnfreePredicate = (import ./nix/lib/unfree.nix).unfreePredicate; }
# Overrides for niv
, sourcesOverride ? { }
, packages ? import ./nix { inherit system crossSystem config sourcesOverride checkMaterialization enableHaskellProfiling; }
, sources ? import ./nix/sources.nix { inherit system; } // sourcesOverride
, isInFlake ? false
, haskellNix ? import sources."haskell.nix" {
sourcesOverride = {
hackage = sources."hackage.nix";
stackage = sources."stackage.nix";
};
}
, packages ? import ./nix { inherit system sources crossSystem config sourcesOverride haskellNix isInFlake checkMaterialization enableHaskellProfiling; }
# An explicit git rev to use, passed when we are in Hydra
# Whether to check that the pinned shas for haskell.nix are correct. We want this to be
# false, generally, since it does more work, but we set it to true in the CI
Expand Down
131 changes: 131 additions & 0 deletions flake.lock

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

42 changes: 42 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# NOTE: This flake is only provided as interface to `bitte` and shouldn't be used otherwise
#
# - Until https://github.com/input-output-hk/haskell.nix/issues/1132 is resolved the
# outputs generated by this flake will differ from the respective outputs built via
# default.nix because the hackage/stackage.nix revisions differ.
# - The revisions the nixpkgs and haskell-nix flake inputs have to be kept in sync with
# the niv versions manually. When haskell.nix is updated in niv things will break.
# - Occasionally building flake builds will segfault. The workaround for this is to
# disable the garbage collector `GC_DONT_GC=1 nix build .#web-ghc-server
#
# In case you are not sure if you should be using this flake, the answer is: No.
{
description = "plutus flake for bitte deployments";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs?rev=7d71001b796340b219d1bfa8552c81995017544a";
haskell-nix.url = "github:input-output-hk/haskell.nix?rev=87084d65a476cc826a0e8c5d281d494254f5bc7a";
flake-utils.url = "github:numtide/flake-utils?rev=b543720b25df6ffdfcf9227afafc5b8c1fabfae8";
};

outputs = { self, nixpkgs, haskell-nix, flake-utils, ... }:
(flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
topLevel = import ./. {
inherit system;
isInFlake = true;
haskellNix = haskell-nix;
gilligan marked this conversation as resolved.
Show resolved Hide resolved
};

inherit (topLevel) pkgs plutus;
in
rec {
packages = rec {
gilligan marked this conversation as resolved.
Show resolved Hide resolved
marlowe-playground-client = topLevel.marlowe-playground.client;
marlowe-playground-server = topLevel.marlowe-playground.server;
plutus-playground-client = topLevel.plutus-playground.client;
plutus-playground-server = topLevel.plutus-playground.server;
marlowe-website = topLevel.marlowe-web;
web-ghc-server = plutus.haskell.project.hsPkgs.web-ghc.components.exes.web-ghc-server;
};
}));
}
32 changes: 17 additions & 15 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,36 @@
, config ? { }
, overlays ? [ ]
, sourcesOverride ? { }
, sources
, isInFlake
, haskellNix
, checkMaterialization ? false
, enableHaskellProfiling ? false
}:
let
sources = import ./sources.nix { inherit pkgs; }
// sourcesOverride;
haskellNix = import sources."haskell.nix" {
sourcesOverride = {
hackage = sources."hackage.nix";
stackage = sources."stackage.nix";
};
};

extraOverlays =
# Haskell.nix (https://github.com/input-output-hk/haskell.nix)
haskellNix.overlays
# our own overlays:
++ [
ownOverlays =
[
# Modifications to derivations from nixpkgs
(import ./overlays/nixpkgs-overrides.nix)
# fix r-modules
(import ./overlays/r.nix)
];

# haskell-nix has to be used differently in flakes/no-flakes scenarios:
# - When imported from flakes, 'haskellNix.overlay' needs to be passed here.
# - When imported from default.nix without flakes, default to haskellNix.overlays
gilligan marked this conversation as resolved.
Show resolved Hide resolved
haskellNixOverlays = if isInFlake then [ haskellNix.overlay ] else haskellNix.overlays;

# haskell-nix provides some global config settings but it's exposed under different
# attribute paths when imported as flake/non-flake.
haskellNixConfig = if isInFlake then haskellNix.internal.config else haskellNix.config;

extraOverlays = haskellNixOverlays ++ ownOverlays;

pkgs = import sources.nixpkgs {
inherit system crossSystem;
overlays = extraOverlays ++ overlays;
config = haskellNix.config // config;
gilligan marked this conversation as resolved.
Show resolved Hide resolved
config = haskellNixConfig // config;
};

plutus = import ./pkgs { inherit pkgs checkMaterialization enableHaskellProfiling sources; };
Expand Down
3 changes: 2 additions & 1 deletion nix/tests/vm-tests/plutus-playground.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ makeTest {
machine.succeed("cp ${envFile} /var/lib/playgrounds/plutus.env")
machine.succeed("systemctl restart plutus-playground")
machine.wait_for_unit("plutus-playground.service")
machine.sleep(2)

res = machine.succeed("journalctl -u plutus-playground.service --no-pager")
res = machine.succeed("journalctl -eu plutus-playground.service --no-pager")
assert "Loading environment config from '/var/lib/playgrounds/plutus.env'" in res, "Expected playground to load config. Actual: {}".format(res)
'';

Expand Down
7 changes: 2 additions & 5 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{ crossSystem ? null
, system ? builtins.currentSystem
, config ? { allowUnfreePredicate = (import ./nix/lib/unfree.nix).unfreePredicate; }
, sourcesOverride ? { }
, packages ? import ./. { inherit crossSystem config sourcesOverride enableHaskellProfiling; }
{ system ? builtins.currentSystem
, enableHaskellProfiling ? false
gilligan marked this conversation as resolved.
Show resolved Hide resolved
, packages ? import ./. { inherit system enableHaskellProfiling; }
}:
let
inherit (packages) pkgs plutus plutus-playground marlowe-playground plutus-pab marlowe-dashboard deployment docs;
Expand Down