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
Conversation
stripRoot = false; | ||
}; | ||
|
||
nasnet = fetchModel { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 = [ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danielfullmer @andir @SuperSandro2000 any opinions?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
||
mkdir -p $out/{bin,assets} | ||
# install backend | ||
cp ${backend}/bin/photoprism $out/bin/photoprism |
There was a problem hiding this comment.
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.
I have the following error when trying to build this:
|
@danielfullmer sorry, I forget to push the |
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 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! 👍 |
@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. |
There was a problem hiding this 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 = [ |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
@andir I've tried to adapt your derivation to use npmlock2nix, but failed (When I try to set |
@@ -0,0 +1,127 @@ | |||
{ lib | |||
, pkgs |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; [ ]; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
I marked this as stale due to inactivity. → More info |
any chance to ever get a working photoprism package in nixpkgs? |
}: | ||
|
||
let | ||
version = "2020-09-21"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version = "2020-09-21"; | |
version = "unstable-2020-09-21"; |
runHook postInstall | ||
''; | ||
|
||
meta = with stdenv.lib; { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meta = with stdenv.lib; { | |
meta = with lib; { |
@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; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing final new line.
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. |
ping @Sohalt - any chance you're going to tackle this again? |
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. |
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. |
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. |
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. |
Motivation for this change
Closes #96043
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)