Skip to content

Commit

Permalink
Add a Nix flake
Browse files Browse the repository at this point in the history
Add a basic nix flake that simply exports several packages from the
toplevel default.nix
  • Loading branch information
gilligan committed Jun 8, 2021
1 parent 072d1b7 commit 7539aab
Show file tree
Hide file tree
Showing 3 changed files with 200 additions and 15 deletions.
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.

53 changes: 53 additions & 0 deletions flake.nix
@@ -0,0 +1,53 @@
{
description = "Flake for Plutus";

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
#
# Obtain all niv sources extending it with the 'nixpkgs' flake input
#
sources =
let
sourcesInfo = builtins.fromJSON (builtins.readFile ./nix/sources.json);
fetch = sourceInfo: builtins.fetchTarball { inherit (sourceInfo) url sha256; };
in
builtins.mapAttrs (name: info: fetch info) sourcesInfo // { inherit nixpkgs; };

#
# all packages from nix/default.nix
#
plutusPackages = import ./nix {
inherit system sources;
haskellNixOverlays = [ haskell-nix.overlay ];
};

#
# all packages from ./default.nix
#
topLevel = import ./. {
inherit system;
packages = plutusPackages;
};

inherit (plutusPackages) pkgs plutus ownOverlays;
inherit (plutus) haskell iohkNix;
inherit (plutus.lib) buildPursPackage buildNodeModules filterNpm gitignore-nix;
in
rec {
packages = rec {
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;
};
}));
}
31 changes: 16 additions & 15 deletions nix/default.nix
Expand Up @@ -3,30 +3,31 @@
, config ? { }
, overlays ? [ ]
, sourcesOverride ? { }
, checkMaterialization ? false
, enableHaskellProfiling ? false
}:
let
sources = import ./sources.nix { inherit pkgs; }
// sourcesOverride;
haskellNix = import sources."haskell.nix" {
, sources ? import ./sources.nix { } // 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:
++ [
}
# 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
, haskellNixOverlays ? haskellNix.overlays
, checkMaterialization ? false
, enableHaskellProfiling ? false
}:
let
ownOverlays =
[
# Modifications to derivations from nixpkgs
(import ./overlays/nixpkgs-overrides.nix)
# fix r-modules
(import ./overlays/r.nix)
];

extraOverlays = haskellNixOverlays ++ ownOverlays;

pkgs = import sources.nixpkgs {
inherit system crossSystem;
overlays = extraOverlays ++ overlays;
Expand All @@ -37,5 +38,5 @@ let

in
{
inherit pkgs plutus sources;
inherit pkgs plutus sources ownOverlays;
}

0 comments on commit 7539aab

Please sign in to comment.