-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
98 lines (82 loc) · 2.75 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
{
description = "alt-dex";
inputs = {
flake-utils = {
type = "github";
owner = "numtide";
repo = "flake-utils";
};
# The Plutus "flake" isn't really a flake - it doesn't define any
# outputs and is only used for input pinning according to to
# the comments
plutusSrc = {
type = "github";
owner = "input-output-hk";
repo = "plutus";
rev = "3f089ccf0ca746b399c99afe51e063b0640af547";
flake = false;
};
haskellNix = {
type = "github";
owner = "input-output-hk";
repo = "haskell.nix";
# FIXME rev taken from Plutus doesn't work?
rev = "64cd5f70ce0d619390039a1a3d57c442552b0924";
};
nixpkgs.follows = "haskellNix/nixpkgs-unstable";
flake-compat = {
type = "github";
owner = "edolstra";
repo = "flake-compat";
rev = "12c64ca55c1014cdc1b16ed5a804aa8576601ff2";
flake = false;
};
};
outputs = { self, flake-utils, plutusSrc, nixpkgs, haskellNix, ... }:
let
inherit (flake-utils.lib) defaultSystems;
perSystem = nixpkgs.lib.genAttrs defaultSystems;
nixpkgsFor = system: import nixpkgs {
overlays = [ haskellNix.overlay ];
inherit (haskellNix) config;
inherit system;
};
projectFor = system:
let
pkgs = nixpkgsFor system;
plutus = import plutusSrc { inherit system; };
fakeSrc = pkgs.runCommand "real-src" {} ''
cp -rT ${self} $out || cp -rT ${self} $out
chmod u+w $out/cabal.project
cat $out/nix/haskell-nix-cabal.project >> $out/cabal.project
'';
src = fakeSrc.outPath;
in
import ./nix/haskell.nix {
inherit src pkgs plutus system;
};
in
{
flake = perSystem (system: (projectFor system).flake {});
defaultPackage = perSystem (
system:
self.flake.${system}.packages."alt-dex:lib:alt-dex"
);
packages = perSystem (system: self.flake.${system}.packages);
apps = perSystem (system: self.flake.${system}.apps);
devShell = perSystem (system: self.flake.${system}.devShell);
# This will build all of the project's executables and the tests
check = perSystem (
system:
(nixpkgsFor system).runCommand "combined-executables" {
nativeBuildInputs = builtins.attrValues self.checks.${system};
} "touch $out"
);
# NOTE `nix flake check` will not work at the moment due to use of
# IFD in haskell.nix
#
# Includes all of the packages in the `checks`, otherwise only the
# test suite would be included
checks = perSystem (system: self.flake.${system}.packages);
};
}