Browse Source

feat: Module

tags/0.3.2
Dale 1 week ago
parent
commit
7121896047
Signed by: Deiru <deiru2k@gmail.com> GPG Key ID: AA250C0277B927E1
3 changed files with 38 additions and 6 deletions
  1. +0
    -2
      default.nix
  2. +35
    -0
      module.nix
  3. +3
    -4
      src/config.ts

+ 0
- 2
default.nix View File

@@ -45,8 +45,6 @@ in mkYarnPackage {
makeWrapper ${nodePkg}/bin/node $out/bin/${executableName} \
--add-flags $out/server.js \
--set NODE_PATH $NODE_PATH:$out:$node_modules \
--set STATIC_PATH $out/static \
--set PORT ${toString port}
'';

distPhase = ''


+ 35
- 0
module.nix View File

@@ -0,0 +1,35 @@
{ lib, pkgs, config, ... }:

with lib;
let
statusPkg = (import "${pkgs.fetchgit {
url = "https://code.gensokyo.social/Gensokyo.social/status.git";
rev = "9ff093415e82fb522a9942a5b632b1690ae73d23";
sha256 = "0dgzabsv4lc2i5mi17zch9jfmsrbsmh6h4s7v9j4r779zbgvmidm";
}}/default.nix");
in {
options.services.miracle-tv = {
enable = mkEnableOption "Gensokyo.social status";
port = {
type = types.int;
default = 8080;
description = "Governs port number that server will listen on";
};
settings = {
MASTODON_API_KEY = {
type = types.string;
description = "Mastodon API key";
};
};
};

config = let
configFile = pkgs.writeText "config.json" (builtins.toJSON cfg.settings);
in lib.mkIf cfg.enable {
# systemd unit for miracle-tv-server
systemd.services.miracle-tv = {
wantedBy = [ "multi-user.target" "postgresql.service" ];
serviceConfig.ExecStart = "CONFIG_FILE=${configFile} PORT=${cfg.port} ${statusPkg}/bin/gensocStatus";
};
};
}

+ 3
- 4
src/config.ts View File

@@ -1,9 +1,8 @@
import * as configFile from "src/config.json";

interface IConfig {
'MASTODON_API_KEY': string;
}

const config: IConfig = configFile
export default config;
const configPath = process.env.CONFIG_PATH || './config.json';
const config: IConfig = require(configPath);

export default config;

Loading…
Cancel
Save