Bug 266564

Summary: [NEW PORT] x11/eww: ElKowars wacky widgets
Product: Ports & Packages Reporter: Jesús Daniel Colmenares Oviedo <DtxdF>
Component: Individual Port(s)Assignee: Jan Beich <jbeich>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   
URL: https://elkowar.github.io/eww
Attachments:
Description Flags
eww-0.4.0
none
eww-0.4.0
none
eww-0.4.0
none
eww-0.4.0 none

Description Jesús Daniel Colmenares Oviedo 2022-09-23 12:45:26 UTC
Created attachment 236764 [details]
eww-0.4.0

Description:

Elkowars Wacky Widgets is a standalone widget system made in Rust
that allows you to implement your own, custom widgets in any window
manager.

QA:

* portlint: OK (looks fine.)
* testport: OK (poudriere: 13-1, amd64, WAYLAND X11 tested)
Comment 1 Jesús Daniel Colmenares Oviedo 2022-09-23 20:08:28 UTC
Created attachment 236775 [details]
eww-0.4.0

Description:

* move CARGO_CRATES from Makefile to Makefile.crates

QA:

* portlint: OK (looks fine.)
* testport: OK (poudriere: 13-1, amd64, WAYLAND X11 tested)
Comment 2 Jan Beich freebsd_committer freebsd_triage 2022-09-24 15:55:17 UTC
Comment on attachment 236775 [details]
eww-0.4.0

> +USES=	cargo gnome

Whitespace: add one more <tab> after USES=. Otherwise, looks unaligned with the lines below.

> +USE_GNOME=	cairo gdkpixbuf2 glib20 gtk30 pango

glib20 and pango can be omitted as already specified via gtk30. See _IMPL logic in /usr/ports/Mk/Uses/gnome.mk

