tv wwan: make uqmi-wrapper available to root

This commit is contained in:
tv 2023-01-19 14:07:23 +01:00
parent 23fdaa1eed
commit 3e5c82d968

View File

@ -26,9 +26,19 @@ with import ./lib;
config = let config = let
cfg = config.tv.wwan; cfg = config.tv.wwan;
in mkIf cfg.enable { in mkIf cfg.enable {
nixpkgs.overlays = singleton (self: super: {
uqmi-wrapper = pkgs.symlinkJoin {
name = "uqmi-wrapper";
paths = [
(pkgs.writeDashBin "uqmi" ''
exec ${pkgs.uqmi}/bin/uqmi --device=${cfg.device} "$@"
'')
pkgs.uqmi
];
};
});
systemd.services.wwan = { systemd.services.wwan = {
environment = { environment = {
DEVICE = cfg.device;
SECRETS = "%d/secrets"; SECRETS = "%d/secrets";
}; };
path = [ path = [
@ -36,21 +46,12 @@ with import ./lib;
pkgs.coreutils pkgs.coreutils
pkgs.iproute2 pkgs.iproute2
pkgs.jq pkgs.jq
(pkgs.symlinkJoin { pkgs.uqmi-wrapper
name = "uqmi-wrapper";
paths = [
(pkgs.writeDashBin "uqmi" ''
set -efu
exec ${pkgs.uqmi}/bin/uqmi --device="$DEVICE" "$@"
'')
pkgs.uqmi
];
})
(pkgs.writeDashBin "get-interface" ( (pkgs.writeDashBin "get-interface" (
if cfg.interface != null then /* sh */ '' if cfg.interface != null then /* sh */ ''
echo ${cfg.interface} echo ${cfg.interface}
'' else /* sh */ '' '' else /* sh */ ''
exec ${pkgs.libqmi}/bin/qmicli -d "$DEVICE" -p --get-wwan-iface exec ${pkgs.libqmi}/bin/qmicli -d ${cfg.device} -p --get-wwan-iface
'' ''
)) ))
]; ];
@ -158,6 +159,9 @@ with import ./lib;
''; '';
}; };
}; };
users.users.root.packages = [
pkgs.uqmi-wrapper
];
tv.systemd.services.wwan.operators = cfg.operators; tv.systemd.services.wwan.operators = cfg.operators;
}; };
} }