diff --git a/.gitignore b/.gitignore index 7798247..0393d58 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,18 @@ +# Nix build results result result-* -.direnv \ No newline at end of file +# Nix development +.direnv +.envrc + +# Editor files +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# OS files +.DS_Store +Thumbs.db diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..f1f3222 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,75 @@ + + +# Contributing to RustFS Flake + +First off, thank you for considering contributing to RustFS! It's people like you that make RustFS such a great tool. + +## Development Workflow + +This repository manages the Nix Flake for prebuilt RustFS binaries. + +### Prerequisites + +- [Nix](https://nixos.org/download.html) with Flakes enabled. +- [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) for code formatting. + +### Local Testing + +Before submitting a PR, please ensure your changes are valid: + +```bash +# Format check +nix shell nixpkgs#nixpkgs-fmt -c nixpkgs-fmt --check . + +# Syntax and basic flake check +nix flake check + +# Build the default package for your system +nix build .#default + +# Test the example configuration +cd examples && nix eval .#nixosConfigurations.example-host.config.services.rustfs +``` + +### Updating Binaries + +The `sources.json` file tracks the upstream versions and hashes. When a new version of RustFS is released: + +1. Update the `version` field in `sources.json`. +2. Update the `sha256` hashes for all supported platforms. +3. Verify the build: `nix build .`. + +## Coding Standards + +- **Nix Style**: Follow the [Nixpkgs architecture](https://nixos.org/manual/nixpkgs/stable/) guidelines. +- **Modularity**: Keep the NixOS module (`nixos/rustfs.nix`) decoupled from the package definition. +- **Documentation**: Any new option in the NixOS module must include a clear `description`. + +## Pull Request Process + +1. Create a new branch: `git checkout -b feat/your-feature-name`. +2. Commit your changes using [Conventional Commits](https://www.conventionalcommits.org/) (e.g., `feat: add tlsDirectory option`). +3. Ensure the `examples/` are updated if you change the module interface. +4. Submit the PR and wait for the maintainers' review. + +## Security + +If you discover a security vulnerability, please do **not** open an issue. Instead, contact the maintainers directly using the contact options provided in this repository's hosting platform. + +--- + +*By contributing, you agree that your contributions will be licensed under the project's LICENSE.* diff --git a/README.md b/README.md index bdbf814..b18b538 100644 --- a/README.md +++ b/README.md @@ -93,4 +93,4 @@ The TLS directory. Additional environment variables to set for the RustFS service. These will be appended to the environment file at /etc/default/rustfs. -Used for advanced configuration not covered by other options. (e.g. `RUST_BACKTRACE`) +Used for advanced configuration not covered by other options. (e.g. `RUST_BACKTRACE`) \ No newline at end of file diff --git a/examples/flake.nix b/examples/flake.nix new file mode 100644 index 0000000..b5c566f --- /dev/null +++ b/examples/flake.nix @@ -0,0 +1,51 @@ +# Copyright 2024 RustFS Team +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +{ + description = "Example NixOS system using RustFS Flake"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + rustfs-flake.url = "path:../."; + }; + + outputs = { self, nixpkgs, rustfs-flake }: { + nixosConfigurations.example-host = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + rustfs-flake.nixosModules.default + + ({ config, pkgs, ... }: { + services.rustfs = { + enable = true; + package = rustfs-flake.packages.${pkgs.stdenv.hostPlatform.system}.default; + + volumes = "/var/lib/rustfs/data"; + address = "0.0.0.0:9000"; + consoleEnable = true; + consoleAddress = "0.0.0.0:9001"; + + accessKey = "admin-access-key"; + secretKey = "secure-secret-key"; + + logLevel = "info"; + }; + + networking.firewall.allowedTCPPorts = [ 9000 9001 ]; + system.stateVersion = "24.11"; + }) + ]; + }; + }; +} diff --git a/examples/nixos-configuration.nix b/examples/nixos-configuration.nix new file mode 100644 index 0000000..b8e0e3d --- /dev/null +++ b/examples/nixos-configuration.nix @@ -0,0 +1,56 @@ +# Copyright 2024 RustFS Team +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +{ config, pkgs, ... }: + +{ + services.rustfs = { + enable = true; + + # Storage path + volumes = "/var/lib/rustfs/data"; + + # API server address (Port 9000) + address = "127.0.0.1:9000"; + + # Management console configuration (Port 9001) + consoleEnable = true; + consoleAddress = "127.0.0.1:9001"; + + # Logging configuration + logLevel = "info"; + logDirectory = "/var/log/rustfs"; + + # Security: In production, do not hard-code secrets. Integrate a secret + # management tool such as sops-nix or agenix to provide these values. + # + # Example with sops-nix (assuming you have defined the secrets + # `rustfs-access-key` and `rustfs-secret-key` in your sops file): + # services.rustfs.accessKey = + # builtins.readFile config.sops.secrets."rustfs-access-key".path; + # services.rustfs.secretKey = + # builtins.readFile config.sops.secrets."rustfs-secret-key".path; + # + # For this example configuration, we use obvious placeholders instead of + # real secrets. Replace them with values injected by your secret manager. + accessKey = ""; + secretKey = ""; + }; + + # Open firewall ports for both API and Console + networking.firewall.allowedTCPPorts = [ + 9000 # RustFS API + 9001 # RustFS Console + ]; +} diff --git a/flake.nix b/flake.nix index 97888b9..22299b9 100644 --- a/flake.nix +++ b/flake.nix @@ -31,9 +31,11 @@ forAllSystems = nixpkgs.lib.genAttrs supportedSystems; in { + # Standard NixOS Module nixosModules.rustfs = import ./nixos/rustfs.nix; nixosModules.default = self.nixosModules.rustfs; + # Overlays for extending nixpkgs overlays.default = final: prev: { rustfs = self.packages.${prev.system}.default; };