I have been trying to build the wm6980 audio hat driver into a nix package (hopefully to use on a Raspberry Pi with wyoming-satellite.) I keep running into a lot Permission denied errors. I think this outlines a huge knowledge gap I have with nix. Since my source is set to fetchFromGitHub, my understanding is that the store path will be used within the flake, but then the store path is read-only. I hope someone here can set me straight, because by this logic no nix package should build.
Here are the errors:
error: builder for '/nix/store/p78pj1ii3fim40ij2aybp10gkacjwf41-wm6980-audio-hat.drv' failed with exit code 2;
last 10 log lines:
> mkdir: cannot create directory '/nix/store/0ns9h5r5d7k0z4brzf4d8kl0ap2kq5c1-source/.tmp_139': Permission denied
> mkdir: cannot create directory '/nix/store/0ns9h5r5d7k0z4brzf4d8kl0ap2kq5c1-source/.tmp_142': Permission denied
> mkdir: cannot create directory '/nix/store/0ns9h5r5d7k0z4brzf4d8kl0ap2kq5c1-source/.tmp_145': Permission denied
> mkdir: cannot create directory '/nix/store/0ns9h5r5d7k0z4brzf4d8kl0ap2kq5c1-source/.tmp_148': Permission denied
> mkdir: cannot create directory '/nix/store/0ns9h5r5d7k0z4brzf4d8kl0ap2kq5c1-source/.tmp_151': Permission denied
> /nix/store/9vafkkic27k7m4934fpawl6yip3a6k4h-bash-5.2-p21/bin/bash: line 1: /nix/store/0ns9h5r5d7k0z4brzf4d8kl0ap2kq5c1-source/snd-soc-wm8960.mod: Permission denied
> make[2]: *** [/nix/store/8qsg7kkmxwyva5ns6wikm1ppbcx4j93n-linux-6.7-dev/lib/modules/6.7.0/source/scripts/Makefile.build:252: /nix/store/0ns9h5r5d7k0z4brzf4d8kl0ap2kq5c1-source/snd-soc-wm8960.mod] Error 1
> make[1]: *** [/nix/store/8qsg7kkmxwyva5ns6wikm1ppbcx4j93n-linux-6.7-dev/lib/modules/6.7.0/source/Makefile:1911: /nix/store/0ns9h5r5d7k0z4brzf4d8kl0ap2kq5c1-source] Error 2
> make: *** [/nix/store/8qsg7kkmxwyva5ns6wikm1ppbcx4j93n-linux-6.7-dev/lib/modules/6.7.0/source/Makefile:234: __sub-make] Error 2
> make: Leaving directory '/nix/store/8qsg7kkmxwyva5ns6wikm1ppbcx4j93n-linux-6.7-dev/lib/modules/6.7.0/build'
For full logs, run 'nix log /nix/store/p78pj1ii3fim40ij2aybp10gkacjwf41-wm6980-audio-hat.drv'.
And here is the current iteration of my flake.nix:
{
description = "wm6980 audio hat";
inputs = {
# nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs.url = "git+file:///home/myuser/Projects/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, flake-utils, nixpkgs }:
flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system:
let
pkgs = nixpkgs.legacyPackages.${system};
kernel = pkgs.linux_6_7;
in rec {
packages = rec {
wm6980-audio-hat = pkgs.stdenv.mkDerivation rec {
name = "wm6980-audio-hat";
inherit system;
buildInputs = with pkgs; [
stdenv
nukeReferences
];
src = pkgs.fetchFromGitHub {
owner = "waveshare";
repo = "WM8960-Audio-HAT";
rev = "rpi-4.9.y";
hash = "sha256-EZkR/lZIORYP8qpsDcrdMQCSToVTrif042BBynBpXV4=";
# url = "github:rhasspy/wyoming-satellite";
};
makeFlags = kernel.makeFlags ++ [
"-C"
"${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
"M=${src}"
];
buildFlags = [ "modules" ];
installFlags = [ "INSTALL_MOD_PATH=${placeholder "out"}" ];
};
default = packages.wm6980-audio-hat;
};
}
);
}