2025-01-23 00:01:01 +00:00
|
|
|
{
|
|
|
|
stdenv,
|
|
|
|
lib,
|
|
|
|
buildNpmPackage,
|
|
|
|
fetchFromGitHub,
|
2025-03-23 04:41:20 +00:00
|
|
|
makeWrapper,
|
2025-01-23 00:01:01 +00:00
|
|
|
nix-update-script,
|
2025-03-23 04:41:20 +00:00
|
|
|
versionCheckHook,
|
|
|
|
libsecret,
|
|
|
|
nodejs,
|
|
|
|
perl,
|
|
|
|
pkg-config,
|
2025-01-23 00:01:01 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildNpmPackage (finalAttrs: {
|
|
|
|
pname = "filen-cli";
|
2025-05-06 08:38:11 +00:00
|
|
|
version = "0.0.34";
|
2025-01-23 00:01:01 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "FilenCloudDienste";
|
|
|
|
repo = "filen-cli";
|
|
|
|
tag = "v${finalAttrs.version}";
|
2025-05-06 08:38:11 +00:00
|
|
|
hash = "sha256-iISW9EAk8haWUCh9I8qHhrBKLqHeBUC8sWA0MnXqQSA=";
|
2025-01-23 00:01:01 +00:00
|
|
|
};
|
|
|
|
|
2025-05-06 08:38:11 +00:00
|
|
|
npmDepsHash = "sha256-0DpiUjUFc0ThzP6/qrSEebKDq2fnr/CpcmtPFaIVHhU=";
|
2025-03-23 04:41:20 +00:00
|
|
|
|
|
|
|
inherit nodejs;
|
|
|
|
|
|
|
|
env.npm_config_build_from_source = "true";
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
makeWrapper
|
|
|
|
pkg-config # for keytar
|
|
|
|
]
|
|
|
|
++ lib.optionals stdenv.buildPlatform.isDarwin [
|
|
|
|
# for utf-8-validate
|
|
|
|
# https://github.com/websockets/utf-8-validate/blob/1439ad4cdf99d421084ae3a5f81e2cf43199a690/binding.gyp#L17
|
|
|
|
perl
|
|
|
|
];
|
|
|
|
|
|
|
|
# for keytar
|
2025-04-14 09:29:14 -04:00
|
|
|
buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ libsecret ];
|
2025-01-23 00:01:01 +00:00
|
|
|
|
|
|
|
postPatch = ''
|
2025-03-23 04:41:20 +00:00
|
|
|
# The version string is substituted during publishing:
|
2025-01-23 00:01:01 +00:00
|
|
|
# https://github.com/FilenCloudDienste/filen-cli/blob/c7d5eb2a2cd6d514321992815f16475f6909af36/.github/workflows/build-and-publish.yml#L24
|
|
|
|
substituteInPlace package.json \
|
2025-03-23 04:41:20 +00:00
|
|
|
--replace-fail '"version": "0.0.0"' '"version": "${finalAttrs.version}"' \
|
|
|
|
--replace-fail '\"--external:*keytar.node\" --external:keytar' \
|
|
|
|
'--loader:.node=copy'
|
2025-01-23 00:01:01 +00:00
|
|
|
'';
|
|
|
|
|
2025-03-23 04:41:20 +00:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
mkdir -p $out/bin $out/lib
|
|
|
|
install -T -m755 dist/bundle.js $out/lib/index.js
|
|
|
|
install -D -m755 dist/*.node $out/lib
|
|
|
|
install -D -m644 package.json $out/lib
|
|
|
|
makeWrapper "${lib.getExe nodejs}" $out/bin/filen \
|
|
|
|
--add-flags $out/lib/index.js
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
2025-01-23 00:01:01 +00:00
|
|
|
|
|
|
|
nativeInstallCheckInputs = [ versionCheckHook ];
|
|
|
|
versionCheckProgram = "${placeholder "out"}/bin/filen";
|
2025-04-05 14:02:09 +02:00
|
|
|
versionCheckProgramArg = "--version";
|
2025-01-23 00:01:01 +00:00
|
|
|
|
|
|
|
# Writes $HOME/Library/Application Support on darwin
|
|
|
|
doInstallCheck = !stdenv.hostPlatform.isDarwin;
|
|
|
|
|
|
|
|
passthru.updateScript = nix-update-script {
|
|
|
|
extraArgs = [ "--version-regex=^v([0-9.]+)$" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "CLI tool for interacting with the Filen cloud";
|
|
|
|
homepage = "https://github.com/FilenCloudDienste/filen-cli";
|
|
|
|
changelog = "https://github.com/FilenCloudDienste/filen-cli/releases/tag/v${finalAttrs.version}";
|
|
|
|
license = lib.licenses.agpl3Only;
|
|
|
|
maintainers = with lib.maintainers; [ eilvelia ];
|
|
|
|
mainProgram = "filen";
|
|
|
|
};
|
|
|
|
})
|