-
-
Save hakujin/49116ee6ae2664cbe3c9464e230cf912 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ 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