> +WRKSRC_SUBDIR=	crates/eww
> +
> +PLIST_FILES=	bin/eww
[...]
> +post-install:
> +	${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/eww

eww can be replaced with ${PORTNAME} to make the style easier to unify across ports or use this port as a template when creating a similar port.

> +WRKSRC_SUBDIR=	crates/eww
> +CARGO_CARGOLOCK=	${WRKSRC}/../../Cargo.lock
> +LICENSE_FILE=	${WRKSRC}/../../LICENSE

Unless ${WRKSRC} contains several unrelated components better set CARGO_INSTALL_PATH=crates/${PORTNAME}. See also https://github.com/rust-lang/cargo/issues/4101
crates/eww uses other crates/*, so everything seems related. AUR, Alpine, NixPkgs seem to build eww package from toplevel directory.

  $ rg CARGO_INSTALL_PATH
  audio/spotify-player/Makefile
  22:CARGO_INSTALL_PATH=  ./spotify_player

  devel/rust-analyzer/Makefile
  189:CARGO_INSTALL_PATH= crates/rust-analyzer

  editors/helix/Makefile
  128:CARGO_INSTALL_PATH= ./helix-term

  games/veloren/Makefile
  752:CARGO_INSTALL_PATH= server-cli voxygen

  math/kalker/Makefile
  84:CARGO_INSTALL_PATH=  ./cli

  math/savage/Makefile
  18:CARGO_INSTALL_PATH=  ./savage

  security/acmed/Makefile
  22:CARGO_INSTALL_PATH=  ./acmed ./tacd

  sysutils/czkawka/Makefile
  347:CARGO_INSTALL_PATH= ${PLIST_FILES:Mbin/*:T}

  sysutils/gstat-rs/Makefile
  94:CARGO_INSTALL_PATH=  gstat

  textproc/meilisearch/Makefile
  24:CARGO_INSTALL_PATH=  meilisearch-http

  www/garage/Makefile
  20:CARGO_INSTALL_PATH=  src/garage

  www/lychee/Makefile
  20:CARGO_INSTALL_PATH=  lychee-bin

  x11/alacritty/Makefile
  223:CARGO_INSTALL_PATH= alacritty

  x11/wezterm/Makefile
  574:CARGO_INSTALL_PATH= ${PLIST_FILES:Mbin/*:T}

  x11-wm/leftwm/Makefile
  162:CARGO_INSTALL_PATH= ./leftwm


> +BUILD_DEPENDS=	rust-nightly>0:lang/rust-nightly
> +CARGO_BUILDDEP=	no

RUSTC_BOOTSTRAP is better than lang/rust-nightly because consumers (reverse dependencies) are actually tested and fixed on compiler upgrades. Besides, rust-nightly can be older than rust like now (1.63.0.20220622 vs. 1.63.0 released on 2022-08-08). Also, NixPkgs uses RUSTC_BOOTSTRAP=1 in its eww package recipe.

  $ rg RUSTC_BOOTSTRAP
  games/veloren/Makefile
  750:CARGO_ENV+=         RUSTC_BOOTSTRAP=1

  net-im/libsignal-client/Makefile
  246:                    RUSTC_BOOTSTRAP=aes,polyval

  net-im/libsignal-node/Makefile
  243:MAKE_ENV+=  RUSTC_BOOTSTRAP=aes,polyval

  security/vaultwarden/Makefile
  375:CARGO_ENV+= RUSTC_BOOTSTRAP=1

  textproc/ripgrep/Makefile
  110:SIMD_MAKE_ENV=      RUSTC_BOOTSTRAP=encoding_rs,packed_simd_2

  www/deno/Makefile
  32:             RUSTC_BOOTSTRAP=1 \

> +OPTIONS_DEFAULT=	X11
> +OPTIONS_SINGLE=		PROTOCOL
> +OPTIONS_SINGLE_PROTOCOL=	WAYLAND X11
>
> +WAYLAND_LIB_DEPENDS=	libgtk-layer-shell.so:x11-toolkits/gtk-layer-shell
> +WAYLAND_VARS=	CARGO_FEATURES+=wayland
> +X11_VARS=	CARGO_FEATURES+=x11

After bug 227509 Wayland should be enabled by default. If it cannot co-exist with X11 use flavors e.g.,

  FLAVORS=	x11 wayland

  PKGNAMESUFFIX=	-${FLAVOR}
  CARGO_FEATURES=	--no-default-features ${FLAVOR}
  wayland_LIB_DEPENDS=	libgtk-layer-shell.so:x11-toolkits/gtk-layer-shell
  wayland_CONFLICTS_INSTALL=	${PORTNAME}-x11
  x11_CONFLICTS_INSTALL=	${PORTNAME}-wayland

To test every flavor use: poudriere bulk -tj 131amd64 x11/eww@all

https://docs.freebsd.org/en/books/porters-handbook/flavors/
Comment 3 Jesús Daniel Colmenares Oviedo 2022-09-25 01:08:30 UTC
Created attachment 236798 [details]
eww-0.4.0

Changes:

* pet portfmt
* remove glib20 and pango
* replace hardcoded eww entries with ${PORTNAME}
* use CARGO_INSTALL_PATH
* add a patch to fix the correct version of eww in Cargo.lock.

---

Hi!

Thank you for that information, this is very useful.

---

A missing change that I cannot add is remove nightly because eww could not compile.

I have seen that NixPkg [1] uses that environment variable and I don't know much about Nix but I can't understand why/how it can compile eww that way. AUR [2] and Alpine [3] does not use that variable, they use nightly.

The error that rust shows me when nightly is not used is:

```
        rustc --explain E0658
        An unstable feature was used.

        Erroneous code example:

        ```
        #[repr(u128)] // error: use of unstable library feature 'repr128'
        enum Foo {
            Bar(u64),
        }
        ```

        If you're using a stable or a beta version of rustc, you won't be able to use
        any unstable features. In order to do so, please switch to a nightly version of
        rustc (by using [rustup]).

        If you're using a nightly version of rustc, just add the corresponding feature
        to be able to use it:

        ```
        #![feature(repr128)]

        #[repr(u128)] // ok!
        enum Foo {
            Bar(u64),
        }
        ```

        [rustup]: https://rust-lang.github.io/rustup/concepts/channels.html
```

[1] https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/window-managers/eww/default.nix
[2] https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=eww#n19
[3] https://git.alpinelinux.org/aports/tree/testing/eww/APKBUILD#n10
Comment 4 Jan Beich freebsd_committer freebsd_triage 2022-09-25 02:36:53 UTC
(In reply to Jesús Daniel Colmenares Oviedo from comment #3)
> * add a patch to fix the correct version of eww in Cargo.lock.

Seems cosmetic. USES=cargo doesn't pass --frozen, so Cargo.lock is automatically updated from Cargo.toml during build e.g.,

  ===>   Updating Cargo.lock
      Updating eww v0.3.0 (/wrkdirs/usr/ports/x11/eww/work-x11/eww-0.4.0/crates/eww) -> v0.4.0

> +PLIST_FILES=	bin/${PORTNAME}

This can probably moved/grouped under USE_GNOME since that section already has non-USE* like GH_ACCOUNT.

> I have seen that NixPkg [1] uses that environment variable and I don't know
> much about Nix but I can't understand why/how it can compile eww that way. AUR
> [2] and Alpine [3] does not use that variable, they use nightly.

I did provide examples in other ports. Adding CARGO_ENV=RUSTC_BOOTSTRAP=1 to Makefile should've been enough (tested in x11/eww myself, even on i386 which is not supported by lang/rust-nightly). Whether to use CARGO_ENV or MAKE_ENV doesn't matter as USES=cargo inherits both but if you need to apply RUSTC_BOOTSTRAP only in certain port options then MAKE_ENV is easier because there's an option helper while CARGO_ENV would require using generic _VARS + _VARS_OFF helper.

Note, Firefox has been using RUSTC_BOOTSTRAP for years, see https://searchfox.org/mozilla-release/search?q=RUSTC_BOOTSTRAP
Comment 5 Jan Beich freebsd_committer freebsd_triage 2022-09-25 16:26:06 UTC
RUSTC_BOOTSTRAP is a cheat knob to enable unstable features on stable channel as if using nightly of the same version. Accepted values are: 1 or <crate-names> (comma-separated); other/invalid values can be used to disable the effect. Supposed to be set from environ(7) before running rustc or cargo. More details are in lang/rust source (vendor code, not the port) as it seems to be intentionally underdocumented.

lang/rust-nightly is very rarely updated and mostly serves for rust@ team and other individuals to experiment and debug the compiler or consumers. Regular users should get fresh or specific nightly via rustup. Either way nightly is only available for 1 of 9 architectures FreeBSD supports[1] without rust@ team hard work to generate bootstraps[2] and test runtime but nightly bootstraps change very often. Note, review D29548 proposed to make USES=rust:nightly set RUSTC_BOOTSTRAP=1 because depending on lang/rust-nightly is undesirable.

Porter's Handook probably needs to document RUSTC_BOOTSTRAP which may go against Rust upstream wishes to keep it hidden.

[1] https://static.rust-lang.org/dist/channel-rust-nightly.toml
[2] lang/rust-bootstrap is nowadays used to automate the process
Comment 6 Jesús Daniel Colmenares Oviedo 2022-09-26 02:34:06 UTC
Created attachment 236827 [details]
eww-0.4.0

Changes:

* use CARGO_ENV=RUSTC_BOOTSTRAP instead of lang/rust-nightly
* remove Cargo.lock patch because it is fixed automatically

---

>> +PLIST_FILES=	bin/${PORTNAME}
> This can probably moved/grouped under USE_GNOME since that section already has non-USE* like GH_ACCOUNT.

I can move that, but portclippy still recommends PLIST_FILES to be under the CARGO_* variables. Is it necessary to move it?

---

Thank you Jan for all this help!
Comment 7 commit-hook freebsd_committer freebsd_triage 2022-09-26 02:51:57 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=34cd5e3b86cdab8b62afa9579993f5d78628d0b7

commit 34cd5e3b86cdab8b62afa9579993f5d78628d0b7
Author:     Jesús Daniel Colmenares Oviedo <DtxdF@disroot.org>
AuthorDate: 2022-09-26 02:17:13 +0000
Commit:     Jan Beich <jbeich@FreeBSD.org>
CommitDate: 2022-09-26 02:51:14 +0000

    x11/eww: New port: ElKowars wacky widgets

    Elkowars Wacky Widgets is a standalone widget system made in Rust
    that allows you to implement your own, custom widgets in any window
    manager.

    WWW: https://elkowar.github.io/eww

    PR:             266564

 x11/Makefile                  |   1 +
 x11/eww/Makefile (new)        |  33 ++++
 x11/eww/Makefile.crates (new) | 221 +++++++++++++++++++++
 x11/eww/distinfo (new)        | 445 ++++++++++++++++++++++++++++++++++++++++++
 x11/eww/pkg-descr (new)       |   3 +
 5 files changed, 703 insertions(+)
Comment 8 Jan Beich freebsd_committer freebsd_triage 2022-09-26 03:03:06 UTC
Thanks. Landed.