forked from elixir-tools/next-ls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
124 lines (110 loc) · 3.5 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
};
outputs = { self, nixpkgs }:
let
# Systems supported
allSystems = [
"x86_64-linux" # 64-bit Intel/AMD Linux
"aarch64-linux" # 64-bit ARM Linux
"x86_64-darwin" # 64-bit Intel macOS
"aarch64-darwin" # 64-bit ARM macOS
];
pname = "next-ls";
version = "0.13.4"; # x-release-please-version
src = ./.;
# Helper to provide system-specific attributes
forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system:
let
pkgs = import nixpkgs { inherit system; };
in
f {
inherit pkgs;
# src = pkgs.fetchFromGitHub {
# owner = "elixir-tools";
# repo = "next-ls";
# rev = "v${version}";
# sha256 = "sha256-jpOInsr7Le0fjJZToNNrlNyXNF1MtF1kQONXdC2VsV0=";
# };
system = system;
});
burritoExe = system:
if system == "aarch64-darwin" then
"darwin_arm64"
else if system == "x86_64-darwin" then
"darwin_amd64"
else if system == "x86_64-linux" then
"linux_amd64"
else if system == "aarch64-linux" then
"linux_arm64"
else
"";
in
{
packages = forAllSystems ({ pkgs, system }:
let
beamPackages = pkgs.beam.packages.erlang_26;
build = type: beamPackages.mixRelease {
inherit pname version src;
erlang = beamPackages.erlang;
elixir = beamPackages.elixir_1_15;
nativeBuildInputs = [ pkgs.xz pkgs.zig_0_11 pkgs._7zz ];
mixFodDeps = beamPackages.fetchMixDeps {
inherit src version;
pname = "${pname}-deps";
hash = "sha256-ekB71eDfcFqC3JojFMnlGRQ/XiPwbUqFVor7ndpUd90=";
};
preConfigure = ''
bindir="$(pwd)/bin"
mkdir -p "$bindir"
echo '#!/usr/bin/env bash
7zz "$@"' > "$bindir/7z"
chmod +x "$bindir/7z"
export HOME="$(pwd)"
export PATH="$bindir:$PATH"
'';
preBuild = ''
export BURRITO_ERTS_PATH=${beamPackages.erlang}/lib/erlang
'';
preInstall =
if type == "local" then ''
export BURRITO_TARGET="${burritoExe(system)}"
''
else "";
postInstall =
if system == "x86_64-linux" then ''
chmod +x ./burrito_out/*
cp -r ./burrito_out "$out"
patchelf --set-interpreter ${pkgs.glibc}/lib/ld-linux-x86-64.so.2 "$out/burrito_out/next_ls_linux_amd64"
'' else ''
chmod +x ./burrito_out/*
cp -r ./burrito_out "$out"
'';
};
in
{
default = build ("local");
ci = build ("ci");
});
apps = forAllSystems ({ pkgs, system, ... }: {
default = {
type = "app";
program = "${self.packages.${system}.default}/burrito_out/next_ls_${burritoExe(system)}";
};
});
devShells = forAllSystems ({ pkgs, ... }:
let
beamPackages = pkgs.beam.packages.erlang_26;
in
{
default = pkgs.mkShell {
# The Nix packages provided in the environment
packages = [
beamPackages.erlang
beamPackages.elixir_1_15
];
};
});
};
}