move libcamera stuff into a separate overlay

This commit is contained in:
Travis Staton 2024-01-23 22:00:36 -05:00
parent 2e2c5b13fb
commit 9c35dd99cf
6 changed files with 51 additions and 30 deletions

View file

@ -37,7 +37,13 @@
}; };
outputs = srcs@{ self, ... }: { outputs = srcs@{ self, ... }: {
overlay = import ./overlay (builtins.removeAttrs srcs [ "self" ]); overlays = {
nixosModules.raspberry-pi = import ./rpi { overlay = self.overlay; }; core = import ./overlays (builtins.removeAttrs srcs [ "self" ]);
libcamera = import ./overlays/libcamera.nix (builtins.removeAttrs srcs [ "self" ]);
};
nixosModules.raspberry-pi = import ./rpi {
core-overlay = self.overlays.core;
libcamera-overlay = self.overlays.libcamera;
};
}; };
} }

View file

@ -3,9 +3,7 @@
, rpi-firmware-src , rpi-firmware-src
, rpi-firmware-nonfree-src , rpi-firmware-nonfree-src
, rpi-bluez-firmware-src , rpi-bluez-firmware-src
, libcamera-apps-src , ...
, libcamera-src
, libpisp-src
}: }:
final: prev: final: prev:
let let
@ -40,29 +38,6 @@ in
# the path expected by raspberry pi firmware/device tree # the path expected by raspberry pi firmware/device tree
compressFirmwareXz = x: x; compressFirmwareXz = x: x;
# A recent known working version of libcamera-apps
libcamera-apps =
final.callPackage ./libcamera-apps.nix { inherit libcamera-apps-src; };
libpisp = final.stdenv.mkDerivation {
name = "libpisp";
version = "1.0.3";
src = libpisp-src;
nativeBuildInputs = with final; [ pkg-config meson ninja ];
buildInputs = with final; [ nlohmann_json boost ];
# Meson is no longer able to pick up Boost automatically.
# https://github.com/NixOS/nixpkgs/issues/86131
BOOST_INCLUDEDIR = "${prev.lib.getDev final.boost}/include";
BOOST_LIBRARYDIR = "${prev.lib.getLib final.boost}/lib";
};
libcamera = prev.libcamera.overrideAttrs (old: {
version = "0.1.0";
src = libcamera-src;
buildInputs = old.buildInputs ++ (with final; [ libpisp ]);
patches = [ ];
});
# provide generic rpi arm64 u-boot # provide generic rpi arm64 u-boot
uboot_rpi_arm64 = prev.buildUBoot rec { uboot_rpi_arm64 = prev.buildUBoot rec {
defconfig = "rpi_arm64_defconfig"; defconfig = "rpi_arm64_defconfig";

30
overlays/libcamera.nix Normal file
View file

@ -0,0 +1,30 @@
{ libcamera-apps-src
, libcamera-src
, libpisp-src
, ...
}:
final: prev:
{
# A recent known working version of libcamera-apps
libcamera-apps =
final.callPackage ./libcamera-apps.nix { inherit libcamera-apps-src; };
libpisp = final.stdenv.mkDerivation {
name = "libpisp";
version = "1.0.3";
src = libpisp-src;
nativeBuildInputs = with final; [ pkg-config meson ninja ];
buildInputs = with final; [ nlohmann_json boost ];
# Meson is no longer able to pick up Boost automatically.
# https://github.com/NixOS/nixpkgs/issues/86131
BOOST_INCLUDEDIR = "${prev.lib.getDev final.boost}/include";
BOOST_LIBRARYDIR = "${prev.lib.getLib final.boost}/lib";
};
libcamera = prev.libcamera.overrideAttrs (old: {
version = "0.1.0";
src = libcamera-src;
buildInputs = old.buildInputs ++ (with final; [ libpisp ]);
patches = [ ];
});
}

View file

@ -1,4 +1,4 @@
{ overlay }: { core-overlay, libcamera-overlay }:
{ lib, pkgs, config, ... }: { lib, pkgs, config, ... }:
{ {
@ -12,6 +12,12 @@
type = types.bool; type = types.bool;
}; };
}; };
libcamera-overlay = {
enable = mkOption {
default = true;
type = types.bool;
};
};
}; };
}; };
@ -171,7 +177,11 @@
}; };
}; };
nixpkgs = { overlays = [ overlay ]; }; nixpkgs = {
overlays = [ core-overlay ]
++ (if config.raspberry-pi-nix.libcamera-overlay.enable
then [ libcamera-overlay ] else [ ]);
};
boot = { boot = {
initrd.availableKernelModules = [ initrd.availableKernelModules = [
"usbhid" "usbhid"