upd and cache

This commit is contained in:
mjallen18
2025-12-26 11:45:05 -06:00
parent f7cb1cb217
commit c9f75a053c
22 changed files with 523 additions and 126 deletions

View File

@@ -127,11 +127,12 @@ in
};
services = {
nextcloud-client.enable = lib.mkDefault hasDestopEnvironment;
nextcloud-client.enable = false;#lib.mkDefault hasDestopEnvironment;
pass-secret-service = lib.mkDefault enabled;
kdeconnect = {
enable = lib.mkDefault hasDestopEnvironment;
indicator = lib.mkDefault hasDestopEnvironment;
package = pkgs.gnomeExtensions.gsconnect;
};
};
}

View File

@@ -0,0 +1,184 @@
# This file is a modified version of config.txt generator
# Licensed under the terms of MIT License
# https://raw.githubusercontent.com/nix-community/raspberry-pi-nix/refs/heads/master/rpi/config.nix
# with modifications
# https://raw.githubusercontent.com/nvmd/raspberry-pi-nix/refs/heads/master/rpi/config.nix
{ lib, config, pkgs, namespace, ... }:
let
cfg = config.${namespace}.hardware.raspberry-pi;
render-raspberrypi-config = let
render-kvs = kvs: let
render-kv = k: v:
if isNull v.value then k
else "${k}=${toString v.value}";
in lib.attrsets.mapAttrsToList render-kv
(lib.filterAttrs (k: v: v.enable) kvs);
render-dt-param = x: "dtparam=" + x;
render-dt-params = params:
lib.strings.concatMapStringsSep "\n" render-dt-param (render-kvs params);
render-dt-overlay = { overlay, params }:
lib.concatStringsSep "\n" (lib.filter (x: x != "") [
("dtoverlay=" + overlay)
(render-dt-params params)
"dtoverlay="
]);
render-options = opts:
lib.strings.concatStringsSep "\n" (render-kvs opts);
render-base-dt-params = render-dt-params;
render-dt-overlays = overlays:
lib.strings.concatMapStringsSep "\n" render-dt-overlay
(lib.attrsets.mapAttrsToList
(overlay: params: {
inherit overlay;
inherit (params) params;
})
(lib.filterAttrs (k: v: v.enable) overlays));
render-config-section = conditionalFilter:
{ options, base-dt-params, dt-overlays }:
let all-config = lib.concatStringsSep "\n" (lib.filter (x: x != "") [
(render-options options)
(render-base-dt-params base-dt-params)
(render-dt-overlays dt-overlays)
]);
in ''
[${conditionalFilter}]
${all-config}
'';
in conf: lib.strings.concatStringsSep "\n"
((lib.attrsets.mapAttrsToList render-config-section conf)
++ [ cfg.extra-config ]);
in {
options.${namespace}.hardware.raspberry-pi = {
config = let
rpi-config-param = {
options = {
enable = lib.mkEnableOption "attr";
value = lib.mkOption {
type = with lib.types; oneOf [ int str bool ];
};
};
};
dt-param = {
options = {
enable = lib.mkEnableOption "attr";
value = lib.mkOption {
type = with lib.types; nullOr (oneOf [ int str bool ]);
default = null;
};
};
};
dt-overlay = {
options = {
enable = lib.mkEnableOption "overlay";
params = lib.mkOption {
type = with lib.types; attrsOf (submodule dt-param);
default = {};
};
};
};
raspberry-pi-config-options = {
options = {
options = lib.mkOption {
type = with lib.types; attrsOf (submodule rpi-config-param);
default = { };
description = ''
Common hardware configuration options, translates to
`<option>=<value>` in the `config.txt`.
<https://www.raspberrypi.com/documentation/computers/config_txt.html#common-hardware-configuration-options>
'';
example = {
arm_boost = { # arm_boost=1
enable = true;
value = true;
};
};
};
base-dt-params = lib.mkOption {
type = with lib.types; attrsOf (submodule dt-param);
default = { };
description = ''
Parameters to pass to the base DTB, translates to
`dtparam=<param>=<value>` in the `config.txt`.
<https://www.raspberrypi.com/documentation/computers/configuration.html#part3.2>
'';
example = {
i2c = { # dtparam=i2c=on
enable = true;
value = "on";
};
ant2 = { # dtparam=ant2
enable = true;
};
};
};
dt-overlays = lib.mkOption {
type = with lib.types; attrsOf (submodule dt-overlay);
default = { };
description = ''
DTB overlays to enable and configure with parameters, translates to
```
dtoverlay=<overlay>
dtparam=<param>=<value>
dtoverlay=
```, which is an equivalent to a more popular format of
`dtoverlay=<overlay>,<param>=<value>`.
<https://www.raspberrypi.com/documentation/computers/configuration.html#part3.1>
'';
example = {
vc4-kms-v3d = { # dtoverlay=vc4-kms-v3d,cma-256
enable = true;
params = {
cma-256 = {
enable = true;
# value = "";
};
};
};
disable-bt = { # dtoverlay=disable-bt
enable = true;
};
};
};
};
};
in lib.mkOption {
type = with lib.types; attrsOf (submodule raspberry-pi-config-options);
description = ''
Configures `config.txt` file for Raspberry Pi devices.
The file is located on a firmware partition, usually mounted at
`/boot/firmware`.
<https://www.raspberrypi.com/documentation/computers/config_txt.html>
'';
};
extra-config = lib.mkOption {
type = lib.types.lines;
default = "";
description = ''
Extra options that will be appended to `/boot/firmware/config.txt` file.
For possible values, see: https://www.raspberrypi.com/documentation/computers/config_txt.html
'';
};
config-generated = lib.mkOption {
type = lib.types.str;
description = ''
The config file text generated by hardware.raspberry-pi.config
'';
readOnly = true;
};
};
config = {
hardware.raspberry-pi.config-generated = render-raspberrypi-config cfg.config;
};
}

