forked from Makesesama/openrouter.ex
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
122 lines (114 loc) · 3.33 KB
/
flake.nix
File metadata and controls
122 lines (114 loc) · 3.33 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
118
119
120
121
122
{
description = "An Elixir development shell.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
treefmt-nix.url = "github:numtide/treefmt-nix";
pre-commit-hooks.url = "github:cachix/git-hooks.nix";
};
outputs =
{
self,
nixpkgs,
treefmt-nix,
pre-commit-hooks,
}@inputs:
let
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
overlays = [
(
final: prev:
let
beamPkgs = final.beam.packagesWith final.beam.interpreters.erlang_27;
in
{
beamPackages = beamPkgs;
elixir = beamPkgs.elixir_1_18;
hex = beamPkgs.hex;
}
)
];
forAllSystems =
function:
nixpkgs.lib.genAttrs supportedSystems (
system:
function {
pkgs = import nixpkgs { inherit overlays system; };
}
);
treefmtEval = forAllSystems ({ pkgs }: treefmt-nix.lib.evalModule pkgs ./nix/treefmt.nix);
in
{
# packages = forAllSystems (
# { pkgs }:
# {
# default = pkgs.callPackage ./nix/package.nix { };
# }
# );
checks = forAllSystems (
{ pkgs }:
{
pre-commit-check = inputs.pre-commit-hooks.lib.${pkgs.system}.run {
src = ./.;
hooks = {
credo.enable = true;
credo.package = pkgs.elixir;
dialyzer.enable = true;
# mix-test.enable = true;
# mix-test.package = pkgs.elixir;
treefmt = {
enable = true;
package = treefmtEval.${pkgs.system}.config.build.wrapper;
};
};
};
}
);
devShells = forAllSystems (
{ pkgs }:
{
default =
let
opts =
with pkgs;
lib.optional stdenv.isLinux inotify-tools
++ lib.optionals stdenv.isDarwin (
with darwin.apple_sdk.frameworks;
[
CoreServices
Foundation
]
);
pre-commit-shell = self.checks.${pkgs.system}.pre-commit-check.shellHook;
in
pkgs.mkShell {
buildInputs = self.checks.${pkgs.system}.pre-commit-check.enabledPackages;
# inputsFrom = [ self.packages.${pkgs.system}.default ];
packages = [
pkgs.elixir
pkgs.beamPackages.elixir-ls
]
++ opts;
shellHook = ''
${pre-commit-shell}
# Set up `mix` to save dependencies to the local directory
mkdir -p .nix-mix
mkdir -p .nix-hex
export MIX_HOME=$PWD/.nix-mix
export HEX_HOME=$PWD/.nix-hex
export PATH=$MIX_HOME/bin:$PATH
export PATH=$HEX_HOME/bin:$PATH
# BEAM-specific
export LANG=en_US.UTF-8
export ERL_AFLAGS="-kernel shell_history enabled"
'';
};
}
);
formatter = forAllSystems ({ pkgs }: treefmtEval.${pkgs.system}.config.build.wrapper);
};
}