152 lines
4.2 KiB
Nix
152 lines
4.2 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
hostName = "music-bedroom";
|
|
snapserverHost = "snapcast.cloonar.com";
|
|
in
|
|
{
|
|
nixpkgs.crossSystem.system = "aarch64-linux";
|
|
imports = [
|
|
<nixpkgs/nixos/modules/installer/sd-card/sd-image-aarch64.nix>
|
|
<nixos-hardware/raspberry-pi/4>
|
|
];
|
|
|
|
networking.hostName = hostName;
|
|
networking.wireless = {
|
|
enable = true;
|
|
networks = {
|
|
"Cloonar-Multimedia" = {
|
|
hidden = true;
|
|
psk = "";
|
|
};
|
|
};
|
|
};
|
|
|
|
boot = {
|
|
# loader.grub.enable = false;
|
|
# loader.raspberryPi.enable = true;
|
|
# loader.raspberryPi.version = 3;
|
|
loader.raspberryPi.firmwareConfig = ''
|
|
dtparam=audio=on
|
|
'';
|
|
};
|
|
|
|
hardware.deviceTree.filter = "bcm2710-rpi-zero-2-w.dtb";
|
|
hardware.deviceTree = {
|
|
enable = true;
|
|
overlays = [
|
|
{
|
|
name = "hifiberry-dacplus";
|
|
dtsText = ''
|
|
/dts-v1/;
|
|
/plugin/;
|
|
|
|
/ {
|
|
compatible = "brcm,bcm2710,bcm2837";
|
|
|
|
fragment@0 {
|
|
target-path = "/";
|
|
__overlay__ {
|
|
dacpro_osc: dacpro_osc {
|
|
compatible = "hifiberry,dacpro-clk";
|
|
#clock-cells = <0>;
|
|
};
|
|
};
|
|
};
|
|
|
|
fragment@1 {
|
|
target = <&i2s>;
|
|
__overlay__ {
|
|
status = "okay";
|
|
};
|
|
};
|
|
|
|
fragment@2 {
|
|
target = <&i2c1>;
|
|
__overlay__ {
|
|
#address-cells = <1>;
|
|
#size-cells = <0>;
|
|
status = "okay";
|
|
|
|
pcm5122@4d {
|
|
#sound-dai-cells = <0>;
|
|
compatible = "ti,pcm5122";
|
|
reg = <0x4d>;
|
|
clocks = <&dacpro_osc>;
|
|
AVDD-supply = <&vdd_3v3_reg>;
|
|
DVDD-supply = <&vdd_3v3_reg>;
|
|
CPVDD-supply = <&vdd_3v3_reg>;
|
|
status = "okay";
|
|
};
|
|
hpamp: hpamp@60 {
|
|
compatible = "ti,tpa6130a2";
|
|
reg = <0x60>;
|
|
status = "disabled";
|
|
};
|
|
};
|
|
};
|
|
|
|
fragment@3 {
|
|
target = <&sound>;
|
|
hifiberry_dacplus: __overlay__ {
|
|
compatible = "hifiberry,hifiberry-dacplus";
|
|
i2s-controller = <&i2s>;
|
|
status = "okay";
|
|
};
|
|
};
|
|
|
|
__overrides__ {
|
|
24db_digital_gain =
|
|
<&hifiberry_dacplus>,"hifiberry,24db_digital_gain?";
|
|
slave = <&hifiberry_dacplus>,"hifiberry-dacplus,slave?";
|
|
leds_off = <&hifiberry_dacplus>,"hifiberry-dacplus,leds_off?";
|
|
};
|
|
};
|
|
'';
|
|
}
|
|
];
|
|
};
|
|
|
|
sound.enable = true;
|
|
|
|
systemd.services.snapclient = {
|
|
description = "Snapcast client";
|
|
wantedBy = ["multi-user.target"];
|
|
wants = ["network-online.target"];
|
|
after = ["network-online.target"];
|
|
|
|
serviceConfig = {
|
|
Type = "forking";
|
|
ExecStart = "${pkgs.snapcast}/bin/snapclient --daemon --hostID ${config.networking.hostName} -h ${snapserverHost} --player alsa";
|
|
PIDFile = "/run/snapclient/pid";
|
|
Restart = "on-failure";
|
|
RestartSec = "5s";
|
|
DynamicUser = true;
|
|
SupplementaryGroups = "audio";
|
|
RuntimeDirectory = "snapclient";
|
|
};
|
|
};
|
|
|
|
services.openssh.enable = true;
|
|
users = {
|
|
mutableUsers = false;
|
|
users.root = {
|
|
hashedPassword = lib.mkForce "$6$7IKExnDde920x.YH$ggegnnKJYdmg1Wt33fxuPpM.MmIaX32LXVyjL8ed7ohT385lKotFGzRpitncQ3pd9Lci1QCFGRn2tVJGxkFAm0";
|
|
openssh.authorizedKeys.keys = [
|
|
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDN/2SAFm50kraB1fepAizox/QRXxB7WbqVbH+5OPalDT47VIJGNKOKhixQoqhABHxEoLxdf/C83wxlCVlPV9poLfDgVkA3Lyt5r3tSFQ6QjjOJAgchWamMsxxyGBedhKvhiEzcr/Lxytnoz3kjDG8fqQJwEpdqMmJoMUfyL2Rqp16u+FQ7d5aJtwO8EUqovhMaNO7rggjPpV/uMOg+tBxxmscliN7DLuP4EMTA/FwXVzcFNbOx3K9BdpMRAaSJt4SWcJO2cS2KHA5n/H+PQI7nz5KN3Yr/upJN5fROhi/SHvK39QOx12Pv7FCuWlc+oR68vLaoCKYhnkl3DnCfc7A7"
|
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIRQuPqH5fdX3KEw7DXzWEdO3AlUn1oSmtJtHB71ICoH Generated By Termius"
|
|
];
|
|
};
|
|
};
|
|
|
|
system.stateVersion = "22.05";
|
|
|
|
sdImage = {
|
|
compressImage = false;
|
|
};
|
|
}
|