Skip to content

Commit

Permalink
feat(klipper): package camera-streamer
Browse files Browse the repository at this point in the history
  • Loading branch information
truelecter committed Sep 10, 2023
1 parent 337c892 commit afa2a02
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 35 deletions.
8 changes: 5 additions & 3 deletions cells/klipper/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
inherit nixpkgs sources;

packages = ./packages;
extraArguments = {
inherit cell;
};
extraArguments =
{
inherit cell;
}
// packages;
};

excluded-plugins-from-full = ["sources"];
Expand Down
59 changes: 43 additions & 16 deletions cells/klipper/packages/camera-streamer.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
pkg-config,
ccache,
unixtools,
cmake,
# dependencies
nlohmann_json,
ffmpeg,
libcamera,
live555,
gnutls,
usrsctp,
libdatachannel,
libjuice,
openssl,
srtp,
# Build flags
useHWH264 ? true,
useFfmpeg ? false,
Expand All @@ -21,51 +24,75 @@
useLibdatachannel ? true,
...
}: let
inherit (lib) optionals optional;
inherit (lib) optionals optional optionalString;

libdatachannel0_17 = libdatachannel.overrideAttrs (_: _: {
inherit (sources.libdatachannel0_17) version src;

buildInputs = [
libjuice
openssl
srtp
];

cmakeFlags = [
"-DUSE_SYSTEM_SRTP=ON"
"-DUSE_SYSTEM_JUICE=ON"
"-DNO_EXAMPLES=ON"
];
});
in
stdenv.mkDerivation rec {
pname = "camera-streamer";

inherit (sources.camera-streamer) version src;

# NIX_DEBUG = 1;
# NIX_CFLAGS_COMPILE = "-Wno-error";

hardeningDisable = ["all"];

makeFlags =
[
"GIT_VERSION=${version}"
"GIT_REVISION=${version}"
"-DGIT_VERSION=${version}"
"-DGIT_REVISION=${version}"
"-DUSE_LIBDATACHANNEL=0"
]
++ optional useHWH264 "USE_HW_H264=1"
++ optional useFfmpeg "USE_FFMPEG=1"
++ optional useLibcamera "USE_LIBCAMERA=1"
++ optional useRtsp "USE_RTSP=1";
++ optional useHWH264 "-DUSE_HW_H264=1"
++ optional useFfmpeg "-DUSE_FFMPEG=1"
++ optional useLibcamera "-DUSE_LIBCAMERA=1"
++ optional useRtsp "-DUSE_RTSP=1";

nativeBuiltInputs = [pkg-config ccache unixtools.xxd cmake];
nativeBuildInputs = [pkg-config ccache unixtools.xxd];

buildInputs =
[nlohmann_json]
++ optional useFfmpeg ffmpeg
++ optional useLibcamera libcamera
++ optional useRtsp live555
++ optional useLibdatachannel gnutls;
++ optionals useLibdatachannel ([libdatachannel0_17 usrsctp] ++ libdatachannel0_17.buildInputs);

configurePhase = ''
echo '#define GIT_VERSION "${version}"' > version.h
echo '#define GIT_REVISION "${version}"' >> version.h
sed -i 's/all: version/all:/g' Makefile
export PATH="${pkg-config}/bin:${unixtools.xxd}/bin:${cmake}/bin::$PATH"
${optionalString useLibdatachannel ''
export NIX_CFLAGS_COMPILE="-DUSE_LIBDATACHANNEL $NIX_CFLAGS_COMPILE"
export NIX_LDFLAGS="$NIX_LDFLAGS -ljuice -ldatachannel -lsrtp2 -lcrypto -lssl -lusrsctp"
''}
rm -rf third_party/libdatachannel
'';

buildPhase = ''
make camera-streamer list-devices
'';

installPhase = ''
$preInstallPhase
mkdir -p $out/bin
cp camera-streamer $out/bin/
cp camera-streamer list-devices $out/bin/
$postInstallPhase
'';
Expand Down
31 changes: 31 additions & 0 deletions cells/klipper/packages/libjuice.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
lib,
stdenv,
sources,
cmake,
noServer ? true,
noTests ? true,
...
}: let
inherit (lib) optional;
in
stdenv.mkDerivation rec {
pname = "libjuice";

inherit (sources.libjuice) version src;

cmakeFlags =
[
]
++ optional noServer "-DNO_SERVER=ON"
++ optional noTests "-DNO_TESTS=ON";

nativeBuildInputs = [cmake];

meta = with lib; {
description = "JUICE is a UDP Interactive Connectivity Establishment library";
homepage = "https://github.com/paullouisageneau/libjuice/tree/06bbfe93ab344e95797220d89b55c7204c3ffa9d";
platforms = platforms.linux;
license = licenses.gpl3Only;
};
}
56 changes: 48 additions & 8 deletions cells/klipper/sources/generated.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"klipper": {
"cargoLocks": null,
"date": "2023-08-21",
"date": "2023-09-10",
"extract": null,
"name": "klipper",
"passthru": null,
Expand All @@ -33,11 +33,11 @@
"name": null,
"owner": "Klipper3d",
"repo": "klipper",
"rev": "5f990f93d533247d3a675e8c423280f4333ad8ce",
"sha256": "sha256-jICOEzLvy2wBInW4qIbFZbhRuHjsio6UM13K9UlZi1U=",
"rev": "2acfa282942c13c725af6a2cb3ea314edf53406f",
"sha256": "sha256-3tfTkUxlEZS2yZXmz+BywrWk/af9LtF24zBMisS8RbY=",
"type": "github"
},
"version": "5f990f93d533247d3a675e8c423280f4333ad8ce"
"version": "2acfa282942c13c725af6a2cb3ea314edf53406f"
},
"klipper-ercf": {
"cargoLocks": null,
Expand All @@ -61,7 +61,7 @@
},
"klipper-happy-hare": {
"cargoLocks": null,
"date": "2023-09-09",
"date": "2023-09-10",
"extract": null,
"name": "klipper-happy-hare",
"passthru": null,
Expand All @@ -73,11 +73,11 @@
"name": null,
"owner": "moggieuk",
"repo": "Happy-Hare",
"rev": "bb8eef4e7741db91a11e932c23d9eb40cfffe3b5",
"sha256": "sha256-YU+okOaXoVCW9Df3mZRKKIyNQ8p99OsM/S8GXC2gvls=",
"rev": "373eade4732447f19ca81231f434fd3ee2395580",
"sha256": "sha256-XOiBIA07ueq6/XM52sTFCw9UlXVenKkjtfj8Jl8JMPs=",
"type": "github"
},
"version": "bb8eef4e7741db91a11e932c23d9eb40cfffe3b5"
"version": "373eade4732447f19ca81231f434fd3ee2395580"
},
"klipper-kamp": {
"cargoLocks": null,
Expand Down Expand Up @@ -179,6 +179,46 @@
},
"version": "v1.0.2"
},
"libdatachannel0_17": {
"cargoLocks": null,
"date": null,
"extract": null,
"name": "libdatachannel0_17",
"passthru": null,
"pinned": false,
"src": {
"deepClone": false,
"fetchSubmodules": false,
"leaveDotGit": false,
"name": null,
"owner": "paullouisageneau",
"repo": "libdatachannel",
"rev": "v0.17.10",
"sha256": "sha256-3f84GxAgQiObe+DYuTQABvK+RTihKKFKaf48lscUex4=",
"type": "github"
},
"version": "v0.17.10"
},
"libjuice": {
"cargoLocks": null,
"date": null,
"extract": null,
"name": "libjuice",
"passthru": null,
"pinned": false,
"src": {
"deepClone": false,
"fetchSubmodules": false,
"leaveDotGit": false,
"name": null,
"owner": "paullouisageneau",
"repo": "libjuice",
"rev": "v1.0.4",
"sha256": "sha256-LAqi5F6okhGj0LyJasPKRkUz6InlM6rbYN+1sX1N4Qo=",
"type": "github"
},
"version": "v1.0.4"
},
"mainsail": {
"cargoLocks": null,
"date": "2023-09-05",
Expand Down
38 changes: 30 additions & 8 deletions cells/klipper/sources/generated.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
};
klipper = {
pname = "klipper";
version = "5f990f93d533247d3a675e8c423280f4333ad8ce";
version = "2acfa282942c13c725af6a2cb3ea314edf53406f";
src = fetchFromGitHub {
owner = "Klipper3d";
repo = "klipper";
rev = "5f990f93d533247d3a675e8c423280f4333ad8ce";
rev = "2acfa282942c13c725af6a2cb3ea314edf53406f";
fetchSubmodules = false;
sha256 = "sha256-jICOEzLvy2wBInW4qIbFZbhRuHjsio6UM13K9UlZi1U=";
sha256 = "sha256-3tfTkUxlEZS2yZXmz+BywrWk/af9LtF24zBMisS8RbY=";
};
date = "2023-08-21";
date = "2023-09-10";
};
klipper-ercf = {
pname = "klipper-ercf";
Expand All @@ -38,15 +38,15 @@
};
klipper-happy-hare = {
pname = "klipper-happy-hare";
version = "bb8eef4e7741db91a11e932c23d9eb40cfffe3b5";
version = "373eade4732447f19ca81231f434fd3ee2395580";
src = fetchFromGitHub {
owner = "moggieuk";
repo = "Happy-Hare";
rev = "bb8eef4e7741db91a11e932c23d9eb40cfffe3b5";
rev = "373eade4732447f19ca81231f434fd3ee2395580";
fetchSubmodules = false;
sha256 = "sha256-YU+okOaXoVCW9Df3mZRKKIyNQ8p99OsM/S8GXC2gvls=";
sha256 = "sha256-XOiBIA07ueq6/XM52sTFCw9UlXVenKkjtfj8Jl8JMPs=";
};
date = "2023-09-09";
date = "2023-09-10";
};
klipper-kamp = {
pname = "klipper-kamp";
Expand Down Expand Up @@ -106,6 +106,28 @@
sha256 = "sha256-QDsr09aIP09pI2r18atTRvbbMBS0rbjeiWOSnp9nRUk=";
};
};
libdatachannel0_17 = {
pname = "libdatachannel0_17";
version = "v0.17.10";
src = fetchFromGitHub {
owner = "paullouisageneau";
repo = "libdatachannel";
rev = "v0.17.10";
fetchSubmodules = false;
sha256 = "sha256-3f84GxAgQiObe+DYuTQABvK+RTihKKFKaf48lscUex4=";
};
};
libjuice = {
pname = "libjuice";
version = "v1.0.4";
src = fetchFromGitHub {
owner = "paullouisageneau";
repo = "libjuice";
rev = "v1.0.4";
fetchSubmodules = false;
sha256 = "sha256-LAqi5F6okhGj0LyJasPKRkUz6InlM6rbYN+1sX1N4Qo=";
};
};
mainsail = {
pname = "mainsail";
version = "ecaa894fbb7ae9cb2ebc1dbb9688b7eef312b740";
Expand Down
8 changes: 8 additions & 0 deletions cells/klipper/sources/nvfetcher.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ src.github = "ayufan/camera-streamer"
fetch.github = "ayufan/camera-streamer"
git.fetchSubmodules = true

[libdatachannel0_17]
src.manual = "v0.17.10"
fetch.github = "paullouisageneau/libdatachannel"

[libjuice]
src.manual = "v1.0.4"
fetch.github = "paullouisageneau/libjuice"

# mainsail
[mainsail]
src.git = "https://github.com/mainsail-crew/mainsail"
Expand Down

0 comments on commit afa2a02

Please sign in to comment.