Reorganize and finish configuration
parent
a67f620b82
commit
9deabe3699
@ -1,7 +1,55 @@
|
|||||||
{pkgs, ...}@args:
|
{pkgs, ...}@args:
|
||||||
(import ../lib/node-application.nix) args {
|
with pkgs.stdenv.lib;
|
||||||
tarball = "https://git.cryto.net/joepie91/pastebin-stream/archive/master.tar.gz";
|
|
||||||
|
let
|
||||||
|
fetchFromCrytoGit = (import ../lib/fetch/from-cryto-git.nix) args;
|
||||||
|
nodeApplication = (import ../lib/node-application.nix) args;
|
||||||
|
createJsonConfiguration = (import ../lib/build/json-configuration.nix) args;
|
||||||
|
in
|
||||||
|
{errorPath, debugMode ? false, rev, sha256}:
|
||||||
|
let
|
||||||
|
configuration = {
|
||||||
|
errors = {
|
||||||
|
directory = errorPath;
|
||||||
|
};
|
||||||
|
|
||||||
|
scraperSettings = {
|
||||||
|
pastebinCom = {
|
||||||
|
listInterval = 60;
|
||||||
|
listLimit = 100;
|
||||||
|
pasteInterval = 1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
configurationFile = createJsonConfiguration {
|
||||||
|
name = "pastebin-stream-configuration.json";
|
||||||
|
contents = configuration;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
nodeApplication {
|
||||||
name = "pastebin-stream";
|
name = "pastebin-stream";
|
||||||
|
|
||||||
|
src = fetchFromCrytoGit {
|
||||||
|
owner = "joepie91";
|
||||||
|
repo = "pastebin-stream";
|
||||||
|
inherit rev sha256;
|
||||||
|
};
|
||||||
|
|
||||||
hasErrorReporting = true;
|
hasErrorReporting = true;
|
||||||
mainBinaryPath = "server.js";
|
errorPath = errorPath;
|
||||||
|
mainBinaryPath = "bin/pastebin-stream";
|
||||||
|
setupCommands = ''
|
||||||
|
cp ${configurationFile} $out/config.json
|
||||||
|
'';
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
preStart = ''
|
||||||
|
mkdir -m 0700 -p ${errorPath}
|
||||||
|
chown pastebin-stream ${errorPath}
|
||||||
|
'';
|
||||||
|
environment = mkIf debugMode {
|
||||||
|
DEBUG = "pastebinStream:*";
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
{pkgs, ...}@args:
|
||||||
|
{name ? "config.json", contents}:
|
||||||
|
builtins.toFile name (builtins.toJSON contents)
|
@ -0,0 +1,12 @@
|
|||||||
|
{pkgs, ...}@args:
|
||||||
|
{name, src, setupCommands}:
|
||||||
|
((import (pkgs.stdenv.mkDerivation {
|
||||||
|
name = name;
|
||||||
|
src = src;
|
||||||
|
buildCommand = ''
|
||||||
|
mkdir $out
|
||||||
|
tar -xzvf $src -C $out
|
||||||
|
cd $out
|
||||||
|
${setupCommands}
|
||||||
|
'';
|
||||||
|
})) {}).package
|
@ -0,0 +1,11 @@
|
|||||||
|
{pkgs, ...}@args:
|
||||||
|
# FIXME: The below `name` default should be updated to use `gitRepoToName` in 17.09
|
||||||
|
{owner, repo, rev, name ? ("${repo}-${rev}-src"), ...}@sourceArgs:
|
||||||
|
let
|
||||||
|
baseUrl = "https://git.cryto.net/${owner}/${repo}";
|
||||||
|
in
|
||||||
|
pkgs.fetchurl ({
|
||||||
|
inherit name;
|
||||||
|
url = "${baseUrl}/archive/${rev}.tar.gz";
|
||||||
|
meta.homepage = baseUrl;
|
||||||
|
} // removeAttrs sourceArgs ["owner" "repo" "rev"])
|
@ -0,0 +1,19 @@
|
|||||||
|
{pkgs, ...}@args:
|
||||||
|
with pkgs.stdenv.lib;
|
||||||
|
|
||||||
|
applications:
|
||||||
|
concatStrings (map (application: ''
|
||||||
|
${application.hostname} {
|
||||||
|
timeouts none
|
||||||
|
|
||||||
|
${optionalString (application.tls == false) "tls off"}
|
||||||
|
${optionalString (application?root && application.root != null) "root ${application.root}"}
|
||||||
|
${optionalString (application?proxyTarget && application.proxyTarget != null) ''
|
||||||
|
proxy / ${application.proxyTarget} {
|
||||||
|
websocket
|
||||||
|
transparent
|
||||||
|
}
|
||||||
|
''}
|
||||||
|
${optionalString (application?config) application.config}
|
||||||
|
}
|
||||||
|
'') applications)
|
@ -0,0 +1,12 @@
|
|||||||
|
{pkgs, ...}:
|
||||||
|
{
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
wget
|
||||||
|
curl
|
||||||
|
htop
|
||||||
|
iotop
|
||||||
|
iftop
|
||||||
|
nload
|
||||||
|
lsof
|
||||||
|
];
|
||||||
|
}
|
@ -1,11 +0,0 @@
|
|||||||
pkgs: {
|
|
||||||
environment.systemPackages = with pkgs; [
|
|
||||||
wget
|
|
||||||
curl
|
|
||||||
htop
|
|
||||||
iotop
|
|
||||||
iftop
|
|
||||||
nload
|
|
||||||
lsof
|
|
||||||
];
|
|
||||||
}
|
|
@ -0,0 +1,5 @@
|
|||||||
|
condition: value:
|
||||||
|
if condition then
|
||||||
|
value
|
||||||
|
else
|
||||||
|
null
|
@ -1,12 +1,16 @@
|
|||||||
let
|
let
|
||||||
removeNewlines = (import ../lib/remove-newlines.nix);
|
removeNewlines = (import ../lib/util/remove-newlines.nix);
|
||||||
|
presetRootSsh = (import ../lib/presets/root-ssh.nix);
|
||||||
in {
|
in {
|
||||||
resources.sshKeyPairs.ssh-key = {};
|
resources.sshKeyPairs.ssh-key = {};
|
||||||
|
|
||||||
osmium = { config, pkgs, ... }: {
|
osmium = {config, pkgs, ...}@args: let
|
||||||
|
presetTools = (import ../lib/presets/tools.nix) args;
|
||||||
|
in
|
||||||
|
{
|
||||||
deployment.targetEnv = "digitalOcean";
|
deployment.targetEnv = "digitalOcean";
|
||||||
deployment.digitalOcean.region = "ams2";
|
deployment.digitalOcean.region = "ams2";
|
||||||
deployment.digitalOcean.size = "512mb";
|
deployment.digitalOcean.size = "512mb";
|
||||||
#deployment.digitalOcean.authToken = removeNewlines (builtins.readFile ../credentials/digitalocean-auth-token);
|
#deployment.digitalOcean.authToken = removeNewlines (builtins.readFile ../credentials/digitalocean-auth-token);
|
||||||
} // (import ../lib/root-ssh.nix) // ((import ../lib/tools.nix) pkgs);
|
} // presetRootSsh // presetTools;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue