summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2025-03-15 06:39:42 +0100
committerMartin Fischer <martin@push-f.com>2025-03-15 07:06:51 +0100
commitae67ef4f60656557d2408f3a4c2ba01959eef2c5 (patch)
treedd3a4411aedbe99fba9fa90ad2cc1ae17a99dd9b
parent8f0377eec717a6d1bb8578bcb8da481c82423310 (diff)
build: introduce NixOS package & serviceHEADmaster
-rw-r--r--default.nix12
-rwxr-xr-xdeploy.sh6
-rw-r--r--service.nix40
3 files changed, 52 insertions, 6 deletions
diff --git a/default.nix b/default.nix
new file mode 100644
index 0000000..1fb47c4
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,12 @@
+{ pkgs ? import <nixpkgs> {} }:
+
+pkgs.stdenv.mkDerivation {
+ name = "geopos-share";
+
+ src = ./.;
+
+ installPhase = ''
+ mkdir -p $out
+ cp index.html script.js $out
+ '';
+}
diff --git a/deploy.sh b/deploy.sh
deleted file mode 100755
index 1b3c6a9..0000000
--- a/deploy.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-tar cf - index.html script.js | ssh push-f.com 'sh -c "
-set -x &&
-cd /var/www/geopos.link &&
-rm -rf * &&
-tar xvf -
-"'
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}";
+ }
+ ];
+ };
+ };
+}