ghidra-server: create admin cli bin

This commit is contained in:
xenia 2024-04-09 16:38:40 -04:00
parent 636d3d98a6
commit 787ae9af8e
2 changed files with 27 additions and 1 deletions

View File

@ -1,6 +1,11 @@
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.services.ghidra-server; in {
let
cfg = config.services.ghidra-server;
adminCli = pkgs.callPackage ../../pkgs/ghidra-server-cli {
inherit (cfg) package jdkPackage directory;
};
in {
options.services.ghidra-server = {
enable = mkEnableOption "ghidra-server";
enableAdminCli = mkEnableOption "ghidra-svrAdmin";
@ -80,5 +85,6 @@ let cfg = config.services.ghidra-server; in {
};
wantedBy = ["multi-user.target"];
};
environment.systemPackages = optionals cfg.enableAdminCli [ adminCli ];
};
}

View File

@ -0,0 +1,20 @@
{
writeShellScriptBin,
writeText,
directory,
jdkPackage,
package
}:
let
server_conf = writeText "server.conf" "ghidra.repositories.dir=${directory}/repositories";
in writeShellScriptBin "ghidra-svrAdmin" ''
exec ${jdkPackage}/bin/java \
-cp ${package}/lib/ghidra/Ghidra/Framework/Utility/lib/Utility.jar \
-Djava.system.class.loader=ghidra.GhidraClassLoader \
-Dfile.encoding=UTF8 \
-Duser.country=US -Duser.language=en -Duser.variant= \
-Xshare:off ghidra.Ghidra ghidra.server.ServerAdmin \
${server_conf} "$@"
''