parent
3fb6f96d13
commit
6d087046b8
4 changed files with 290 additions and 0 deletions
26
README.md
26
README.md
|
|
@ -47,6 +47,32 @@ On Alpine, `shadow` is needed for the user creation process during the install.
|
||||||
# xbps-install -S libxml2-devel libcurl-devel
|
# xbps-install -S libxml2-devel libcurl-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### NixOS
|
||||||
|
Add the flake to your inputs and import the module. That is all you need.
|
||||||
|
Here's an example of using the modules in a flake:
|
||||||
|
```nix
|
||||||
|
# flake.nix
|
||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
omnisearch = {
|
||||||
|
url = "git+https://git.bwaaa.monster/omnisearch";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, omnisearch, ... }: {
|
||||||
|
nixosConfigurations.mySystem = nixpkgs.lib.nixosSystem {
|
||||||
|
modules = [
|
||||||
|
omnisearch.nixosModules.default
|
||||||
|
{
|
||||||
|
services.omnisearch.enable = true;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### macOS (Homebrew)
|
### macOS (Homebrew)
|
||||||
```
|
```
|
||||||
$ brew install libxml2 curl openssl pkg-config
|
$ brew install libxml2 curl openssl pkg-config
|
||||||
|
|
|
||||||
46
flake.lock
generated
Normal file
46
flake.lock
generated
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"beaker-src": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1775244490,
|
||||||
|
"narHash": "sha256-4TJv7X6D0l4rEbTRKf47gU43L8G5uJgxxtsqMkVixQY=",
|
||||||
|
"ref": "refs/heads/master",
|
||||||
|
"rev": "3fab89ecf8f4c664477a82add660d28db87357b4",
|
||||||
|
"revCount": 27,
|
||||||
|
"shallow": false,
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.bwaaa.monster/beaker"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"shallow": false,
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.bwaaa.monster/beaker"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1773734432,
|
||||||
|
"narHash": "sha256-IF5ppUWh6gHGHYDbtVUyhwy/i7D261P7fWD1bPefOsw=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "cda48547b432e8d3b18b4180ba07473762ec8558",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"beaker-src": "beaker-src",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
76
flake.nix
Normal file
76
flake.nix
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
beaker-src = {
|
||||||
|
url = "git+https://git.bwaaa.monster/beaker?shallow=0";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
{
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
beaker-src,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
supportedSystems = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"aarch64-linux"
|
||||||
|
];
|
||||||
|
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt);
|
||||||
|
packages = forAllSystems (
|
||||||
|
system:
|
||||||
|
let
|
||||||
|
pkgs = import nixpkgs { inherit system; };
|
||||||
|
|
||||||
|
beaker = pkgs.stdenv.mkDerivation {
|
||||||
|
pname = "beaker";
|
||||||
|
version = "git";
|
||||||
|
src = beaker-src;
|
||||||
|
makeFlags = [
|
||||||
|
"INSTALL_PREFIX=$(out)/"
|
||||||
|
"LDCONFIG=true"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
default = pkgs.stdenv.mkDerivation {
|
||||||
|
pname = "omnisearch";
|
||||||
|
version = "git";
|
||||||
|
src = ./.;
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
|
pkgs.libxml2.dev
|
||||||
|
pkgs.curl.dev
|
||||||
|
pkgs.openssl
|
||||||
|
beaker
|
||||||
|
];
|
||||||
|
|
||||||
|
preBuild = ''
|
||||||
|
makeFlagsArray+=(
|
||||||
|
"PREFIX=$out"
|
||||||
|
"CFLAGS=-Wall -Wextra -O2 -Isrc -I${pkgs.libxml2.dev}/include/libxml2"
|
||||||
|
"LIBS=-lbeaker -lcurl -lxml2 -lpthread -lm -lssl -lcrypto"
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin $out/share/omnisearch
|
||||||
|
install -Dm755 bin/omnisearch $out/bin/omnisearch
|
||||||
|
cp -r templates static locales -t $out/share/omnisearch/
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "Lightweight metasearch engine in C";
|
||||||
|
platforms = pkgs.lib.platforms.linux;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
nixosModules.default = import ./module.nix self;
|
||||||
|
};
|
||||||
|
}
|
||||||
142
module.nix
Normal file
142
module.nix
Normal file
|
|
@ -0,0 +1,142 @@
|
||||||
|
self:
|
||||||
|
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.services.omnisearch;
|
||||||
|
pkg = cfg.package;
|
||||||
|
|
||||||
|
finalConfigFile =
|
||||||
|
if cfg.configFile != null then
|
||||||
|
cfg.configFile
|
||||||
|
else
|
||||||
|
pkgs.writeText "omnisearch.ini" ''
|
||||||
|
[server]
|
||||||
|
host = ${cfg.settings.server.host}
|
||||||
|
port = ${toString cfg.settings.server.port}
|
||||||
|
domain = ${cfg.settings.server.domain}
|
||||||
|
${lib.optionalString (cfg.settings.server.locale != null) "locale = ${cfg.settings.server.locale}"}
|
||||||
|
|
||||||
|
[proxy]
|
||||||
|
${lib.optionalString (cfg.settings.proxy.proxy != null) "proxy = \"${cfg.settings.proxy.proxy}\""}
|
||||||
|
${lib.optionalString (
|
||||||
|
cfg.settings.proxy.list_file != null
|
||||||
|
) "list_file = ${cfg.settings.proxy.list_file}"}
|
||||||
|
max_retries = ${toString cfg.settings.proxy.max_retries}
|
||||||
|
randomize_username = ${lib.boolToString cfg.settings.proxy.randomize_username}
|
||||||
|
randomize_password = ${lib.boolToString cfg.settings.proxy.randomize_password}
|
||||||
|
|
||||||
|
[cache]
|
||||||
|
dir = ${cfg.settings.cache.dir}
|
||||||
|
ttl_search = ${toString cfg.settings.cache.ttl_search}
|
||||||
|
ttl_infobox = ${toString cfg.settings.cache.ttl_infobox}
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.services.omnisearch = {
|
||||||
|
enable = lib.mkEnableOption "OmniSearch metasearch engine";
|
||||||
|
|
||||||
|
package = lib.mkOption {
|
||||||
|
type = lib.types.package;
|
||||||
|
default = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
||||||
|
description = "The omnisearch package to use.";
|
||||||
|
};
|
||||||
|
|
||||||
|
configFile = lib.mkOption {
|
||||||
|
type = lib.types.nullOr lib.types.path;
|
||||||
|
default = null;
|
||||||
|
description = "Path to a custom config.ini. Overrides 'settings'.";
|
||||||
|
};
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
server = {
|
||||||
|
host = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "0.0.0.0";
|
||||||
|
};
|
||||||
|
port = lib.mkOption {
|
||||||
|
type = lib.types.port;
|
||||||
|
default = 8087;
|
||||||
|
};
|
||||||
|
domain = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "http://localhost:${toString cfg.settings.server.port}";
|
||||||
|
};
|
||||||
|
locale = lib.mkOption {
|
||||||
|
type = lib.types.nullOr lib.types.str;
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
proxy = {
|
||||||
|
proxy = lib.mkOption {
|
||||||
|
type = lib.types.nullOr lib.types.str;
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
list_file = lib.mkOption {
|
||||||
|
type = lib.types.nullOr lib.types.str;
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
max_retries = lib.mkOption {
|
||||||
|
type = lib.types.int;
|
||||||
|
default = 3;
|
||||||
|
};
|
||||||
|
randomize_username = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
randomize_password = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
cache = {
|
||||||
|
dir = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "/var/cache/omnisearch";
|
||||||
|
};
|
||||||
|
ttl_search = lib.mkOption {
|
||||||
|
type = lib.types.int;
|
||||||
|
default = 3600;
|
||||||
|
};
|
||||||
|
ttl_infobox = lib.mkOption {
|
||||||
|
type = lib.types.int;
|
||||||
|
default = 86400;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
systemd.services.omnisearch = {
|
||||||
|
description = "OmniSearch Service";
|
||||||
|
after = [ "network.target" ];
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
ExecStart = "${pkg}/bin/omnisearch";
|
||||||
|
|
||||||
|
WorkingDirectory = "/var/lib/omnisearch";
|
||||||
|
StateDirectory = "omnisearch";
|
||||||
|
CacheDirectory = "omnisearch";
|
||||||
|
|
||||||
|
BindReadOnlyPaths = [
|
||||||
|
"${pkg}/share/omnisearch/templates:/var/lib/omnisearch/templates"
|
||||||
|
"${pkg}/share/omnisearch/static:/var/lib/omnisearch/static"
|
||||||
|
"${pkg}/share/omnisearch/locales:/var/lib/omnisearch/locales"
|
||||||
|
"${finalConfigFile}:/var/lib/omnisearch/config.ini"
|
||||||
|
];
|
||||||
|
|
||||||
|
DynamicUser = true;
|
||||||
|
ProtectSystem = "strict";
|
||||||
|
ProtectHome = true;
|
||||||
|
PrivateTmp = true;
|
||||||
|
Restart = "always";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue