flake: add Nix flake for reproducible builds (#1096)

Co-authored-by: loverustfs <hello@rustfs.com>
Co-authored-by: 0xdx2 <xuedamon2@gmail.com>
This commit is contained in:
Jörg Thalheim
2025-12-13 16:54:54 +01:00
committed by GitHub
parent 67095c05f9
commit 89a155a35d
2 changed files with 93 additions and 0 deletions

27
flake.lock generated Normal file
View File

@@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1765270179,
"narHash": "sha256-g2a4MhRKu4ymR4xwo+I+auTknXt/+j37Lnf0Mvfl1rE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "677fbe97984e7af3175b6c121f3c39ee5c8d62c9",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

66
flake.nix Normal file
View File

@@ -0,0 +1,66 @@
# Nix flake for building RustFS
#
# Prerequisites:
# Install Nix: https://nixos.org/download/
# Enable flakes: https://nixos.wiki/wiki/Flakes#Enable_flakes
#
# Usage:
# nix build # Build rustfs binary
# nix run # Build and run rustfs
# ./result/bin/rustfs --help
{
description = "RustFS - High-performance S3-compatible object storage";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs =
{ nixpkgs, ... }:
let
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems = nixpkgs.lib.genAttrs systems;
in
{
packages = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
default = pkgs.rustPlatform.buildRustPackage {
pname = "rustfs";
version = "0.0.5";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = with pkgs; [
pkg-config
protobuf
];
buildInputs = with pkgs; [ openssl ];
cargoBuildFlags = [
"--package"
"rustfs"
];
doCheck = false;
meta = {
description = "High-performance S3-compatible object storage";
homepage = "https://rustfs.com";
license = pkgs.lib.licenses.asl20;
mainProgram = "rustfs";
};
};
}
);
};
}