From 7de74be87eeaf28a1339b99cde78afe070d3e3e4 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sat, 11 Apr 2020 11:44:33 -0700 Subject: Deploy que-website to Run.Que.Prod --- Run/Que/Prod.nix | 5 +++++ Run/Que/Website.hs | 3 +-- Run/Que/Website.nix | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ default.nix | 2 ++ 4 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 Run/Que/Website.nix diff --git a/Run/Que/Prod.nix b/Run/Que/Prod.nix index 63e4be3..97749c8 100644 --- a/Run/Que/Prod.nix +++ b/Run/Que/Prod.nix @@ -9,6 +9,11 @@ port = 80; package = pkgs.que-server; }; + services.que-website = { + enable = true; + namespace = "_"; + package = pkgs.que-website; + }; networking = { nameservers = [ "67.207.67.2" diff --git a/Run/Que/Website.hs b/Run/Que/Website.hs index 25610dd..5e2f4d6 100644 --- a/Run/Que/Website.hs +++ b/Run/Que/Website.hs @@ -25,7 +25,6 @@ import qualified Data.Text as Text import Data.Text.Encoding ( encodeUtf8 ) import qualified Data.Text.IO as Text import Network.HTTP.Req -import Prelude ( error ) import qualified System.Directory as Directory import System.Environment as Environment import qualified System.Exit as Exit @@ -55,7 +54,7 @@ main = do } needConf :: error -needConf = error "you need a ~/.config/que.conf" +needConf = panic "you need a ~/.config/que.conf" data Sources = Sources { index :: FilePath diff --git a/Run/Que/Website.nix b/Run/Que/Website.nix new file mode 100644 index 0000000..6a24d9d --- /dev/null +++ b/Run/Que/Website.nix @@ -0,0 +1,59 @@ +{ options +, lib +, config +, pkgs +, modulesPath +}: + +let + cfg = config.services.que-website; + static = pkgs.stdenv.mkDerivation { + src = ./.; + name = "que-website-static"; + installPhase = '' + mkdir -p $out + cp ${./apidocs.md} $out/apidocs.md + cp ${./index.md} $out/index.md + cp ${./quescripts.md} $out/quescripts.md + cp ${./style.css} $out/style.css + cp ${./tutorial.md} $out/tutorial.md + cp ${./client.py} $out/client.py + ''; + }; +in +{ + options.services.que-website = { + enable = lib.mkEnableOption "Enable the que-website service"; + namespace = lib.mkOption { + type = lib.types.str; + default = "_"; + description = '' + The que namespace on which que-website will broadcast. + ''; + }; + package = lib.mkOption { + type = lib.types.package; + description = "que-website package to use"; + }; + }; + config = lib.mkIf cfg.enable { + systemd.services.que-website = { + path = [ cfg.package pkgs.pandoc ]; + wantedBy = [ "multi-user.target" ]; + script = '' + ${cfg.package}/bin/que-website ${static} ${cfg.namespace} + ''; + description = '' + Que website server + ''; + serviceConfig = { + User = "root"; + Environment = "HOME=/root"; + KillSignal = "INT"; + Type = "simple"; + Restart = "on-abort"; + RestartSec = "1"; + }; + }; + }; +} diff --git a/default.nix b/default.nix index 33ba285..86d584f 100644 --- a/default.nix +++ b/default.nix @@ -57,12 +57,14 @@ in rec { Run.Que.Prod = buildOS { deps = { que-server = Run.Que.Server; + que-website = Run.Que.Website; }; configuration = { imports = [ ./Com/Simatime/packages.nix ./Com/Simatime/users.nix ./Run/Que/Server.nix + ./Run/Que/Website.nix ./Run/Que/Prod.nix ]; networking.hostName = "prod.que.run"; -- cgit v1.2.3