!RbXGJhHMsnQcNIDFWN:nixos.org

Haskell in Nixpkgs/NixOS

720 Members
For discussions and questions about Haskell with Nix, cabal2nix and haskellPackages in nixpkgs | Current Docs: https://haskell4nix.readthedocs.io/ | More Nix: #community:nixos.org | More Haskell: #haskell-space:matrix.org144 Servers

Load older messages


SenderMessageTime
18 Jan 2025
@implicit_operative:matrix.orgymeister It gets the tarball with the hash from hackage, and, I assume, gets the rest of the deps from nixpkgs. 22:48:12
@magic_rb:matrix.redalder.orgmagic_rb
pkgs.haskellPackages.lens.overrideAttrs {
  version = "5.3.3";
  src = pkgs.fetchzip {
     url = "mirror://hackage/lens-5.3.3/lens-5.3.3.tar.gz";
     hash = "sha256-3xm0+HH2CY3rcigl8x1kYVLOW5PVFhilg0s0hxHxzWE=";
  };
};
22:48:43
@magic_rb:matrix.redalder.orgmagic_rbright, but it doesnt know which deps, so it has to do a FOD or IFD22:48:58
@maralorn:maralorn.demaralorn
In reply to @implicit_operative:matrix.org

Maybe something like this?

lens_5_3_3 = pkgs.haskell.lib.callHackageDirect {
  pkg = "lens";
  ver = "5.3.3";
  sha256 = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
} {};
Yeah that uses ifd
22:57:30
@alexfmpe:matrix.orgalexfmpeFYI, using `sha256 = ""` does the same AAAA screaming23:04:36
@magic_rb:matrix.redalder.orgmagic_rbthat i know and it was the highlight of that years nix releases :)23:13:21
@alexfmpe:matrix.orgalexfmpehear hear23:37:59
19 Jan 2025
@b:chreekat.netchreekat They're fundamentally in conflict. You only avoid conflict precisely by applying them loosely. :) DRY, applied religiously, requires you to define abstractions very early that allow slightly different use cases to share common expressions. But abstractions have a cost. Copy/paste/modify is often cheaper. And most importantly, it requires a lot less careful thought. Wasting brainpower to develop a thoughtful abstraction for something that will never have more than two use cases is a shame. That's really the essence of YAGNI. 12:22:37
@maralorn:maralorn.demaralorn
In reply to @b:chreekat.net
They're fundamentally in conflict. You only avoid conflict precisely by applying them loosely. :) DRY, applied religiously, requires you to define abstractions very early that allow slightly different use cases to share common expressions. But abstractions have a cost. Copy/paste/modify is often cheaper. And most importantly, it requires a lot less careful thought. Wasting brainpower to develop a thoughtful abstraction for something that will never have more than two use cases is a shame. That's really the essence of YAGNI.
It's a very interesting dispute in our company. Our code is very YAGNI but the newer part of the team, mostly juniors, me included, have mostly heard the DRY gospel.
12:35:47
@maralorn:maralorn.demaralornEverytime my boss comes with a new requirement and it's a three liner for me because there is exactly one central function for it I am sooo happy.12:37:32
@maralorn:maralorn.demaralornWhereas applying the same API change roughly 15 times to slight variations of the same code drives me mad.12:38:17
@maralorn:maralorn.demaralornOtoh abstracting over those 15 slight variations would (have been) be quite a lot of work.12:40:12
@alex:tunstall.xyzAlex
In reply to @b:chreekat.net
They're fundamentally in conflict. You only avoid conflict precisely by applying them loosely. :) DRY, applied religiously, requires you to define abstractions very early that allow slightly different use cases to share common expressions. But abstractions have a cost. Copy/paste/modify is often cheaper. And most importantly, it requires a lot less careful thought. Wasting brainpower to develop a thoughtful abstraction for something that will never have more than two use cases is a shame. That's really the essence of YAGNI.

That's hardly the bare minimum needed to avoid repetition.

Perhaps DRY fails to explicitly account for the idea that some repetition is needed for defining things that are different even though they seem similar.

For me, problems like this tend to go away when I model the problem more carefully.

