From 8553f5efd9653a98f41adbf62a6258600be56d8e Mon Sep 17 00:00:00 2001 From: electria Date: Tue, 10 Nov 2026 13:43:26 -0800 Subject: [PATCH 1/4] build: optimize flake --- flake.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 26109ec..c62878e 100644 --- a/flake.nix +++ b/flake.nix @@ -10,9 +10,15 @@ inputs.flake-utils.lib.eachDefaultSystem ( system: let - pkgs = import inputs.nixpkgs { inherit system; }; + pkgs = inputs.nixpkgs.legacyPackages.${system}; + lib = inputs.nixpkgs.lib; + + src = lib.sourceFilesBySuffices ./. [ + "Cargo.toml" + "Cargo.lock" + ".rs" + ]; - src = ./.; cargoToml = fromTOML (builtins.readFile "${src}/Cargo.toml"); name = cargoToml.package.name; From f05eb164cd62e02d460eb91a58fc4741280b3c13 Mon Sep 17 00:00:00 2001 From: electria Date: Tue, 10 Nov 2026 13:45:53 -0800 Subject: [PATCH 2/4] refactor: rename derivation binding (crate -> bin) --- flake.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index c62878e..5d01d01 100644 --- a/flake.nix +++ b/flake.nix @@ -22,7 +22,7 @@ cargoToml = fromTOML (builtins.readFile "${src}/Cargo.toml"); name = cargoToml.package.name; - crate = pkgs.rustPlatform.buildRustPackage { + bin = pkgs.rustPlatform.buildRustPackage { inherit name src; cargoLock.lockFile = "${src}/Cargo.lock"; @@ -33,10 +33,10 @@ }; in { - packages.default = crate; + packages.default = bin; devShells.default = pkgs.mkShell { - inputsFrom = [ crate ]; + inputsFrom = [ bin ]; packages = with pkgs; [ rustc From b4f0b81d9b85ca2f7e6118a29f53f8f676815a73 Mon Sep 17 00:00:00 2001 From: electria Date: Tue, 10 Nov 2026 14:13:01 -0800 Subject: [PATCH 3/4] refactor: simplify devshell inputFrom already inherits cargo and rustc (from the rustPlatform used in the bin package) --- flake.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/flake.nix b/flake.nix index 5d01d01..e55276e 100644 --- a/flake.nix +++ b/flake.nix @@ -39,8 +39,6 @@ inputsFrom = [ bin ]; packages = with pkgs; [ - rustc - cargo clippy rustfmt rust-analyzer From ff9befd9ee549bf91e1faa81cd48758f8e62a6a3 Mon Sep 17 00:00:00 2001 From: electria Date: Tue, 10 Nov 2026 14:31:19 -0800 Subject: [PATCH 4/4] build: add statically linked output if only something like this was possible with wayland and others... --- Cargo.toml | 3 +++ flake.nix | 26 +++++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5793b00..60d7a9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,9 @@ thiserror = "2.0.18" version = "1.30" default-features = false features = ["std", "float"] +[dependencies.gmp-mpfr-sys] +version = "*" +features = ["force-cross"] [profile.release] lto = true diff --git a/flake.nix b/flake.nix index e55276e..99a051a 100644 --- a/flake.nix +++ b/flake.nix @@ -22,21 +22,29 @@ cargoToml = fromTOML (builtins.readFile "${src}/Cargo.toml"); name = cargoToml.package.name; - bin = pkgs.rustPlatform.buildRustPackage { - inherit name src; + bin = + { + rustPlatform, + m4, + }: + rustPlatform.buildRustPackage { + inherit name src; - cargoLock.lockFile = "${src}/Cargo.lock"; + cargoLock.lockFile = "${src}/Cargo.lock"; - nativeBuildInputs = with pkgs; [ - m4 - ]; - }; + nativeBuildInputs = [ + m4 + ]; + }; + + default = pkgs.callPackage bin { }; in { - packages.default = bin; + packages.default = default; + packages.static = pkgs.pkgsStatic.callPackage bin { }; devShells.default = pkgs.mkShell { - inputsFrom = [ bin ]; + inputsFrom = [ default ]; packages = with pkgs; [ clippy