Hey all, I’ve been trying to update some derivations I have for macOS apps to point to more recent versions of those available in the wild.
I’m hitting a strange error:
building '/nix/store/1b4an9if0sdqgynwjbgybn93lnnb0kpz-hm_.authinfo.drv'...
building '/nix/store/bxx0a22lj1022fkxc17gslr1ls2a3lb0-authy-2.2.3.drv'...
unpacking sources
unpacking source archive /nix/store/18azal3rfigpw2c4warn04qixm4dfm0i-authy-x86_64-2.2.3.dmg
error: only HFS file systems are supported.
do not know how to unpack source archive /nix/store/18azal3rfigpw2c4warn04qixm4dfm0i-authy-x86_64-2.2.3.dmg
error: builder for '/nix/store/bxx0a22lj1022fkxc17gslr1ls2a3lb0-authy-2.2.3.drv' failed with exit code 1;
last 4 log lines:
> unpacking sources
> unpacking source archive /nix/store/18azal3rfigpw2c4warn04qixm4dfm0i-authy-x86_64-2.2.3.dmg
> error: only HFS file systems are supported.
> do not know how to unpack source archive /nix/store/18azal3rfigpw2c4warn04qixm4dfm0i-authy-x86_64-2.2.3.dmg
For full logs, run 'nix log /nix/store/bxx0a22lj1022fkxc17gslr1ls2a3lb0-authy-2.2.3.drv'.
error: 1 dependencies of derivation '/nix/store/qbb0zg93a694nw8c6gznhdzp414v6z03-home-manager-applications.drv' failed to build
My app.nix
function is as follows:
{
# custom args
name,
appname ? name,
version,
src,
description,
homepage,
postInstall ? "",
sourceRoot ? ".",
# nix supplied
pkgs,
stdenv,
lib,
undmg,
unzip,
...
}:
if stdenv.isDarwin then
[(stdenv.mkDerivation {
name = "${name}-${version}";
version = "${version}";
src = src;
buildInputs = [ undmg unzip ];
sourceRoot = sourceRoot;
phases = [ "unpackPhase" "installPhase" ];
installPhase = ''
mkdir -p "$out/Applications/${appname}.app"
cp -pR * "$out/Applications/${appname}.app"
'' + postInstall;
meta = {
description = description;
homepage = homepage;
maintainers = [ "ldeck <ldeck@example.com>" ];
platforms = lib.platforms.darwin;
};
})]
else
[]
The app in question (Authy) is defined as a module as follows:
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.macOS.apps.authy;
stdenv = pkgs.stdenv;
arch = if stdenv.isDarwin then stdenv.hostPlatform.darwinArch else stdenv.system;
toHyphenedLower = str:
(lib.strings.toLower (builtins.replaceStrings [" "] ["-"] str));
archSpecs = {
x86_64-darwin = rec {
version = "2.2.3";
revision = "";
date = "";
arch = "amd64";
url = "https://pkg.authy.com/authy/stable/${version}/darwin/x64/Authy%20Desktop-${version}.dmg";
sha256 = "a75657222028822949516805f5af5406d4a786d0db0a9f91bd04cc08779883df";
};
aarch64-darwin = rec {
version = "2.2.3";
revision = "";
date = "";
arch = "arm64";
url = "https://pkg.authy.com/authy/stable/${version}/darwin/x64/Authy%20Desktop-${version}.dmg";
sha256 = "a75657222028822949516805f5af5406d4a786d0db0a9f91bd04cc08779883df";
};
};
in {
options = {
macOS.apps.authy = {
enable = mkOption {
default = false;
description = "Whether to enable this app.";
};
sourceRoot = mkOption {
default = "Authy Desktop.app";
description = "The app folder name to recursively copy from the install archive. e.g., Foo.app";
};
version = mkOption {
default = archSpecs.${stdenv.hostPlatform.system}.version;
description = "The version of the app.";
};
date = mkOption {
default = archSpecs.${stdenv.hostPlatform.system}.date;
description = "The build date (if applicable).";
};
revision = mkOption {
default = archSpecs.${stdenv.hostPlatform.system}.revision;
description = "The build number of the app (if applicable).";
};
url = mkOption {
default = archSpecs.${stdenv.hostPlatform.system}.url;
description = "The url or url template for the archive.";
};
sha256 = mkOption {
default = archSpecs.${stdenv.hostPlatform.system}.sha256;
description = "The sha256 for the app.";
};
};
};
config = mkIf cfg.enable {
home.packages =
(pkgs.callPackage ./lib/app.nix rec {
name = "authy";
description = "Two-factor authentication software";
sourceRoot = cfg.sourceRoot;
version = cfg.version;
src = pkgs.fetchurl {
url = cfg.url;
sha256 = cfg.sha256;
name = "${(toHyphenedLower name)}-${arch}-${version}.dmg";
};
appcast = "https://formulae.brew.sh/api/cask/authy.json";
homepage = "https://authy.com/";
});
};
}
I assume it’s something to do with undmg. But any suggestions on why this might be failing?
I can download the same dmg manually and happily open it.
nix-shell -p nix-info --run "nix-info -m"
- system: `"x86_64-darwin"`
- host os: `Darwin 22.3.0, macOS 10.16`
- multi-user?: `yes`
- sandbox: `no`
- version: `nix-env (Nix) 2.8.1`
- channels(root): `"nixpkgs"`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`