-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
98 lines (86 loc) · 3.05 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 = "Trying out flakes with Tulars";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "nixpkgs/nixos-unstable";
elm-review-tool-src = {
url = "github:jfmengels/node-elm-review";
flake = false;
};
mkElmDerivation = {
url = "github:r-k-b/mkElmDerivation?ref=support-elm-review";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ elm-review-tool-src, self, mkElmDerivation, nixpkgs, flake-utils }:
let supportedSystems = with flake-utils.lib.system; [ x86_64-linux ];
in flake-utils.lib.eachSystem supportedSystems (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ mkElmDerivation.overlays.makeDotElmDirectoryCmd ];
};
inherit (pkgs) lib stdenv callPackage;
inherit (lib) fileset hasInfix hasSuffix;
toSource = fsets:
fileset.toSource {
root = ./.;
fileset = fileset.unions fsets;
};
# The build cache will be invalidated if any of the files within change.
# So, exclude files from here unless they're necessary for `elm make` et al.
minimalElmSrc = toSource [
(fileset.fileFilter (file: file.hasExt "elm") ./app)
./dist
./elm.json
];
testsSrc = toSource [
(fileset.difference (fileset.fromSource minimalElmSrc) ./dist)
(fileset.fileFilter (file: file.hasExt "elm") ./tests)
];
reviewSrc = toSource [
(fileset.fromSource testsSrc)
(fileset.fileFilter (file: file.hasExt "elm") ./review)
./review/elm.json
];
elm-review-tool = callPackage ./nix/elm-review-tool.nix {
inherit elm-review-tool-src;
};
compiledElmApp =
callPackage ./nix/default.nix { inherit minimalElmSrc; };
built = callPackage ./nix/built.nix {
inherit compiledElmApp minimalElmSrc;
sourceInfo = self.sourceInfo;
};
elmtests = callPackage ./nix/elmtests.nix { inherit testsSrc; };
elmReviewed = callPackage ./nix/elmReviewed.nix {
inherit elm-review-tool reviewSrc;
};
peekSrc = name: src:
stdenv.mkDerivation {
src = src;
name = "peekSource-${name}";
buildPhase = "mkdir -p $out";
installPhase = "cp -r ./* $out";
};
in {
packages = {
inherit built compiledElmApp elm-review-tool;
default = built;
minimalElmSrc = peekSrc "minimal-elm" minimalElmSrc;
testsSrc = peekSrc "tests" testsSrc;
reviewSrc = peekSrc "elm-review" reviewSrc;
};
checks = { inherit built elmReviewed elmtests; };
devShells.default =
import ./nix/shell.nix { inherit elm-review-tool pkgs; };
apps.default = {
type = "app";
program = "${pkgs.writeScript "tularsApp" ''
#!${pkgs.bash}/bin/bash
xdg-open ${built}/index.html
''}";
};
});
}