/
flake.nix
130 lines (109 loc) · 4.19 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/release-23.11";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let pkgs = nixpkgs.legacyPackages.${system};
in rec {
# `nix fmt`
formatter = pkgs.nixpkgs-fmt;
# `nix build`
packages.elo-anything = pkgs.stdenv.mkDerivation {
name = "elo-anything";
src = builtins.filterSource (path: type: builtins.match ".+(flake.nix|flake.lock|.github)$" path == null) ./.;
buildInputs = [ pkgs.elmPackages.elm pkgs.elmPackages.elm-test ];
buildPhase = pkgs.elmPackages.fetchElmDeps {
elmPackages = import ./nix/elm-srcs.nix;
elmVersion = "0.19.1";
registryDat = ./nix/registry.dat;
};
installPhase = ''
make dist
mkdir -p $out/share/
mv dist $out/share/elo-anything
'';
};
defaultPackage = packages.elo-anything;
overlay = final: prev: { elo-anything = packages.elo-anything; };
packages.nginx-conf = pkgs.writeTextFile {
name = "nginx.conf";
destination = "/etc/nginx/nginx.conf";
text = ''
user nobody nobody;
daemon off;
error_log /dev/stdout info;
pid /dev/null;
events {}
http {
include ${pkgs.nginx}/conf/mime.types;
types_hash_max_size 4096;
# optimization
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
gzip on;
gzip_static on;
gzip_vary on;
gzip_comp_level 5;
gzip_min_length 256;
gzip_types application/atom+xml application/geo+json application/javascript application/json application/ld+json application/manifest+json application/rdf+xml application/vnd.ms-fontobject application/wasm application/x-rss+xml application/x-web-app-manifest+json application/xhtml+xml application/xliff+xml application/xml font/collection font/otf font/ttf image/bmp image/svg+xml image/vnd.microsoft.icon text/cache-manifest text/calendar text/css text/csv text/javascript text/markdown text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/xml;
access_log /dev/stdout;
server {
listen 0.0.0.0:80 default_server;
listen [::0]:80;
http2 on;
root ${packages.elo-anything}/share/elo-anything;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
}
}
'';
};
# for debugging, if needed
# packages.container = pkgs.dockerTools.buildLayeredImage {
packages.container = pkgs.dockerTools.streamLayeredImage {
name = "elo-anything";
# make /var/log/nginx so Nginx doesn't fail trying to open it (which
# it does no matter what you say in log settings, apparently.
extraCommands = ''
mkdir -p tmp/nginx_client_body
mkdir -p var/log/nginx
'';
contents = [
pkgs.fakeNss
pkgs.nginxMainline
packages.nginx-conf
# for debugging, if needed
# pkgs.dockerTools.binSh
# pkgs.coreutils
];
config = {
"ExposedPorts"."80/tcp" = { };
Entrypoint = [ "nginx" ];
Cmd = [ "-c" "/etc/nginx/nginx.conf" ];
# for debugging, if needed
# Entrypoint = "/bin/sh";
};
};
# `nix shell`
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
git
# Elm
elmPackages.elm
elmPackages.elm-format
elmPackages.elm-json
elmPackages.elm-test
elm2nix
# Build Stuff
gnumake
modd
devd
];
};
});
}