mirror of
https://codeberg.org/icewind/cube.git
synced 2026-06-03 20:14:10 +02:00
flake update
This commit is contained in:
parent
36aff48c7e
commit
5c083bbd4e
6 changed files with 199 additions and 166 deletions
95
flake.lock
generated
95
flake.lock
generated
|
|
@ -1,56 +1,103 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"flake-utils": {
|
"crane": {
|
||||||
"inputs": {
|
|
||||||
"systems": "systems"
|
|
||||||
},
|
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1705309234,
|
"lastModified": 1742394900,
|
||||||
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
|
"narHash": "sha256-vVOAp9ahvnU+fQoKd4SEXB2JG2wbENkpqcwlkIXgUC0=",
|
||||||
"owner": "numtide",
|
"owner": "ipetkov",
|
||||||
"repo": "flake-utils",
|
"repo": "crane",
|
||||||
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
|
"rev": "70947c1908108c0c551ddfd73d4f750ff2ea67cd",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "numtide",
|
"owner": "ipetkov",
|
||||||
"repo": "flake-utils",
|
"repo": "crane",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"flakelight": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1748868585,
|
||||||
|
"narHash": "sha256-DrrbahOQAwvNM8l5EuGxxkVS7X5/S59zcG0N9ZWQFhk=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "flakelight",
|
||||||
|
"rev": "dfbecd12d99c1bf82906521a6a7d5b75d2aa1ca2",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "flakelight",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mill-scale": {
|
||||||
|
"inputs": {
|
||||||
|
"crane": "crane",
|
||||||
|
"flakelight": [
|
||||||
|
"flakelight"
|
||||||
|
],
|
||||||
|
"rust-overlay": "rust-overlay"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1748205441,
|
||||||
|
"narHash": "sha256-W+UUBT/l1DSTZo5G43494mRNNspJ2i9jW2QELC9JuMQ=",
|
||||||
|
"ref": "refs/heads/main",
|
||||||
|
"rev": "dac3b74a89cebbeb21cc6602e4a346604adbee8b",
|
||||||
|
"revCount": 49,
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://codeberg.org/icewind/mill-scale"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://codeberg.org/icewind/mill-scale"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1707650010,
|
"lastModified": 1748708770,
|
||||||
"narHash": "sha256-dOhphIA4MGrH4ElNCy/OlwmN24MsnEqFjRR6+RY7jZw=",
|
"narHash": "sha256-q8jG2HJWgooWa9H0iatZqBPF3bp0504e05MevFmnFLY=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "809cca784b9f72a5ad4b991e0e7bcf8890f9c3a6",
|
"rev": "a59eb7800787c926045d51b70982ae285faa2346",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"id": "nixpkgs",
|
"id": "nixpkgs",
|
||||||
"ref": "nixos-23.11",
|
"ref": "nixos-25.05",
|
||||||
"type": "indirect"
|
"type": "indirect"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
"flakelight": "flakelight",
|
||||||
|
"mill-scale": "mill-scale",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems": {
|
"rust-overlay": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"mill-scale",
|
||||||
|
"flakelight",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1681028828,
|
"lastModified": 1742697269,
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
"narHash": "sha256-Lpp0XyAtIl1oGJzNmTiTGLhTkcUjwSkEb0gOiNzYFGM=",
|
||||||
"owner": "nix-systems",
|
"owner": "oxalica",
|
||||||
"repo": "default",
|
"repo": "rust-overlay",
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
"rev": "01973c84732f9275c50c5f075dd1f54cc04b3316",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nix-systems",
|
"owner": "oxalica",
|
||||||
"repo": "default",
|
"repo": "rust-overlay",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
49
flake.nix
49
flake.nix
|
|
@ -1,46 +1,33 @@
|
||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "nixpkgs/nixos-23.11";
|
nixpkgs.url = "nixpkgs/nixos-25.05";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flakelight = {
|
||||||
|
url = "github:nix-community/flakelight";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
mill-scale = {
|
||||||
outputs = {
|
url = "git+https://codeberg.org/icewind/mill-scale";
|
||||||
self,
|
inputs.flakelight.follows = "flakelight";
|
||||||
nixpkgs,
|
};
|
||||||
flake-utils,
|
};
|
||||||
}:
|
outputs = {mill-scale, ...}:
|
||||||
flake-utils.lib.eachDefaultSystem (
|
mill-scale ./. {
|
||||||
system: let
|
withOverlays = [
|
||||||
overlays = [
|
(import ./nix/overlay.nix)
|
||||||
(import ./overlay.nix)
|
|
||||||
];
|
];
|
||||||
pkgs = (import nixpkgs) {
|
nixosModules = {outputs, ...}: {
|
||||||
inherit system overlays;
|
default = {
|
||||||
};
|
|
||||||
in rec {
|
|
||||||
packages = rec {
|
|
||||||
cube = pkgs.cube;
|
|
||||||
default = cube;
|
|
||||||
};
|
|
||||||
|
|
||||||
devShell = pkgs.mkShell {
|
|
||||||
nativeBuildInputs = with pkgs; [rustc cargo bacon cargo-edit cargo-outdated clippy cargo-audit];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
)
|
|
||||||
// {
|
|
||||||
overlays.default = import ./overlay.nix;
|
|
||||||
nixosModules.default = {
|
|
||||||
pkgs,
|
pkgs,
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
imports = [./module.nix];
|
imports = [./nix/module.nix];
|
||||||
config = lib.mkIf config.services.cube.enable {
|
config = lib.mkIf config.services.cube.enable {
|
||||||
nixpkgs.overlays = [self.overlays.default];
|
nixpkgs.overlays = [outputs.overlays.default];
|
||||||
services.cube.package = lib.mkDefault pkgs.cube;
|
services.cube.package = lib.mkDefault pkgs.cube;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
103
module.nix
103
module.nix
|
|
@ -1,103 +0,0 @@
|
||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib; let
|
|
||||||
cfg = config.services.cube;
|
|
||||||
format = pkgs.formats.toml {};
|
|
||||||
configFile = format.generate "cube.toml" {
|
|
||||||
inherit (cfg) listen;
|
|
||||||
exports =
|
|
||||||
mapAttrs (_: export: {
|
|
||||||
inherit (export) path;
|
|
||||||
read_only = export.readOnly;
|
|
||||||
})
|
|
||||||
cfg.exports;
|
|
||||||
};
|
|
||||||
pkg = self.defaultPackage.${pkgs.system};
|
|
||||||
in {
|
|
||||||
options.services.cube = {
|
|
||||||
enable = mkEnableOption "cube";
|
|
||||||
|
|
||||||
log = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "INFO";
|
|
||||||
description = "Log level";
|
|
||||||
};
|
|
||||||
|
|
||||||
listen = mkOption {
|
|
||||||
type = types.submodule {
|
|
||||||
options = {
|
|
||||||
port = mkOption {
|
|
||||||
type = types.int;
|
|
||||||
default = 10809;
|
|
||||||
description = "Port to listen on";
|
|
||||||
};
|
|
||||||
address = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "0.0.0.0";
|
|
||||||
description = "Address to listen on";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
default = {
|
|
||||||
address = "0.0.0.0";
|
|
||||||
port = 10809;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
exports = mkOption {
|
|
||||||
default = [];
|
|
||||||
type = types.attrsOf (types.submodule {
|
|
||||||
options = {
|
|
||||||
path = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
description = "Source path to the image to export";
|
|
||||||
};
|
|
||||||
readOnly = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Whether to export the image readonly";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
openPorts = mkOption {
|
|
||||||
default = false;
|
|
||||||
type = types.bool;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
type = types.package;
|
|
||||||
description = "package to use";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
|
||||||
# symlink instead of passing `configFile` directly to cube to allread changing the config without changing the path
|
|
||||||
environment.etc."cube/cube.toml".source = configFile;
|
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = optional cfg.openPorts cfg.listen.port;
|
|
||||||
|
|
||||||
systemd.services.cube = {
|
|
||||||
description = "NBD block server";
|
|
||||||
|
|
||||||
environment = {
|
|
||||||
RUST_LOG = cfg.log;
|
|
||||||
};
|
|
||||||
|
|
||||||
serviceConfig = {
|
|
||||||
ExecStart = "${cfg.package}/bin/cube -c /etc/cube/cube.toml";
|
|
||||||
ExecReload = "${pkgs.util-linux}/bin/kill -HUP $MAINPID";
|
|
||||||
Restart = "on-failure";
|
|
||||||
RestartSec = 10;
|
|
||||||
};
|
|
||||||
wantedBy = ["multi-user.target"];
|
|
||||||
reloadTriggers = [configFile];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
102
nix/module.nix
Normal file
102
nix/module.nix
Normal file
|
|
@ -0,0 +1,102 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib; let
|
||||||
|
cfg = config.services.cube;
|
||||||
|
format = pkgs.formats.toml {};
|
||||||
|
configFile = format.generate "cube.toml" {
|
||||||
|
inherit (cfg) listen;
|
||||||
|
exports =
|
||||||
|
mapAttrs (_: export: {
|
||||||
|
inherit (export) path;
|
||||||
|
read_only = export.readOnly;
|
||||||
|
})
|
||||||
|
cfg.exports;
|
||||||
|
};
|
||||||
|
pkg = self.defaultPackage.${pkgs.system};
|
||||||
|
in {
|
||||||
|
options.services.cube = {
|
||||||
|
enable = mkEnableOption "cube";
|
||||||
|
|
||||||
|
log = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "INFO";
|
||||||
|
description = "Log level";
|
||||||
|
};
|
||||||
|
|
||||||
|
listen = mkOption {
|
||||||
|
type = types.submodule {
|
||||||
|
options = {
|
||||||
|
port = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
default = 10809;
|
||||||
|
description = "Port to listen on";
|
||||||
|
};
|
||||||
|
address = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "0.0.0.0";
|
||||||
|
description = "Address to listen on";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
default = {
|
||||||
|
address = "0.0.0.0";
|
||||||
|
port = 10809;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
exports = mkOption {
|
||||||
|
default = [];
|
||||||
|
type = types.attrsOf (types.submodule {
|
||||||
|
options = {
|
||||||
|
path = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "Source path to the image to export";
|
||||||
|
};
|
||||||
|
readOnly = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Whether to export the image readonly";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
openPorts = mkOption {
|
||||||
|
default = false;
|
||||||
|
type = types.bool;
|
||||||
|
};
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
type = types.package;
|
||||||
|
description = "package to use";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
# symlink instead of passing `configFile` directly to cube to allread changing the config without changing the path
|
||||||
|
environment.etc."cube/cube.toml".source = configFile;
|
||||||
|
|
||||||
|
networking.firewall.allowedTCPPorts = optional cfg.openPorts cfg.listen.port;
|
||||||
|
|
||||||
|
systemd.services.cube = {
|
||||||
|
description = "NBD block server";
|
||||||
|
|
||||||
|
environment = {
|
||||||
|
RUST_LOG = cfg.log;
|
||||||
|
};
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
ExecStart = "${cfg.package}/bin/cube -c /etc/cube/cube.toml";
|
||||||
|
ExecReload = "${pkgs.util-linux}/bin/kill -HUP $MAINPID";
|
||||||
|
Restart = "on-failure";
|
||||||
|
RestartSec = 10;
|
||||||
|
};
|
||||||
|
wantedBy = ["multi-user.target"];
|
||||||
|
reloadTriggers = [configFile];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
rustPlatform,
|
rustPlatform,
|
||||||
lib,
|
lib,
|
||||||
}: let
|
}: let
|
||||||
src = lib.sources.sourceByRegex ./. ["Cargo.*" "(src)(/.*)?"];
|
src = lib.sources.sourceByRegex ../. ["Cargo.*" "(src)(/.*)?"];
|
||||||
in
|
in
|
||||||
rustPlatform.buildRustPackage rec {
|
rustPlatform.buildRustPackage rec {
|
||||||
version = "0.1.0";
|
version = "0.1.0";
|
||||||
|
|
@ -11,7 +11,7 @@ in
|
||||||
inherit src;
|
inherit src;
|
||||||
|
|
||||||
cargoLock = {
|
cargoLock = {
|
||||||
lockFile = ./Cargo.lock;
|
lockFile = ../Cargo.lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
Loading…
Add table
Add a link
Reference in a new issue