-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
74 lines (66 loc) · 2.46 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
{
description = "A flake to build patternfly-elm examples and provide a development shell";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
mkElmDerivation.url = "github:jeslie0/mkElmDerivation";
};
outputs = { self, nixpkgs, mkElmDerivation, flake-utils }:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
overlays = [ mkElmDerivation.overlays.mkElmDerivation ];
inherit system;
};
patternfly = pkgs.stdenvNoCC.mkDerivation rec {
pname = "patternfly";
version = "4.224.2";
src = builtins.fetchTarball {
url = "https://registry.npmjs.org/@patternfly/patternfly/-/patternfly-${version}.tgz";
sha256 = "sha256:04v9kl36ala47vg9snq1bcmsg1d0dm5kq2dl9i85hmi6505qlxjb";
};
installPhase = "mkdir -p $out; mv * $out";
};
makeExample = dirname:
let js = pkgs.mkElmDerivation {
name = "${dirname}JS";
src = ./.;
elmJson = ./examples/elm.json;
targets = [ "src/${dirname}/Main.elm"];
outputJavaScript = true;
optimizationLevel = 2;
preInstall = "cd examples";
postInstall = "mv $out/Main.min.js $out/main.min.js";
};
in
pkgs.stdenvNoCC.mkDerivation {
name = "${dirname}Example";
src = ./.;
buildPhase = "mkdir -p $out/patternfly-css";
installPhase = ''
cp examples/src/${dirname}/index.html $out/index.html
cp -r ${patternfly}/* $out/patternfly-css
cp ${js}/main.min.js $out
'';
};
packages = with builtins;
let examplesContents = readDir ./examples/src;
exampleDirectories = filter (name: examplesContents.${name} == "directory") (attrNames examplesContents);
in
listToAttrs (map (dirName: { name = dirName; value= makeExample dirName; }) exampleDirectories);
in
{
packages = packages;
devShell = pkgs.mkShell {
packages = with pkgs.elmPackages;
[ elm
elm-format
elm-live
elm-language-server
elm-doc-preview
];
};
}
);
}