mirror of
https://github.com/anotherhadi/default-creds-web.git
synced 2026-10-05 10:58:24 +02:00
split default-creds/default-creds-web
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{
|
||||
description = "default-creds – Open-source default credentials database";
|
||||
description = "default-creds-web: Web frontend for the default-creds credentials database";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
@@ -20,8 +20,8 @@
|
||||
|
||||
bun2nixPkg = bun2nix.packages.${system}.default;
|
||||
|
||||
default-creds = pkgs.stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "default-creds";
|
||||
default-creds-web = pkgs.stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "default-creds-web";
|
||||
version = "1.0.0";
|
||||
|
||||
src = ./.;
|
||||
@@ -44,36 +44,36 @@
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/share/default-creds/src
|
||||
mkdir -p $out/share/default-creds-web
|
||||
|
||||
cp -r dist $out/share/default-creds/dist
|
||||
cp -r src/data $out/share/default-creds/src/data
|
||||
cp package.json $out/share/default-creds/package.json
|
||||
cp -r node_modules $out/share/default-creds/node_modules
|
||||
cp -r dist $out/share/default-creds-web/dist
|
||||
cp package.json $out/share/default-creds-web/package.json
|
||||
cp -r node_modules $out/share/default-creds-web/node_modules
|
||||
|
||||
mkdir -p $out/bin
|
||||
cat > $out/bin/default-creds << EOF
|
||||
cat > $out/bin/default-creds-web << EOF
|
||||
#!/bin/sh
|
||||
export HOST="\''${HOST:-127.0.0.1}"
|
||||
export PORT="\''${PORT:-4321}"
|
||||
exec ${pkgs.nodejs}/bin/node $out/share/default-creds/dist/server/entry.mjs
|
||||
export PATH="${pkgs.git}/bin:\$PATH"
|
||||
exec ${pkgs.nodejs}/bin/node $out/share/default-creds-web/dist/server/entry.mjs
|
||||
EOF
|
||||
chmod +x $out/bin/default-creds
|
||||
chmod +x $out/bin/default-creds-web
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Open-source database of factory-set credentials";
|
||||
homepage = "https://github.com/anotherhadi/default-creds";
|
||||
description = "Web frontend for the default-creds credentials database";
|
||||
homepage = "https://github.com/anotherhadi/default-creds-web";
|
||||
license = pkgs.lib.licenses.mit;
|
||||
mainProgram = "default-creds";
|
||||
mainProgram = "default-creds-web";
|
||||
};
|
||||
});
|
||||
in {
|
||||
packages.${system} = {
|
||||
inherit default-creds;
|
||||
default = default-creds;
|
||||
inherit default-creds-web;
|
||||
default = default-creds-web;
|
||||
};
|
||||
|
||||
devShells.${system}.default = pkgs.mkShell {
|
||||
@@ -88,36 +88,52 @@
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
cfg = config.services.default-creds;
|
||||
cfg = config.services.default-creds-web;
|
||||
in {
|
||||
options.services.default-creds = {
|
||||
enable = lib.mkEnableOption "default-creds credential search service";
|
||||
options.services.default-creds-web = {
|
||||
enable = lib.mkEnableOption "default-creds-web credential search service";
|
||||
|
||||
port = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
default = 4321;
|
||||
description = "TCP port the service will listen on.";
|
||||
};
|
||||
|
||||
dataRepoUrl = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "https://github.com/anotherhadi/default-creds.git";
|
||||
description = "Git URL of the default-creds data repository to clone/pull.";
|
||||
};
|
||||
|
||||
dataSyncIntervalHours = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 6;
|
||||
description = "How often (in hours) to re-pull the data repository.";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
systemd.services.default-creds = {
|
||||
description = "default-creds – default credentials database";
|
||||
systemd.services.default-creds-web = {
|
||||
description = "default-creds-web – default credentials database";
|
||||
wantedBy = ["multi-user.target"];
|
||||
after = ["network.target"];
|
||||
|
||||
environment = {
|
||||
HOST = "127.0.0.1";
|
||||
PORT = toString cfg.port;
|
||||
DATA_REPO_URL = cfg.dataRepoUrl;
|
||||
DATA_SYNC_INTERVAL_HOURS = toString cfg.dataSyncIntervalHours;
|
||||
DATA_REPO_DIR = "/var/lib/default-creds-web/data-repo";
|
||||
};
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart = "${self.packages.${system}.default}/bin/default-creds";
|
||||
WorkingDirectory = "${self.packages.${system}.default}/share/default-creds";
|
||||
ExecStart = "${self.packages.${system}.default}/bin/default-creds-web";
|
||||
WorkingDirectory = "${self.packages.${system}.default}/share/default-creds-web";
|
||||
Restart = "on-failure";
|
||||
RestartSec = "5s";
|
||||
|
||||
DynamicUser = true;
|
||||
StateDirectory = "default-creds-web";
|
||||
|
||||
NoNewPrivileges = true;
|
||||
PrivateTmp = true;
|
||||
@@ -134,6 +150,6 @@
|
||||
};
|
||||
};
|
||||
|
||||
nixosModules.default-creds = self.nixosModules.default;
|
||||
nixosModules.default-creds-web = self.nixosModules.default;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user