Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jimj92120/nixos-pi-hole
A NixOS image build for Raspberry Pi with Pi-hole.
https://github.com/jimj92120/nixos-pi-hole
docker nixos pi-hole raspberry-pi
Last synced: 1 day ago
JSON representation
A NixOS image build for Raspberry Pi with Pi-hole.
- Host: GitHub
- URL: https://github.com/jimj92120/nixos-pi-hole
- Owner: JimJ92120
- Created: 2024-02-09T15:22:34.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-02-09T16:28:51.000Z (8 months ago)
- Last Synced: 2024-09-26T13:02:45.397Z (1 day ago)
- Topics: docker, nixos, pi-hole, raspberry-pi
- Language: Nix
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nixos-pi-hole
An example to run `pi-hole` with `docker` in a Raspberry Pi device (`arm` based device).
Refer to [NixOS `arm` documentation](https://nixos.wiki/wiki/NixOS_on_ARM) for boards' specifications.The following documentation will build a NixOS image to write on a SD card for targetted devices (`arm` / `aarch64`).
`pi-hole` will be setup through Docker and `docker-compose`.Example has been tested on a `Raspberry Pi 4` (`4GB`) and a `Raspberry Pi Zero 2 WH`.
### important notes
- ensure that no sensitive data (e.g credentials) are passed and store into `/nix/store`.
- update the default user password with `sudo passwd $USER_NAME`---
---
# installation
## build and write image
```sh
# example variables### the SD card /dev/ path
SD_CARD='/dev/sda'### the image name (output after step 1)
IMAGE_NAME='nixos-sd-image-...-linux.img'
```#### 1. update variables in `configuration.nix` (system configuration) and `docker.nix` (containers)
#### 2. build the image from `./configuration.nix`
```sh
export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1nix-build '' -A config.system.build.sdImage -I nixos-config=./configuration.nix
```Some `read-only` permission may occur.
Copy the `result/sd-image/${IMAGE_NAME}.zst` file to another location if this happens.```sh
cp "result/sd-image/${IMAGE_NAME}.zst" /path/to/new/location/cd /path/to/new/location/
```#### 3. de-compress the `.img.zst` output file
```sh
unzstd -d "${IMAGE_NAME}.zst"
```#### 4. write `.img` to SD card
```sh
# write to sd card
sudo dd if=$IMAGE_NAME of=$SD_CARD bs=4096 conv=fsync status=progress
```#### 5. mount the card on the target device
#### 6. update `nix-channel`
By default `nix-channel` is not updated.
This may cause issue such as `nixpkgs` or `$NIX_PATH` not found though already set.Following may be run:
```sh
sudo -i nix-channel --update
```## run `pi-hole`
#### 1. adjust files in [`./pi-hole`](./pi-hole) directory
#### 2. upload / copy `./pi-hole` directory to the target host
#### 3. run `docker-compose up -d` to start the `pi-hole` container
---
---
# docker
`docker` and `docker-compose` are setup as `root` (to change).
Files may be copied over via e.g `scp` or additional `nix` tools may be used (e.g `oci-containers`, `arion`).
The current example uses `oci-containers` to run `pi-hole` as a service.
See [NixOS Docker documentation](https://nixos.wiki/wiki/Docker).
---
# pi-hole
### change password
```sh
docker exec -it pi-hole /bin/bash#
pihole -a -p
```---
---
# documentation and links
- https://rbf.dev/blog/2020/05/custom-nixos-build-for-raspberry-pis/
- https://nixos.org/manual/nixos/stable/#sec-building-image-instructions
- https://nixos.wiki/wiki/NixOS_on_ARM/Raspberry_Pi
- https://nixos.wiki/wiki/Docker
- https://github.com/pi-hole/docker-pi-hole