nixos/twingate: add package option and test

This commit is contained in:
Ilan Joselevich 2023-07-07 19:50:29 +03:00
parent 73d174c62b
commit 160edcf2c5
No known key found for this signature in database
4 changed files with 27 additions and 17 deletions

View file

@ -1,28 +1,24 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.twingate;
in {
in
{
options.services.twingate = {
enable = mkEnableOption (lib.mdDoc "Twingate Client daemon");
enable = lib.mkEnableOption (lib.mdDoc "Twingate Client daemon");
package = lib.mkPackageOptionMD pkgs "twingate" { };
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
systemd.packages = [ cfg.package ];
systemd.services.twingate = {
preStart = "cp -r -n ${cfg.package}/etc/twingate/. /etc/twingate/";
wantedBy = [ "multi-user.target" ];
};
networking.firewall.checkReversePath = lib.mkDefault false;
networking.networkmanager.enable = true;
networking.firewall.checkReversePath = lib.mkDefault "loose";
services.resolved.enable = !(config.networking.networkmanager.enable);
environment.systemPackages = [ pkgs.twingate ]; # for the CLI
systemd.packages = [ pkgs.twingate ];
systemd.services.twingate.preStart = ''
cp -r -n ${pkgs.twingate}/etc/twingate/. /etc/twingate/
'';
systemd.services.twingate.wantedBy = [ "multi-user.target" ];
environment.systemPackages = [ cfg.package ]; # For the CLI.
};
}

View file

@ -801,6 +801,7 @@ in {
tuptime = handleTest ./tuptime.nix {};
turbovnc-headless-server = handleTest ./turbovnc-headless-server.nix {};
tuxguitar = handleTest ./tuxguitar.nix {};
twingate = runTest ./twingate.nix;
ucarp = handleTest ./ucarp.nix {};
udisks2 = handleTest ./udisks2.nix {};
ulogd = handleTest ./ulogd.nix {};

10
nixos/tests/twingate.nix Normal file
View file

@ -0,0 +1,10 @@
{
name = "twingate";
nodes.machine.services.twingate.enable = true;
testScript = { nodes, ... }: ''
machine.wait_for_unit("twingate.service")
machine.succeed("twingate --version | grep '${nodes.machine.services.twingate.package.version}' >&2")
'';
}

View file

@ -8,6 +8,7 @@
, udev
, cryptsetup
, stdenv
, nixosTests
}:
stdenv.mkDerivation rec {
@ -41,6 +42,8 @@ stdenv.mkDerivation rec {
mv usr/share $out/share
'';
passthru.tests = { inherit (nixosTests) twingate; };
meta = with lib; {
description = "Twingate Client";
homepage = "https://twingate.com";