drastikbot as a flake
This commit is contained in:
parent
43e31a8d2d
commit
ca6a2c1bef
@ -12,7 +12,6 @@
|
||||
./zerobin.nix
|
||||
./gitea.nix
|
||||
./privatebin/privatebin.nix
|
||||
./drastikbot.nix
|
||||
./radio.nix
|
||||
];
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.services.drastikbot;
|
||||
drastikbot = pkgs.python3Packages.buildPythonApplication rec {
|
||||
pname = "drastikbot";
|
||||
version = "v2.1";
|
||||
|
||||
format = "other";
|
||||
|
||||
srcs = [
|
||||
config.inputs.drastikbot
|
||||
config.inputs.drastikbot_modules
|
||||
config.inputs.dailybuild_modules
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||
|
||||
phases = [ "installPhase" ]; # Removes all phases except installPhase
|
||||
|
||||
installPhase = ''
|
||||
arr=($srcs)
|
||||
mkdir -p $out/irc/modules
|
||||
cp -r ''${arr[0]}/src/* $out/
|
||||
cp -r ''${arr[1]}/* $out/irc/modules
|
||||
cp -r ''${arr[2]}/* $out/irc/modules
|
||||
|
||||
sed -i 's|\(http://drastik.org/drastikbot"\)|\1 " https://git.neet.dev/zuckerberg/dailybuild_modules"|' $out/irc/modules/information.py
|
||||
sed -i 's|\(https://github.com/olagood/drastikbot_modules\\x0F"\)|\1 " : \\x0311https://git.neet.dev/zuckerberg/dailybuild_modules\\x0F"|' $out/irc/modules/information.py
|
||||
sed -i 's|AppID = "Enter your AppID here"|import pathlib\nAppID = pathlib.Path("${cfg.wolframAppIdFile}").read_text()|' $out/irc/modules/wolframalpha.py
|
||||
|
||||
makeWrapper ${pkgs.python3}/bin/python3 $out/drastikbot \
|
||||
--prefix PYTHONPATH : ${with pkgs.python3Packages; makePythonPath [requests beautifulsoup4]} \
|
||||
--add-flags "$out/drastikbot.py"
|
||||
'';
|
||||
};
|
||||
in {
|
||||
options.services.drastikbot = {
|
||||
enable = lib.mkEnableOption "enable drastikbot";
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "drastikbot";
|
||||
description = ''
|
||||
The user drastikbot should run as
|
||||
'';
|
||||
};
|
||||
group = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "drastikbot";
|
||||
description = ''
|
||||
The group drastikbot should run as
|
||||
'';
|
||||
};
|
||||
dataDir = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "/var/lib/drastikbot";
|
||||
description = ''
|
||||
Path to the drastikbot data directory
|
||||
'';
|
||||
};
|
||||
wolframAppIdFile = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
The file containing the Wolfram Alpha App ID
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
users.users.${cfg.user} = {
|
||||
isSystemUser = true;
|
||||
group = cfg.group;
|
||||
home = cfg.dataDir;
|
||||
createHome = true;
|
||||
};
|
||||
users.groups.${cfg.group} = {};
|
||||
systemd.services.drastikbot = {
|
||||
enable = true;
|
||||
after = ["network.target"];
|
||||
wantedBy = ["multi-user.target"];
|
||||
serviceConfig.ExecStart = "${drastikbot}/drastikbot -c ${cfg.dataDir}";
|
||||
serviceConfig.User = cfg.user;
|
||||
serviceConfig.Group = cfg.group;
|
||||
preStart = ''
|
||||
mkdir -p ${cfg.dataDir}
|
||||
chown ${cfg.user} ${cfg.dataDir}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
60
flake.lock
generated
60
flake.lock
generated
@ -37,13 +37,18 @@
|
||||
}
|
||||
},
|
||||
"dailybuild_modules": {
|
||||
"flake": false,
|
||||
"inputs": {
|
||||
"drastikbot": "drastikbot",
|
||||
"drastikbot_modules": "drastikbot_modules",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1633210754,
|
||||
"narHash": "sha256-jBIE07mLsF+qHoa/CQLSRipvfNSivgbuWUatI6Wwy0s=",
|
||||
"lastModified": 1648509055,
|
||||
"narHash": "sha256-y8AXfcbkAqn9UcfnfQz1MisT4YIXxj2I6P7uMnqMn9E=",
|
||||
"ref": "master",
|
||||
"rev": "e6a1c8686dad46b7847a5c690107a48fc20a6a29",
|
||||
"revCount": 9,
|
||||
"rev": "82f4cddc27be4370f321a8d758db1b35c2ce28e5",
|
||||
"revCount": 11,
|
||||
"type": "git",
|
||||
"url": "https://git.neet.dev/zuckerberg/dailybuild_modules.git"
|
||||
},
|
||||
@ -87,6 +92,21 @@
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1648297722,
|
||||
"narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"locked": {
|
||||
"lastModified": 1620759905,
|
||||
"narHash": "sha256-WiyWawrgmyN0EdmiHyG2V+fqReiVi8bM9cRdMaKQOFg=",
|
||||
@ -103,16 +123,16 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1646675913,
|
||||
"narHash": "sha256-ZvGf51XpXM7JojKLZ5yI0XLUq8UOFX6AwZ3bhtdcpIo=",
|
||||
"lastModified": 1638239011,
|
||||
"narHash": "sha256-AjhmbT4UBlJWqxY0ea8a6GU2C2HdKUREkG43oRr3TZg=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9b1c7ba323732ddc85a51850a7f10ecc5269b8e9",
|
||||
"rev": "a7ecde854aee5c4c7cd6177f54a99d2c1ff28a31",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-21.11",
|
||||
"ref": "21.11",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
@ -132,9 +152,25 @@
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1646675913,
|
||||
"narHash": "sha256-ZvGf51XpXM7JojKLZ5yI0XLUq8UOFX6AwZ3bhtdcpIo=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9b1c7ba323732ddc85a51850a7f10ecc5269b8e9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-21.11",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"radio": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
@ -174,9 +210,7 @@
|
||||
"inputs": {
|
||||
"agenix": "agenix",
|
||||
"dailybuild_modules": "dailybuild_modules",
|
||||
"drastikbot": "drastikbot",
|
||||
"drastikbot_modules": "drastikbot_modules",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"radio": "radio",
|
||||
"radio-web": "radio-web",
|
||||
"simple-nixos-mailserver": "simple-nixos-mailserver"
|
||||
|
@ -18,12 +18,7 @@
|
||||
radio-web.flake = false;
|
||||
|
||||
# drastikbot
|
||||
drastikbot.url = "github:olagood/drastikbot/v2.1";
|
||||
drastikbot.flake = false;
|
||||
drastikbot_modules.url = "github:olagood/drastikbot_modules/v2.1";
|
||||
drastikbot_modules.flake = false;
|
||||
dailybuild_modules.url = "git+https://git.neet.dev/zuckerberg/dailybuild_modules.git";
|
||||
dailybuild_modules.flake = false;
|
||||
};
|
||||
|
||||
outputs = inputs: {
|
||||
@ -39,6 +34,7 @@
|
||||
./common
|
||||
inputs.simple-nixos-mailserver.nixosModule
|
||||
inputs.agenix.nixosModules.age
|
||||
inputs.dailybuild_modules.nixosModule
|
||||
({ lib, ... }: {
|
||||
config.environment.systemPackages = [ inputs.agenix.defaultPackage.${system} ];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user