Skip to content

Instantly share code, notes, and snippets.

@dminuoso

dminuoso/f.hs Secret

Created January 31, 2023 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dminuoso/7a51d818b97d2c60c3099637807164c8 to your computer and use it in GitHub Desktop.
Save dminuoso/7a51d818b97d2c60c3099637807164c8 to your computer and use it in GitHub Desktop.
let sources = import nix/sources.nix {};
nixpkgs = import sources.nixpkgs {};
powerdns-test = (import ./default.nix).powerdns.components.tests.powerdns-test;
nixos-lib = import (sources.nixpkgs + "/nixos/lib") {};
sqlitePath = "/var/lib/pdns/backend.sqlite";
in
nixos-lib.runTest {
nodes = {
pdns = { pkgs, ... }: {
config = {
environment.systemPackages = [ powerdns-test ];
networking.firewall.allowedTCPPorts = [ 8081 ];
systemd.services.pdns-init = {
enable = true;
script = ''
${pkgs.sqlite}/bin/sqlite3 ${sqlitePath} < ${pkgs.pdns}/share/doc/pdns/schema.sqlite3.sql
'';
requiredBy = [ "pdns.service" ];
before = [ "pdns.service" ];
serviceConfig.Type = "oneshot";
serviceConfig.User = "pdns";
serviceConfig.RemainAfterExit = true;
serviceConfig.StateDirectory = "pdns";
};
services.powerdns.enable = true;
services.powerdns.extraConfig = ''
api=yes
api-key=secret
launch=gsqlite3
gsqlite3-database=${sqlitePath}
'';
};
};
};
name = "powerdns library tests";
hostPkgs = nixpkgs;
testScript = ''
pdns.wait_for_unit("pdns.service")
pdns.succeed("powerdns-test")
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment