pi is here
This commit is contained in:
+2
-5
@@ -8,7 +8,6 @@
|
||||
imports =
|
||||
[ # Include the results of the hardware scan...
|
||||
./hardware-configuration.nix
|
||||
./hwaccel.nix
|
||||
./network.nix
|
||||
|
||||
# ...and additional configurations...
|
||||
@@ -26,12 +25,11 @@
|
||||
./docker.nix
|
||||
./chrony.nix
|
||||
./docker-device-mapper.nix
|
||||
./seaweedfs-mount.nix
|
||||
];
|
||||
|
||||
# Use the systemd-boot EFI boot loader.
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
boot.loader.efi.canTouchEfiVariables = true;
|
||||
# boot.loader.systemd-boot.enable = true;
|
||||
# boot.loader.efi.canTouchEfiVariables = true;
|
||||
|
||||
# Enable IP forwarding for NAT (used in wireguard.nix) and load specific modules.
|
||||
boot.kernel.sysctl = {
|
||||
@@ -111,7 +109,6 @@
|
||||
zoxide
|
||||
yazi
|
||||
fzf
|
||||
intel-gpu-tools
|
||||
];
|
||||
|
||||
# Open ports in the firewall.
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
virtualisation.docker.enable = true;
|
||||
|
||||
virtualisation.oci-containers.containers.openccu = {
|
||||
# Official RaspberryMatic image (contains the necessary CCU logic)
|
||||
image = "ghcr.io/openccu/openccu:latest";
|
||||
|
||||
autoStart = true;
|
||||
|
||||
# These options are critical for:
|
||||
# 1. Swarm Networking (connecting to 'public')
|
||||
# 2. Hardware Access (GPIO/USB)
|
||||
extraOptions = [
|
||||
"--privileged" # Required for internal systemd & hardware
|
||||
"--network=public" # Connects to your Swarm Overlay network
|
||||
"--device=/dev/raw-uart:/dev/raw-uart"
|
||||
"--device=/dev/eq3loop:/dev/eq3loop"
|
||||
"--device=/dev/ttyUSB0:/dev/ttyUSB0" # Pass the underlying USB too, just in case
|
||||
];
|
||||
|
||||
# Map the web interface locally, or rely on Swarm IP
|
||||
ports = [ "80:80" ];
|
||||
|
||||
volumes = [
|
||||
"/mnt/service/data/openccu:/usr/local"
|
||||
"/sys/fs/cgroup:/sys/fs/cgroup:ro" # Required for RaspberryMatic
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
# Boot Options
|
||||
boot.loader.grub.enable = lib.mkForce false;
|
||||
boot.loader.generic-extlinux-compatible.enable = lib.mkForce true;
|
||||
|
||||
# tty Console
|
||||
boot.kernelParams = [
|
||||
"console=ttyS1,115200n8"
|
||||
];
|
||||
|
||||
# Bluetooth
|
||||
hardware.bluetooth = {
|
||||
enable = true;
|
||||
powerOnBoot = true;
|
||||
settings = {
|
||||
General = {
|
||||
Experimental = true;
|
||||
FastConnectable = true;
|
||||
};
|
||||
Policy = {
|
||||
AutoEnable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#systemd.services.btattach = {
|
||||
# before = [ "bluetooth.service" ];
|
||||
# after = [ "dev-ttyAMA0.device" ];
|
||||
# wantedBy = [ "multi-user.target" ];
|
||||
# serviceConfig = {
|
||||
# ExecStart = "${pkgs.bluez}/bin/btattach -B /dev/ttyAMA0 -P bcm -S 3000000";
|
||||
# };
|
||||
#};
|
||||
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
pivccu-modules = config.boot.kernelPackages.callPackage ({ stdenv, fetchFromGitHub, kernel }: stdenv.mkDerivation rec {
|
||||
pname = "pivccu-modules";
|
||||
version = "master";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "alexreinert";
|
||||
repo = "piVCCU";
|
||||
rev = "master";
|
||||
# Ensure this matches the hash you got earlier
|
||||
sha256 = "sha256-cXvrLcASU/2nsfJBf+cVtC4JnAq4G5JFzcFgj5ztThc=";
|
||||
};
|
||||
|
||||
# Set the source root to the kernel subdirectory
|
||||
sourceRoot = "${src.name}/kernel";
|
||||
|
||||
hardeningDisable = [ "pic" "format" ];
|
||||
nativeBuildInputs = kernel.moduleBuildDependencies;
|
||||
|
||||
# 1. FORCE delete the upstream Makefile (which causes the build error)
|
||||
# 2. Create a clean Makefile that only builds the modules we need
|
||||
postPatch = ''
|
||||
rm -f Makefile
|
||||
echo "obj-m += eq3_char_loop.o plat_eq3ccu2.o" > Makefile
|
||||
'';
|
||||
|
||||
# 3. Explicitly point to the kernel build directory
|
||||
makeFlags = [
|
||||
"KERNEL_DIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
|
||||
"INSTALL_MOD_PATH=$(out)"
|
||||
"M=$(pwd)"
|
||||
"modules"
|
||||
];
|
||||
|
||||
# 4. Use the kernel build system to compile the modules
|
||||
buildPhase = ''
|
||||
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build M=$(pwd) modules
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build M=$(pwd) INSTALL_MOD_PATH=$out modules_install
|
||||
'';
|
||||
}) {};
|
||||
|
||||
in
|
||||
{
|
||||
boot.extraModulePackages = [ pivccu-modules ];
|
||||
|
||||
# Load the modules required for the USB stick
|
||||
boot.kernelModules = [ "cp210x" "eq3_char_loop" "plat_eq3ccu2" ];
|
||||
|
||||
# Udev rules for HmIP-RFUSB
|
||||
services.udev.extraRules = ''
|
||||
# 1. FORCE BINDING: Tell cp210x to handle the HmIP-RFUSB (1b1f:c020)
|
||||
# We use 'sh -c echo' because 'new_id' is a virtual file that tells the driver to accept new IDs.
|
||||
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="1b1f", ATTR{idProduct}=="c020", \
|
||||
RUN+="${pkgs.kmod}/bin/modprobe cp210x", \
|
||||
RUN+="${pkgs.bash}/bin/sh -c 'echo 1b1f c020 > /sys/bus/usb-serial/drivers/cp210x/new_id'"
|
||||
|
||||
# 2. CREATE SYMLINK: Once the driver binds, a ttyUSBx device appears.
|
||||
# We symlink it to /dev/raw-uart and set permissions.
|
||||
SUBSYSTEM=="tty", ATTRS{idVendor}=="1b1f", ATTRS{idProduct}=="c020", SYMLINK+="raw-uart", OWNER="root", GROUP="root", MODE="0666"
|
||||
|
||||
# 3. USB PERMISSIONS: Ensure the raw USB device is also accessible
|
||||
SUBSYSTEM=="usb", ATTRS{idVendor}=="1b1f", ATTRS{idProduct}=="c020", MODE="0666"
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user