nixos/services.kbfs: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-28 21:18:58 +02:00 committed by Jörg Thalheim
parent d70aff4804
commit c51036c276

View File

@ -1,5 +1,4 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
inherit (config.security) wrapperDir; inherit (config.security) wrapperDir;
cfg = config.services.kbfs; cfg = config.services.kbfs;
@ -12,14 +11,14 @@ in {
services.kbfs = { services.kbfs = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Whether to mount the Keybase filesystem."; description = "Whether to mount the Keybase filesystem.";
}; };
enableRedirector = mkOption { enableRedirector = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to enable the Keybase root redirector service, allowing Whether to enable the Keybase root redirector service, allowing
@ -28,15 +27,15 @@ in {
''; '';
}; };
mountPoint = mkOption { mountPoint = lib.mkOption {
type = types.str; type = lib.types.str;
default = "%h/keybase"; default = "%h/keybase";
example = "/keybase"; example = "/keybase";
description = "Mountpoint for the Keybase filesystem."; description = "Mountpoint for the Keybase filesystem.";
}; };
extraFlags = mkOption { extraFlags = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
default = []; default = [];
example = [ example = [
"-label kbfs" "-label kbfs"
@ -52,7 +51,7 @@ in {
###### implementation ###### implementation
config = mkIf cfg.enable (mkMerge [ config = lib.mkIf cfg.enable (lib.mkMerge [
{ {
# Upstream: https://github.com/keybase/client/blob/master/packaging/linux/systemd/kbfs.service # Upstream: https://github.com/keybase/client/blob/master/packaging/linux/systemd/kbfs.service
systemd.user.services.kbfs = { systemd.user.services.kbfs = {
@ -61,7 +60,7 @@ in {
# Note that the "Requires" directive will cause a unit to be restarted whenever its dependency is restarted. # Note that the "Requires" directive will cause a unit to be restarted whenever its dependency is restarted.
# Do not issue a hard dependency on keybase, because kbfs can reconnect to a restarted service. # Do not issue a hard dependency on keybase, because kbfs can reconnect to a restarted service.
# Do not issue a hard dependency on keybase-redirector, because it's ok if it fails (e.g., if it is disabled). # Do not issue a hard dependency on keybase-redirector, because it's ok if it fails (e.g., if it is disabled).
wants = [ "keybase.service" ] ++ optional cfg.enableRedirector "keybase-redirector.service"; wants = [ "keybase.service" ] ++ lib.optional cfg.enableRedirector "keybase-redirector.service";
path = [ "/run/wrappers" ]; path = [ "/run/wrappers" ];
unitConfig.ConditionUser = "!@system"; unitConfig.ConditionUser = "!@system";
@ -89,7 +88,7 @@ in {
environment.systemPackages = [ pkgs.kbfs ]; environment.systemPackages = [ pkgs.kbfs ];
} }
(mkIf cfg.enableRedirector { (lib.mkIf cfg.enableRedirector {
security.wrappers."keybase-redirector".source = "${pkgs.kbfs}/bin/redirector"; security.wrappers."keybase-redirector".source = "${pkgs.kbfs}/bin/redirector";
systemd.tmpfiles.settings."10-kbfs"."/keybase".d = { systemd.tmpfiles.settings."10-kbfs"."/keybase".d = {