diff --git a/flake.nix b/flake.nix index 0e952e5..e20abc5 100644 --- a/flake.nix +++ b/flake.nix @@ -37,7 +37,13 @@ }; outputs = srcs@{ self, ... }: { - overlay = import ./overlay (builtins.removeAttrs srcs [ "self" ]); - nixosModules.raspberry-pi = import ./rpi { overlay = self.overlay; }; + overlays = { + 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; + }; }; } diff --git a/overlay/default.nix b/overlays/default.nix similarity index 82% rename from overlay/default.nix rename to overlays/default.nix index caaad0d..5585e2e 100644 --- a/overlay/default.nix +++ b/overlays/default.nix @@ -3,9 +3,7 @@ , rpi-firmware-src , rpi-firmware-nonfree-src , rpi-bluez-firmware-src -, libcamera-apps-src -, libcamera-src -, libpisp-src +, ... }: final: prev: let @@ -40,29 +38,6 @@ in # the path expected by raspberry pi firmware/device tree 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 uboot_rpi_arm64 = prev.buildUBoot rec { defconfig = "rpi_arm64_defconfig"; diff --git a/overlay/libcamera-apps.nix b/overlays/libcamera-apps.nix similarity index 100% rename from overlay/libcamera-apps.nix rename to overlays/libcamera-apps.nix diff --git a/overlays/libcamera.nix b/overlays/libcamera.nix new file mode 100644 index 0000000..4869ed0 --- /dev/null +++ b/overlays/libcamera.nix @@ -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 = [ ]; + }); +} diff --git a/overlay/raspberrypi-wireless-firmware.nix b/overlays/raspberrypi-wireless-firmware.nix similarity index 100% rename from overlay/raspberrypi-wireless-firmware.nix rename to overlays/raspberrypi-wireless-firmware.nix diff --git a/rpi/default.nix b/rpi/default.nix index 32957f1..6ed0563 100644 --- a/rpi/default.nix +++ b/rpi/default.nix @@ -1,4 +1,4 @@ -{ overlay }: +{ core-overlay, libcamera-overlay }: { lib, pkgs, config, ... }: { @@ -12,6 +12,12 @@ 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 = { initrd.availableKernelModules = [ "usbhid"