13:24:44
@maralorn:maralorn.demaralornI think when modeling things more carefully always makes the result better. The question is does it make the process more efficient.13:28:32
@kenran_:matrix.orgkenran_ I've updated the hscurses library a little bit; in particular its new version would no longer need the line hscurses = addExtraLibrary pkgs.ncurses super.hscurses; in configuration-nix.nix (but would need to inherit ncurses from pkgs instead in the mkDerivation call in hackage-packages.nix instead in order to not pull in the Haskell lib named ncurses). Is the version update + the latter step something that's automagically made somehow? Or would that need a PR somewhere? 13:53:33
@kenran_:matrix.orgkenran_ * I've updated the hscurses library a little bit; in particular its new version would no longer need the line hscurses = addExtraLibrary pkgs.ncurses super.hscurses; in configuration-nix.nix (but would need to inherit ncurses from pkgs instead in the mkDerivation call in hackage-packages.nix instead in order to not pull in the Haskell lib named ncurses). Is the version update + the latter step something that's automagically made somehow? Or would that need a PR somewhere? (My guess would be that changing configuration-nix.nix is a manual step?) 13:54:12
@cdepillabout:matrix.orgcdepillabout Changes in configuration-nix.nix and configuration-common.nix are always manual steps. However the version updates are automatic. It happens about once every two weeks on the haskell-updates branch in Nixpkgs. (Although now its more like once a month or so?) Here's an example PR where you can see the version updates happen: https://github.com/NixOS/nixpkgs/pull/371032 14:03:26
@kenran_:matrix.orgkenran_ Cool, thanks! If I (or you) would want to make the above changes after the update to hscurses is through (and the package is then presumably marked broken), we'd then have to PR to haskell-updates when a new draft PR is made? 14:07:08
@kenran_:matrix.orgkenran_ And if hackage-packages.nix is automatically generated: is that mechanism smart enough to detect that the ncurses argument is not meaning haskellPackages.ncurses, but needs to be overridden with { inherit (pkgs) ncurses: }? 14:10:08
@kenran_:matrix.orgkenran_ * And if hackage-packages.nix is automatically generated: is that mechanism smart enough to detect that the ncurses argument is not supposed to need haskellPackages.ncurses, but needs to be overridden with { inherit (pkgs) ncurses: }? 14:11:39
@sternenseemann:systemli.orgsterni (he/him) I'd recommend using haskell.lib.compose.overrideSrc since that deals with hackage revisions and allows further haskell specific overrides. 19:12:17
@aspendowntime:matrix.org@aspendowntime:matrix.org changed their display name from Nerissa (it/she) to Eden (they/it/she).23:11:22
20 Jan 2025
@lambda-mike:matrix.org@lambda-mike left the room.10:22:02
@joaomoreira:matrix.orgJoão Moreira

chreekat linj: Thanks for the hints back then. Does haskell.lib.compose.overrideCabal (as in both pretty-simple and nixfmt-rfc-style) can do the same as

haskell.packages.ghc910.callPackage and haskellPackages = haskell.packages.ghc910;?

I really need ghc910 (GHC2024).

17:19:09
@joaomoreira:matrix.orgJoão Moreira *

chreekat linj: Thanks for the hints back then. Does haskell.lib.compose.overrideCabal (as in both given derivation examples pretty-simple and nixfmt-rfc-style) can do the same as

haskell.packages.ghc910.callPackage and haskellPackages = haskell.packages.ghc910;?

I really need ghc910 (GHC2024).

17:19:41
@joaomoreira:matrix.orgJoão Moreira
In reply to @joaomoreira:matrix.org

how can I move, haskell.lib.compose.justStaticExecutables, haskell.packages.ghc910 etc from all-packages.nix to package.nix so that nixpkgs-vet job succesffully passes (i.e. fits pkgs/by-name)? I tried finding examples on nixpkgs, but they don't seem right / too complex for my derivation.

How it is now:

pkgs/top-level/all-packages.nix

  # Check kind-lang.cabal. GHC2024 >= ghc910.
  kind-lang = haskell.lib.compose.justStaticExecutables (haskell.packages.ghc910.callPackage ../by-name/ki/kind-lang/package.nix {
    haskellPackages = haskell.packages.ghc910;
  });

nixpkgs-vet error

- Because pkgs/by-name/ki/kind-lang exists, the attribute `pkgs.kind-lang` must be defined like

    kind-lang = callPackage ./../by-name/ki/kind-lang/package.nix { /* ... */ };

  However, in this PR, it isn't defined that way. See the definition in pkgs/top-level/all-packages.nix:6458

    kind-lang = haskell.lib.compose.justStaticExecutables (haskell.packages.ghc910.callPackage ../by-name/ki/kind-lang/package.nix {
      haskellPackages = haskell.packages.ghc910;
    });

This PR introduces the problems listed above. Please fix them before merging, otherwise the base branch would break.
To run locally: ./ci/nixpkgs-vet.sh master https://github.com/NixOS/nixpkgs.git
If you're having trouble, ping @NixOS/nixpkgs-vet
Error: Process completed with exit code 1.

pr https://github.com/NixOS/nixpkgs/pull/371934

for reference
17:20:54
@joaomoreira:matrix.orgJoão Moreiraotherwise, how can I do it?17:21:59
@alexfmpe:matrix.orgalexfmpeyou can apply overrideCabal in an overlay for ghc910, just need nested //18:31:24
@alexfmpe:matrix.orgalexfmpe``` haskell = nixpkgs.haskell // { packages = nixpkgs.haskell.packages // { "${compiler}" = nixpkgs.haskell.packages.${compiler}.override(old: { overrides = self: super: { mypkg = overrideCabal super.mypkg (drv: ...) } }); }; }; }; ```18:37:05
@alexfmpe:matrix.orgalexfmpeThis sort of thjng18:37:08

Show newer messages


Back to Room ListRoom Version: 6