From 13e2cb64cfc4236c6b0f11076636b471d97ac0b0 Mon Sep 17 00:00:00 2001 From: Emily Date: Wed, 2 Aug 2023 04:03:53 +0100 Subject: [PATCH 1/3] cdrdao: use `finalAttrs` --- pkgs/tools/cd-dvd/cdrdao/default.nix | 33 ++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/pkgs/tools/cd-dvd/cdrdao/default.nix b/pkgs/tools/cd-dvd/cdrdao/default.nix index 527d70e7a90d..a58754c0370d 100644 --- a/pkgs/tools/cd-dvd/cdrdao/default.nix +++ b/pkgs/tools/cd-dvd/cdrdao/default.nix @@ -1,18 +1,33 @@ -{lib, stdenv, fetchurl, libvorbis, libmad, pkg-config, libao}: +{ + lib, + stdenv, + fetchurl, + pkg-config, + libvorbis, + libmad, + libao, +}: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "cdrdao"; version = "1.2.5"; src = fetchurl { - url = "mirror://sourceforge/cdrdao/cdrdao-${version}.tar.bz2"; + url = "mirror://sourceforge/cdrdao/cdrdao-${finalAttrs.version}.tar.bz2"; hash = "sha256-0ZtnyFPF26JAavqrbNeI53817r5jTKxGeVKEd8e+AbY="; }; makeFlags = [ "RM=rm" "LN=ln" "MV=mv" ]; - nativeBuildInputs = [ pkg-config ]; - buildInputs = [ libvorbis libmad libao ]; + nativeBuildInputs = [ + pkg-config + ]; + + buildInputs = [ + libvorbis + libmad + libao + ]; hardeningDisable = [ "format" ]; @@ -25,10 +40,10 @@ stdenv.mkDerivation rec { # Needed on gcc >= 6. env.NIX_CFLAGS_COMPILE = "-Wno-narrowing"; - meta = with lib; { + meta = { description = "A tool for recording audio or data CD-Rs in disk-at-once (DAO) mode"; homepage = "https://cdrdao.sourceforge.net/"; - platforms = platforms.linux; - license = licenses.gpl2; + platforms = lib.platforms.linux; + license = lib.licenses.gpl2; }; -} +}) From 58dff2378fec180a2d273bccfe10a6423fafcba5 Mon Sep 17 00:00:00 2001 From: Emily Date: Wed, 2 Aug 2023 04:04:42 +0100 Subject: [PATCH 2/3] {cdrdao,whipper}: support Darwin --- pkgs/applications/audio/whipper/default.nix | 2 +- pkgs/tools/cd-dvd/cdrdao/default.nix | 19 ++++++++++++++++++- pkgs/top-level/all-packages.nix | 4 +++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/audio/whipper/default.nix b/pkgs/applications/audio/whipper/default.nix index e92b2f13187e..eb179bfa5496 100644 --- a/pkgs/applications/audio/whipper/default.nix +++ b/pkgs/applications/audio/whipper/default.nix @@ -95,6 +95,6 @@ in python3.pkgs.buildPythonApplication rec { description = "A CD ripper aiming for accuracy over speed"; maintainers = with maintainers; [ emily ]; license = licenses.gpl3Plus; - platforms = platforms.linux; + platforms = platforms.unix; }; } diff --git a/pkgs/tools/cd-dvd/cdrdao/default.nix b/pkgs/tools/cd-dvd/cdrdao/default.nix index a58754c0370d..8d557993f9dc 100644 --- a/pkgs/tools/cd-dvd/cdrdao/default.nix +++ b/pkgs/tools/cd-dvd/cdrdao/default.nix @@ -2,10 +2,14 @@ lib, stdenv, fetchurl, + fetchpatch, pkg-config, + libiconv, libvorbis, libmad, libao, + CoreServices, + IOKit, }: stdenv.mkDerivation (finalAttrs: { @@ -24,13 +28,26 @@ stdenv.mkDerivation (finalAttrs: { ]; buildInputs = [ + libiconv libvorbis libmad libao + ] ++ lib.optionals stdenv.isDarwin [ + CoreServices + IOKit ]; hardeningDisable = [ "format" ]; + patches = [ + # Fix build on macOS SDK < 12 + # https://github.com/cdrdao/cdrdao/pull/19 + (fetchpatch { + url = "https://github.com/cdrdao/cdrdao/commit/105d72a61f510e3c47626476f9bbc9516f824ede.patch"; + hash = "sha256-NVIw59CSrc/HcslhfbYQNK/qSmD4QbfuV8hWYhWelX4="; + }) + ]; + # we have glibc/include/linux as a symlink to the kernel headers, # and the magic '..' points to kernelheaders, and not back to the glibc/include postPatch = '' @@ -43,7 +60,7 @@ stdenv.mkDerivation (finalAttrs: { meta = { description = "A tool for recording audio or data CD-Rs in disk-at-once (DAO) mode"; homepage = "https://cdrdao.sourceforge.net/"; - platforms = lib.platforms.linux; + platforms = lib.platforms.unix; license = lib.licenses.gpl2; }; }) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 2a9362c02dcf..1ec575b69bf5 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6547,7 +6547,9 @@ with pkgs; cdpr = callPackage ../tools/networking/cdpr { }; - cdrdao = callPackage ../tools/cd-dvd/cdrdao { }; + cdrdao = callPackage ../tools/cd-dvd/cdrdao { + inherit (darwin.apple_sdk.frameworks) CoreServices IOKit; + }; cdrkit = callPackage ../tools/cd-dvd/cdrkit { }; From 8d08ce1f93bfec78965195851b874abf904f8cc9 Mon Sep 17 00:00:00 2001 From: Emily Date: Wed, 2 Aug 2023 04:05:21 +0100 Subject: [PATCH 3/3] cdrdao: add patch to fix uninitialized variable --- pkgs/tools/cd-dvd/cdrdao/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/tools/cd-dvd/cdrdao/default.nix b/pkgs/tools/cd-dvd/cdrdao/default.nix index 8d557993f9dc..959899d3b3f3 100644 --- a/pkgs/tools/cd-dvd/cdrdao/default.nix +++ b/pkgs/tools/cd-dvd/cdrdao/default.nix @@ -46,6 +46,13 @@ stdenv.mkDerivation (finalAttrs: { url = "https://github.com/cdrdao/cdrdao/commit/105d72a61f510e3c47626476f9bbc9516f824ede.patch"; hash = "sha256-NVIw59CSrc/HcslhfbYQNK/qSmD4QbfuV8hWYhWelX4="; }) + + # Fix undefined behaviour caused by uninitialized variable + # https://github.com/cdrdao/cdrdao/pull/21 + (fetchpatch { + url = "https://github.com/cdrdao/cdrdao/commit/251a40ab42305c412674c7c2d391374d91e91c95.patch"; + hash = "sha256-+nGlWw5rgc5Ns2l+6fQ4Hp2LbhO4R/I95h9WGIh/Ebw="; + }) ]; # we have glibc/include/linux as a symlink to the kernel headers,