-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
103 lines (98 loc) · 3.51 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
{
description = "Lan party seating application for Otakuthon";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
devenv.url = "github:cachix/devenv";
nix2container.url = "github:nlewo/nix2container";
};
outputs = inputs@{ flake-parts, devenv, nix2container, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.devenv.flakeModule
];
perSystem = { config, self', inputs', pkgs, system, ... }: rec {
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
(final: prev: {
nix2container = nix2container.packages.${system}.nix2container;
})
];
};
# Per-system attributes can be defined here. The self' and inputs'
# module parameters provide easy access to attributes of the same
# system.
packages.default = pkgs.callPackage ./default.nix { };
packages.lanparty-seating = pkgs.callPackage ./default.nix { };
packages.container = let
# temp path to store tzdata information
tmp = pkgs.runCommand "tmp" {} ''
mkdir -p $out/tmp/tzdata
'';
utils = pkgs.buildEnv {
name = "root";
paths = with pkgs; [ bashInteractive coreutils gnused gnugrep packages.lanparty-seating ];
pathsToLink = [ "/bin" ];
};
in pkgs.nix2container.buildImage {
name = "lanparty-seating";
tag = packages.lanparty-seating.version;
copyToRoot = [ tmp utils ];
perms = [{
path = tmp;
regex = ".*";
mode = "0777";
}];
config = {
entrypoint = ["${packages.lanparty-seating}/bin/server"];
env = [
"RELEASE_COOKIE=changeme213482308949234"
"PORT=4000"
"STORAGE_DIR=/tmp/tzdata"
"TZ=America/Toronto"
"SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
"LOCALE_ARCHIVE=${pkgs.glibcLocales}/lib/locale/locale-archive"
"LANG=en_US.UTF-8"
"LC_ALL=en_US.UTF-8"
];
user = "1000";
};
};
devenv.shells.default = {
languages.elixir.enable = true;
languages.elixir.package = pkgs.beam.packages.erlangR26.elixir_1_16;
languages.erlang.enable = true;
languages.erlang.package = pkgs.beam.interpreters.erlangR26;
languages.javascript.enable = true;
languages.javascript.yarn.enable = true;
services.postgres = {
enable = true;
initialDatabases = [ { name = "lanpartyseating_dev"; } ];
initialScript = ''
CREATE USER postgres WITH SUPERUSER PASSWORD 'password';
'';
listen_addresses = "::1,127.0.0.1";
};
env.MIX_REBAR3 = "${pkgs.rebar3}/bin/rebar3";
env.MIX_ESBUILD_PATH = "${pkgs.esbuild}/bin/esbuild";
enterShell = ''
alias mdg="mix deps.get"
alias mps="mix phx.server"
alias test="mix test"
alias c="iex -S mix"
'';
};
};
flake = {
# Put your original flake attributes here.
};
systems = [
# systems for which you want to build the `perSystem` attributes
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];
};
}