elkowar / eww

ElKowars wacky widgets
https://elkowar.github.io/eww
MIT License
9.3k stars 382 forks source link

[BUG] nix flake requires having rust-overlay installed separately #817

Closed Anomalocaridid closed 6 months ago

Anomalocaridid commented 1 year ago

Checklist before submitting an issue

Description of the bug

When building from the nix flake, I get an error if I do not have the rust-overlay flake installed even thought it is declared as a dependency in eww's flake.

Reproducing the issue

  1. Using a flake-based NixOS setup, add eww's flake, add its overlay, either enable eww in home manager or install its package, and run nixos-rebuild test. This should fail with an error from nix saying error: attribute 'rust-bin' missing
  2. Add rust-overlay as a flake input, add its overlay, and run nixos-rebuild test again. Eww should build and install successfully.

Expected behaviour

I expected to not need to manually set up rust-overlay for eww to successfully build.

Additional context

error:
       … while calling the 'head' builtin

         at /nix/store/vby8c3909sglr03fxkclkly29vs49ncy-source/lib/attrsets.nix:784:11:

          783|         || pred here (elemAt values 1) (head values) then
          784|           head values
             |           ^
          785|         else

       … while evaluating the attribute 'value'

         at /nix/store/vby8c3909sglr03fxkclkly29vs49ncy-source/lib/modules.nix:759:9:

          758|     in warnDeprecation opt //
          759|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          760|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: attribute 'rust-bin' missing

       at /nix/store/a0h8yw7sjr5i75x5s0s3jj1lkz15h1xb-source/flake.nix:21:31:

           20|       targetSystems = [ "aarch64-linux" "x86_64-linux" ];
           21|       mkRustToolchain = pkgs: pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
             |                               ^
           22|     in
PatrickShaw commented 1 year ago

Not sure if it's related but the version of rust-overlay that eww is using has known issues with newer versions of nixpkgs. See https://github.com/oxalica/rust-overlay/issues/121 . Fixed by bump the version in #818

If you're using a nix flake you can avoid the issue temporarily with:

{
  inputs = {
      eww.url = "github:elkowar/eww";
      eww.inputs.nixpkgs.follows = "nixpkgs";
      eww.inputs.rust-overlay.follows = "rust-overlay";
      // ...
  };
  // ...
}
danielgafni commented 10 months ago

Hey @PatrickShaw!

I've tried doing what you suggested but am still getting errors like

> error[E0599]: no method named `drain_filter` found for struct `std::collections::HashMap` in the current scope
       >    --> crates/eww/src/widgets/widget_definitions.rs:130:62
       >     |
       > 130 |     let contained_deprecated: Vec<_> = bargs.unhandled_attrs.drain_filter(|a, _| deprecated.contains(&a.0 as &str)).collect();
       >     |                                                              ^^^^^^^^^^^^ method not found in `HashMap<AttrName, AttrEntry>`

when compiling eww-wayland. Seems like the rust version used for eww-wayland build is still not up do date. These are my inputs:

    nixpkgs.url = "github:NixOs/nixpkgs/nixos-unstable";
    rust-overlay.url = "github:oxalica/rust-overlay";
    eww-wayland.url = "github:elkowar/eww";
    # tmp fix https://github.com/elkowar/eww/issues/817
    eww-wayland.inputs.nixpkgs.follows = "nixpkgs";
    eww-wayland.inputs.rust-overlay.follows = "rust-overlay";

any idea what's going on here? :thinking: