-
Notifications
You must be signed in to change notification settings - Fork 819
Build nix packages from source #253
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
Open
toast003
wants to merge
11
commits into
9001:hovudstraum
Choose a base branch
from
toast003:nix-overhaul
base: hovudstraum
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+139
−98
Open
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9f6c983
nix: get source tarball with update.py
toast003 2bada04
nix: build from source
toast003 48dfd73
nix: remove unused code from update.py
toast003 ddecb19
nix: fix extra python packages
toast003 fe529da
nix: add optional dependencies
toast003 9858b71
nix: add partftpy package
toast003 6bd0172
nix: add tftp parameter to package
toast003 023f019
nix: enable pyproject for partftpy package
toast003 f356ef9
nix: replace partftpy overlay with real package
toast003 910e2e3
nix: add updater for partftpy
toast003 0f57518
nix: bring back local release pin to update.py
toast003 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
lib, | ||
stdenv, | ||
makeWrapper, | ||
buildPythonApplication, | ||
fetchurl, | ||
util-linux, | ||
python, | ||
setuptools, | ||
jinja2, | ||
impacket, | ||
pyopenssl, | ||
|
@@ -15,6 +15,10 @@ | |
pyzmq, | ||
ffmpeg, | ||
mutagen, | ||
pyftpdlib, | ||
magic, | ||
partftpy, | ||
fusepy, # for partyfuse | ||
|
||
# use argon2id-hashed passwords in config files (sha2 is always available) | ||
withHashedPasswords ? true, | ||
|
@@ -40,12 +44,21 @@ | |
# send ZeroMQ messages from event-hooks | ||
withZeroMQ ? true, | ||
|
||
# enable FTP server | ||
withFTP ? true, | ||
|
||
# enable FTPS support in the FTP server | ||
withFTPS ? false, | ||
|
||
# enable TFTP server | ||
withTFTP ? false, | ||
|
||
# samba/cifs server; dangerous and buggy, enable if you really need it | ||
withSMB ? false, | ||
|
||
# enables filetype detection for nameless uploads | ||
withMagic ? false, | ||
|
||
# extra packages to add to the PATH | ||
extraPackages ? [ ], | ||
|
||
|
@@ -58,40 +71,38 @@ | |
|
||
let | ||
pinData = lib.importJSON ./pin.json; | ||
pyEnv = python.withPackages ( | ||
ps: | ||
with ps; | ||
runtimeDeps = ([ util-linux ] ++ extraPackages ++ lib.optional withMediaProcessing ffmpeg); | ||
in | ||
buildPythonApplication { | ||
pname = "copyparty"; | ||
inherit (pinData) version; | ||
src = fetchurl { | ||
inherit (pinData) url hash; | ||
}; | ||
dependencies = | ||
[ | ||
jinja2 | ||
fusepy | ||
] | ||
++ lib.optional withSMB impacket | ||
++ lib.optional withFTP pyftpdlib | ||
++ lib.optional withFTPS pyopenssl | ||
++ lib.optional withTFTP partftpy | ||
++ lib.optional withCertgen cfssl | ||
++ lib.optional withThumbnails pillow | ||
++ lib.optional withFastThumbnails pyvips | ||
++ lib.optional withMediaProcessing ffmpeg | ||
++ lib.optional withBasicAudioMetadata mutagen | ||
++ lib.optional withHashedPasswords argon2-cffi | ||
++ lib.optional withZeroMQ pyzmq | ||
++ (extraPythonPackages ps) | ||
); | ||
++ lib.optional withMagic magic | ||
++ (extraPythonPackages python.pkgs); | ||
makeWrapperArgs = [ "--prefix PATH : ${lib.makeBinPath runtimeDeps}" ]; | ||
|
||
runtimeDeps = ([ util-linux ] ++ extraPackages ++ lib.optional withMediaProcessing ffmpeg); | ||
in | ||
stdenv.mkDerivation { | ||
pname = "copyparty"; | ||
inherit (pinData) version; | ||
src = fetchurl { | ||
inherit (pinData) url hash; | ||
}; | ||
nativeBuildInputs = [ makeWrapper ]; | ||
dontUnpack = true; | ||
installPhase = '' | ||
install -Dm755 $src $out/share/copyparty-sfx.py | ||
makeWrapper ${pyEnv.interpreter} $out/bin/copyparty \ | ||
--prefix PATH : ${lib.makeBinPath runtimeDeps} \ | ||
--add-flag $out/share/copyparty-sfx.py | ||
''; | ||
pyproject = true; | ||
build-system = [ | ||
setuptools | ||
]; | ||
meta = { | ||
description = "Turn almost any device into a file server"; | ||
longDescription = '' | ||
|
@@ -101,8 +112,7 @@ stdenv.mkDerivation { | |
homepage = "https://github.com/9001/copyparty"; | ||
changelog = "https://github.com/9001/copyparty/releases/tag/v${pinData.version}"; | ||
license = lib.licenses.mit; | ||
inherit (python.meta) platforms; | ||
mainProgram = "copyparty"; | ||
sourceProvenance = [ lib.sourceTypes.binaryBytecode ]; | ||
sourceProvenance = [ lib.sourceTypes.fromSource ]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the way this is implicitly the default when no |
||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"url": "https://github.com/9001/copyparty/releases/download/v1.18.6/copyparty-sfx.py", | ||
"url": "https://github.com/9001/copyparty/releases/download/v1.18.6/copyparty-1.18.6.tar.gz", | ||
"version": "1.18.6", | ||
"hash": "sha256-No89mzKHHZZH19ws9dqfvQO0pnZw7jKDMGhNa4LOFlY=" | ||
"hash": "sha256-gHYtkayIgV5z0MooBsY5Hc+MzVIbxALMMSNJ87yOiyg=" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
lib, | ||
buildPythonPackage, | ||
fetchurl, | ||
setuptools, | ||
}: | ||
let | ||
pinData = lib.importJSON ./pin.json; | ||
in | ||
|
||
buildPythonPackage rec { | ||
pname = "partftpy"; | ||
inherit (pinData) version; | ||
pyproject = true; | ||
|
||
src = fetchurl { | ||
inherit (pinData) url hash; | ||
}; | ||
|
||
build-system = [ setuptools ]; | ||
|
||
pythonImportsCheck = [ "partftpy.TftpServer" ]; | ||
|
||
meta = { | ||
description = "Pure Python TFTP library (copyparty edition)"; | ||
homepage = "https://github.com/9001/partftpy"; | ||
changelog = "https://github.com/9001/partftpy/releases/tag/${version}"; | ||
license = lib.licenses.mit; | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"url": "https://github.com/9001/partftpy/releases/download/v0.4.0/partftpy-0.4.0.tar.gz", | ||
"version": "0.4.0", | ||
"hash": "sha256-5Q2zyuJ892PGZmb+YXg0ZPW/DK8RDL1uE0j5HPd4We0=" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Update the Nix package pin | ||
# | ||
# Usage: ./update.sh | ||
|
||
import base64 | ||
import json | ||
import hashlib | ||
import sys | ||
from pathlib import Path | ||
|
||
OUTPUT_FILE = Path("pin.json") | ||
TARGET_ASSET = lambda version: f"partftpy-{version}.tar.gz" | ||
HASH_TYPE = "sha256" | ||
LATEST_RELEASE_URL = "https://api.github.com/repos/9001/partftpy/releases/latest" | ||
|
||
|
||
def get_formatted_hash(binary): | ||
hasher = hashlib.new("sha256") | ||
hasher.update(binary) | ||
asset_hash = hasher.digest() | ||
encoded_hash = base64.b64encode(asset_hash).decode("ascii") | ||
return f"{HASH_TYPE}-{encoded_hash}" | ||
|
||
|
||
def remote_release_pin(): | ||
import requests | ||
|
||
response = requests.get(LATEST_RELEASE_URL).json() | ||
version = response["tag_name"].lstrip("v") | ||
asset_info = [a for a in response["assets"] if a["name"] == TARGET_ASSET(version)][0] | ||
download_url = asset_info["browser_download_url"] | ||
asset = requests.get(download_url) | ||
formatted_hash = get_formatted_hash(asset.content) | ||
|
||
result = {"url": download_url, "version": version, "hash": formatted_hash} | ||
return result | ||
|
||
|
||
def main(): | ||
result = remote_release_pin() | ||
|
||
print(result) | ||
json_result = json.dumps(result, indent=4) | ||
OUTPUT_FILE.write_text(json_result) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Just saying this is something that can be done, it's quite common for python packages in nixpkgs and I figured why not...
I think this also allows us to move away from the custom update script, because nix-update has special support for PyPi packages. That's for another PR I think though.
Then all the info would be contained in the derivation, like this:
And the update script would then be a measly
nix-update copyparty --flake
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.
While I do think it would be a good idea, if we were to do this @9001 would need to have nix installed to be able to update the nix packages (assuming that nix-update depends on nix), so we would need to know if he's ok with that.
If he is I'll be glad to do this in a separate PR tho
Uh oh!
There was an error while loading. Please reload this page.
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.
Alternatively (maybe digging the hole even further in the process lol) you could have a Github action with
on: workflow_dispatch
that does the update withnix-update
I guess...TBF the updater for openjdk in nixpkgs also does this...