Skip to content

Commit 8162d88

Browse files
authored
fix(nix): use normal release for flake (#484)
1 parent eca10e2 commit 8162d88

File tree

6 files changed

+40
-87
lines changed

6 files changed

+40
-87
lines changed

.github/workflows/release.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ jobs:
5353
if: ${{ needs.release.outputs.release_created }}
5454
env:
5555
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
NEXTLS_RELEASE_MODE: "burrito"
5657
steps:
5758
- uses: actions/checkout@v4
5859
- uses: DeterminateSystems/nix-installer-action@main

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,28 @@ mix test
5151

5252
## Production release
5353

54+
### Burrito
55+
56+
Burrito is the classic way of building Next LS, it produces a single executable that fully wraps Elixir, OTP, and your application.
57+
5458
Executables are output to `./burrito_out`.
5559

5660
```bash
5761
# produces executables for all the targets specified in the `mix.exs` file
58-
MIX_ENV=prod mix release
62+
NEXTLS_RELEASE_MODE="burrito" MIX_ENV=prod mix release
5963

6064
# produce an executable for a single target
6165
BURRITO_TARGET=linux_amd64 MIX_ENV=prod mix release
6266
```
6367

68+
### Traditional
69+
70+
You can also build Next LS as a traditional Mix release.
71+
72+
```bash
73+
MIX_ENV=prod mix release plain
74+
```
75+
6476
## Contributing
6577

6678
This project follows [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) and will "Squash and Merge" pull requests.

config/runtime.exs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import Config
22

3+
case System.get_env("NEXTLS_RELEASE_MODE", "plain") do
4+
"burrito" ->
5+
config :next_ls, arg_parser: {Burrito.Util.Args, :get_arguments, []}
6+
7+
"plain" ->
8+
config :next_ls, arg_parser: {System, :argv, []}
9+
end
10+
311
if System.get_env("NEXTLS_OTEL") == "1" do
412
config :next_ls,
513
otel: true

flake.nix

Lines changed: 15 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,9 @@
1818

1919
# Helper to provide system-specific attributes
2020
forAllSystems = f:
21-
lib.genAttrs (builtins.attrNames burritoExe) (system: let
21+
lib.genAttrs systems (system: let
2222
pkgs = nixpkgs.legacyPackages.${system};
2323
beamPackages = pkgs.beam_minimal.packages.erlang_26;
24-
beam = fetchTarball beams.${system};
25-
rawmusl = musls.${system};
26-
musl = lib.optionals nixpkgs.legacyPackages.${system}.stdenv.isLinux (builtins.fetchurl (nixpkgs.lib.attrsets.getAttrs ["url" "sha256"] musls.${system}));
2724
otp = (pkgs.beam.packagesWith beamPackages.erlang).extend (final: prev: {
2825
elixir_1_17 = prev.elixir_1_16.override {
2926
rev = "e3b6a91b173f7e836401a6a75c3906c26bd7fd39";
@@ -39,64 +36,21 @@
3936
});
4037
elixir = otp.elixir;
4138
in
42-
f {inherit system pkgs beamPackages elixir beam rawmusl musl;});
43-
44-
burritoExe = {
45-
"aarch64-darwin" = "darwin_arm64";
46-
"x86_64-darwin" = "darwin_amd64";
47-
"x86_64-linux" = "linux_amd64";
48-
"aarch64-linux" = "linux_arm64";
49-
};
50-
51-
beams = {
52-
"aarch64-darwin" = {
53-
url = "https://beam-machine-universal.b-cdn.net/OTP-26.2.1/macos/universal/otp_26.2.1_macos_universal_ssl_3.1.4.tar.gz?please-respect-my-bandwidth-costs=thank-you";
54-
sha256 = "0sdadkl80pixj9q3l71zxamh9zgmnmawsc4hpllgvx9r9hl30f40";
55-
};
56-
"x86_64-darwin" = {
57-
url = "https://beam-machine-universal.b-cdn.net/OTP-26.2.1/macos/universal/otp_26.2.1_macos_universal_ssl_3.1.4.tar.gz?please-respect-my-bandwidth-costs=thank-you";
58-
sha256 = "0sdadkl80pixj9q3l71zxamh9zgmnmawsc4hpllgvx9r9hl30f40";
59-
};
60-
"x86_64-linux" = {
61-
url = "https://beam-machine-universal.b-cdn.net/OTP-26.2.1/linux/x86_64/any/otp_26.2.1_linux_any_x86_64_ssl_3.1.4.tar.gz?please-respect-my-bandwidth-costs=thank-you";
62-
sha256 = "11z50xrmngsn0bzg7vn7w5h76iwmhscx01vij9ir2ivybjc8niky";
63-
};
64-
"aarch64-linux" = {
65-
url = "https://beam-machine-universal.b-cdn.net/OTP-26.2.1/linux/aarch64/any/otp_26.2.1_linux_any_aarch64_ssl_3.1.4.tar.gz?please-respect-my-bandwidth-costs=thank-you";
66-
sha256 = "0ich3xkhbb3sb82m7sncg0pr1d3z92klpwrlh8csr8i1qjhg40h5";
67-
};
68-
};
69-
70-
musls = {
71-
"x86_64-linux" = {
72-
url = "https://beam-machine-universal.b-cdn.net/musl/libc-musl-17613ec13d9aa9e5e907e6750785c5bbed3ad49472ec12281f592e2f0f2d3dbd.so?please-respect-my-bandwidth-costs=thank-you";
73-
sha256 = "1g9x5l7jybjr3wl15v3jjka3mvdvqn2hfxg60zlybacs7p0kwq8p";
74-
file = "libc-musl-17613ec13d9aa9e5e907e6750785c5bbed3ad49472ec12281f592e2f0f2d3dbd.so";
75-
};
76-
"aarch64-linux" = {
77-
url = "https://beam-machine-universal.b-cdn.net/musl/libc-musl-939d11dcd3b174a8dee05047f2ae794c5c43af54720c352fa946cd8b0114627a.so?please-respect-my-bandwidth-costs=thank-you";
78-
sha256 = "0yk22h0qpka6m4pka33jajpl6p2cg6pg4ishw3gahx5isgf137ck";
79-
file = "libc-musl-939d11dcd3b174a8dee05047f2ae794c5c43af54720c352fa946cd8b0114627a.so";
80-
};
81-
};
39+
f {inherit system pkgs beamPackages elixir;});
40+
41+
systems = [
42+
"aarch64-darwin"
43+
"x86_64-darwin"
44+
"x86_64-linux"
45+
"aarch64-linux"
46+
];
8247
in {
8348
packages = forAllSystems ({
8449
pkgs,
8550
system,
8651
beamPackages,
87-
beam,
88-
musl,
89-
rawmusl,
9052
elixir,
91-
}: let
92-
aliased_7zz = pkgs.symlinkJoin {
93-
name = "7zz-aliased";
94-
paths = [pkgs._7zz];
95-
postBuild = ''
96-
ln -s ${pkgs._7zz}/bin/7zz $out/bin/7z
97-
'';
98-
};
99-
in {
53+
}: {
10054
default = lib.makeOverridable ({
10155
localBuild,
10256
beamPackages,
@@ -106,11 +60,10 @@
10660
pname = "next-ls";
10761
src = self.outPath;
10862
mixEnv = "prod";
63+
removeCookie = false;
10964
inherit version elixir;
11065
inherit (beamPackages) erlang;
11166

112-
nativeBuildInputs = [pkgs.xz pkgs.zig_0_11 aliased_7zz beam];
113-
11467
mixFodDeps = beamPackages.fetchMixDeps {
11568
src = self.outPath;
11669
inherit version elixir;
@@ -119,30 +72,10 @@
11972
mixEnv = "prod";
12073
};
12174

122-
BURRITO_ERTS_PATH = "/tmp/beam/";
123-
BURRITO_TARGET = lib.optional localBuild burritoExe.${system};
124-
125-
preBuild =
126-
''
127-
export HOME="$TEMPDIR"
128-
mkdir -p /tmp/beam/otp
129-
cp -r --no-preserve=ownership,timestamps ${beam}/. /tmp/beam/otp
130-
''
131-
+ (
132-
if (pkgs.stdenv.isLinux)
133-
then ''
134-
cp --no-preserve=ownership,timestamps ${musl} /tmp/${rawmusl.file}
135-
chmod +x /tmp/${rawmusl.file}
136-
''
137-
else ""
138-
);
139-
140-
postInstall = ''
141-
chmod +x ./burrito_out/*
142-
cp -r ./burrito_out "$out"
143-
rm -rf "$out/bin"
144-
mv "$out/burrito_out" "$out/bin"
145-
mv "$out/bin/next_ls_${burritoExe.${system}}" "$out/bin/nextls"
75+
installPhase = ''
76+
mix release --no-deps-check --path $out plain
77+
echo "$out/bin/plain eval \"System.no_halt(true); Application.ensure_all_started(:next_ls)\" \"\$@\"" > "$out/bin/nextls"
78+
chmod +x "$out/bin/nextls"
14679
'';
14780

14881
meta = with lib; {
@@ -155,8 +88,6 @@
15588
inherit beamPackages elixir;
15689
localBuild = true;
15790
};
158-
159-
ci = self.packages.${system}.default.override {localBuild = false;};
16091
});
16192

16293
devShells = forAllSystems ({

lib/next_ls/lsp_supervisor.ex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ defmodule NextLS.LSPSupervisor do
1414
if @env == :test do
1515
:ignore
1616
else
17-
{m, f, a} =
18-
if @env == :prod, do: {Burrito.Util.Args, :get_arguments, []}, else: {System, :argv, []}
17+
{m, f, a} = Application.get_env(:next_ls, :arg_parser)
1918

2019
argv = apply(m, f, a)
2120

mix.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ defmodule NextLS.MixProject do
1313
elixirc_paths: elixirc_paths(Mix.env()),
1414
start_permanent: Mix.env() == :prod,
1515
releases: releases(),
16+
default_release: :next_ls,
1617
package: package(),
1718
deps: deps(),
1819
docs: [
@@ -38,6 +39,7 @@ defmodule NextLS.MixProject do
3839

3940
def releases do
4041
[
42+
plain: [],
4143
next_ls: [
4244
steps: [:assemble, &Burrito.wrap/1],
4345
burrito: [

0 commit comments

Comments
 (0)