Skip to content

Commit

Permalink
Add sshwifty service
Browse files Browse the repository at this point in the history
  • Loading branch information
diamondburned committed May 3, 2024
1 parent 9825e23 commit e29f68e
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

rec {
jre_small = pkgs.callPackage ./jre-small {};
sshwifty = pkgs.callPackage ./sshwifty {};
quizler = pkgs.callPackage ./quizler {};

# Go
Expand Down
1 change: 1 addition & 0 deletions packages/imports.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ in {
imports = [
./caddy/caddy.nix
./sysmet/sysmet.nix
./sshwifty/service.nix
./dischord/service.nix
./christmasd/service.nix
];
Expand Down
23 changes: 23 additions & 0 deletions packages/sshwifty/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{ pkgs }:

let
version = "0.3.9-beta-release-prebuild";
url = "https://github.com/nirui/sshwifty/releases/download/0.3.9-beta-release-prebuild/sshwifty_0.3.9-beta-release_linux_amd64.tar.gz";
src = pkgs.fetchzip {
inherit url;
sha256 = "sha256-M7SX3nec9LVlII0iPb3udkUY/ESh6EZaW2U2fjhZAiE=";
stripRoot = false;
};
in

pkgs.runCommandLocal "sshwifty" {
nativeBuildInputs = with pkgs; [
autoPatchelfHook
];
meta = {
mainProgram = "sshwifty";
};
} ''
mkdir -p $out/bin
ln -s ${src}/sshwifty_linux_amd64 $out/bin/sshwifty
''
47 changes: 47 additions & 0 deletions packages/sshwifty/service.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{ config, lib, pkgs, ... }:

with lib;
with builtins;

let
self = config.services.sshwifty;
in

{
options.services.sshwifty = {
enable = mkEnableOption "sshwifty server";

config = mkOption {
type = types.attrs;
description = ''
Verbatim JSON configuration for sshwifty
See https://github.com/nirui/sshwifty?tab=readme-ov-file#configuration-file-option-and-descriptions.
'';
};

package = mkOption {
type = types.package;
default = pkgs.sshwifty;
description = "The sshwifty package to use.";
};
};

config = mkIf self.enable {
systemd.services.sshwifty = {
description = "sshwifty server";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
environment = {
SSHWIFTY_CONFIG = pkgs.writeText "sshwifty.json" self.config;
};
serviceConfig = {
ExecStart = "${lib.getExe self.package}";
DynamicUser = true;
ProtectSystem = "strict";
ProtectHome = true;
PrivateTmp = true;
PrivateDevices = true;
};
};
};
}
4 changes: 4 additions & 0 deletions servers/cs306/caddy/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@ isos.acmcsuf.com {
@files not path / */
header @files Cache-Control "public, max-age=31536000, immutable"
}

ssh.acmcsuf.com {
reverse_proxy * localhost:38274
}
19 changes: 19 additions & 0 deletions servers/cs306/services.nix
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,23 @@ in
enable = true;
config = builtins.readFile <acm-aws/secrets/dischord-config.toml>;
};

services.sshwifty = {
enable = true;
config = {
Servers = [
{
ListenInterface = "127.0.0.1";
ListenPort = 38274;
}
];
Presets = [
# {
# Title = "GitHub";
# Type = "SSH";
# }
];
OnlyAllowPresetRemotes = true;
};
};
}

0 comments on commit e29f68e

Please sign in to comment.