home

My NixOS systems configurations.
Log | Files | Refs | LICENSE

govanityurl.nix (1166B)


      1 { config, lib, pkgs, ... }:
      2 
      3 with lib;
      4 let
      5   cfg = config.services.govanityurl;
      6 in
      7 {
      8   options = {
      9     services.govanityurl = {
     10       enable = mkEnableOption ''
     11         govanityurl is a go canonical path server
     12       '';
     13       package = mkOption {
     14         type = types.package;
     15         default = pkgs.my.govanityurl;
     16         description = ''
     17           govanityurl package to use.
     18         '';
     19       };
     20 
     21       user = mkOption {
     22         type = types.str;
     23       };
     24 
     25       host = mkOption {
     26         type = types.str;
     27       };
     28 
     29       config = mkOption {
     30         type = types.lines;
     31       };
     32     };
     33   };
     34   config = mkIf cfg.enable {
     35     systemd.packages = [ cfg.package ];
     36     environment.etc."govanityurl/config.yaml".text = ''
     37       host: ${cfg.host}
     38       ${cfg.config}
     39     '';
     40     systemd.services.govanityurl = {
     41       description = "Govanity service";
     42       after = [ "network.target" ];
     43       wantedBy = [ "multi-user.target" ];
     44       serviceConfig = {
     45         User = cfg.user;
     46         Restart = "on-failure";
     47         ExecStart = ''
     48           ${cfg.package}/bin/vanityurl /etc/govanityurl/config.yaml
     49         '';
     50       };
     51       path = [ cfg.package ];
     52     };
     53   };
     54 }