nixpkgs/pkgs/by-name/ph/photofield/package.nix
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

82 lines
1.6 KiB
Nix

{ lib
, fetchFromGitHub
, buildGo122Module
, buildNpmPackage
, makeWrapper
, exiftool
, ffmpeg
, testers
, photofield
, nix-update-script
}:
let
version = "0.17.0";
src = fetchFromGitHub {
owner = "SmilyOrg";
repo = "photofield";
rev = "refs/tags/v${version}";
hash = "sha256-GYU0BR5X3s3SGmZEFMyK7m+zUa2i2E9krAbtk8dwPdg=";
};
webui = buildNpmPackage {
inherit src version;
pname = "photofield-ui";
sourceRoot = "${src.name}/ui";
npmDepsHash = "sha256-ULl4wHEo/PP0Y0O5po7eRDd+T/UjkZhQGIj262WFtFU=";
installPhase = ''
mkdir -p $out/share
mv dist $out/share/photofield-ui
'';
};
in
buildGo122Module {
pname = "photofield";
inherit version src;
vendorHash = "sha256-eN9syG9/QUA8yut3LaeIb+xlaNUvRAFspyqcCHv6oSA=";
preBuild = ''
cp -r ${webui}/share/photofield-ui ui/dist
'';
ldflags = [
"-s"
"-w"
"-X main.version=${version}"
"-X main.builtBy=Nix"
];
tags = [ "embedui" ];
doCheck = false; # tries to modify filesytem
nativeBuildInputs = [ makeWrapper ];
postInstall = ''
wrapProgram $out/bin/photofield \
--prefix PATH : "${lib.makeBinPath [exiftool ffmpeg]}"
'';
passthru = {
updateScript = nix-update-script { };
tests.version = testers.testVersion {
package = photofield;
command = "photofield -version";
};
};
meta = with lib; {
description = "Experimental fast photo viewer";
homepage = "https://github.com/SmilyOrg/photofield";
license = licenses.mit;
mainProgram = "photofield";
maintainers = with maintainers; [ dit7ya ];
};
}