-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdefault.nix
More file actions
117 lines (104 loc) · 3.02 KB
/
default.nix
File metadata and controls
117 lines (104 loc) · 3.02 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
{
config ? { },
nixpkgs ? import <nixpkgs> config,
}:
with nixpkgs;
let
albumTypes = import ./album-types-gen.nix { inherit nixpkgs; };
versionsDat = ./nix/versions.dat;
elmStuffElmReview = ./nix/elm-stuff/generated-code/jfmengels/elm-review;
nodejs = nodejs_24;
mkDerivation =
{
srcs ? ./nix/elm-srcs.nix,
src,
name,
srcdir ? "./src",
targets ? [ ],
}:
stdenv.mkDerivation rec {
inherit name src;
npmDeps = importNpmLock.buildNodeModules {
npmRoot = ./.;
inherit nodejs;
};
buildInputs = [
elmPackages.elm
importNpmLock.hooks.linkNodeModulesHook
nodejs
];
postUnpack = (
elmPackages.fetchElmDeps {
elmVersion = "0.19.1";
elmPackages = import ./nix/elm-srcs.nix;
registryDat = ./nix/registry.dat;
}
);
buildPhase =
let
elmfile = module: "${srcdir}/${builtins.replaceStrings [ "." ] [ "/" ] module}.elm";
in
''
mkdir -p $out/share/doc
cp -iv ${albumTypes}/Album.elm src;
${lib.concatStrings (
map (module: ''
elm make ${elmfile module} --output $out/${module}.js --docs $out/share/doc/${module}.json --optimize
'') targets
)}
'';
installPhase = ''
mv -iv $out/src/Main.js $out/elbum.js;
cp -iv index.html $out;
cp -iv .htaccess $out;
'';
doCheck = true;
checkPhase = ''
# pre-populate the generated elm-review application.
# use 'elm-review prepare-offline' to generate new versions
# of these caches
mkdir -p elm-stuff/generated-code/jfmengels/;
cp -R ${elmStuffElmReview} elm-stuff/generated-code/jfmengels/elm-review/;
chmod -R ugo+w elm-stuff/generated-code/;
echo; echo running elm-review ...
./node_modules/.bin/elm-review --offline
echo; echo running elm-test ...
./node_modules/.bin/elm-test --seed 20221126
'';
};
in
mkDerivation {
name = "jerith666-elbum-0.1.0";
srcs = ./elm-srcs.nix;
src = lib.cleanSourceWith {
src = ./.;
filter =
path: type:
(
type == "regular"
&& (
pkgs.lib.hasSuffix ".elm" path
|| pkgs.lib.hasSuffix "elm.json" path
|| pkgs.lib.hasSuffix "index.html" path
|| pkgs.lib.hasSuffix "package.json" path
|| pkgs.lib.hasSuffix "package-lock.json" path
|| pkgs.lib.hasSuffix ".htaccess" path
)
)
|| (
type == "directory"
&& (
pkgs.lib.hasSuffix "vendor" path
|| pkgs.lib.hasSuffix "elm-route-url" path
|| pkgs.lib.hasSuffix "touch-events" path
|| pkgs.lib.hasSuffix "src" path
|| pkgs.lib.hasSuffix "tests" path
|| pkgs.lib.hasSuffix "review" path
|| pkgs.lib.hasSuffix "Sandbox" path
|| pkgs.lib.hasSuffix "Utils" path
)
);
};
srcdir = ".";
targets = [ "src/Main" ];
}