Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
kugland committed Jan 30, 2025
1 parent 1e4222c commit d366de9
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 70 deletions.
126 changes: 70 additions & 56 deletions modules/autossh-tunnels.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@
, config
, ...
}:
with lib;
let

with lib; let
cfg = config.services.autosshTunnels;

mkTunnel = tunnel:
"-L " + (if tunnel.localAddress != null then "${tunnel.localAddress}:" else "") + "${toString tunnel.localPort}" + ":" + (if tunnel.remoteAddress != null then "${tunnel.remoteAddress}:" else "127.0.0.1:") + "${toString tunnel.remotePort}";

"-L "
+ (
if tunnel.localAddress != null
then "${tunnel.localAddress}:"
else ""
)
+ "${toString tunnel.localPort}"
+ ":"
+ (
if tunnel.remoteAddress != null
then "${tunnel.remoteAddress}:"
else "127.0.0.1:"
)
+ "${toString tunnel.remotePort}";
in
{
options = {
Expand Down Expand Up @@ -96,60 +106,64 @@ in
};
groups.autossh = { };
};
services.autossh.sessions = map
(name:
let session = cfg.sessions.${name}; in
{
inherit name;
user = "autossh";
monitoringPort = 0;
extraArguments = lib.concatStringsSep " " ([
"-N"
"-o Port=${toString session.port}"
"-o ControlMaster=no"
"-o Compression=no"
"-o ExitOnForwardFailure=yes"
"-o TCPKeepAlive=yes"
"-o ServerAliveInterval=60"
"-i ${session.secretKey}"
"${session.user}@${session.host}"
] ++ (map mkTunnel session.tunnels));
}
)
(builtins.attrNames cfg.sessions);
services.autossh.sessions =
map
(
name:
let
session = cfg.sessions.${name};
in
{
inherit name;
user = "autossh";
monitoringPort = 0;
extraArguments = lib.concatStringsSep " " ([
"-N"
"-o Port=${toString session.port}"
"-o ControlMaster=no"
"-o Compression=no"
"-o ExitOnForwardFailure=yes"
"-o TCPKeepAlive=yes"
"-o ServerAliveInterval=60"
"-i ${session.secretKey}"
"${session.user}@${session.host}"
]
++ (map mkTunnel session.tunnels));
}
)
(builtins.attrNames cfg.sessions);

systemd.services = builtins.listToAttrs (map
(name:
{
name = "autossh-${name}";
value = {
serviceConfig = {
Environment = [ "LD_PRELOAD=${pkgs.graphene-hardened-malloc}/lib/libhardened_malloc.so" ];
CapabilityBoundingSet = lib.mkForce [ "CAP_NET_BIND_SERVICE" ];
CPUQuota = "10%";
DevicePolicy = "closed";
LockPersonality = true;
MemoryDenyWriteExecute = true;
NoNewPrivileges = true;
PrivateDevices = true;
PrivateIPC = true;
PrivateTmp = true;
PrivateUsers = true;
ProcSubset = "pid";
ProtectClock = true;
ProtectControlGroups = true;
ProtectHostname = true;
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectProc = "invisible";
RestrictAddressFamilies = lib.mkForce [ "AF_UNIX" "AF_INET" ];
RestrictNamespaces = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
};
(name: {
name = "autossh-${name}";
value = {
serviceConfig = {
Environment = [ "LD_PRELOAD=${pkgs.graphene-hardened-malloc}/lib/libhardened_malloc.so" ];
CapabilityBoundingSet = lib.mkForce [ "CAP_NET_BIND_SERVICE" ];
CPUQuota = "10%";
DevicePolicy = "closed";
LockPersonality = true;
MemoryDenyWriteExecute = true;
NoNewPrivileges = true;
PrivateDevices = true;
PrivateIPC = true;
PrivateTmp = true;
PrivateUsers = true;
ProcSubset = "pid";
ProtectClock = true;
ProtectControlGroups = true;
ProtectHostname = true;
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectProc = "invisible";
RestrictAddressFamilies = lib.mkForce [ "AF_UNIX" "AF_INET" ];
RestrictNamespaces = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
};
})
};
})
(builtins.attrNames cfg.sessions));
};
}
2 changes: 1 addition & 1 deletion pkgs/bip39/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
, libsodium
, cunit
, fetchFromGitHub
,
}:

stdenv.mkDerivation (final: rec {
pname = "bip39";
version = "0.2.1";
Expand Down
28 changes: 15 additions & 13 deletions pkgs/subtitlecomposer/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
, openal
, stdenv
, libsForQt5
,
}:

stdenv.mkDerivation rec {
pname = "subtitlecomposer";
version = "0.8.1";
Expand All @@ -21,18 +21,20 @@ stdenv.mkDerivation rec {
};

nativeBuildInputs = [ cmake extra-cmake-modules libsForQt5.wrapQtAppsHook ];
buildInputs = [ ffmpeg_6 openal ] ++ (with libsForQt5; [
kcodecs
kconfig
kconfigwidgets
kcoreaddons
ki18n
kio
ktextwidgets
kwidgetsaddons
kxmlgui
sonnet
]);
buildInputs =
[ ffmpeg_6 openal ]
++ (with libsForQt5; [
kcodecs
kconfig
kconfigwidgets
kcoreaddons
ki18n
kio
ktextwidgets
kwidgetsaddons
kxmlgui
sonnet
]);

meta = with lib; {
homepage = "https://apps.kde.org/subtitlecomposer";
Expand Down

0 comments on commit d366de9

Please sign in to comment.