From 42f3e98abbdd95bd795e56a3485a3b948caf3f63 Mon Sep 17 00:00:00 2001 From: Dennis Gosnell Date: Thu, 7 Dec 2023 15:27:52 +0900 Subject: [PATCH 1/3] Setup tz package overrides to reference system tzdata package correctly This commit changes the cabal2nix hooks for the `tz` Haskell package. Originally, the `tz` package had a hook that added a phase override for `preConfigure` that looked like the following: ```nix preConfigure = "export TZDIR=${pkgs.tzdata}/share/zoneinfo"; ``` This works for `hackage2nix`, but the problem is that when using `cabal2nix` by itself, this produces a Nix file like the following: ```nix { mkDerivation, base, binary, bytestring, containers, criterion , data-default, deepseq, HUnit, lens, lib, QuickCheck, tasty , tasty-hunit, tasty-quickcheck, tasty-th, template-haskell, thyme , time, timezone-olson, timezone-series, tzdata, vector }: mkDerivation { pname = "tz"; version = "0.1.3.6"; preConfigure = "export TZDIR=${pkgs.tzdata}/share/zoneinfo"; ... } ``` This is trying to reference `pkgs.tzdata`, but `pkgs` is not available here! This commit changes the hook for `tz` to take a `system-tzdata` package as an argument, and then correctly reference this `system-tzdata` for the tests: ```nix { mkDerivation, base, binary, bytestring, containers, criterion , data-default, deepseq, HUnit, lens, lib, QuickCheck , system-tzdata, tasty, tasty-hunit, tasty-quickcheck, tasty-th , template-haskell, thyme, time, timezone-olson, timezone-series , tzdata, vector }: mkDerivation { pname = "tz"; version = "0.1.3.6"; preCheck = "export TZDIR=${system-tzdata}/share/zoneinfo"; ... } ``` --- .../Nixpkgs/Haskell/FromCabal/PostProcess.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cabal2nix/src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs b/cabal2nix/src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs index fa460a1c9..83db65f63 100644 --- a/cabal2nix/src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs +++ b/cabal2nix/src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs @@ -174,7 +174,7 @@ hooks = , ("tensorflow-proto", set (libraryDepends . tool . contains (pkg "protobuf")) True) , ("thyme", set (libraryDepends . tool . contains (self "cpphs")) True) -- required on Darwin , ("twilio", set doCheck False) -- attempts to access the network - , ("tz", set phaseOverrides "preConfigure = \"export TZDIR=${pkgs.tzdata}/share/zoneinfo\";") + , ("tz", tzOverrides) , ("udev", set (metaSection . platforms) (Just $ Set.singleton (NixpkgsPlatformGroup (ident # "linux")))) , ("websockets", set doCheck False) -- https://github.com/jaspervdj/websockets/issues/104 , ("Win32", set (metaSection . platforms) (Just $ Set.singleton (NixpkgsPlatformGroup (ident # "windows")))) @@ -405,5 +405,14 @@ bustleOverrides = set (libraryDepends . pkgconfig . contains "system-glib = pkgs . set (metaSection . license) (Known "lib.licenses.lgpl21Plus") . set (metaSection . hydraPlatforms) Nothing +tzOverrides :: Derivation -> Derivation +tzOverrides = + -- The tz Haskell package uses zoneinfo files from the system tzdata package in its tests. + set phaseOverrides "preCheck = \"export TZDIR=${system-tzdata}/share/zoneinfo\";" . + -- The tz Haskell package depends on both the tzdata Haskell package, as well as the + -- tzdata system package. The following passes in the tzdata system package as + -- "system-tzdata". + set (testDepends . system . contains "system-tzdata = pkgs.tzdata") True + nullBinding :: Identifier -> Binding nullBinding name = binding # (name, path # [ident # "null"]) From c2b01f600924969a349f15120d1bfe58c80ac6b8 Mon Sep 17 00:00:00 2001 From: Dennis Gosnell Date: Wed, 27 Dec 2023 15:02:08 +0900 Subject: [PATCH 2/3] tz package overrides don't need to explicitly set TZDIR The `tzdata` system package has a setup hook that sets the `TZDIR` env var. This was suggested in https://github.com/NixOS/cabal2nix/pull/611#discussion_r1418704793 --- .../Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cabal2nix/src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs b/cabal2nix/src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs index 83db65f63..30080d300 100644 --- a/cabal2nix/src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs +++ b/cabal2nix/src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs @@ -405,13 +405,11 @@ bustleOverrides = set (libraryDepends . pkgconfig . contains "system-glib = pkgs . set (metaSection . license) (Known "lib.licenses.lgpl21Plus") . set (metaSection . hydraPlatforms) Nothing +-- | The tz Haskell package depends on both the tzdata Haskell package, as well as the +-- tzdata system package. The following passes in the tzdata system package as +-- \"system-tzdata\". tzOverrides :: Derivation -> Derivation tzOverrides = - -- The tz Haskell package uses zoneinfo files from the system tzdata package in its tests. - set phaseOverrides "preCheck = \"export TZDIR=${system-tzdata}/share/zoneinfo\";" . - -- The tz Haskell package depends on both the tzdata Haskell package, as well as the - -- tzdata system package. The following passes in the tzdata system package as - -- "system-tzdata". set (testDepends . system . contains "system-tzdata = pkgs.tzdata") True nullBinding :: Identifier -> Binding From 945e8ee8491424d4e335152b2932b63757838c17 Mon Sep 17 00:00:00 2001 From: Dennis Gosnell Date: Tue, 2 Jan 2024 20:05:51 +0900 Subject: [PATCH 3/3] Remove tz Haskell package override from cabal2nix We've decided that the entire tz override doesn't make sense in cabal2nix. The tests for the tz Haskell package require the tzdata system library, but we can add that in Nixpkgs. That seems like the least confusing way to provide it. --- .../Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/cabal2nix/src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs b/cabal2nix/src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs index 30080d300..9b71779e7 100644 --- a/cabal2nix/src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs +++ b/cabal2nix/src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs @@ -174,7 +174,6 @@ hooks = , ("tensorflow-proto", set (libraryDepends . tool . contains (pkg "protobuf")) True) , ("thyme", set (libraryDepends . tool . contains (self "cpphs")) True) -- required on Darwin , ("twilio", set doCheck False) -- attempts to access the network - , ("tz", tzOverrides) , ("udev", set (metaSection . platforms) (Just $ Set.singleton (NixpkgsPlatformGroup (ident # "linux")))) , ("websockets", set doCheck False) -- https://github.com/jaspervdj/websockets/issues/104 , ("Win32", set (metaSection . platforms) (Just $ Set.singleton (NixpkgsPlatformGroup (ident # "windows")))) @@ -405,12 +404,5 @@ bustleOverrides = set (libraryDepends . pkgconfig . contains "system-glib = pkgs . set (metaSection . license) (Known "lib.licenses.lgpl21Plus") . set (metaSection . hydraPlatforms) Nothing --- | The tz Haskell package depends on both the tzdata Haskell package, as well as the --- tzdata system package. The following passes in the tzdata system package as --- \"system-tzdata\". -tzOverrides :: Derivation -> Derivation -tzOverrides = - set (testDepends . system . contains "system-tzdata = pkgs.tzdata") True - nullBinding :: Identifier -> Binding nullBinding name = binding # (name, path # [ident # "null"])