This commit is contained in:
alsaiduq-lab 2025-03-14 19:13:10 -06:00
parent 03c20a3bd8
commit 562180961e
5 changed files with 48 additions and 4 deletions

2
.gitignore vendored
View file

@ -1,5 +1,7 @@
backup/
.secrets
result
*.nix.bak

View file

@ -8,19 +8,16 @@
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
./local-packages.nix
../modules
../modules/default.nix
];
networking.hostName = "nixos";
# Setup garbage collection for old generations
nix.gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 30d";
};
# Limit the number of generations
boot.loader.systemd-boot.configurationLimit = 5;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions

View file

@ -45,6 +45,12 @@ in
libtool
gawk
lazygit
# Java ecosystem
jdk17
maven
gradle
visualvm
jdt-language-server
(python310.withPackages (ps: with ps; [
virtualenv
ipython
@ -117,6 +123,8 @@ in
go
sqls
deno
redis
cloudflared
# Rust ecosystem
rustup
rust-analyzer

View file

@ -17,6 +17,7 @@
./steam.nix
./timezone.nix
./user.nix
./systemd.nix
];
# Enable CUPS to print documents.

36
modules/systemd.nix Normal file
View file

@ -0,0 +1,36 @@
{ config, lib, pkgs, ... }:
{
environment.systemPackages = with pkgs; [
autossh
];
systemd.services.autossh-redbot = {
description = "Persistent SSH Tunnel to Cloud Server";
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
User = "cobray";
Group = "cobray";
Restart = "always";
RestartSec = 30;
EnvironmentFile = "/home/cobray/.secrets/autossh-redbot.conf";
Environment = [
"AUTOSSH_GATETIME=0"
"AUTOSSH_POLL=60"
"AUTOSSH_FIRST_POLL=30"
"AUTOSSH_PORT=0"
];
ExecStart = ''
${pkgs.autossh}/bin/autossh -M 0 -N \
-o "ServerAliveInterval 60" \
-o "ServerAliveCountMax 3" \
-o "ExitOnForwardFailure=yes" \
-o "ConnectTimeout=10" \
-R "0.0.0.0:$REMOTE_PORT:localhost:$LOCAL_PORT" \
root@$REMOTE_HOST
'';
};
};
}