mirror of
https://github.com/lightly-toasted/nix-config.git
synced 2025-12-10 07:59:43 +00:00
Compare commits
No commits in common. "fb9b981a1dea623eb9d68d67484534d4ee15612b" and "bd9cb2afff1206fc164a38180eae31a08bb2574b" have entirely different histories.
fb9b981a1d
...
bd9cb2afff
8 changed files with 16 additions and 94 deletions
|
|
@ -18,16 +18,6 @@
|
||||||
description = "Shell commands executed as the service's main process";
|
description = "Shell commands executed as the service's main process";
|
||||||
};
|
};
|
||||||
log.enable = lib.mkEnableOption "Enable logging";
|
log.enable = lib.mkEnableOption "Enable logging";
|
||||||
environment = lib.mkOption {
|
|
||||||
type = lib.types.attrsOf lib.types.str;
|
|
||||||
default = {};
|
|
||||||
description = "Environment variables passed to the service's processes";
|
|
||||||
};
|
|
||||||
environmentFile = lib.mkOption {
|
|
||||||
type = lib.types.nullOr lib.types.path;
|
|
||||||
default = null;
|
|
||||||
description = "Environment file passed to the service";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
@ -38,45 +28,21 @@
|
||||||
config = {
|
config = {
|
||||||
home.file = lib.mkMerge (
|
home.file = lib.mkMerge (
|
||||||
lib.mapAttrsToList (serviceName: sCfg:
|
lib.mapAttrsToList (serviceName: sCfg:
|
||||||
let
|
{
|
||||||
envExports = lib.concatStringsSep "\n" (
|
# run script
|
||||||
lib.mapAttrsToList (k: v: "export ${k}='${v}'") sCfg.environment
|
"runit/services/${serviceName}/run" = {
|
||||||
);
|
text = sCfg.script;
|
||||||
envFile = lib.mkIf (sCfg.environmentFile != null) {
|
executable = true;
|
||||||
"runit/services/${serviceName}/.env" = {
|
|
||||||
source = sCfg.environmentFile;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
envFileSetup = if sCfg.environmentFile != null then ''
|
|
||||||
set -a
|
|
||||||
source .env
|
|
||||||
set +a
|
|
||||||
'' else "";
|
|
||||||
in
|
|
||||||
lib.mkMerge [
|
|
||||||
{
|
|
||||||
# run script
|
|
||||||
"runit/services/${serviceName}/run" = {
|
|
||||||
text = ''
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
${envExports}
|
|
||||||
${envFileSetup}
|
|
||||||
${sCfg.script}
|
|
||||||
'';
|
|
||||||
executable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
# logging
|
# logging
|
||||||
"runit/services/${serviceName}/log/run" = lib.mkIf sCfg.log.enable {
|
"runit/services/${serviceName}/log/run" = lib.mkIf sCfg.log.enable {
|
||||||
text = ''
|
text = ''
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
exec svlogd -t ./main
|
exec svlogd -t ./main
|
||||||
'';
|
'';
|
||||||
executable = true;
|
};
|
||||||
};
|
}
|
||||||
}
|
|
||||||
envFile
|
|
||||||
]
|
|
||||||
) config.runit.services
|
) config.runit.services
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
{ pkgs, config, rootPath, ... }:
|
|
||||||
|
|
||||||
let
|
|
||||||
tunnel = "cb0d9c2c-48f9-4bca-9e81-ef92423c5afa";
|
|
||||||
in
|
|
||||||
{
|
|
||||||
home.file.".cloudflared/${tunnel}.json".source = rootPath + /secrets/gitcrypt/cloudflared/${tunnel}.json;
|
|
||||||
home.file.".cloudflared/cert.pem".source = rootPath + /secrets/gitcrypt/cloudflared/cert.pem;
|
|
||||||
home.file.".cloudflared/config.yml".text = ''
|
|
||||||
tunnel: ${tunnel}
|
|
||||||
credentials-file: ${config.home.homeDirectory}/.cloudflared/${tunnel}.json
|
|
||||||
|
|
||||||
ingress:
|
|
||||||
- hostname: gist.toast.name
|
|
||||||
service: http://${config.runit.services.opengist.environment.OG_HTTP_HOST}:${config.runit.services.opengist.environment.OG_HTTP_PORT}
|
|
||||||
- service: http_status:404
|
|
||||||
'';
|
|
||||||
|
|
||||||
runit.services.cloudflared = {
|
|
||||||
script = ''
|
|
||||||
exec ${pkgs.cloudflared}/bin/cloudflared tunnel run
|
|
||||||
'';
|
|
||||||
log.enable = true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -3,7 +3,8 @@
|
||||||
{
|
{
|
||||||
runit.services.glances = {
|
runit.services.glances = {
|
||||||
script = ''
|
script = ''
|
||||||
exec ${pkgs.glances}/bin/glances -w
|
#!/bin/bash
|
||||||
|
${pkgs.glances}/bin/glances -w
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
{ pkgs, rootPath, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
runit.services.opengist = {
|
|
||||||
script = ''
|
|
||||||
exec ${pkgs.opengist}/bin/opengist start
|
|
||||||
'';
|
|
||||||
|
|
||||||
environment = {
|
|
||||||
OG_HTTP_HOST = "127.0.0.1";
|
|
||||||
OG_HTTP_PORT = "6157";
|
|
||||||
OG_SSH_HOST = "127.0.0.1";
|
|
||||||
OG_SSH_PORT = "6522";
|
|
||||||
};
|
|
||||||
|
|
||||||
environmentFile = rootPath + /secrets/gitcrypt/opengist.env;
|
|
||||||
|
|
||||||
log.enable = true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
secrets/gitcrypt/runit/env
Normal file
BIN
secrets/gitcrypt/runit/env
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue