Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate a .deb file #12453

Merged
merged 17 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,6 @@ jobs:
if: "!matrix.skip_tests"
run: ${{ env.CARGO }} test --release --locked --target ${{ matrix.target }} --workspace

- name: Set profile.release.strip = true
shell: bash
run: |
cat >> .cargo/config.toml <<EOF
[profile.release]
strip = true
EOF

- name: Build release binary
run: ${{ env.CARGO }} build --release --locked --target ${{ matrix.target }}

Expand Down Expand Up @@ -206,6 +198,17 @@ jobs:
mv "$APP-$VERSION-$ARCH.AppImage" \
"$APP-$VERSION-$ARCH.AppImage.zsync" dist

- name: Build Deb
shell: bash
if: matrix.build == 'x86_64-linux'
run: |
cargo install cargo-deb
mkdir -p target/release
cp target/${{ matrix.target }}/release/hx target/release/
cargo deb --no-build
mkdir -p dist
mv target/debian/*.deb dist/

- name: Build archive
shell: bash
run: |
Expand Down Expand Up @@ -241,6 +244,7 @@ jobs:
set -ex

source="$(pwd)"
tag=${GITHUB_REF_NAME//\//}
mkdir -p runtime/grammars/sources
tar xJf grammars/grammars.tar.xz -C runtime/grammars/sources
rm -rf grammars
Expand All @@ -254,7 +258,7 @@ jobs:
if [[ $platform =~ "windows" ]]; then
exe=".exe"
fi
pkgname=helix-$GITHUB_REF_NAME-$platform
pkgname=helix-$tag-$platform
mkdir -p $pkgname
cp $source/LICENSE $source/README.md $pkgname
mkdir $pkgname/contrib
Expand All @@ -265,6 +269,7 @@ jobs:

if [[ "$platform" = "x86_64-linux" ]]; then
mv bins-$platform/helix-*.AppImage* dist/
mv bins-$platform/*.deb dist/
fi

if [ "$exe" = "" ]; then
Expand All @@ -274,7 +279,7 @@ jobs:
fi
done

tar cJf dist/helix-$GITHUB_REF_NAME-source.tar.xz -C $source .
tar cJf dist/helix-$tag-source.tar.xz -C $source .
mv dist $source/

- name: Upload binaries to release
Expand Down
7 changes: 1 addition & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@ default-members = [
]

[profile.release]
lto = "thin"
# debug = true

[profile.opt]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to keep two profiles: --release is intended for quick builds of develop, and is what anyone running from develop is using. These users will be the first to encounter bugs so we deliberately keep the backtraces on so we get usable bug reports. I also often use --release several times per day/when testing because debug builds are much less performant.

Release builds should use --opt to build the smallest and most performant binary, at the expense of lengthy compile times.

Copy link
Contributor Author

@janos-r janos-r Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so from the current PR, I will rename release to opt in both the manifest and the release CI.
I will keep a release profile in the manifest as it was before, with just thin lto and without strip. I hope I understood you correctly there. I am glad that the release CI will use an optimized build from now on. Even though it will not be called "release".

we can support .deb releases until they're available on distributions, at which point we'll remove them

Why remove them? If Helix makes it to the Debian and Ubuntu repositories and you remove .deb from the releases, the users would have to stay on an old repository version without enjoying any of the updates.

Copy link
Member

@archseer archseer Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, that's actually a good catch, the release CI was definitely intended to use --profile opt, must have been oversight.

Why remove them?

I prefer to hand off packaging to distributions if we can because it's just another maintenance burden. e.g. if cargo deb becomes out of date or unmaintained. We've already had issues with cross compilation before because the cargo-cross images we were using were a couple years out of date with no upstream updates.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo-deb is a dependency, that's true. Non the less I hope you can keep shipping these DEBs as long as possible. It is the best way how to install software of this kind on Debian, Ubuntu, Mint, etc.

I made the profile name changes as you wished. I still think release should be final and the current release profile feels more like "testing", but whatever. I am happy that Helix now ships an even more performant binary 🚀️ and a well integrated Deb ❤️

I tested this latest build on Mint21 and it seams fine 👍️
If you are ok with it, merge away ^^

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like once Debian adds Helix, we might find ourselves back at square one for getting the latest version through Homebrew. Oh well! 🙄

Copy link
Contributor Author

@janos-r janos-r Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like once Debian adds Helix, we might find ourselves back at square one for getting the latest version through Homebrew. Oh well! 🙄

I never used homebrew on linux and I don't plan on starting!
I really hope archseer keeps this DEB around while cargo-deb still works.
There is also the PPA maintained by Maveonair. It's just that Helix set a rust-version (in manifest) that is newer than LTS Ubuntu and so it can't be built anymore on launchepad. That was actually the cause that pushed me to make this DEB build. If Helix keeps a relatively old rust-version in the manifest, we could still get the package through the PPA.

inherits = "release"
lto = "fat"
codegen-units = 1
# strip = "debuginfo" # TODO: or strip = true
strip = true
opt-level = 3

[profile.integration]
Expand Down
38 changes: 37 additions & 1 deletion book/src/building-from-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ to package the runtime into `/usr/lib/helix/runtime`. The rough steps a build
script could follow are:

1. `export HELIX_DEFAULT_RUNTIME=/usr/lib/helix/runtime`
1. `cargo build --profile opt --locked`
1. `cargo build --release --locked`
1. `cp -r runtime $BUILD_DIR/usr/lib/helix/`
1. `cp target/opt/hx $BUILD_DIR/usr/bin/hx`

Expand Down Expand Up @@ -162,3 +162,39 @@ file. For example, to use `kitty`:
sed -i "s|Exec=hx %F|Exec=kitty hx %F|g" ~/.local/share/applications/Helix.desktop
sed -i "s|Terminal=true|Terminal=false|g" ~/.local/share/applications/Helix.desktop
```

### Building the Deb package

The `.deb` provided on the release page (built in CI) may use a libc version greater
than what your Debian / Ubuntu / Mint uses. In this case you can build the `.deb`
from source and this higher dependency will not apply.
janos-r marked this conversation as resolved.
Show resolved Hide resolved

Install `cargo-deb`, the tool we use to build the `.deb`
janos-r marked this conversation as resolved.
Show resolved Hide resolved

```sh
cargo install cargo-deb
janos-r marked this conversation as resolved.
Show resolved Hide resolved
```

After you clone and enter the repository (viz. above), the command bellow will first
build the release binary, and later package it into the `.deb` file, in one command.
janos-r marked this conversation as resolved.
Show resolved Hide resolved

```sh
cargo deb -- --locked
```

> 💡 This locks you into the `--release` profile. But you can also build helix in any way you like.
> As long as you leave a `target/release/hx` file, it will get packaged with `cargo deb --no-build`

> 💡 Don't worry about the repeated
> ```
> warning: Failed to find dependency specification
> ```
> warnings. Cargo deb just reports which packaged files it didn't derive dependencies for. But
> so far the dependency deriving seams very good, even if some of the grammar files are skipped.

You can find the resulted `.deb` in `target/debian/`. It should contain everything it needs, including the

- completions for bash, fish, zsh
- .desktop file
- icon (though desktop environments might use their own since the name of the package is correctly `helix`)
- launcher to the binary with the runtime
janos-r marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 8 additions & 1 deletion book/src/package-managers.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@

The following third party repositories are available:

### Ubuntu
### Ubuntu/Debian (Deb)

Install the `Deb` package from the release page.
janos-r marked this conversation as resolved.
Show resolved Hide resolved
janos-r marked this conversation as resolved.
Show resolved Hide resolved

If you run a system older than Ubuntu 22.04 / Mint 21 / Debian 12, you can build the `.deb` package locally
janos-r marked this conversation as resolved.
Show resolved Hide resolved
[from source](https://docs.helix-editor.com/building-from-source.html#building-the-deb-package).
janos-r marked this conversation as resolved.
Show resolved Hide resolved

### Ubuntu (PPA)

Add the `PPA` for Helix:

Expand Down
3 changes: 3 additions & 0 deletions contrib/hx_launcher.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh

HELIX_RUNTIME=/usr/lib/helix/runtime exec /usr/lib/helix/hx "$@"
18 changes: 18 additions & 0 deletions helix-term/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,24 @@ categories.workspace = true
repository.workspace = true
homepage.workspace = true

[package.metadata.deb]
# generate a .deb in target/debian/ with the command: cargo deb --no-build
name = "helix"
assets = [
{ source = "target/release/hx", dest = "/usr/lib/helix/", mode = "755" },
{ source = "../contrib/hx_launcher.sh", dest = "/usr/bin/hx", mode = "755" },
{ source = "../runtime/*", dest = "/usr/lib/helix/runtime/", mode = "644" },
{ source = "../runtime/grammars/*", dest = "/usr/lib/helix/runtime/grammars/", mode = "644" }, # to avoid sources/
{ source = "../runtime/queries/**/*", dest = "/usr/lib/helix/runtime/queries/", mode = "644" },
{ source = "../runtime/themes/**/*", dest = "/usr/lib/helix/runtime/themes/", mode = "644" },
{ source = "../README.md", dest = "/usr/share/doc/helix/", mode = "644" },
{ source = "../contrib/completion/hx.bash", dest = "/usr/share/bash-completion/completions/hx", mode = "644" },
{ source = "../contrib/completion/hx.fish", dest = "/usr/share/fish/vendor_completions.d/hx.fish", mode = "644" },
{ source = "../contrib/completion/hx.zsh", dest = "/usr/share/zsh/vendor-completions/_hx", mode = "644" },
{ source = "../contrib/Helix.desktop", dest = "/usr/share/applications/Helix.desktop", mode = "644" },
{ source = "../contrib/helix.png", dest = "/usr/share/icons/hicolor/256x256/apps/helix.png", mode = "644" },
]

[features]
default = ["git"]
unicode-lines = ["helix-core/unicode-lines", "helix-view/unicode-lines"]
Expand Down
Loading