Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

photoprism: init at 2020-09-21 #99016

Closed
wants to merge 1 commit into from
Closed

Conversation

Sohalt
Copy link
Contributor

@Sohalt Sohalt commented Sep 28, 2020

Motivation for this change

Closes #96043

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

stripRoot = false;
};

nasnet = fetchModel {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fetches the pretrained tensorflow models for classifying images.
The models don't have a stable URL, so I'm not sure how to best handle that. We could upload the models to archive.org.
In addition the models are quite large (~40MB and ~90MB), so I'm not sure if we should include them in the derivation at all.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The size of the models doesn't bother me particularly. You could also add an optional argument to the derivation to enable/disable them as well. But you're right, we'd need a stable URL


inherit pname version;

buildInputs = [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are only needed at runtime and can be specified with a commandline flag, environment variable, or config entry.
We probably don't need them here then?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I don't think they would have any effect here.

One alternative would be to patch the default path in the source to explicitly refer to the path to the tool from nixpkgs. E.g. ffmpeg here: https://github.com/photoprism/photoprism/blob/46b9239026bae49a3ae2dbb57b0a374750d6f9e2/internal/config/filenames.go#L241

Currently, adding video files fails if I don't have ffmpeg in my PATH or pass it in the commandline / env vars.

Copy link
Contributor Author

@Sohalt Sohalt Oct 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any opinion on what would be cleaner?

  • patching the source
  • creating a wrapper with the proper PATH
  • creating a wrapper that passes the commandline args
  • not doing this in the derivation at all, but instead in the module

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think creating a wrapper is maybe nicer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there's a commandline flag for this in photoprism, might as well use it, feels cleaner indeed

@@ -0,0 +1,8 @@
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p nodePackages.node2nix
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This currently needs a development build of https://github.com/svanderburg/node2nix because it depends on svanderburg/node2nix#199

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR you mentioned was merged. Waiting for a release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's the general question, if we want to keep the node2nix approach or rather use https://github.com/tweag/npmlock2nix
I've briefly tried to make the change, but failed.

@Sohalt Sohalt mentioned this pull request Sep 28, 2020

mkdir -p $out/{bin,assets}
# install backend
cp ${backend}/bin/photoprism $out/bin/photoprism
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When launching the frontend you currently need to specify the path to the assets. This should probably be done automatically with a wrapper.

@danielfullmer
Copy link
Contributor

I have the following error when trying to build this:

unpacking source archive /nix/store/yfxwlbc1r7k62y4k1v5hc5g9vd6xdlbz-wrap-ansi-5.1.0.tgz
unpacking source archive /nix/store/c5mrzczb3k2j5n8387wiqn12lqvz8w1j-yargs-14.2.3.tgz
unpacking source archive /nix/store/llms5dwk7sv6fcfcm1hjwg1n56md09p9-yargs-parser-15.0.1.tgz
unpacking source archive /nix/store/ldjjxy75frr4acjywaggs00mpdpqzvc2-yauzl-2.10.0.tgz
unpacking source archive /nix/store/lbb37yhx0sdqzp6aswllfw37y7m3llp4-yeast-0.1.2.tgz
cp: cannot stat '/nix/store/dmy4bwy0as5xl4l0zh424viypi8viz0a-photoprism/package.json': No such file or directory
error: --- Error --- nix-daemon
builder for '/nix/store/mzwzf5ivgp5larzmbhrv3y6pvpgn5yn3-node-dependencies-photoprism-1.0.0.drv' failed with exit code 1; last 10 log lines:

@Sohalt
Copy link
Contributor Author

Sohalt commented Oct 2, 2020

@danielfullmer sorry, I forget to push the package.json. Can you try again?

@andir
Copy link
Member

andir commented Oct 3, 2020

Nice to see more people that are using photoprism in the Nix community! I've for a few months now had a private module for that https://github.com/andir/infra/blob/master/config/modules/photoprism.nix as well as an expression to package it: https://github.com/andir/infra/blob/master/nix/packages/photoprism/default.nix . Maybe this can be of value for this work here.

I didn't consider adding it to nixpkgs as I really dislike generating Nix code and checking that into the repo. I instead built (at first ranz2nix (https://github.com/andir/ranz2nix/ which eventually to) npmlock2nix which only requires the lock files and no generated nix expressions.

I'll try to give this PR a review in the next days as that would remove the sole maintenance burden from me. Thank you for the work so far! 👍

@Sohalt
Copy link
Contributor Author

Sohalt commented Oct 3, 2020

@andir thanks! As said, I sadly didn't see your work before starting this. I think your derivation is a bunch cleaner than mine. I wanted to incorporate some of your approach into this PR (or maybe just get your stuff upstreamed instead?) I just didn't get around to it yet.
I agree that npmlock2nix seems cleaner than having all the node2nix generated stuff. Would be nice to see that adopted more throughout nixpkgs.

Copy link
Contributor

@danielfullmer danielfullmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this package out briefly. Seems to be mostly working, but requires setting a number of env vars / command line args that could probably be handled automatically. I'd also be interested in a NixOS module that makes this trivial to set up. Thanks for the work thus far!


inherit pname version;

buildInputs = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I don't think they would have any effect here.

One alternative would be to patch the default path in the source to explicitly refer to the path to the tool from nixpkgs. E.g. ffmpeg here: https://github.com/photoprism/photoprism/blob/46b9239026bae49a3ae2dbb57b0a374750d6f9e2/internal/config/filenames.go#L241

Currently, adding video files fails if I don't have ffmpeg in my PATH or pass it in the commandline / env vars.

stripRoot = false;
};

nasnet = fetchModel {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The size of the models doesn't bother me particularly. You could also add an optional argument to the derivation to enable/disable them as well. But you're right, we'd need a stable URL

@Sohalt
Copy link
Contributor Author

Sohalt commented Nov 12, 2020

@andir I've tried to adapt your derivation to use npmlock2nix, but failed (When I try to set packageLockJson to src + "/frontend/package-lock.json" I get /nix/store/ib6rys6q6pybfll90pdm4z3gzh2bhm95-source/frontend/package-lock.json must a path). Do you think you can find the time to upstream your version? Not sure, if I can be of any help, but if you think so, just ping me.

@@ -0,0 +1,127 @@
{ lib
, pkgs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't pass in pkgs and you only need stdenv and not stdenv and lib.

pushd frontend
ln -s ${nodeDependencies}/lib/node_modules ./node_modules
export PATH="${nodeDependencies}/bin:$PATH"
NODE_ENV=production npm run build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we set this globally?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is only required for the build of the static files.

description = "Personal Photo Management powered by Go and Google TensorFlow ";
platforms = platforms.linux;
license = licenses.agpl3;
maintainers = with maintainers; [ ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add yourself as a maintainer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to add me as well. I'm using this actively and wouldn't mind having a look at this every now and then.

@@ -0,0 +1,8 @@
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p nodePackages.node2nix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR you mentioned was merged. Waiting for a release.

@stale
Copy link

stale bot commented Jun 3, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 3, 2021
@polynomial
Copy link
Contributor

Found this, thankfully before starting my own. Guess I will now see what it takes to get both this and/or andir's running. Thanks to everyone who provided this(@andir @Sohalt ). I will now attempt to stand on the toes of giants.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 9, 2021
@makefu
Copy link
Contributor

makefu commented Jul 24, 2021

any chance to ever get a working photoprism package in nixpkgs?

}:

let
version = "2020-09-21";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
version = "2020-09-21";
version = "unstable-2020-09-21";

runHook postInstall
'';

meta = with stdenv.lib; {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
meta = with stdenv.lib; {
meta = with lib; {

@mbrgm
Copy link
Member

mbrgm commented Jul 30, 2021

@Sohalt @polynomial Are you going to to tackle this anytime soon? I'm desperately waiting for non-dockered photoprism in nixpkgs and would postpone my own efforts if this PR will be merged soon.

import ./node-packages.nix {
inherit (pkgs) fetchurl fetchgit;
inherit nodeEnv;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing final new line.

@Sohalt
Copy link
Contributor Author

Sohalt commented Aug 4, 2021

@Sohalt @polynomial Are you going to to tackle this anytime soon? I'm desperately waiting for non-dockered photoprism in nixpkgs and would postpone my own efforts if this PR will be merged soon.

I won't have time in the immediate future, but am hoping to get this done before November, if nobody else does it until then.

@aanderse
Copy link
Member

aanderse commented Dec 9, 2021

ping @Sohalt - any chance you're going to tackle this again?

@Sohalt
Copy link
Contributor Author

Sohalt commented Dec 9, 2021

I've had another look at this but I don't really like the node2nix approach, because it generates so many intermediary files. I'd prefer using npmlock2nix, but that cannot be included in nixpkgs. In the meantime I found a flake at https://github.com/GTrunSec/photoprism2nix, which I might improve on. If someone else want's to continue this effort here, feel free.

@Sohalt Sohalt closed this Dec 9, 2021
@pinpox
Copy link
Member

pinpox commented Jan 27, 2022

In the meantime I found a flake at https://github.com/GTrunSec/photoprism2nix, which I might improve on.

Did you end up using that flake? It seems to be unmaintained or at least not get many updates. I'm looking for a good solution on how to run photoprism on nixOS and not sure where to go from here.

@Sohalt
Copy link
Contributor Author

Sohalt commented Jan 27, 2022

I've started to implement some adjustments at https://github.com/Sohalt/photoprism2nix/, but left it in a rough state and didn't deploy it yet, because I'm waiting on the multi-user support in photoprism to land first. That should hopefully happen in Q1 of 2022.

@pinpox
Copy link
Member

pinpox commented Jan 28, 2022

Thanks, I'll keep an eye on that repository. Had not noticed that multi user support is still missing, that is definitely a dealbreaker for me. Not sure what the alternatives are for now, everything seems either unmaintained or rudimentary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Package Photoprism
10 participants