Compare commits
No commits in common. "b47e660c2ff8da514a9b303170788cdf5c37b779" and "9d29f4fcccd28653f3bc6240b99d84dd11d03d8e" have entirely different histories.
b47e660c2f
...
9d29f4fccc
|
@ -205,7 +205,7 @@ ACTION=="add", SUBSYSTEM=="tty", \
|
|||
"lab.m-labs.hk" = {
|
||||
addSSL = true;
|
||||
useACMEHost = "nixbld.m-labs.hk";
|
||||
locations."/homu/".proxyPass = "http://127.0.0.1:54856/";
|
||||
locations."/".proxyPass = "http://192.168.1.100";
|
||||
};
|
||||
"nixbld.m-labs.hk" = {
|
||||
forceSSL = true;
|
||||
|
@ -245,10 +245,16 @@ ACTION=="add", SUBSYSTEM=="tty", \
|
|||
};
|
||||
};
|
||||
|
||||
services.homu = {
|
||||
enable = true;
|
||||
config = "/etc/nixos/secret/homu.toml";
|
||||
};
|
||||
# services.homu = {
|
||||
# enable = true;
|
||||
# # See https://github.com/servo/homu/blob/master/cfg.sample.toml
|
||||
# config = {
|
||||
# max_priority = 9001;
|
||||
# github = {
|
||||
# access_token = "...";
|
||||
# };
|
||||
# };
|
||||
# };
|
||||
|
||||
# This value determines the NixOS release with which your system is to be
|
||||
# compatible, in order to avoid breaking some software such as database
|
||||
|
|
|
@ -2,7 +2,40 @@
|
|||
with lib;
|
||||
let
|
||||
homu = pkgs.callPackage ./pkg.nix {};
|
||||
|
||||
toToml = key: value:
|
||||
let valueString =
|
||||
if builtins.isString value
|
||||
then "\"" + (builtins.replaceStrings ["\"" "\\"] ["\\\"" "\\\\"] value) + "\""
|
||||
else toString value;
|
||||
in "${key} = ${valueString}\n";
|
||||
|
||||
defaultConfig = {
|
||||
db = {
|
||||
file = "/var/db/homu/main.db";
|
||||
};
|
||||
};
|
||||
cfg = config.services.homu;
|
||||
homuConfig = defaultConfig // cfg.config;
|
||||
configFilter = f:
|
||||
filterAttrs (key: value: f value) homuConfig;
|
||||
topLevelConfig =
|
||||
configFilter (value: ! builtins.isAttrs value);
|
||||
configSections =
|
||||
configFilter (value: builtins.isAttrs value);
|
||||
|
||||
configFile = builtins.toFile "config.toml" (
|
||||
builtins.concatStringsSep "" (
|
||||
(attrsets.mapAttrsToList toToml topLevelConfig) ++
|
||||
(builtins.concatLists (attrsets.mapAttrsToList
|
||||
(sectionName: sectionConfig:
|
||||
[ "[${sectionName}]\n" ] ++
|
||||
(attrsets.mapAttrsToList toToml sectionConfig)
|
||||
) configSections)
|
||||
))
|
||||
);
|
||||
|
||||
dbDir = dirOf homuConfig.db.file;
|
||||
in
|
||||
|
||||
{
|
||||
|
@ -12,21 +45,16 @@ in
|
|||
default = false;
|
||||
description = "Enable the bot";
|
||||
};
|
||||
dbDir = mkOption {
|
||||
type = types.str;
|
||||
default = "/var/db/homu";
|
||||
description = "Path to the database file (use the same path in config.toml)";
|
||||
};
|
||||
config = mkOption {
|
||||
description = "Location of config.toml";
|
||||
type = types.str;
|
||||
description = "Structured data for config.toml";
|
||||
type = with types; attrsOf unspecified;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
users.users.homu = {
|
||||
group = "homu";
|
||||
home = cfg.dbDir;
|
||||
home = dbDir;
|
||||
createHome = true;
|
||||
};
|
||||
users.groups.homu = {};
|
||||
|
@ -37,7 +65,7 @@ in
|
|||
after = [ "network.target" ];
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
ExecStart = "${homu}/bin/homu -c ${cfg.config}";
|
||||
ExecStart = "${homu}/bin/homu -c ${configFile}";
|
||||
|
||||
Restart = "always";
|
||||
RestartSec = "5sec";
|
||||
|
|
Loading…
Reference in New Issue