From e504123ceff6a9a424fd23ece87a5e7e25c909c0 Mon Sep 17 00:00:00 2001 From: MeexReay Date: Sun, 13 Apr 2025 23:49:00 +0300 Subject: [PATCH] more nix dev --- README.md | 35 +++++++++++++++++++++++++++-------- flake.nix | 14 ++++++++++---- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 2946e85..a9cef99 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,30 @@ better RAC client go to [releases](https://github.com/MeexReay/bRAC/releases/latest) and download file you need. its simple. -### from flake +### build from source + +1. Make sure [Rust](https://www.rust-lang.org/tools/install) is installed + +2. Clone repository +```bash +git clone https://github.com/MeexReay/bRAC.git +cd bRAC +``` + +3. Build or run with Cargo +```bash +cargo build --release # build release (target/release/bRAC) +cargo run --release # run (builds and runs bRAC itself) +``` + +Minimal version: + +```bash +cargo build --release --no-default-features +cargo run --release --no-default-features +``` + +### nix package If you have Nix package manager installed, you can use: @@ -36,15 +59,11 @@ nix build github:MeexReay/bRAC # build binary (result/bin/bRAC) nix run github:MeexReay/bRAC # run (builds and runs bRAC) ``` -### build from source - -(you have to install [rust](https://www.rust-lang.org/tools/install) at first) +Minimal version: ```bash -git clone https://github.com/MeexReay/bRAC.git -cd bRAC -cargo build --release # build release (target/release/bRAC) -cargo run --release # run (builds and runs bRAC itself) +nix build .#bRAC-minimal +nix run .#bRAC-minimal ``` ## default config diff --git a/flake.nix b/flake.nix index 771375f..837f8bc 100644 --- a/flake.nix +++ b/flake.nix @@ -19,17 +19,23 @@ cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); msrv = cargoToml.package.rust-version; - rustPackage = features: + rustPackage = { version, features }: (pkgs.makeRustPlatform { cargo = pkgs.rust-bin.stable.latest.minimal; rustc = pkgs.rust-bin.stable.latest.minimal; }).buildRustPackage { - inherit (cargoToml.package) name version; + inherit (cargoToml.package) name; src = ./.; cargoLock.lockFile = ./Cargo.lock; + version = lib.concatStrings [ cargoToml.package.version version ]; buildFeatures = features; buildInputs = runtimeDeps; nativeBuildInputs = buildDeps; + patchPhase = '' + substituteInPlace Cargo.toml --replace \ + 'version = "${cargoToml.package.version}"' \ + 'version = "${lib.concatStrings [ cargoToml.package.version version ]}"' + ''; }; mkDevShell = rustc: @@ -49,8 +55,8 @@ packages.default = self'.packages.bRAC; devShells.default = self'.devShells.stable; - packages.bRAC = (rustPackage "default"); - packages.bRAC-minimal = (rustPackage ""); + packages.bRAC = (rustPackage { version = ""; features = "default"; }); + packages.bRAC-minimal = (rustPackage { version = "-minimal"; features = ""; }); devShells.nightly = (mkDevShell (pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default))); devShells.stable = (mkDevShell pkgs.rust-bin.stable.latest.default);