feat(nix): add NixOS service module and client package (#6856)

Co-authored-by: heihutu <heihutu@gmail.com>
This commit is contained in:
houseme
2026-08-30 00:14:44 +08:00
committed by GitHub
parent 8055aeb1d4
commit 759e1041bd
5 changed files with 269 additions and 4 deletions
+70 -4
View File
@@ -35,6 +35,23 @@
forAllSystems = nixpkgs.lib.genAttrs systems;
in
{
nixosModules.rustfs = import ./nix/rustfs-module.nix {
defaultPackage = system: self.packages.${system}.rustfs;
};
nixosModules.default = self.nixosModules.rustfs;
overlays.default = final: prev:
let
packages = self.packages.${prev.stdenv.hostPlatform.system};
in
{
rustfs = packages.rustfs;
}
// prev.lib.optionalAttrs (builtins.hasAttr "rustfs-client" packages) {
rustfs-client = packages.rustfs-client;
rc = packages.rustfs-client;
};
packages = forAllSystems (
system:
let
@@ -55,9 +72,10 @@
cargo = rustToolchain;
rustc = rustToolchain;
};
in
{
default = rustPlatform.buildRustPackage {
clientVersion = "0.1.32";
rustfs = rustPlatform.buildRustPackage {
pname = "rustfs";
version = "1.0.0-rc.4";
@@ -82,7 +100,6 @@
"rustfs"
];
# Set environment variables for build
PROTOC = "${pkgs.protobuf}/bin/protoc";
doCheck = false;
@@ -94,6 +111,55 @@
mainProgram = "rustfs";
};
};
clientAssets = {
"x86_64-linux" = {
name = "rustfs-cli-linux-amd64-v${clientVersion}.tar.gz";
hash = "sha256-qwDZNwedy28ce0HTS7+q0OsL1PchhnLLy3wzZS0cRt8=";
};
"aarch64-linux" = {
name = "rustfs-cli-linux-arm64-v${clientVersion}.tar.gz";
hash = "sha256-1T1M9Q3lcy9IJo/n5eQezmbTaEgHVJbx1QFCaTX3BYY=";
};
};
clientSupported = builtins.hasAttr system clientAssets;
clientPackage =
if clientSupported then
let
asset = clientAssets.${system};
in
pkgs.stdenvNoCC.mkDerivation {
pname = "rustfs-cli";
version = clientVersion;
src = pkgs.fetchurl {
url = "https://github.com/rustfs/cli/releases/download/v${clientVersion}/${asset.name}";
inherit (asset) hash;
};
sourceRoot = ".";
installPhase = ''
runHook preInstall
install -Dm755 rc "$out/bin/rc"
runHook postInstall
'';
meta = {
description = "RustFS S3-compatible command-line client";
homepage = "https://github.com/rustfs/cli";
license = pkgs.lib.licenses.asl20;
mainProgram = "rc";
};
}
else
null;
in
{
inherit rustfs;
default = rustfs;
}
// pkgs.lib.optionalAttrs clientSupported {
rustfs-client = clientPackage;
rc = clientPackage;
}
);