mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-10-05 03:57:58 +03:00
Merge pull request #334559 from litchipi/ifm_fixup
ifm-web: init at 4.0.2
This commit is contained in:
commit
d38f701636
@ -83,7 +83,7 @@
|
|||||||
|
|
||||||
- [Misskey](https://misskey-hub.net/en/), an interplanetary microblogging platform. Available as [services.misskey](options.html#opt-services.misskey).
|
- [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).
|
- [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
|
let
|
||||||
cfg = config.services.ifm;
|
cfg = config.services.ifm;
|
||||||
|
in
|
||||||
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 {
|
|
||||||
options.services.ifm = {
|
options.services.ifm = {
|
||||||
enable = lib.mkEnableOption ''
|
enable = lib.mkEnableOption ''
|
||||||
Improved file manager, a single-file web-based filemanager
|
Improved file manager, a single-file web-based filemanager
|
||||||
|
|
||||||
Lightweight and minimal, served using PHP's built-in server
|
Lightweight and minimal, served using PHP's built-in server
|
||||||
'';
|
'';
|
||||||
|
|
||||||
dataDir = lib.mkOption {
|
dataDir = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
@ -37,7 +35,7 @@ in {
|
|||||||
|
|
||||||
settings = lib.mkOption {
|
settings = lib.mkOption {
|
||||||
type = with lib.types; attrsOf anything;
|
type = with lib.types; attrsOf anything;
|
||||||
default = {};
|
default = { };
|
||||||
description = ''
|
description = ''
|
||||||
Configuration of the IFM service.
|
Configuration of the IFM service.
|
||||||
|
|
||||||
@ -58,21 +56,15 @@ in {
|
|||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
IFM_ROOT_DIR = "/data";
|
|
||||||
} // (builtins.mapAttrs (_: val: toString val) cfg.settings);
|
} // (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 = {
|
serviceConfig = {
|
||||||
DynamicUser = true;
|
DynamicUser = true;
|
||||||
User = "ifm";
|
User = "ifm";
|
||||||
StandardOutput = "journal";
|
StandardOutput = "journal";
|
||||||
BindPaths = "${cfg.dataDir}:/data";
|
BindPaths = "${cfg.dataDir}:/data";
|
||||||
PrivateTmp = true;
|
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