Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup tz package overrides to reference system tzdata package correctly #611

Merged
merged 3 commits into from
Jan 2, 2024

Conversation

cdepillabout
Copy link
Member

This PR 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:

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:

{ 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:

{ 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";
  ...
}

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";
  ...
}
```
@cdepillabout cdepillabout marked this pull request as ready for review December 7, 2023 06:59
@cdepillabout
Copy link
Member Author

I've also tested this by bumping cabal2nix-unstable in Nixpkgs, and regenerating hackage-packages.nix. I've confirmed that haskellPackages.tz is still able to be built.

Also, it appears that CI is failing, but it doesn't appear related to this PR.

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\";" .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be unnecessary, actually, since the tzata setup hook in nixpkgs sets this variable nowadays. Can you try removing this?

If we can drop this, I wonder if having no cabal2nix-override would be better, since system-tzdata needs an external override anyways and it is an arbitrarily chosen name, so probably more confusing than not having it!

Copy link
Member Author

@cdepillabout cdepillabout Dec 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be unnecessary, actually, since the tzata setup hook in nixpkgs sets this variable nowadays. Can you try removing this?

Great suggestion, I made this change in c2b01f6 and it looks like it works well!

I also tried this change by bumping cabal2nix-unstable in Nixpkgs, regenerating haskellPackages.tz and rebuilding. It built fine.

If we can drop this, I wonder if having no cabal2nix-override would be better, since system-tzdata needs an external override anyways and it is an arbitrarily chosen name, so probably more confusing than not having it!

Yeah, that sounds reasonable as well. I don't have a strong opinion either way, but I do slightly agree with you that it is somewhat confusing having the arbitrarily-named system-tzdata argument.

Want me to just drop the override?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Want me to just drop the override?

Yes, I think that is the best solution to this unfortunate situation!

Copy link
Member Author

@cdepillabout cdepillabout Jan 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I've just completely dropped the override in 945e8ee.

@sternenseemann once you approve this, I'll update cabal2nix-unstable in Nixpkgs and fix up the tz package there as well.

The `tzdata` system package has a setup hook that sets the `TZDIR` env
var.

This was suggested in
NixOS#611 (comment)
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.
@sternenseemann sternenseemann merged commit 3f23ae1 into NixOS:master Jan 2, 2024
4 of 5 checks passed
@cdepillabout cdepillabout deleted the tz-and-tzdata branch January 3, 2024 01:48
sternenseemann added a commit to NixOS/nixpkgs that referenced this pull request Jan 4, 2024
See NixOS/cabal2nix#611 for discussion.

While we're changing things, let's also use the tzdata setupHook for
haskellPackages.tz.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants