Skip to content

Commit

Permalink
fix: refactor and fix flake (#1038)
Browse files Browse the repository at this point in the history
* fix: refactor flake

* chore: update flake.lock

* chore: update changelog

* chore: update flake.lock

* chore: update changelog
  • Loading branch information
w-lfchen committed Apr 21, 2024
1 parent 8397744 commit acf57a8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 49 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 34 additions & 43 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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";
};
Expand Down

0 comments on commit acf57a8

Please sign in to comment.