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

Add initial nix build support #156

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/lib
/nbproject
/cmake-build-debug
/result

# Compiled source #
###################
Expand Down
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
description = "OpenDash is a Qt-based infotainment center for your Linux OpenAuto installation!";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};

outputs =
{ self, nixpkgs, ... }:
let
inherit (nixpkgs) lib;

systems = [
"x86_64-linux"
"aarch64-linux"
];
forAllSystems = f: lib.genAttrs systems (system: f system);

pkgsWithOverlay = forAllSystems (
system:
import nixpkgs {
localSystem = system;
overlays = [ self.overlays.openDsh-packages ];
}
);
in
{
overlays = import ./nix/overlays.nix { inherit self lib; };

packages = forAllSystems (
system: {
default = self.packages.${system}.openDsh_dash;
inherit (pkgsWithOverlay.${system})
h264bitstream
openDsh_aasdk
openDsh_dash
openDsh_dash_nonnixos
openDsh_openauto
qtGStreamer
;
}
);

formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
};
}
23 changes: 23 additions & 0 deletions nix/overlays.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{ lib, self }:
{
default = lib.composeManyExtensions (with self.overlays; [ openDsh-packages ]);

openDsh-packages = lib.composeManyExtensions [
(
final: prev:
let
packages = final.callPackage ./pkgs { inherit self; };
in
{
inherit (packages)
openDsh_aasdk
openDsh_dash
openDsh_dash_nonnixos
openDsh_openauto
h264bitstream
qtGStreamer
;
}
)
];
}
53 changes: 53 additions & 0 deletions nix/pkgs/aasdk/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
boost,
cmake,
elfutils,
fetchFromGitHub,
ffmpeg,
glib,
gst_all_1,
gtest,
lib,
libusb,
openssl,
protobuf3_20,
stdenv,
}:
{
openDsh_aasdk = stdenv.mkDerivation {
pname = "openDsh_aasdk";
version = "unstable-2024-02-06";

src = fetchFromGitHub {
owner = "openDsh";
repo = "aasdk";
rev = "1bc0fe69d5f5f505c978a0c6e32c860e820fa8f6";
hash = "sha256-Gqd+IHn3G3yU1/SSrp8B+isn1mhsGj2w41oMmSgkpQY=";
};

outputs = [
"dev"
"out"
];

cmakeFlags = [ "-DCMAKE_BUILD_TYPE=Release" ];

patches = [ ../../../patches/aasdk_openssl-fips-fix.patch ];

buildInputs = [
boost
libusb
protobuf3_20
openssl
gtest
];
nativeBuildInputs = [ cmake ];

meta = with lib; {
homepage = "https://github.com/openDsh/aasdk";
description = "Library containing implementation of core AndroidAuto(tm) functionalities";
license = licenses.gpl3;
platforms = with platforms; intersectLists linux (aarch64 ++ x86_64);
};
};
}
116 changes: 116 additions & 0 deletions nix/pkgs/dash/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{

boost,
cmake,
gst_all_1,
lib,
libsForQt5,
libusb,
mesa,
openDsh_aasdk,
openDsh_openauto,
openssl,
pkg-config,
protobuf3_20,
qt5,
qtGStreamer,
rtaudio,
stdenv,
taglib,
writeScriptBin,
date,
}:
rec {
openDsh_dash = stdenv.mkDerivation {
pname = "openDsh_dash";
version = "${date}";
src =
let
sourceFilter =
name: type:
let
baseName = baseNameOf (toString name);
in
!(
(baseName == "patches" && type == "directory")
|| (lib.hasSuffix ".nix" baseName)
|| baseName == "flake.lock"
|| baseName == "install.sh"
|| baseName == "rpi.sh"
);
in
lib.cleanSourceWith {
filter = sourceFilter;
src = lib.cleanSource ../../../.;
};

# This project may consume a significant amount of memory during compilation.
enableParallelBuilding = false;

cmakeFlags = [ "-DGST_BUILD=TRUE" ];

postInstall = ''
qtWrapperArgs+=(--prefix GST_PLUGIN_SYSTEM_PATH_1_0 : "$GST_PLUGIN_SYSTEM_PATH_1_0")
qtWrapperArgs+=(--prefix 'NIXPKGS_QT5_QML_IMPORT_PATH' ':' '${qtGStreamer}/lib/qt5/qml')
'';

nativeBuildInputs = [
cmake
pkg-config
qt5.wrapQtAppsHook
];
buildInputs = [
boost
libusb
qt5.full
qt5.qtserialbus
libsForQt5.bluez-qt
protobuf3_20
openssl
rtaudio
taglib
openDsh_aasdk
openDsh_openauto
];
propagatedBuildInputs = [
gst_all_1.gstreamer
gst_all_1.gst-plugins-base
gst_all_1.gst-plugins-good
gst_all_1.gst-plugins-bad
gst_all_1.gst-plugins-ugly
gst_all_1.gst-libav
qtGStreamer
];

meta = with lib; {
homepage = "https://github.com/openDsh/dash";
description = "A Qt-based infotainment center for your Linux OpenAuto installation!";
license = licenses.gpl3;
platforms = with platforms; intersectLists linux (aarch64 ++ x86_64);
mainProgram = "dash";
};
};

openDsh_dash_nonnixos = writeScriptBin "dash" ''
# Wrapper for dash for starting dash on Non-NixOS systems, which lack
# GPU drivers existing at /run/opengl-driver.
#
# Dash requires OpenGL drivers or "White Screen" will occur.
# "qt.qpa.wayland: EGL not available"
#
# This solution is a hack, but is the best hack for the situation. The
# alternative is to use nixGL, but that will incur a runtime pentalty as
# a nix evaluation must be done and may require hundreds of megabytes to
# be downloaded at launch time.
#
# Nvidia support is ignored, if that is needed, use nixGL without this wrapper.
#
# If subprocesses are launched and have an issue with the GPU drivers, the user
# should configure the system to create a symlink to the mesa.drivers output
# at /run/opengl-driver and stop using this wrapper.

export LIBGL_DRIVERS_PATH=${mesa.drivers}/lib/dri
export LD_LIBRARY_PATH=${mesa.drivers}/lib
exec ${openDsh_dash}/bin/dash "$@"
'';
}
21 changes: 21 additions & 0 deletions nix/pkgs/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
lib,
pkgs,
self,
}:
let
mkDate =
longDate:
(lib.concatStringsSep "-" [
(builtins.substring 0 4 longDate)
(builtins.substring 4 2 longDate)
(builtins.substring 6 2 longDate)
]);
in
{
inherit (pkgs.callPackage ./h264bitstream { }) h264bitstream;
inherit (pkgs.callPackage ./qtgstreamer { }) qtGStreamer;
inherit (pkgs.callPackage ./aasdk { }) openDsh_aasdk;
inherit (pkgs.callPackage ./openauto { }) openDsh_openauto;
inherit (pkgs.callPackage ./dash { date = (mkDate self.lastModifiedDate); }) openDsh_dash openDsh_dash_nonnixos;
}
39 changes: 39 additions & 0 deletions nix/pkgs/h264bitstream/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
cmake,
fetchFromGitHub,
ffmpeg,
lib,
stdenv,
}:
{
h264bitstream = stdenv.mkDerivation rec {
pname = "h264bitstream";
version = "dev-${src.rev}";

src = fetchFromGitHub {
owner = "aizvorski";
repo = "h264bitstream";
rev = "ae72f7395f328876199a7e928d3b4a6dc6a7ce14";
hash = "sha256-V96hO97PNxq7FHhr/Sk3cAvtXD30MO4LlL9M/OZ3H18=";
};
patches = [ ../../../patches/h264bitstream_path_patch_fixup.patch ];

outputs = [
"out"
"dev"
];
buildInputs = [ ffmpeg ];
nativeBuildInputs = [ cmake ];
postInstall = ''
install -d $out/lib/pkgconfig/
install libh264bitstream.pc $out/lib/pkgconfig/libh264bitstream.pc
'';

meta = with lib; {
homepage = "https://github.com/aizvorski/h264bitstream";
description = "A complete set of functions to read and write H.264 video bitstreams, in particular to examine or modify headers.";
license = licenses.lgpl21;
platforms = with platforms; intersectLists linux (aarch64 ++ x86_64);
};
};
}
Loading