From 221ab415ab93edaeb7753b3b7bbc88d7bc6f2b30 Mon Sep 17 00:00:00 2001 From: Sean Miller Date: Mon, 25 Aug 2025 15:28:13 -0700 Subject: [PATCH] Add isp-setup service --- modules/default.nix | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/modules/default.nix b/modules/default.nix index 5f505754..a5478511 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -169,6 +169,16 @@ in type = types.bool; description = "Enable boot.kernelParams default console configuration"; }; + + ispPkgs = mkOption { + type = types.listOf types.package; + default = [ ]; + description = '' + The list of packages that contain isp files. This + will copy any files in the /nvcam directory to the + /var/nvidia/nvcam directory on the device at boot time. + ''; + }; }; }; @@ -420,6 +430,35 @@ in wantedBy = [ "multi-user.target" ]; }; + systemd.services.isp-setup = + let + ispHash = builtins.hashString "sha256" (builtins.concatStringsSep "\x1f" cfg.ispPkgs); + copyCmd = builtins.concatStringsSep "\n" (builtins.map (pkg: "${lib.getExe' pkgs.coreutils "cp"} -r ${pkg}/nvcam/. /var/nvidia/nvcam") cfg.ispPkgs); + copyISPfiles = pkgs.writeShellScriptBin "copy-isp-files" '' + if [[ -f "/var/nvidia/nvcam/.version" ]]; then + curVersion=$(cat /var/nvidia/nvcam/.version) + if [[ $curVersion == ${ispHash} ]]; then + exit 0 + fi + rm -rf /var/nvidia/nvcam + fi + + ${lib.getExe' pkgs.coreutils "mkdir"} -p /var/nvidia/nvcam + echo ${ispHash} > /var/nvidia/nvcam/.version + ${copyCmd} + ${lib.getExe' pkgs.coreutils "chmod"} -R 644 /var/nvidia/nvcam + ''; + in + mkIf (builtins.length cfg.ispPkgs != 0) { + enable = true; + description = "Copy ISP files to /var/nvidia/nvcam"; + serviceConfig = { + Type = "oneshot"; + ExecStart = lib.getExe copyISPfiles; + }; + wantedBy = [ "multi-user.target" ]; + }; + systemd.services.tee-supplicant = let args = lib.escapeShellArgs (