From aaed546947a205784dd2f88b7fb9be93d2f2b6ee Mon Sep 17 00:00:00 2001 From: Hilmar Wiegand Date: Mon, 4 Dec 2023 00:30:33 +0100 Subject: [PATCH] Use rust-overlay for flake build --- nix/flake.lock | 24 ++++++++++++++++++++++++ nix/flake.nix | 35 +++++++++++++++++++++++------------ 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/nix/flake.lock b/nix/flake.lock index 4bd833e4c..b43da4f2b 100644 --- a/nix/flake.lock +++ b/nix/flake.lock @@ -92,9 +92,33 @@ "harfbuzz": "harfbuzz", "libpng": "libpng", "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay", "zlib": "zlib" } }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1701569797, + "narHash": "sha256-ObvQFAPpC5IVbI2GHedSTQVzYxht2qhBgHHQnh3mYTs=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "516c9477757b628b157780d96d84e8c82b46dc99", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, diff --git a/nix/flake.nix b/nix/flake.nix index d18d3c924..c955a5251 100644 --- a/nix/flake.nix +++ b/nix/flake.nix @@ -4,6 +4,13 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; flake-utils.url = "github:numtide/flake-utils"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-utils.follows = "flake-utils"; + }; + }; freetype2 = { url = "github:wez/freetype2/de8b92dd7ec634e9e2b25ef534c54a3537555c11"; @@ -29,6 +36,7 @@ outputs = { self, flake-utils, + rust-overlay, nixpkgs, freetype2, harfbuzz, @@ -37,7 +45,8 @@ ... }: flake-utils.lib.eachDefaultSystem (system: let - pkgs = import nixpkgs {inherit system;}; + overlays = [(import rust-overlay)]; + pkgs = import nixpkgs {inherit system overlays;}; inherit (nixpkgs) lib; inherit (pkgs) stdenv; @@ -48,6 +57,12 @@ ncurses # tic for terminfo pkg-config python3 + + rust-bin.stable.latest.minimal + rust-bin.stable.latest.clippy + + rust-bin.nightly.latest.rustfmt + rust-bin.nightly.latest.rust-analyzer ] ++ lib.optional stdenv.isDarwin perl; @@ -76,8 +91,13 @@ ]; libPath = lib.makeLibraryPath (with pkgs; [libGL vulkan-loader]); + + rustPlatform = pkgs.makeRustPlatform { + cargo = pkgs.rust-bin.stable.latest.minimal; + rustc = pkgs.rust-bin.stable.latest.minimal; + }; in { - packages.default = pkgs.rustPlatform.buildRustPackage rec { + packages.default = rustPlatform.buildRustPackage rec { inherit buildInputs nativeBuildInputs; name = "wezterm"; @@ -120,16 +140,7 @@ devShell = pkgs.mkShell { name = "wezterm-shell"; - - inherit nativeBuildInputs; - buildInputs = - buildInputs - ++ (with pkgs; [ - cargo - rustc - rustfmt - rustPackages.clippy - ]); + inherit buildInputs nativeBuildInputs; LD_LIBRARY_PATH = libPath; };