rename to cube

This commit is contained in:
Robin Appelman 2023-03-03 21:33:09 +01:00
commit e246c96f95
4 changed files with 34 additions and 36 deletions

30
Cargo.lock generated
View file

@ -69,6 +69,21 @@ dependencies = [
"os_str_bytes", "os_str_bytes",
] ]
[[package]]
name = "cube"
version = "0.1.0"
dependencies = [
"clap",
"miette",
"nbd",
"serde",
"signal-hook",
"thiserror",
"toml",
"tracing",
"tracing-subscriber",
]
[[package]] [[package]]
name = "errno" name = "errno"
version = "0.2.8" version = "0.2.8"
@ -205,21 +220,6 @@ dependencies = [
"byteorder", "byteorder",
] ]
[[package]]
name = "nbs"
version = "0.1.0"
dependencies = [
"clap",
"miette",
"nbd",
"serde",
"signal-hook",
"thiserror",
"toml",
"tracing",
"tracing-subscriber",
]
[[package]] [[package]]
name = "nom8" name = "nom8"
version = "0.2.0" version = "0.2.0"

View file

@ -1,5 +1,5 @@
[package] [package]
name = "nbs" name = "cube"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"

View file

@ -1,6 +1,4 @@
# NBS # Cube
NBD Block Server
## What ## What
@ -29,11 +27,11 @@ block = "/tmp/block.bin"
Run the server with Run the server with
```bash ```bash
nbs -c config.toml cube -c config.toml
``` ```
When the configuration is changed, it can be reloaded by sending `SIGHUP` to the server. When the configuration is changed, it can be reloaded by sending `SIGHUP` to the server.
```bash ```bash
pkill -sighup nbs pkill -sighup cube
``` ```

View file

@ -4,9 +4,9 @@
}; };
outputs = { self, nixpkgs, flake-utils }: let outputs = { self, nixpkgs, flake-utils }: let
buildNbs = pkgs: pkgs.rustPlatform.buildRustPackage rec { buildCube = pkgs: pkgs.rustPlatform.buildRustPackage rec {
version = "0.1.0"; version = "0.1.0";
pname = "nbs"; pname = "cube";
src = ./.; src = ./.;
@ -14,7 +14,7 @@
meta = with pkgs.lib; { meta = with pkgs.lib; {
description = "A basic NBD block server with a single gimmick"; description = "A basic NBD block server with a single gimmick";
homepage = "https://github.com/icewind1991/nbs"; homepage = "https://github.com/icewind1991/cube";
license = licenses.mit; license = licenses.mit;
platforms = platforms.linux; platforms = platforms.linux;
}; };
@ -25,9 +25,9 @@
in in
rec { rec {
# `nix build` # `nix build`
packages.nbs = buildNbs pkgs; packages.cube = buildCube pkgs;
defaultPackage = packages.nbs; defaultPackage = packages.cube;
defaultApp = packages.nbs; defaultApp = packages.cube;
# `nix develop` # `nix develop`
devShell = pkgs.mkShell { devShell = pkgs.mkShell {
@ -42,10 +42,10 @@
... ...
}: }:
with lib; let with lib; let
nbs = buildNbs pkgs; cube = buildCube pkgs;
cfg = config.services.nbs; cfg = config.services.cube;
format = pkgs.formats.toml {}; format = pkgs.formats.toml {};
configFile = format.generate "nbs.toml" ({ configFile = format.generate "cube.toml" ({
inherit (cfg) listen; inherit (cfg) listen;
exports = mapAttrs (_: export: { exports = mapAttrs (_: export: {
inherit (export) path; inherit (export) path;
@ -54,8 +54,8 @@
}); });
pkg = self.defaultPackage.${pkgs.system}; pkg = self.defaultPackage.${pkgs.system};
in { in {
options.services.nbs = { options.services.cube = {
enable = mkEnableOption "nbs"; enable = mkEnableOption "cube";
log = mkOption { log = mkOption {
type = types.str; type = types.str;
@ -108,12 +108,12 @@
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
# symlink instead of passing `configFile` directly to nbs to allread changing the config without changing the path # symlink instead of passing `configFile` directly to cube to allread changing the config without changing the path
environment.etc."nbs/nbs.toml".source = configFile; environment.etc."cube/cube.toml".source = configFile;
networking.firewall.allowedTCPPorts = optional cfg.openPorts cfg.listen.port; networking.firewall.allowedTCPPorts = optional cfg.openPorts cfg.listen.port;
systemd.services.nbs = { systemd.services.cube = {
description = "NBD block server"; description = "NBD block server";
environment = { environment = {
@ -121,7 +121,7 @@
}; };
serviceConfig = { serviceConfig = {
ExecStart = "${nbs}/bin/nbs -c /etc/nbs/nbs.toml"; ExecStart = "${cube}/bin/cube -c /etc/cube/cube.toml";
ExecReload = "${pkgs.util-linux}/bin/kill -HUP $MAINPID"; ExecReload = "${pkgs.util-linux}/bin/kill -HUP $MAINPID";
Restart = "on-failure"; Restart = "on-failure";
RestartSec = 10; RestartSec = 10;