-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
77 lines (69 loc) · 2.05 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
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs = {
self,
nixpkgs,
}: let
system = "aarch64-darwin";
pkgs = import nixpkgs {
inherit system;
};
in {
devShells."${system}".default = with pkgs;
mkShell {
name = "exlings";
packages =
[zig xz _7zz elixir_1_16]
++ lib.optional stdenv.isDarwin [
darwin.apple_sdk.frameworks.CoreServices
darwin.apple_sdk.frameworks.CoreFoundation
];
};
packages."${system}" = rec {
default = exlings;
docker = let
inherit (builtins) filterSource elem;
file_names = ["mix.exs" "mix.lock" "lib"];
files = filterSource (p: _: elem (baseNameOf p) file_names) ./.;
paths = with pkgs; [stdenv git xz gnupg zig elixir_1_14 files];
in
with pkgs;
dockerTools.buildImage {
name = "exlings";
tag = "latest";
copyToRoot = buildEnv {
inherit paths;
name = "exlings-root";
};
config = {
Entrypoint = ["sh"];
Env = ["MIX_ENV=prod"];
};
runAsRoot = ''
mix do local.hex --force, local.rebar --force
mix do deps.get --only $MIX_ENV, deps.compile
mix do compile, release
'';
};
exlings = let
inherit (pkgs) beam;
inherit (beam.interpreters) erlangR26;
beamPackages = beam.packagesWith erlangR26;
pname = "exlings";
version = "0.1.0";
src = ./.;
in
beamPackages.mixRelease {
inherit src pname version;
elixir = pkgs.elixir_1_15;
nativeBuildInputs = with pkgs; [zig xz _7zz];
postBuild = "mix deps.loadpaths --no-deps-check";
mixFodDeps = beamPackages.fetchMixDeps {
inherit src version;
pname = "mix-deps-${pname}";
sha256 = "hefyKmjYmf8s1JmzS2YM/WlXzC+FkfCEGRjh1a43OGo=";
};
};
};
};
}