Skip to content

Instantly share code, notes, and snippets.

@hakujin
Created July 18, 2018 19:52
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 hakujin/49116ee6ae2664cbe3c9464e230cf912 to your computer and use it in GitHub Desktop.
Save hakujin/49116ee6ae2664cbe3c9464e230cf912 to your computer and use it in GitHub Desktop.
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.service-name;
environment = {
REQUIRE_SSL = cfg.REQUIRE_SSL;
};
in {
###### interface
options = {
services.service-name = rec {
enable = mkEnableOption "service-name-service";
package = mkOption {
type = types.path;
description = "The service-name package.";
};
gems = mkOption {
type = types.path;
description = "The service-name-gems package.";
};
REQUIRE_SSL = mkOption {
type = types.bool;
description = "Whether or not to redirect to SSL";
};
};
};
###### implementation
config = mkIf cfg.enable {
systemd.services = {
service-name = {
wantedBy = [ "multi-user.target" ];
bindsTo = [ "service-name-init.service" ];
after = [ "service-name-init.service" ];
inherit environment;
serviceConfig = {
ExecStart = "${cfg.package}/bin/service-name";
User = "mercury";
Group = "mercury";
Restart = "always";
WorkingDirectory = cfg.package;
};
};
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment