···11+# Copied from https://github.com/NixOS/nixpkgs/pull/307601
22+{
33+ config,
44+ lib,
55+ pkgs,
66+ utils,
77+ ...
88+}:
99+let
1010+ cfg = config.services.hysteria;
1111+ settingsFormat = pkgs.formats.json { };
1212+in
1313+{
1414+ options.services.hysteria = {
1515+ enable = lib.mkEnableOption "Hysteria, a powerful, lightning fast and censorship resistant proxy";
1616+1717+ package = lib.mkPackageOption pkgs "hysteria" { };
1818+1919+ mode = lib.mkOption {
2020+ type = lib.types.enum [
2121+ "server"
2222+ "client"
2323+ ];
2424+ default = "server";
2525+ description = "Whether to use Hysteria as a client or a server.";
2626+ };
2727+2828+ settings = lib.mkOption {
2929+ type = lib.types.submodule { freeformType = settingsFormat.type; };
3030+ default = { };
3131+ description = ''
3232+ The Hysteria configuration, see https://hysteria.network/ for documentation.
3333+3434+ Options containing secret data should be set to an attribute set
3535+ containing the attribute `_secret` - a string pointing to a file
3636+ containing the value the option should be set to.
3737+ '';
3838+ };
3939+ };
4040+ config = lib.mkIf cfg.enable {
4141+ systemd.services.hysteria = {
4242+ description = "Hysteria daemon, a powerful, lightning fast and censorship resistant proxy.";
4343+ documentation = [ "https://hysteria.network/" ];
4444+ wantedBy = [ "multi-user.target" ];
4545+ after = [ "network-online.target" ];
4646+ wants = [ "network-online.target" ];
4747+ preStart = utils.genJqSecretsReplacementSnippet cfg.settings "/var/lib/hysteria/config.json";
4848+ serviceConfig = {
4949+ ExecStart = lib.concatStringsSep " " [
5050+ (lib.getExe cfg.package)
5151+ cfg.mode
5252+ "--disable-update-check"
5353+ "--config /var/lib/hysteria/config.json"
5454+ ];
5555+5656+ StateDirectory = "hysteria";
5757+ WorkingDirectory = "/var/lib/hysteria";
5858+5959+ ### Hardening
6060+ AmbientCapabilities = [
6161+ "CAP_NET_ADMIN"
6262+ "CAP_NET_BIND_SERVICE"
6363+ "CAP_NET_RAW"
6464+ ];
6565+ CapabilityBoundingSet = [
6666+ "CAP_NET_ADMIN"
6767+ "CAP_NET_BIND_SERVICE"
6868+ "CAP_NET_RAW"
6969+ ];
7070+ NoNewPrivileges = true;
7171+ PrivateMounts = true;
7272+ PrivateTmp = true;
7373+ ProcSubset = "pid";
7474+ ProtectClock = true;
7575+ ProtectControlGroups = true;
7676+ ProtectHome = true;
7777+ ProtectHostname = true;
7878+ ProtectKernelLogs = true;
7979+ ProtectKernelModules = true;
8080+ ProtectKernelTunables = true;
8181+ ProtectProc = "invisible";
8282+ ProtectSystem = "strict";
8383+ RestrictRealtime = true;
8484+ RestrictSUIDSGID = true;
8585+ RestrictNamespaces = true;
8686+ SystemCallArchitectures = "native";
8787+ SystemCallFilter = "@system-service";
8888+ UMask = "0077";
8989+9090+ # More perf
9191+ CPUSchedulingPolicy = "rr";
9292+ CPUSchedulingPriority = 99;
9393+ };
9494+ };
9595+ };
9696+}
+12-3
overlay.nix
···11# May lord have mercy on my soul
22-_: prev: {
22+final: prev: {
33 jujutsu = prev.jujutsu.overrideAttrs {
44 patches = (prev.patches or [ ]) ++ [
55 # HACK: I am so sick and tired of not being able to push to Nixpkgs
66 # because some edgy fucking idiot thought that it's a good idea to not
77 # specify an email address in a commit
88- #
88+ #
99 # See https://github.com/NixOS/nixpkgs/pull/453871
1010- # See https://github.com/jj-vcs/jj/issues/5723
1010+ # See https://github.com/jj-vcs/jj/issues/5723
1111 (prev.fetchpatch2 {
1212 url = "https://github.com/pluiedev/jj/commit/daa88d4dd485ed0c188023d2af8f811fd4db4a14.patch";
1313 hash = "sha256-F8fp+LXQwuFVVVnYHJAEaQ9dFr6z9tdCkmcKDC39mM8=";
···1515 ];
1616 doCheck = false;
1717 };
1818+1919+ # TODO: Remove when nixpkgs#473189 is available in unstable
2020+ vicinae = final.runCommand "vicinae-patched" { } ''
2121+ mkdir -p $out
2222+ cp -r ${prev.vicinae}/* $out
2323+ substituteInPlace $out/share/systemd/user/vicinae.service \
2424+ --replace-fail "/bin/kill" "${final.lib.getExe' final.coreutils "kill"}" \
2525+ --replace-fail "vicinae" "$out/bin/vicinae"
2626+ '';
1827}
+1-10
systems/common.nix
···7171 algorithm = "zstd";
7272 };
73737474- system = {
7575- # thanks to @getchoo
7676- autoUpgrade = {
7777- enable = true;
7878- flake = "git+https://tangled.sh/@pluie.me/flake#${config.networking.hostName}";
7979- flags = [ "--refresh" ];
8080- };
8181-8282- configurationRevision = inputs.self.rev or inputs.self.dirtyRev or "unknown-dirty";
8383- };
7474+ system.configurationRevision = inputs.self.rev or inputs.self.dirtyRev or "unknown-dirty";
8475}