{nixos,nixosTests}/redlib: format with nixfmt

This commit is contained in:
Guanran Wang 2024-10-01 17:39:13 +08:00
parent d78d09350a
commit e286b91ebc
No known key found for this signature in database
GPG Key ID: 91F97D9ED12639CF
2 changed files with 90 additions and 57 deletions

View File

@ -1,8 +1,21 @@
{ config, lib, pkgs, ... }: {
config,
with lib; lib,
pkgs,
...
}:
let let
inherit (lib)
concatStringsSep
mkEnableOption
mkIf
mkOption
mkPackageOption
mkRenamedOptionModule
types
;
cfg = config.services.redlib; cfg = config.services.redlib;
args = concatStringsSep " " ([ args = concatStringsSep " " ([
@ -12,7 +25,16 @@ let
in in
{ {
imports = [ imports = [
(mkRenamedOptionModule [ "services" "libreddit" ] [ "services" "redlib" ]) (mkRenamedOptionModule
[
"services"
"libreddit"
]
[
"services"
"redlib"
]
)
]; ];
options = { options = {
@ -55,6 +77,7 @@ in
AmbientCapabilities = lib.mkIf (cfg.port < 1024) [ "CAP_NET_BIND_SERVICE" ]; AmbientCapabilities = lib.mkIf (cfg.port < 1024) [ "CAP_NET_BIND_SERVICE" ];
Restart = "on-failure"; Restart = "on-failure";
RestartSec = "2s"; RestartSec = "2s";
# Hardening # Hardening
CapabilityBoundingSet = if (cfg.port < 1024) then [ "CAP_NET_BIND_SERVICE" ] else [ "" ]; CapabilityBoundingSet = if (cfg.port < 1024) then [ "CAP_NET_BIND_SERVICE" ] else [ "" ];
DeviceAllow = [ "" ]; DeviceAllow = [ "" ];
@ -73,12 +96,19 @@ in
ProtectKernelModules = true; ProtectKernelModules = true;
ProtectKernelTunables = true; ProtectKernelTunables = true;
ProtectProc = "invisible"; ProtectProc = "invisible";
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ]; RestrictAddressFamilies = [
"AF_INET"
"AF_INET6"
];
RestrictNamespaces = true; RestrictNamespaces = true;
RestrictRealtime = true; RestrictRealtime = true;
RestrictSUIDSGID = true; RestrictSUIDSGID = true;
SystemCallArchitectures = "native"; SystemCallArchitectures = "native";
SystemCallFilter = [ "@system-service" "~@privileged" "~@resources" ]; SystemCallFilter = [
"@system-service"
"~@privileged"
"~@resources"
];
UMask = "0077"; UMask = "0077";
}; };
}; };

View File

@ -1,4 +1,6 @@
import ./make-test-python.nix ({ lib, pkgs, ... }: { import ./make-test-python.nix (
{ lib, pkgs, ... }:
{
name = "redlib"; name = "redlib";
meta.maintainers = with lib.maintainers; [ soispha ]; meta.maintainers = with lib.maintainers; [ soispha ];
@ -17,4 +19,5 @@ import ./make-test-python.nix ({ lib, pkgs, ... }: {
# Query a page that does not require Internet access # Query a page that does not require Internet access
machine.succeed("curl --fail http://localhost:80/settings") machine.succeed("curl --fail http://localhost:80/settings")
''; '';
}) }
)