summaryrefslogtreecommitdiff
path: root/service.nix
diff options
context:
space:
mode:
Diffstat (limited to 'service.nix')
-rw-r--r--service.nix40
1 files changed, 40 insertions, 0 deletions
diff --git a/service.nix b/service.nix
new file mode 100644
index 0000000..f10c4ab
--- /dev/null
+++ b/service.nix
@@ -0,0 +1,40 @@
+{ config, lib, pkgs, ... }:
+
+let
+ geoposShare = pkgs.callPackage ./default.nix {};
+ cfg = config.services.geopos-share;
+ nginxVhostOptions =
+ (import <nixpkgs/nixos/modules/services/web-servers/nginx/vhost-options.nix> {
+ inherit config lib;
+ }).options;
+in
+{
+ options.services.geopos-share = {
+ enable = lib.mkEnableOption "geopos-share";
+
+ virtualHost = lib.mkOption {
+ type = lib.types.str;
+ description = "Name of the nginx virtualhost to set up.";
+ };
+
+ nginx = lib.mkOption {
+ type = lib.types.submodule {
+ options = lib.removeAttrs nginxVhostOptions ["root"];
+ };
+ default = {};
+ };
+ };
+
+ config = lib.mkIf cfg.enable {
+ services.nginx = {
+ enable = true;
+
+ virtualHosts.${cfg.virtualHost} = lib.mkMerge [
+ cfg.nginx
+ {
+ root = "${geoposShare}";
+ }
+ ];
+ };
+ };
+}