ifm-web: init at 4.0.2
Signed-off-by: Litchi Pi <litchi.pi@proton.me>
This commit is contained in:
parent
2f6604d82a
commit
ef03964b92
@ -79,7 +79,7 @@
|
||||
|
||||
- [Misskey](https://misskey-hub.net/en/), an interplanetary microblogging platform. Available as [services.misskey](options.html#opt-services.misskey).
|
||||
|
||||
- [Improved File Manager](https://github.com/misterunknown/ifm), or IFM, a single-file web-based file manager.
|
||||
- [Improved File Manager](https://github.com/misterunknown/ifm), or IFM, a single-file web-based file manager. Available as [services.ifm](options.html#opt-services.ifm.enable)
|
||||
|
||||
- [OpenGFW](https://github.com/apernet/OpenGFW), an implementation of the Great Firewall on Linux. Available as [services.opengfw](#opt-services.opengfw.enable).
|
||||
|
||||
|
@ -1,21 +1,19 @@
|
||||
{ config, lib, pkgs, ...}:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.services.ifm;
|
||||
|
||||
version = "4.0.2";
|
||||
src = pkgs.fetchurl {
|
||||
url = "https://github.com/misterunknown/ifm/releases/download/v${version}/cdn.ifm.php";
|
||||
hash = "sha256-37WbRM6D7JGmd//06zMhxMGIh8ioY8vRUmxX4OHgqBE=";
|
||||
};
|
||||
|
||||
php = pkgs.php83;
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.services.ifm = {
|
||||
enable = lib.mkEnableOption ''
|
||||
Improved file manager, a single-file web-based filemanager
|
||||
|
||||
Lightweight and minimal, served using PHP's built-in server
|
||||
'';
|
||||
'';
|
||||
|
||||
dataDir = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
@ -37,7 +35,7 @@ in {
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = with lib.types; attrsOf anything;
|
||||
default = {};
|
||||
default = { };
|
||||
description = ''
|
||||
Configuration of the IFM service.
|
||||
|
||||
@ -58,21 +56,15 @@ in {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
environment = {
|
||||
IFM_ROOT_DIR = "/data";
|
||||
} // (builtins.mapAttrs (_: val: toString val) cfg.settings);
|
||||
|
||||
script = ''
|
||||
mkdir -p /tmp/ifm
|
||||
ln -s ${src} /tmp/ifm/index.php
|
||||
${lib.getExe php} -S ${cfg.listenAddress}:${builtins.toString cfg.port} -t /tmp/ifm
|
||||
'';
|
||||
|
||||
serviceConfig = {
|
||||
DynamicUser = true;
|
||||
User = "ifm";
|
||||
StandardOutput = "journal";
|
||||
BindPaths = "${cfg.dataDir}:/data";
|
||||
PrivateTmp = true;
|
||||
ExecStart = "${lib.getExe pkgs.ifm-web} ${lib.escapeShellArg cfg.listenAddress} ${builtins.toString cfg.port} /data";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
55
pkgs/by-name/if/ifm-web/package.nix
Normal file
55
pkgs/by-name/if/ifm-web/package.nix
Normal file
@ -0,0 +1,55 @@
|
||||
{
|
||||
fetchurl,
|
||||
stdenv,
|
||||
lib,
|
||||
php83,
|
||||
writeShellScript,
|
||||
nixosTests,
|
||||
}:
|
||||
let
|
||||
version = "4.0.2";
|
||||
src = fetchurl {
|
||||
url = "https://github.com/misterunknown/ifm/releases/download/v${version}/cdn.ifm.php";
|
||||
hash = "sha256-37WbRM6D7JGmd//06zMhxMGIh8ioY8vRUmxX4OHgqBE=";
|
||||
};
|
||||
|
||||
serve_script = writeShellScript "ifm-serve" ''
|
||||
if [ $# -ne 3 ]; then
|
||||
echo "Usage: $0 <listen address> <port> <data directory>";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
SERVE_DIR=$(dirname "$0")/../php/
|
||||
IFM_ROOT_DIR="$3" ${lib.getExe php83} -S "$1:$2" -t "$SERVE_DIR"
|
||||
'';
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "ifm";
|
||||
inherit version src;
|
||||
|
||||
dontUnpack = true;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p $out/bin $out/php
|
||||
cp $src $out/php/index.php
|
||||
cp ${serve_script} $out/bin/ifm
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
passthru.tests = {
|
||||
inherit (nixosTests) ifm;
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "Improved File Manager, a single-file web-based filemanager";
|
||||
longDescription = ''
|
||||
The IFM is a web-based filemanager, which comes as a single file solution using HTML5, CSS3, JavaScript and PHP.
|
||||
'';
|
||||
homepage = "https://github.com/misterunknown/ifm";
|
||||
changelog = "https://github.com/misterunknown/ifm/releases/tag/v${version}";
|
||||
license = lib.licenses.mit;
|
||||
maintainers = with lib.maintainers; [ litchipi ];
|
||||
mainProgram = "ifm";
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user