forked from elixir-tools/next-ls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
118 lines (105 loc) · 3.38 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
{
inputs = {nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";};
nixConfig = {
extra-substituters = [ "https://elixir-tools.cachix.org" ];
extra-trusted-public-keys = [ "elixir-tools.cachix.org-1:GfK9E139Ysi+YWeS1oNN9OaTfQjqpLwlBaz+/73tBjU=" ];
};
outputs = {
self,
nixpkgs,
}: let
inherit (nixpkgs) lib;
version = "0.15.0"; # x-release-please-version
# Helper to provide system-specific attributes
forAllSystems = f:
nixpkgs.lib.genAttrs (builtins.attrNames burritoExe) (system: let
pkgs = nixpkgs.legacyPackages.${system};
beamPackages = pkgs.beam.packages.erlang_26;
elixir = beamPackages.elixir_1_15;
in
f {inherit system pkgs beamPackages elixir;});
burritoExe = {
"aarch64-darwin" = "darwin_arm64";
"x86_64-darwin" = "darwin_amd64";
"x86_64-linux" = "linux_amd64";
"aarch64-linux" = "linux_arm64";
};
in {
packages = forAllSystems ({
pkgs,
system,
beamPackages,
elixir,
}: let
aliased_7zz = pkgs.symlinkJoin {
name = "7zz-aliased";
paths = [pkgs._7zz];
postBuild = ''
ln -s ${pkgs._7zz}/bin/7zz $out/bin/7z
'';
};
in {
default = lib.makeOverridable ({
localBuild,
beamPackages,
elixir,
}:
beamPackages.mixRelease {
pname = "next-ls";
src = self.outPath;
inherit version elixir;
inherit (beamPackages) erlang;
nativeBuildInputs = [pkgs.xz pkgs.zig_0_11 aliased_7zz];
mixFodDeps = beamPackages.fetchMixDeps {
src = self.outPath;
inherit version elixir;
pname = "next-ls-deps";
hash = "sha256-LV1DYmWi0Mcz1S5k77/jexXYqay7OpysCwOtUcafqGE=";
};
BURRITO_ERTS_PATH = "${beamPackages.erlang}/lib/erlang";
BURRITO_TARGET = lib.optional localBuild burritoExe.${system};
preBuild = ''
export HOME="$tmpDir"
'';
postInstall = ''
chmod +x ./burrito_out/*
cp -r ./burrito_out "$out"
${lib.optionalString pkgs.stdenv.isLinux ''
patchelf --set-interpreter ${pkgs.stdenv.cc.libc}/lib/${
if system == "x86_64-linux"
then "ld-linux-x86-64.so.2"
else if system == "aarch64-linux"
then "ld-linux-aarch64.so.1"
else throw "unsupported Linux system"
} \
"$out/burrito_out/next_ls_${burritoExe.${system}}"
''}
rm -rf "$out/bin"
mv "$out/burrito_out" "$out/bin"
mv "$out/bin/next_ls_${burritoExe.${system}}" "$out/bin/nextls"
'';
meta = with lib; {
license = licenses.mit;
homepage = "https://www.elixir-tools.dev/next-ls/";
description = "The language server for Elixir that just works";
mainProgram = "nextls";
};
}) {
inherit beamPackages elixir;
localBuild = true;
};
ci = self.packages.${system}.default.override {localBuild = false;};
});
devShells = forAllSystems ({
pkgs,
beamPackages,
elixir,
...
}: {
default = pkgs.mkShell {
# The Nix packages provided in the environment
packages = [beamPackages.erlang elixir];
};
});
};
}