-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
72 lines (66 loc) · 2.35 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs, ... } @ inputs:
let
systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
forAllSystems = f: builtins.listToAttrs (map (name: { inherit name; value = f name; }) systems);
getErlangLibs = erlangPkg:
let
erlangPath = "${erlangPkg}/lib/erlang/lib/";
dirs = builtins.attrNames (builtins.readDir erlangPath);
interfaceVersion = builtins.head (builtins.filter (s: builtins.substring 0 13 s == "erl_interface") dirs);
interfacePath = erlangPath + interfaceVersion;
in
{
path = erlangPath;
dirs = dirs;
interface = { version = interfaceVersion; path = interfacePath; };
};
mkEnvVars = pkgs: erlangLatest: erlangLibs: {
LOCALE_ARCHIVE = pkgs.lib.optionalString pkgs.stdenv.isLinux "${pkgs.glibcLocales}/lib/locale/locale-archive";
LANG = "en_US.UTF-8";
# https://www.erlang.org/doc/man/kernel_app.html
ERL_AFLAGS = "-kernel shell_history enabled";
ERL_INCLUDE_PATH = "${erlangLatest}/lib/erlang/usr/include";
ERLANG_INTERFACE_PATH = "${erlangLibs.interface.path}";
ERLANG_PATH = "${erlangLatest}";
};
in
{
apps = forAllSystems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
erlangLatest = pkgs.erlang_26;
erlangLibs = getErlangLibs erlangLatest;
in {});
devShells = forAllSystems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
erlangLatest = pkgs.erlang_26;
erlangLibs = getErlangLibs erlangLatest;
in
{
# `nix develop .#ci`
# reduce the number of packages to the bare minimum needed for CI
ci = pkgs.mkShell {
env = mkEnvVars pkgs erlangLatest erlangLibs;
buildInputs = with pkgs; [ erlangLatest just rebar3 ];
};
# `nix develop`
default = pkgs.mkShell {
packages = with pkgs; [
erlang-ls
erlfmt
just
rebar3
];
shellHook = ''
echo "Starting Erlang environment..."
rebar3 get-deps
'';
};
});
};
}