{"id":30104091,"url":"https://github.com/alh477/nixos_nvr","last_synced_at":"2026-02-09T12:06:48.538Z","repository":{"id":308809030,"uuid":"1034180027","full_name":"ALH477/NixOS_NVR","owner":"ALH477","description":null,"archived":false,"fork":false,"pushed_at":"2025-08-08T01:35:48.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-08T03:23:58.229Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ALH477.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-08T01:35:15.000Z","updated_at":"2025-08-08T01:35:51.000Z","dependencies_parsed_at":"2025-08-08T03:23:59.659Z","dependency_job_id":"b330ceee-11e1-45de-aada-2b3ebb3a7c1c","html_url":"https://github.com/ALH477/NixOS_NVR","commit_stats":null,"previous_names":["alh477/nixos_nvr"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/ALH477/NixOS_NVR","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ALH477%2FNixOS_NVR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ALH477%2FNixOS_NVR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ALH477%2FNixOS_NVR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ALH477%2FNixOS_NVR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ALH477","download_url":"https://codeload.github.com/ALH477/NixOS_NVR/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ALH477%2FNixOS_NVR/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269647028,"owners_count":24453119,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-09T02:00:10.424Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-09T22:15:11.736Z","updated_at":"2026-02-09T12:06:47.503Z","avatar_url":"https://github.com/ALH477.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fully Fleshed Out NixOS Configuration for DIY NVR\n\nThis document provides a complete, standalone NixOS `configuration.nix` template for setting up Frigate as an NVR. It includes basic system setup, hardware configurations with placeholders for x86-64 or ARM64, and support for accelerators like Coral TPU, Intel Quick Sync, or Rockchip NPU. The config assumes a server-like setup (no desktop environment) and uses the built-in `services.frigate` module available in NixOS 23.11+.\n\nApply this to `/etc/nixos/configuration.nix` and run `nixos-rebuild switch`. For ARM64 (e.g., Raspberry Pi), ensure the system is built for aarch64-linux.\n\n## configuration.nix\n\n```nix\n# /etc/nixos/configuration.nix\n# Edit this configuration file to define what should be installed on your system.\n\n{ config, pkgs, lib, ... }:\n\n{\n  imports = [\n    # Include hardware configuration (generate with nixos-generate-config)\n    ./hardware-configuration.nix\n  ];\n\n  # Boot loader configuration\n  boot.loader = {\n    # For x86-64 systems\n    # systemd-boot.enable = true;\n    # efi.canTouchEfiVariables = true;\n\n    # For ARM64 (e.g., Raspberry Pi)\n    # generic-extlinux-compatible.enable = true;\n    # raspberryPi.enable = true;  # If using official Raspberry Pi support\n  };\n\n  # Kernel and modules (adjust for ARM)\n  boot.kernelPackages = pkgs.linuxPackages_latest;  # Or linuxPackages_rpi4 for Pi\n  boot.initrd.availableKernelModules = [ \"usbhid\" \"usb_storage\" ];  # Add for USB devices\n\n  # Networking\n  networking = {\n    hostName = \"nvr-server\";  # Set your hostname\n    useDHCP = lib.mkDefault true;  # Or configure static IP\n    firewall = {\n      enable = true;\n      allowedTCPPorts = [ 5000 8554 ];  # Frigate web UI and RTSP\n    };\n  };\n\n  # Time zone and locale\n  time.timeZone = \"UTC\";\n  i18n.defaultLocale = \"en_US.UTF-8\";\n\n  # Users\n  users.users.root = {\n    initialPassword = \"change-me\";  # Change immediately\n  };\n  users.users.nvruser = {\n    isNormalUser = true;\n    extraGroups = [ \"wheel\" \"video\" \"docker\" ];  # For hardware access\n    initialPassword = \"password\";  # Change this\n  };\n\n  # System packages\n  environment.systemPackages = with pkgs; [\n    vim  # Or your editor\n    git\n    htop\n    ffmpeg-full\n    libedgetpu  # For Coral\n  ];\n\n  # Enable Docker if not using native Frigate service\n  # virtualisation.docker.enable = true;\n\n  # Hardware-specific configurations\n  # INSERT_HARDWARE_HERE\n  hardware.opengl.enable = true;\n  hardware.opengl.extraPackages = with pkgs; [\n    # For Intel: intel-media-driver vaapiIntel\n    # For ARM/Rockchip: mesa\n  ];\n\n  # Services\n  services.openssh.enable = true;  # For remote access\n\n  # Frigate NVR service\n  services.frigate = {\n    enable = true;\n    hostname = \"frigate\";\n    settings = {\n      mqtt = {\n        enabled = false;  # Enable if using Home Assistant\n      };\n      cameras = {\n        # Example camera; add your own\n        front_door = {\n          ffmpeg = {\n            inputs = [\n              { path = \"rtsp://user:pass@camera-ip:554/stream\"; }\n            ];\n          };\n          detect = {\n            enabled = true;\n          };\n        };\n      };\n      detectors = {\n        # INSERT_DETECTOR_HERE\n      };\n      record = {\n        enabled = true;\n        retain = {\n          days = 7;\n        };\n      };\n      # Add storage paths, etc.\n    };\n  };\n\n  # System version (do not edit)\n  system.stateVersion = \"24.05\";  # Adjust to your NixOS version\n}\n```\n\n## Bash Script to Adjust Config (adjust_nvr_config.sh)\n\nThis script modifies the `configuration.nix` based on architecture (x86 or arm) and accelerator (coral, intel, rockchip, or none). It also handles basic boot loader adjustments for ARM vs x86. Run as `./adjust_nvr_config.sh --config /etc/nixos/configuration.nix --arch x86 --accelerator coral --board rpi4` (board optional for ARM specifics).\n\n```bash\n#!/bin/bash\n\n# Usage: ./adjust_nvr_config.sh --config \u003cpath\u003e --arch \u003cx86|arm\u003e --accelerator \u003ccoral|intel|rockchip|none\u003e [--board \u003crpi4|generic\u003e]\n\nCONFIG_FILE=\"\"\nARCH=\"\"\nACCELERATOR=\"none\"\nBOARD=\"generic\"\n\nwhile [[ $# -gt 0 ]]; do\n  case $1 in\n    --config) CONFIG_FILE=\"$2\"; shift 2 ;;\n    --arch) ARCH=\"$2\"; shift 2 ;;\n    --accelerator) ACCELERATOR=\"$2\"; shift 2 ;;\n    --board) BOARD=\"$2\"; shift 2 ;;\n    *) echo \"Unknown option $1\"; exit 1 ;;\n  esac\ndone\n\nif [ -z \"$CONFIG_FILE\" ] || [ -z \"$ARCH\" ]; then\n  echo \"Usage: $0 --config \u003cpath\u003e --arch \u003cx86|arm\u003e --accelerator \u003ccoral|intel|rockchip|none\u003e [--board \u003crpi4|generic\u003e]\"\n  exit 1\nfi\n\nif [ ! -f \"$CONFIG_FILE\" ]; then\n  echo \"Config file not found: $CONFIG_FILE\"\n  exit 1\nfi\n\n# Backup original\ncp \"$CONFIG_FILE\" \"$CONFIG_FILE.bak\"\n\n# Modify boot loader based on arch and board\nif [ \"$ARCH\" = \"x86\" ]; then\n  sed -i 's/# For x86-64 systems/systemd-boot.enable = true;\\n    efi.canTouchEfiVariables = true;/g' \"$CONFIG_FILE\"\n  sed -i 's/# For ARM64 (e.g., Raspberry Pi)//g' \"$CONFIG_FILE\"\nelse\n  sed -i 's/# For x86-64 systems//g' \"$CONFIG_FILE\"\n  if [ \"$BOARD\" = \"rpi4\" ]; then\n    sed -i 's/# For ARM64 (e.g., Raspberry Pi)/generic-extlinux-compatible.enable = true;\\n    raspberryPi.enable = true;\\n    raspberryPi.version = 4;/g' \"$CONFIG_FILE\"\n  else\n    sed -i 's/# For ARM64 (e.g., Raspberry Pi)/generic-extlinux-compatible.enable = true;/g' \"$CONFIG_FILE\"\n  fi\n  # Adjust kernel for ARM\n  sed -i 's/boot.kernelPackages = pkgs.linuxPackages_latest;/boot.kernelPackages = pkgs.linuxPackages_rpi4;  # Or appropriate for your board/g' \"$CONFIG_FILE\"\nfi\n\n# Modify detectors\nDETECTOR=\"\"\ncase $ACCELERATOR in\n  coral)\n    DETECTOR=\"coral = { type = \\\"edgetpu\\\"; device = \\\"usb\\\"; };\"\n    ;;\n  intel)\n    DETECTOR=\"cpu = { type = \\\"cpu\\\"; };  # Use VAAPI in Frigate ffmpeg args\"\n    ;;\n  rockchip)\n    DETECTOR=\"rknpu = { type = \\\"rknpu\\\"; };  # Assuming custom support\"\n    ;;\n  none)\n    DETECTOR=\"cpu = { type = \\\"cpu\\\"; };\"\n    ;;\nesac\nsed -i \"s/# INSERT_DETECTOR_HERE/$DETECTOR/g\" \"$CONFIG_FILE\"\n\n# Modify hardware\nHARDWARE=\"\"\nif [ \"$ARCH\" = \"x86\" ]; then\n  HARDWARE=\"hardware.opengl.extraPackages = with pkgs; [ intel-media-driver vaapiIntel libvdpau-va-gl ];\"\n  if [ \"$ACCELERATOR\" = \"coral\" ]; then\n    HARDWARE=\"$HARDWARE\\n  services.udev.extraRules = \\\"SUBSYSTEM==\\\\\\\"apex\\\\\\\", MODE=\\\\\\\"0660\\\\\\\", GROUP=\\\\\\\"users\\\\\\\"\\\";\"\n  fi\nelif [ \"$ARCH\" = \"arm\" ]; then\n  HARDWARE=\"hardware.opengl.extraPackages = with pkgs; [ mesa ];\"\n  HARDWARE=\"$HARDWARE\\n  boot.kernelModules = [ \\\"videodev\\\" \\\"v4l2loopback\\\" ];  # For video\"\n  if [ \"$ACCELERATOR\" = \"rockchip\" ]; then\n    HARDWARE=\"$HARDWARE\\n  boot.kernelModules = boot.kernelModules ++ [ \\\"rknpu\\\" \\\"mali\\\" ];\"\n  fi\n  if [ \"$ACCELERATOR\" = \"coral\" ]; then\n    HARDWARE=\"$HARDWARE\\n  environment.systemPackages = config.environment.systemPackages ++ [ pkgs.libedgetpu ];\"\n  fi\nfi\nsed -i \"s/# INSERT_HARDWARE_HERE/$HARDWARE/g\" \"$CONFIG_FILE\"\n\necho \"Configuration adjusted for $ARCH ($BOARD) with $ACCELERATOR. Backup: $CONFIG_FILE.bak\"\necho \"Run 'nixos-rebuild switch' to apply. For ARM, ensure aarch64 build.\"\n```\n\n## Notes\n- **Hardware Configuration**: Generate `./hardware-configuration.nix` with `nixos-generate-config` after initial install.\n- **Frigate Customization**: Edit the `services.frigate.settings` section for your cameras, storage, etc. Refer to Frigate docs.\n- **ARM64 Specifics**: For Raspberry Pi 4, use `--board rpi4`. For other ARM boards (e.g., Rockchip), adjust kernel/modules manually.\n- **Python Alternative**: If complex logic is needed (e.g., interactive questions), a Python script could replace bash, but bash suffices here.\n- **Testing**: Verify on a VM first. For Coral, ensure USB passthrough.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falh477%2Fnixos_nvr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falh477%2Fnixos_nvr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falh477%2Fnixos_nvr/lists"}