flake nix

This commit is contained in:
MeexReay 2025-02-11 20:52:45 +03:00
parent 8d671c7e86
commit 47910442b6

View File

@ -1,5 +1,5 @@
{ {
description = "Cargo project with cross-compilation support"; description = "bRAC";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
@ -8,59 +8,28 @@
}; };
outputs = { self, nixpkgs, flake-utils, rust-overlay, ... }: outputs = { self, nixpkgs, flake-utils, rust-overlay, ... }:
flake-utils.lib.eachSystem [ flake-utils.lib.eachDefaultSystem (system:
"x86_64-linux"
"x86_64-darwin"
"x86_64-windows"
"i686-linux"
"i686-windows"
"aarch64-darwin"
] (system:
let let
overlays = [ (import rust-overlay) ]; overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system overlays; inherit system overlays;
crossSystem = (import <nixpkgs/lib>).systems.examples.gnu64 // {
rust.rustcTarget = {
"x86_64-linux" = "x86_64-unknown-linux-gnu";
"x86_64-darwin" = "x86_64-apple-darwin";
"x86_64-windows" = "x86_64-pc-windows-gnu";
"i686-linux" = "i686-unknown-linux-gnu";
"i686-windows" = "i686-pc-windows-gnu";
"aarch64-darwin" = "aarch64-apple-darwin";
}.${system}; # here invalid target format
}; };
};
exeSuffix = if pkgs.stdenv.hostPlatform.isWindows then ".exe" else "";
in { in {
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
rust-bin.stable.latest.default rust-bin.stable.latest.default
pkg-config pkg-config
(if stdenv.isDarwin then darwin.libiconv else null)
]; ];
}; };
packages.default = pkgs.rustPlatform.buildRustPackage { packages.default = pkgs.rustPlatform.buildRustPackage {
pname = "my-cargo-project"; pname = "bRAC";
version = "0.1.0"; version = "0.1.2+1.99.2";
src = pkgs.lib.cleanSource ./.; src = pkgs.lib.cleanSource ./.;
cargoLock = { cargoLock = {
lockFile = ./Cargo.lock; lockFile = ./Cargo.lock;
}; };
meta = with pkgs.lib; {
description = "My Rust project";
license = licenses.mit;
maintainers = with maintainers; [ ];
platforms = platforms.all;
};
postInstall = ''
mv $out/bin/bRAC $out/bin/bRAC-${system}${exeSuffix}
'';
}; };
}); });
} }