home

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

athens.nix (1647B)


      1 { config, lib, pkgs, ... }:
      2 
      3 with lib;
      4 let
      5   cfg = config.services.athens;
      6 in
      7 {
      8   options = {
      9     services.athens = {
     10       enable = mkEnableOption ''
     11         Athens is a go module proxy
     12       '';
     13       package = mkOption {
     14         type = types.package;
     15         default = pkgs.my.athens;
     16         description = ''
     17           Athens package to use.
     18         '';
     19       };
     20 
     21       user = mkOption {
     22         type = types.str;
     23       };
     24 
     25       group = mkOption {
     26         type = types.str;
     27         default = "nogroup";
     28       };
     29     };
     30   };
     31   config = mkIf cfg.enable {
     32     networking.firewall = {
     33       allowedTCPPorts = [ 3000 ];
     34     };
     35     systemd.packages = [ cfg.package ];
     36     environment.etc."athens/config.toml".text = ''
     37       GoBinary = "${pkgs.go}/bin/go"
     38       # what is that ?
     39       GoEnv = "development"
     40       GoGetWorkers = 30
     41       ProtocolWorkers = 30
     42       LogLevel = "debug"
     43       BuffaloLogLevel = "debug"
     44       Port = ":3000"
     45       ForceSSL = false
     46       CloudRuntime = "none"
     47       Timeout = 300
     48       StorageType = "disk"
     49 
     50       [Storage]
     51         [Storage.Disk]
     52           RootPath = "/var/lib/athens"
     53     '';
     54     systemd.services.athens = {
     55       description = "Athens service";
     56       after = [ "network.target" ];
     57       wantedBy = [ "multi-user.target" ];
     58       preStart = ''
     59         mkdir -p /var/lib/athens
     60       '';
     61       environment = { HOME = "/var/lib/athens"; };
     62       serviceConfig = {
     63         User = cfg.user;
     64         Restart = "on-failure";
     65         ExecStart = ''
     66           ${cfg.package}/bin/proxy -config_file=/etc/athens/config.toml
     67         '';
     68       };
     69       path = [ cfg.package ] ++ [ pkgs.go pkgs.git ];
     70     };
     71   };
     72 }