Update nix flake, update config options
This commit is contained in:
parent
a4ec766351
commit
9e948ce6cf
2 changed files with 28 additions and 62 deletions
20
flake.lock
generated
20
flake.lock
generated
|
|
@ -20,11 +20,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1778869304,
|
"lastModified": 1780243769,
|
||||||
"narHash": "sha256-30sZNZoA1cqF5JNO9fVX+wgiQYjB7HJqqJ4ztCDeBZE=",
|
"narHash": "sha256-x5UQuRsH3MqI0U9afaXSNqzTPSeZlRLvFAav2Ux1pNw=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "d233902339c02a9c334e7e593de68855ad26c4cb",
|
"rev": "331800de5053fcebacf6813adb5db9c9dca22a0c",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -64,11 +64,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1779247103,
|
"lastModified": 1780543271,
|
||||||
"narHash": "sha256-DwltBoBl9a7fCzlKi3xnNha1NHbfvawwkNdnTXEyfFQ=",
|
"narHash": "sha256-oPJ7eJN1sM37v92Rp/eyQL7/rUm0BOvXEBAoq/zN0cM=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "86dbfb70dc1c2967245d87ed6d07d2c8bda305e3",
|
"rev": "c30ca201c5093540cf792f6982f81ba1aa0f3514",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -80,11 +80,11 @@
|
||||||
"ttp": {
|
"ttp": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1779304128,
|
"lastModified": 1780494955,
|
||||||
"narHash": "sha256-C/z7JV4RxcuhdYE7vS+x4WJA1rXM/w03kjNfPPRi334=",
|
"narHash": "sha256-i2VRRF6yNips3c4JHgfvmvMxb0HTkTCn69lmsKZLHRw=",
|
||||||
"ref": "refs/heads/main",
|
"ref": "refs/heads/main",
|
||||||
"rev": "3e3f939f64088cb01c13348b58c504593953ec0e",
|
"rev": "23438fa8f884e6ad0d32ca1004c0dedcce0cc8d2",
|
||||||
"revCount": 122,
|
"revCount": 125,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.methanium.net/tensamin/ttp.git"
|
"url": "https://git.methanium.net/tensamin/ttp.git"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
72
flake.nix
72
flake.nix
|
|
@ -26,7 +26,6 @@
|
||||||
systems = [
|
systems = [
|
||||||
"x86_64-linux"
|
"x86_64-linux"
|
||||||
"aarch64-linux"
|
"aarch64-linux"
|
||||||
"x86_64-darwin"
|
|
||||||
"aarch64-darwin"
|
"aarch64-darwin"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -96,7 +95,6 @@
|
||||||
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)";
|
|
||||||
in {
|
in {
|
||||||
options.services.iota = {
|
options.services.iota = {
|
||||||
enable = lib.mkEnableOption "Enable the Iota service.";
|
enable = lib.mkEnableOption "Enable the Iota service.";
|
||||||
|
|
@ -132,16 +130,24 @@
|
||||||
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";
|
||||||
description = "IP address to bind the HTTP server to.";
|
description = "IP address to bind the Iota HTTP and TTP/QUIC servers to.";
|
||||||
|
};
|
||||||
|
|
||||||
|
web = {
|
||||||
|
bindAddress = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "0.0.0.0";
|
||||||
|
description = "IP address to bind the ttyd terminal server to.";
|
||||||
|
};
|
||||||
|
|
||||||
|
port = lib.mkOption {
|
||||||
|
type = lib.types.port;
|
||||||
|
default = 7681;
|
||||||
|
description = "Port to bind the ttyd terminal server to.";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
package = lib.mkOption {
|
package = lib.mkOption {
|
||||||
|
|
@ -150,12 +156,6 @@
|
||||||
description = "The Iota package to use.";
|
description = "The Iota package to use.";
|
||||||
};
|
};
|
||||||
|
|
||||||
useTmux = lib.mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = true;
|
|
||||||
description = "Whether to run Iota inside a tmux session for shared TUI access.";
|
|
||||||
};
|
|
||||||
|
|
||||||
settings = lib.mkOption {
|
settings = lib.mkOption {
|
||||||
type = lib.types.attrs;
|
type = lib.types.attrs;
|
||||||
default = {};
|
default = {};
|
||||||
|
|
@ -181,19 +181,7 @@
|
||||||
|
|
||||||
users.groups.iota = {};
|
users.groups.iota = {};
|
||||||
|
|
||||||
systemd.services.iota = let
|
systemd.services.iota = {
|
||||||
iotaTmuxCmd = pkgs.writeShellScript "iota-tmux-cmd" ''
|
|
||||||
mkdir -p ${cfg.dataDir}
|
|
||||||
echo "[$(date)] Running Iota..."
|
|
||||||
${cfg.package}/bin/iota
|
|
||||||
status=$?
|
|
||||||
echo ""
|
|
||||||
echo "[$(date)] Iota exited with status: $status"
|
|
||||||
echo "Press any key to exit..."
|
|
||||||
read -r -n 1
|
|
||||||
exit $status
|
|
||||||
'';
|
|
||||||
in {
|
|
||||||
description = descriptionText;
|
description = descriptionText;
|
||||||
wantedBy = ["multi-user.target"];
|
wantedBy = ["multi-user.target"];
|
||||||
after = ["network.target"];
|
after = ["network.target"];
|
||||||
|
|
@ -205,29 +193,7 @@
|
||||||
Group = "iota";
|
Group = "iota";
|
||||||
WorkingDirectory = cfg.dataDir;
|
WorkingDirectory = cfg.dataDir;
|
||||||
|
|
||||||
ExecStart =
|
ExecStart = "${pkgs.ttyd}/bin/ttyd -W -i ${cfg.web.bindAddress} -p ${toString cfg.web.port} ${cfg.package}/bin/iota";
|
||||||
if cfg.useTmux
|
|
||||||
then
|
|
||||||
pkgs.writeShellScript "iota-start" ''
|
|
||||||
set -e
|
|
||||||
export TMUX_TMPDIR=${cfg.dataDir}
|
|
||||||
${pkgs.coreutils}/bin/mkdir -p ${cfg.dataDir}
|
|
||||||
${pkgs.coreutils}/bin/chown iota:iota ${cfg.dataDir}
|
|
||||||
|
|
||||||
echo "[iota-start] Creating tmux session..."
|
|
||||||
if ! ${pkgs.tmux}/bin/tmux -S ${cfg.dataDir}/tmux.sock new-session -d -s iota "${iotaTmuxCmd}"; then
|
|
||||||
echo "[iota-start] ERROR: tmux new-session failed"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "[iota-start] tmux session created, waiting..."
|
|
||||||
echo "[iota-start] Run 'tmux -S ${cfg.dataDir}/tmux.sock attach -t iota' to attach to the tmux session."
|
|
||||||
|
|
||||||
while ${pkgs.tmux}/bin/tmux -S ${cfg.dataDir}/tmux.sock has-session -t iota 2>/dev/null; do
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
echo "[iota-start] tmux session ended"
|
|
||||||
''
|
|
||||||
else "${cfg.package}/bin/iota";
|
|
||||||
|
|
||||||
ExecStartPre = [
|
ExecStartPre = [
|
||||||
("+"
|
("+"
|
||||||
|
|
@ -262,7 +228,7 @@
|
||||||
LockPersonality = true;
|
LockPersonality = true;
|
||||||
MemoryDenyWriteExecute = true;
|
MemoryDenyWriteExecute = true;
|
||||||
Environment = [
|
Environment = [
|
||||||
"TTP_BIND=${cfg.ttpBind}"
|
"TTP_BIND=${cfg.bindAddress}"
|
||||||
"BIND_ADDRESS=${cfg.bindAddress}"
|
"BIND_ADDRESS=${cfg.bindAddress}"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
@ -272,7 +238,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.firewall = lib.mkIf cfg.openFirewall {
|
networking.firewall = lib.mkIf cfg.openFirewall {
|
||||||
allowedTCPPorts = [1984];
|
allowedTCPPorts = [1984 cfg.web.port];
|
||||||
allowedUDPPorts = [1984];
|
allowedUDPPorts = [1984];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue