copyparty-unstable build in nix overlay

This commit is contained in:
Shelvacu 2025-09-28 09:56:35 -07:00 committed by Shelvacu on prophecy
parent ac085b8149
commit a57661db15
4 changed files with 87 additions and 19 deletions

1
.gitignore vendored
View file

@ -43,6 +43,7 @@ scripts/docker/*.err
# nix build output link # nix build output link
result result
result-*
# IDEA config # IDEA config
.idea/ .idea/

View file

@ -67,18 +67,64 @@
# additional dependencies # additional dependencies
extraPythonPackages ? (_p: [ ]), extraPythonPackages ? (_p: [ ]),
# to build stable + unstable with the same file
stable ? true,
# for commit date, only used when stable = false
copypartyFlake ? null,
nix-gitignore,
}: }:
let let
pinData = lib.importJSON ./pin.json; pinData = lib.importJSON ./pin.json;
runtimeDeps = ([ util-linux ] ++ extraPackages ++ lib.optional withMediaProcessing ffmpeg); runtimeDeps = ([ util-linux ] ++ extraPackages ++ lib.optional withMediaProcessing ffmpeg);
inherit (copypartyFlake) lastModifiedDate;
# ex: "1970" "01" "01"
dateStringsZeroPrefixed = {
year = builtins.substring 0 4 lastModifiedDate;
month = builtins.substring 4 2 lastModifiedDate;
day = builtins.substring 6 2 lastModifiedDate;
};
# ex: "1970" "1" "1"
dateStringsShort = builtins.mapAttrs (_: val: toString (lib.toIntBase10 val)) dateStringsZeroPrefixed;
unstableVersion =
if copypartyFlake == null then
"${pinData.version}-unstable"
else
with dateStringsZeroPrefixed; "${pinData.version}-unstable-${year}-${month}-${day}"
;
version = if stable then pinData.version else unstableVersion;
stableSrc = fetchurl {
inherit (pinData) url hash;
};
root = ../../../..;
unstableSrc = nix-gitignore.gitignoreSource [] root;
src = if stable then stableSrc else unstableSrc;
rev = copypartyFlake.shortRev or copypartyFlake.dirtyShortRev or "unknown";
unstableCodename = "unstable" + (lib.optionalString (copypartyFlake != null) "-${rev}");
in in
buildPythonApplication { buildPythonApplication {
pname = "copyparty"; pname = "copyparty";
inherit (pinData) version; inherit version src;
src = fetchurl { postPatch = lib.optionalString (!stable) ''
inherit (pinData) url hash; old_src="$(mktemp -d)"
}; tar -C "$old_src" -xf ${stableSrc}
declare -a folders
folders=("$old_src"/*)
count_folders="''${#folders[@]}"
if [[ $count_folders != 1 ]]; then
declare -p folders
echo "Expected 1 folder, found $count_folders" >&2
exit 1
fi
old_src_folder="''${folders[0]}"
cp -r "$old_src_folder"/copyparty/web/deps copyparty/web/deps
sed -i 's/^CODENAME =.*$/CODENAME = "${unstableCodename}"/' copyparty/__version__.py
${lib.optionalString (copypartyFlake != null) (with dateStringsShort; ''
sed -i 's/^BUILD_DT =.*$/BUILD_DT = (${year}, ${month}, ${day})/' copyparty/__version__.py
'')}
'';
dependencies = dependencies =
[ [
jinja2 jinja2

View file

@ -1,8 +1,28 @@
final: prev: { final: prev:
copyparty = final.python3.pkgs.callPackage ./copyparty { let
ffmpeg = final.ffmpeg-full; fullAttrs = {
withHashedPasswords = true;
withCertgen = true;
withThumbnails = true;
withFastThumbnails = true;
withMediaProcessing = true;
withBasicAudioMetadata = true;
withZeroMQ = true;
withFTP = true;
withFTPS = true;
withTFTP = true;
withSMB = true;
withMagic = true;
}; };
call = attrs: final.python3.pkgs.callPackage ./copyparty ({ ffmpeg = final.ffmpeg-full; } // attrs);
in
{
copyparty = call { stable = true; };
copyparty-unstable = call { stable = false; };
copyparty-full = call (fullAttrs // { stable = true; });
copyparty-unstable-full = call (fullAttrs // { stable = false; });
python3 = prev.python3.override { python3 = prev.python3.override {
packageOverrides = pyFinal: pyPrev: { packageOverrides = pyFinal: pyPrev: {
partftpy = pyFinal.callPackage ./partftpy { }; partftpy = pyFinal.callPackage ./partftpy { };

View file

@ -12,7 +12,8 @@
}: }:
{ {
nixosModules.default = ./contrib/nixos/modules/copyparty.nix; nixosModules.default = ./contrib/nixos/modules/copyparty.nix;
overlays.default = import ./contrib/package/nix/overlay.nix; overlays.default = final: prev:
(import ./contrib/package/nix/overlay.nix final prev) // { copypartyFlake = self; };
} }
// flake-utils.lib.eachDefaultSystem ( // flake-utils.lib.eachDefaultSystem (
system: system:
@ -22,26 +23,26 @@
config = { config = {
allowAliases = false; allowAliases = false;
}; };
overlays = [ self.overlays.default ]; overlays = [
self.overlays.default
];
}; };
in in
{ {
# check that copyparty builds with all optionals turned on # check that copyparty builds with all optionals turned on
checks.copyparty-full = self.packages.${system}.copyparty.override { checks = {
withHashedPasswords = true; inherit (pkgs)
withCertgen = true; copyparty-full
withThumbnails = true; copyparty-unstable-full
withFastThumbnails = true; ;
withMediaProcessing = true;
withBasicAudioMetadata = true;
withZeroMQ = true;
withFTPS = true;
withSMB = true;
}; };
packages = { packages = {
inherit (pkgs) inherit (pkgs)
copyparty copyparty
copyparty-full
copyparty-unstable
copyparty-unstable-full
; ;
default = self.packages.${system}.copyparty; default = self.packages.${system}.copyparty;
}; };