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

View File

@ -1,4 +1,6 @@
import ./make-test-python.nix ({ lib, pkgs, ... }: {
import ./make-test-python.nix (
{ lib, pkgs, ... }:
{
name = "redlib";
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
machine.succeed("curl --fail http://localhost:80/settings")
'';
})
}
)