diff --git a/CHANGELOG.md b/CHANGELOG.md index addfcae5..382ee6bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to eww will be listed here, starting at changes since versio ## Unreleased +### Fixes +- Fix and refactor nix flake (By: w-lfchen) + ## [0.6.0] (21.04.2024) ### Fixes diff --git a/flake.lock b/flake.lock index 78c3819a..d34fa0ef 100644 --- a/flake.lock +++ b/flake.lock @@ -36,11 +36,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1708407374, - "narHash": "sha256-EECzarm+uqnNDCwaGg/ppXCO11qibZ1iigORShkkDf0=", + "lastModified": 1709038661, + "narHash": "sha256-Ys611iT6pChGv954aa4f8oKoDKJG3IXjJjPhnj6uaLY=", "owner": "nixos", "repo": "nixpkgs", - "rev": "f33dd27a47ebdf11dc8a5eb05e7c8fbdaf89e73f", + "rev": "8520c158aee718c6e87b56881105fc4223c3c723", "type": "github" }, "original": { @@ -65,11 +65,11 @@ ] }, "locked": { - "lastModified": 1708395022, - "narHash": "sha256-pxHZbfDsLAAcyWz+snbudxhQPlAnK2nWGAqRx11veac=", + "lastModified": 1708999822, + "narHash": "sha256-X55GxqI3oDEfqy38Pt7xyypYNly4bkd/RajFE+FGn+A=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "b4ae18c03af976549a0b6e396b2b5be56d275f8b", + "rev": "1a618c62479a6896ac497aaa0d969c6bd8e24911", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index ef574e15..e6311135 100644 --- a/flake.nix +++ b/flake.nix @@ -13,46 +13,49 @@ outputs = { self, nixpkgs, rust-overlay, flake-compat }: let - pkgsFor = system: - import nixpkgs { - inherit system; - overlays = [ self.overlays.default rust-overlay.overlays.default ]; - }; + overlays = [ (import rust-overlay) self.overlays.default ]; + pkgsFor = system: import nixpkgs { inherit system overlays; }; targetSystems = [ "aarch64-linux" "x86_64-linux" ]; mkRustToolchain = pkgs: pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; in { - overlays.default = final: prev: - let - rust = mkRustToolchain final; + overlays.default = final: prev: { + inherit (self.packages.${prev.system}) eww eww-wayland; + }; - rustPlatform = prev.makeRustPlatform { + packages = nixpkgs.lib.genAttrs targetSystems (system: + let + pkgs = pkgsFor system; + rust = mkRustToolchain pkgs; + rustPlatform = pkgs.makeRustPlatform { cargo = rust; rustc = rust; }; - in { - eww = (prev.eww.override { inherit rustPlatform; }).overrideAttrs - (old: { - version = self.rev or "dirty"; - src = builtins.path { - name = "eww"; - path = prev.lib.cleanSource ./.; - }; - cargoDeps = - rustPlatform.importCargoLock { lockFile = ./Cargo.lock; }; - patches = [ ]; - # remove this when nixpkgs includes it - buildInputs = old.buildInputs ++ [ final.libdbusmenu-gtk3 ]; - }); + version = (builtins.fromTOML + (builtins.readFile ./crates/eww/Cargo.toml)).package.version; + in rec { + eww = rustPlatform.buildRustPackage { + version = "${version}-dirty"; + pname = "eww"; - eww-wayland = final.eww; - }; + src = ./.; + cargoLock.lockFile = ./Cargo.lock; + cargoBuildFlags = [ "--bin" "eww" ]; - packages = nixpkgs.lib.genAttrs targetSystems (system: - let pkgs = pkgsFor system; - in (self.overlays.default pkgs pkgs) // { - default = self.packages.${system}.eww; + nativeBuildInputs = with pkgs; [ pkg-config wrapGAppsHook ]; + buildInputs = with pkgs; [ + gtk3 + librsvg + gtk-layer-shell + libdbusmenu-gtk3 + ]; + }; + + eww-wayland = nixpkgs.lib.warn + "`eww-wayland` is deprecated due to eww building with both X11 and wayland support by default. Use `eww` instead." + eww; + default = eww; }); devShells = nixpkgs.lib.genAttrs targetSystems (system: @@ -61,20 +64,8 @@ rust = mkRustToolchain pkgs; in { default = pkgs.mkShell { - packages = with pkgs; [ - rust - rust-analyzer-unwrapped - gcc - glib - gdk-pixbuf - librsvg - libdbusmenu-gtk3 - gtk3 - gtk-layer-shell - pkg-config - deno - mdbook - ]; + inputsFrom = [ self.packages.${system}.eww ]; + packages = with pkgs; [ deno mdbook ]; RUST_SRC_PATH = "${rust}/lib/rustlib/src/rust/library"; };