View File

@@ -22,6 +22,11 @@ in
};
config = lib.mkIf cfg.enable {
boot.initrd.availableKernelModules = lib.mkIf (cfg.variant == "5") [
"nvme"
];
# Common Raspberry Pi packages
environment.systemPackages = with pkgs; [
i2c-tools
@@ -36,20 +41,26 @@ in
];
# Common Bluetooth configuration
systemd.services.btattach = {
before = [ "bluetooth.service" ];
after = [ "dev-ttyAMA0.device" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${lib.getExe' pkgs.bluez "btattach"} -B /dev/ttyAMA0 -P bcm -S 3000000";
systemd = {
services.btattach = {
before = [ "bluetooth.service" ];
after = [ "dev-ttyAMA0.device" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${lib.getExe' pkgs.bluez "btattach"} -B /dev/ttyAMA0 -P bcm -S 3000000";
};
};
tmpfiles.packages = [
pkgs.${namespace}.udev-rules
];
};
# Common hardware settings
hardware.i2c.enable = lib.mkDefault true;
# Pi specific settings
hardware.graphics.enable32Bit = lib.mkForce false;
hardware = {
i2c.enable = lib.mkDefault true;
graphics.enable32Bit = lib.mkForce false;
};
# Pi specific system tags
system.nixos.tags = (
@@ -67,6 +78,92 @@ in
programs.kdeconnect.enable = lib.mkDefault false;
# Root user shell configuration
users.users.root.shell = pkgs.zsh;
users = {
users.root.shell = pkgs.zsh;
extraGroups = {
gpio = {};
i2c = {};
input = {};
plugdev = {};
spi = {};
video = {};
};
};
services = {
udev.packages = [
pkgs.${namespace}.udev-rules
];
xserver.extraConfig = let
identifier = "rp1";
driver = "rp1-vec|rp1-dsi|rp1-dpi";
in ''
Section "OutputClass"
Identifier "${identifier}"
MatchDriver "${driver}"
Driver "modesetting"
Option "PrimaryGPU" "true"
EndSection
'';
};
nixpkgs.overlays = [
# (_self: super: {
# ffmpeg = super.${namespace}.ffmpeg-rpi;
# })
# (_self: super: {
# libraspberrypi = super.${namespace}.libraspberrypi;
# })
# (_self: super: {
# raspberrypi-utils = super.${namespace}.raspberrypi-utils;
# })
] ++ (if cfg.variant == "5" then [
(final: prev: {
ubootRaspberryPi5 = prev.uboot.ubootRaspberryPi4_64Bit.override {
defconfig = "rpi_5_defconfig";
};
})
# (final: prev:
# let
# mkPi5 = drv:
# prev.lib.overrideDerivation
# (drv // {
# # Make sure we build the BCM2712 defconfig regardless of internal mapping
# argsOverride = (drv.argsOverride or {}) // {
# defconfig = "bcm2712_defconfig";
# };
# # Limit platforms to aarch64 for Pi 5
# extraMeta = (drv.extraMeta or {}) // {
# platforms = with prev.lib.platforms; prev.lib.intersectLists aarch64 linux;
# hydraPlatforms = [ "aarch64-linux" ];
# };
# })
# (old: {
# postFixup = (old.postFixup or "") + ''
# dtbDir=${if old.stdenv.hostPlatform.isAarch64 then "$out/dtbs/broadcom" else "$out/dtbs"}
# copyDTB() { cp -v "$dtbDir/$1" "$dtbDir/$2"; }
# # Pi 5 alias (only if your boot chain expects bcm283x-style names)
# if [ -e "$dtbDir/bcm2712-rpi-5-b.dtb" ]; then
# copyDTB bcm2712-rpi-5-b.dtb bcm2839-rpi-5-b.dtb
# fi
# '';
# });
# in {
# # Assuming your package is exposed as pkgs.linux-rpi; adapt the name if different
# linux-rpi5 = mkPi5 (prev.linux_rpi4.override { rpiVersion = 5; });
# })
(final: prev: {
# https://github.com/nvmd/nixos-raspberrypi/issues/64
# credit for the initial version of this snippet goes to @micahcc
jemalloc = prev.jemalloc.overrideAttrs (old: {
# --with-lg-page=(log2 page_size)
# RPi5 (bcm2712): since our page size is 16384 (2**14), we need 14
configureFlags = let
pageSizeFlag = "--with-lg-page";
in (prev.lib.filter (flag: prev.lib.hasPrefix pageSizeFlag flag == false) old.configureFlags)
++ [ "${pageSizeFlag}=14" ];
});
})
] else [ ]);
};
}

View File

@@ -16,10 +16,9 @@
"cachyos-server-lto-znver4"
"cachyos-rc-lto"
"cachyos-rc-lto-znver4"
# "chromium"
"dolphin-emu"
"electron"
# "ffmpeg"
"ffmpeg_8"
"ffmpeg_7"
"ffmpeg_6"
"ffmpeg-full"
@@ -28,6 +27,7 @@
"gst-plugins-bad"
"gst-plugins-rs"
"gtk4"
"hipblaslt"
"jemalloc"
"jupiter-fan-control"
"libcamera-rpi"
@@ -36,8 +36,9 @@
"linux"
"linuxPackages_cachyos"
"linuxPackages_cachyos-lto"
"linuxPackages_rpi4"
"linuxPackages_rpi5"
"linuxPackages_cachyos-lto-znver4"
"linuxPackages_cachyos-lto-server"
"linuxPackages_cachyos-lto-server-znver4"
"mesa"
"mesa-radeonsi-jupiter"
"mgba"
@@ -63,18 +64,20 @@
};
nixpkgs.overlays = [
(_self: super: {
"linux_rpi-bcm2711" = super."linux_rpi-bcm2711".override { stdenv = super.ccacheStdenv; };
})
(_self: super: {
"mesa" = super."mesa".override { buildPackages.stdenv = super.ccacheStdenv; };
})
(_self: super: {
"webkitgtk_4_1" = super.stable."webkitgtk_4_1".override { clangStdenv = super.ccacheStdenv; };
})
(_self: super: {
"webkitgtk_6_0" = super."webkitgtk_6_0".override { clangStdenv = super.ccacheStdenv; };
electron = super.stable.electron-bin;
electron_36 = super.stable.electron_36-bin;
electron_37 = super.stable.electron_37-bin;
})
# (_self: super: {
# "webkitgtk_4_1" = super.stable."webkitgtk_4_1".override { clangStdenv = super.ccacheStdenv; };
# })
# (_self: super: {
# "webkitgtk_6_0" = super."webkitgtk_6_0".override { clangStdenv = super.ccacheStdenv; };
# })
(_self: super: {
"jellyfin-ffmpeg" = super."jellyfin-ffmpeg".override {
ffmpeg_7-full = super.ffmpeg_7-full.override { stdenv = super.ccacheStdenv; };
@@ -105,8 +108,13 @@
qt3d = super.kdePackages.qt3d.override {
qtbase = super.kdePackages.qtbase.override { stdenv = super.ccacheStdenv; };
};
# qtbase = super.kdePackages.qtbase.override { stdenv = super.ccacheStdenv; };
qtwebengine = super.kdePackages.qtwebengine.override { stdenv = super.ccacheStdenv; };
# qtbase = super.stable.kdePackages.qtbase;#.override { stdenv = super.ccacheStdenv; };
qtwebengine = super.stable.kdePackages.qtwebengine; #.override { stdenv = super.ccacheStdenv; };
};
})
(_self: super: {
rocmPackages = super.rocmPackages // {
hipblaslt = super.rocmPackages.hipblaslt.override { stdenv = super.ccacheStdenv; };
};
})
# (_self: super: {

View File

@@ -30,6 +30,7 @@ let
environment = {
DISPATCHARR_LOG_LEVEL = "DEBUG";
DISPATCHARR_ENV = "aio";
DJANGO_SECRET_KEY = "123456";
PUID = cfg.puid;
PGID = cfg.pgid;
TZ = cfg.timeZone;