[Clean] Remove legacy TTP flake configuration
This commit is contained in:
parent
f82500ea7d
commit
9d67824f28
2 changed files with 265 additions and 265 deletions
19
flake.lock
generated
19
flake.lock
generated
|
|
@ -53,8 +53,7 @@
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-parts": "flake-parts",
|
"flake-parts": "flake-parts",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"rust-overlay": "rust-overlay",
|
"rust-overlay": "rust-overlay"
|
||||||
"ttp": "ttp"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rust-overlay": {
|
"rust-overlay": {
|
||||||
|
|
@ -76,22 +75,6 @@
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"ttp": {
|
|
||||||
"flake": false,
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1780494955,
|
|
||||||
"narHash": "sha256-i2VRRF6yNips3c4JHgfvmvMxb0HTkTCn69lmsKZLHRw=",
|
|
||||||
"ref": "refs/heads/main",
|
|
||||||
"rev": "23438fa8f884e6ad0d32ca1004c0dedcce0cc8d2",
|
|
||||||
"revCount": 125,
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://git.methanium.net/tensamin/ttp.git"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://git.methanium.net/tensamin/ttp.git"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|
|
||||||
129
flake.nix
129
flake.nix
|
|
@ -8,21 +8,17 @@
|
||||||
url = "github:oxalica/rust-overlay";
|
url = "github:oxalica/rust-overlay";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
ttp = {
|
|
||||||
url = "git+https://git.methanium.net/tensamin/ttp.git";
|
|
||||||
flake = false;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = inputs @ {
|
outputs =
|
||||||
|
inputs@{
|
||||||
self,
|
self,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
flake-parts,
|
flake-parts,
|
||||||
rust-overlay,
|
rust-overlay,
|
||||||
ttp,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
flake-parts.lib.mkFlake {inherit inputs;} {
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
systems = [
|
systems = [
|
||||||
"x86_64-linux"
|
"x86_64-linux"
|
||||||
"aarch64-linux"
|
"aarch64-linux"
|
||||||
|
|
@ -30,20 +26,28 @@
|
||||||
"aarch64-darwin"
|
"aarch64-darwin"
|
||||||
];
|
];
|
||||||
|
|
||||||
perSystem = {
|
perSystem =
|
||||||
|
{
|
||||||
self',
|
self',
|
||||||
pkgs,
|
pkgs,
|
||||||
system,
|
system,
|
||||||
...
|
...
|
||||||
}: let
|
}:
|
||||||
|
let
|
||||||
rustPkgs = import nixpkgs {
|
rustPkgs = import nixpkgs {
|
||||||
inherit system;
|
inherit system;
|
||||||
overlays = [(import rust-overlay)];
|
overlays = [ (import rust-overlay) ];
|
||||||
};
|
};
|
||||||
rustToolchain = rustPkgs.rust-bin.stable.latest.default.override {
|
rustToolchain = rustPkgs.rust-bin.stable.latest.default.override {
|
||||||
extensions = ["rust-src" "rust-analyzer" "clippy" "rustfmt"];
|
extensions = [
|
||||||
|
"rust-src"
|
||||||
|
"rust-analyzer"
|
||||||
|
"clippy"
|
||||||
|
"rustfmt"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
packages = {
|
packages = {
|
||||||
default = self'.packages.iota;
|
default = self'.packages.iota;
|
||||||
iota = pkgs.rustPlatform.buildRustPackage {
|
iota = pkgs.rustPlatform.buildRustPackage {
|
||||||
|
|
@ -54,14 +58,16 @@
|
||||||
lockFile = ./Cargo.lock;
|
lockFile = ./Cargo.lock;
|
||||||
allowBuiltinFetchGit = true;
|
allowBuiltinFetchGit = true;
|
||||||
};
|
};
|
||||||
nativeBuildInputs = with pkgs; [cmake perl pkg-config];
|
nativeBuildInputs = with pkgs; [
|
||||||
buildInputs = with pkgs; [openssl sqlite];
|
cmake
|
||||||
|
perl
|
||||||
|
pkg-config
|
||||||
|
];
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
openssl
|
||||||
|
sqlite
|
||||||
|
];
|
||||||
dontUseCmakeConfigure = true;
|
dontUseCmakeConfigure = true;
|
||||||
preConfigure = ''
|
|
||||||
if [ -d ../cargo-vendor-dir/ttp-core-0.1.0 ]; then
|
|
||||||
cp ${ttp}/ttp-codec.json ../cargo-vendor-dir/ttp-codec.json
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
mv $out/bin/iota-core $out/bin/iota
|
mv $out/bin/iota-core $out/bin/iota
|
||||||
for f in $out/bin/*; do
|
for f in $out/bin/*; do
|
||||||
|
|
@ -75,29 +81,44 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
nativeBuildInputs = with pkgs; [rustToolchain git cmake perl pkg-config];
|
nativeBuildInputs = with pkgs; [
|
||||||
buildInputs = with pkgs; [openssl sqlite];
|
rustToolchain
|
||||||
|
git
|
||||||
|
cmake
|
||||||
|
perl
|
||||||
|
pkg-config
|
||||||
|
];
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
openssl
|
||||||
|
sqlite
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
flake = {
|
flake = {
|
||||||
nixosModules.default = {
|
nixosModules.default =
|
||||||
|
{
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}:
|
||||||
|
let
|
||||||
cfg = config.services.iota;
|
cfg = config.services.iota;
|
||||||
defaultPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.default or (throw "iota: no pre-built package for system ${pkgs.stdenv.hostPlatform.system}");
|
defaultPackage =
|
||||||
|
self.packages.${pkgs.stdenv.hostPlatform.system}.default
|
||||||
|
or (throw "iota: no pre-built package for system ${pkgs.stdenv.hostPlatform.system}");
|
||||||
|
|
||||||
configFile =
|
configFile =
|
||||||
if cfg.settingsFile != null
|
if cfg.settingsFile != null then
|
||||||
then cfg.settingsFile
|
cfg.settingsFile
|
||||||
else pkgs.writeText "iota-config.json" (builtins.toJSON cfg.settings);
|
else
|
||||||
|
pkgs.writeText "iota-config.json" (builtins.toJSON cfg.settings);
|
||||||
|
|
||||||
descriptionText = "Tensamin Iota";
|
descriptionText = "Tensamin Iota";
|
||||||
#+ lib.optionalString cfg.useTmux " (attach TUI: tmux -S ${cfg.dataDir}/tmux.sock attach -t iota)";
|
#+ lib.optionalString cfg.useTmux " (attach TUI: tmux -S ${cfg.dataDir}/tmux.sock attach -t iota)";
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
options.services.iota = {
|
options.services.iota = {
|
||||||
enable = lib.mkEnableOption "Enable the Iota service.";
|
enable = lib.mkEnableOption "Enable the Iota service.";
|
||||||
|
|
||||||
|
|
@ -122,7 +143,7 @@
|
||||||
|
|
||||||
environmentFiles = lib.mkOption {
|
environmentFiles = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.path;
|
type = lib.types.listOf lib.types.path;
|
||||||
default = [];
|
default = [ ];
|
||||||
description = "Environment files to load for the Iota service.";
|
description = "Environment files to load for the Iota service.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -132,12 +153,6 @@
|
||||||
description = "Whether to open the firewall for ports used by Iota.";
|
description = "Whether to open the firewall for ports used by Iota.";
|
||||||
};
|
};
|
||||||
|
|
||||||
ttpBind = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "0.0.0.0";
|
|
||||||
description = "IP address to bind the TTP/QUIC server to.";
|
|
||||||
};
|
|
||||||
|
|
||||||
bindAddress = lib.mkOption {
|
bindAddress = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = "0.0.0.0";
|
default = "0.0.0.0";
|
||||||
|
|
@ -158,7 +173,7 @@
|
||||||
|
|
||||||
settings = lib.mkOption {
|
settings = lib.mkOption {
|
||||||
type = lib.types.attrs;
|
type = lib.types.attrs;
|
||||||
default = {};
|
default = { };
|
||||||
description = "Configuration attributes for Iota, written to config.json.";
|
description = "Configuration attributes for Iota, written to config.json.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -179,9 +194,10 @@
|
||||||
shell = pkgs.bash;
|
shell = pkgs.bash;
|
||||||
};
|
};
|
||||||
|
|
||||||
users.groups.iota = {};
|
users.groups.iota = { };
|
||||||
|
|
||||||
systemd.services.iota = let
|
systemd.services.iota =
|
||||||
|
let
|
||||||
iotaTmuxCmd = pkgs.writeShellScript "iota-tmux-cmd" ''
|
iotaTmuxCmd = pkgs.writeShellScript "iota-tmux-cmd" ''
|
||||||
mkdir -p ${cfg.dataDir}
|
mkdir -p ${cfg.dataDir}
|
||||||
echo "[$(date)] Running Iota..."
|
echo "[$(date)] Running Iota..."
|
||||||
|
|
@ -193,21 +209,20 @@
|
||||||
read -r -n 1
|
read -r -n 1
|
||||||
exit $status
|
exit $status
|
||||||
'';
|
'';
|
||||||
in {
|
in
|
||||||
description = descriptionText;
|
|
||||||
wantedBy = ["multi-user.target"];
|
|
||||||
after = ["network.target"];
|
|
||||||
|
|
||||||
serviceConfig =
|
|
||||||
{
|
{
|
||||||
|
description = descriptionText;
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
after = [ "network.target" ];
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
User = "iota";
|
User = "iota";
|
||||||
Group = "iota";
|
Group = "iota";
|
||||||
WorkingDirectory = cfg.dataDir;
|
WorkingDirectory = cfg.dataDir;
|
||||||
|
|
||||||
ExecStart =
|
ExecStart =
|
||||||
if cfg.useTmux
|
if cfg.useTmux then
|
||||||
then
|
|
||||||
pkgs.writeShellScript "iota-start" ''
|
pkgs.writeShellScript "iota-start" ''
|
||||||
set -e
|
set -e
|
||||||
export TMUX_TMPDIR=${cfg.dataDir}
|
export TMUX_TMPDIR=${cfg.dataDir}
|
||||||
|
|
@ -227,10 +242,12 @@
|
||||||
done
|
done
|
||||||
echo "[iota-start] tmux session ended"
|
echo "[iota-start] tmux session ended"
|
||||||
''
|
''
|
||||||
else "${cfg.package}/bin/iota";
|
else
|
||||||
|
"${cfg.package}/bin/iota";
|
||||||
|
|
||||||
ExecStartPre = [
|
ExecStartPre = [
|
||||||
("+"
|
(
|
||||||
|
"+"
|
||||||
+ pkgs.writeShellScript "iota-setup" ''
|
+ pkgs.writeShellScript "iota-setup" ''
|
||||||
mkdir -p ${cfg.dataDir}/certs
|
mkdir -p ${cfg.dataDir}/certs
|
||||||
|
|
||||||
|
|
@ -240,20 +257,21 @@
|
||||||
install -m 644 ${configFile} ${cfg.dataDir}/config.json
|
install -m 644 ${configFile} ${cfg.dataDir}/config.json
|
||||||
|
|
||||||
chown -R iota:iota ${cfg.dataDir}
|
chown -R iota:iota ${cfg.dataDir}
|
||||||
'')
|
''
|
||||||
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
RestartSec = "5s";
|
RestartSec = "5s";
|
||||||
|
|
||||||
AmbientCapabilities = ["CAP_NET_BIND_SERVICE"];
|
AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ];
|
||||||
CapabilityBoundingSet = ["CAP_NET_BIND_SERVICE"];
|
CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ];
|
||||||
|
|
||||||
ProtectSystem = "strict";
|
ProtectSystem = "strict";
|
||||||
ProtectHome = true;
|
ProtectHome = true;
|
||||||
PrivateTmp = true;
|
PrivateTmp = true;
|
||||||
NoNewPrivileges = true;
|
NoNewPrivileges = true;
|
||||||
ReadWritePaths = [cfg.dataDir];
|
ReadWritePaths = [ cfg.dataDir ];
|
||||||
ProtectKernelTunables = true;
|
ProtectKernelTunables = true;
|
||||||
ProtectKernelModules = true;
|
ProtectKernelModules = true;
|
||||||
ProtectControlGroups = true;
|
ProtectControlGroups = true;
|
||||||
|
|
@ -262,18 +280,17 @@
|
||||||
LockPersonality = true;
|
LockPersonality = true;
|
||||||
MemoryDenyWriteExecute = true;
|
MemoryDenyWriteExecute = true;
|
||||||
Environment = [
|
Environment = [
|
||||||
"TTP_BIND=${cfg.ttpBind}"
|
|
||||||
"BIND_ADDRESS=${cfg.bindAddress}"
|
"BIND_ADDRESS=${cfg.bindAddress}"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
// lib.optionalAttrs (cfg.environmentFiles != []) {
|
// lib.optionalAttrs (cfg.environmentFiles != [ ]) {
|
||||||
EnvironmentFile = cfg.environmentFiles;
|
EnvironmentFile = cfg.environmentFiles;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.firewall = lib.mkIf cfg.openFirewall {
|
networking.firewall = lib.mkIf cfg.openFirewall {
|
||||||
allowedTCPPorts = [1984];
|
allowedTCPPorts = [ 1984 ];
|
||||||
allowedUDPPorts = [1984];
|
allowedUDPPorts = [ 1984 ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue