From b3d4d4eacc88282a5a0f5b5670904e9434ba1a2e Mon Sep 17 00:00:00 2001 From: seth Date: Mon, 30 Sep 2024 19:13:55 -0400 Subject: flake: use rust-overlay in dev shell This allows `niri-visual-tests` to still be built and run in the dev shell where it's necessary, as well as brings back the nightly `rustfmt` used by the project We can't use `fenix` again though as it doesn't wrap `ld` like nixpkgs and rust-overlay do; without it, the way we link `dlopen()`'d libraries breaks --- flake.lock | 23 ++++++++++++++++++++++- flake.nix | 30 ++++++++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index f685c8f4..3ff73531 100644 --- a/flake.lock +++ b/flake.lock @@ -34,7 +34,28 @@ "root": { "inputs": { "nix-filter": "nix-filter", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1727663505, + "narHash": "sha256-83j/GrHsx8GFUcQofKh+PRPz6pz8sxAsZyT/HCNdey8=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "c2099c6c7599ea1980151b8b6247a8f93e1806ee", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 5b9361d0..9ef68722 100644 --- a/flake.nix +++ b/flake.nix @@ -5,6 +5,13 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nix-filter.url = "github:numtide/nix-filter"; + + # NOTE: This is not necessary for end users + # You can omit it with `inputs.rust-overlay.follows = ""` + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = @@ -12,6 +19,7 @@ self, nixpkgs, nix-filter, + rust-overlay, }: let inherit (nixpkgs) lib; @@ -30,11 +38,29 @@ devShells = forAllSystems ( system: let + pkgs = nixpkgsFor.${system}; inherit (self.packages.${system}) niri; in { - default = nixpkgsFor.${system}.mkShell { - inputsFrom = [ niri ]; + default = pkgs.mkShell { + packages = [ + # NOTE: Nixpkgs' Rust toolchain isn't used here as we prefer + # a nightly toolchain for development, and *require* a nightly + # `rustfmt` + rust-overlay.packages.${system}.rust-nightly + + pkgs.rust-analyzer + ]; + + nativeBuildInputs = [ + pkgs.clang + pkgs.pkg-config + pkgs.wrapGAppsHook4 # For `niri-visual-tests` + ]; + + buildInputs = niri.buildInputs ++ [ + pkgs.libadwaita # For `niri-visual-tests` + ]; env = { inherit (niri) LIBCLANG_PATH; -- cgit