Skip to content

Commit

Permalink
fix: update and improve flake (#1032)
Browse files Browse the repository at this point in the history
* fix: update and improve flake

* chore: update changelog
  • Loading branch information
w-lfchen authored Feb 24, 2024
1 parent d96586c commit 7bfd47e
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 72 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to eww will be listed here, starting at changes since versio

### Fixes
- The `shell-completions` subcommand is now run before anything is set up
- Fix nix flake

## [0.5.0] (17.02.2024)

Expand Down
19 changes: 6 additions & 13 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
(import
(
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{
src = ./.;
}).defaultNix
(import (let lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in fetchTarball {
url =
"https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}) { src = ./.; }).defaultNix
42 changes: 30 additions & 12 deletions flake.lock

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

72 changes: 38 additions & 34 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
{
inputs = {
flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
rust-overlay.url = "github:oxalica/rust-overlay";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, rust-overlay, flake-compat, ... }:
outputs = { self, nixpkgs, rust-overlay, flake-compat }:
let
pkgsFor = system: import nixpkgs {
inherit system;

overlays = [
self.overlays.default
rust-overlay.overlays.default
];
};
pkgsFor = system:
import nixpkgs {
inherit system;
overlays = [ self.overlays.default rust-overlay.overlays.default ];
};

targetSystems = [ "aarch64-linux" "x86_64-linux" ];
mkRustToolchain = pkgs: pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
in
{
mkRustToolchain = pkgs:
pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
in {
overlays.default = final: prev:
let
rust = mkRustToolchain final;
Expand All @@ -29,33 +31,33 @@
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 = [ ];
});
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 = [ ];
});

eww-wayland = final.eww.override { withWayland = true; };
eww-wayland = final.eww;
};

packages = nixpkgs.lib.genAttrs targetSystems (system:
let
pkgs = pkgsFor system;
in
(self.overlays.default pkgs pkgs) // {
let pkgs = pkgsFor system;
in (self.overlays.default pkgs pkgs) // {
default = self.packages.${system}.eww;
}
);
});

devShells = nixpkgs.lib.genAttrs targetSystems (system:
let
pkgs = pkgsFor system;
rust = mkRustToolchain pkgs;
in
{
in {
default = pkgs.mkShell {
packages = with pkgs; [
rust
Expand All @@ -70,7 +72,9 @@

RUST_SRC_PATH = "${rust}/lib/rustlib/src/rust/library";
};
}
);
});

formatter =
nixpkgs.lib.genAttrs targetSystems (system: (pkgsFor system).nixfmt);
};
}
19 changes: 6 additions & 13 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
(import
(
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{
src = ./.;
}).shellNix
(import (let lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in fetchTarball {
url =
"https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}) { src = ./.; }).shellNix

0 comments on commit 7bfd47e

Please sign in to comment.