!RbXGJhHMsnQcNIDFWN:nixos.org

Haskell in Nixpkgs/NixOS

731 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.org148 Servers

Load older messages


SenderMessageTime
4 Jan 2025
@cdepillabout:matrix.orgcdepillabout

It's a boot package, so it is shipped with ghc itself:

$ nix-shell -p ghc --command 'ghc-pkg list' | grep unix
    unix-2.8.4.0
07:58:08
@cdepillabout:matrix.orgcdepillabout You should be able to find it being nulled out if you grep nixpkgs for unix = null. 07:58:29
@kranzes:matrix.org@kranzes:matrix.org left the room.15:30:07
@collinarnett:matrix.orgCollin Arnett joined the room.17:18:33
5 Jan 2025
@peterbecich:matrix.orgPeter Becich

Thanks, that helps a lot. So I guess Nix GHC 9.10 is providing unix-2.8.5.1. Nix GHC 9.12 provides unix-2.8.6.0. This explains why my package is not getting the version in haskellPackages, i.e.:

nix search nixpkgs/haskell-updates#haskellPackages '^unix'
* legacyPackages.x86_64-linux.haskellPackages.unix_2_8_6_0 (2.8.6.0)

this version is not the one used

07:35:12
@peterbecich:matrix.orgPeter Becich *

Thanks, that helps a lot. So I guess Nix GHC 9.10 is providing unix-2.8.5.1. Nix GHC 9.12 provides unix-2.8.6.0. This explains why my package is not getting the version in haskellPackages, i.e.:

nix search nixpkgs/haskell-updates#haskellPackages '^unix'
* legacyPackages.x86_64-linux.haskellPackages.unix_2_8_6_0 (2.8.6.0)

this unix_2_8_6_0 is not the one used

07:35:48
@sternenseemann:systemli.orgsterni (he/him)New Cabal version new Setup.hs regression :) https://github.com/haskell/cabal/issues/1071716:58:44
6 Jan 2025
@joaomoreira:matrix.orgJoão Moreirait doesn't seem like nix-init has support for caba.project, project.cabal?14:52:57
@joaomoreira:matrix.orgJoão Moreira * it doesn't seem like nix-init has support for cabal.project, project.cabal?14:53:12
@joaomoreira:matrix.orgJoão Moreirawell then, is this what i should follow if I want to create a derivation for a cabal project to import into my NixOS config? https://nixos.org/manual/nixpkgs/stable/#haskell-mkderivation14:55:50
@maralorn:maralorn.demaralornYou will most likely want to use cabal2nix.14:57:25
@joaomoreira:matrix.orgJoão Moreira maralorn: thanks, looking into that! 15:06:11
@mangoiv.:matrix.orgMangoIV

on this topic, I actually have a question: would it generally be accepted to upstream haskell executables in that way? i.e. by using a package definition like so:

{haskellPackages, ...}: haskellPackages.callPackage {...}
15:38:48
@mangoiv.:matrix.orgMangoIVbecause I think that the main reason why e.g. nix-init is not compatible is because that most executables are just in the hackage-pacages.nix, right? but I think it would be nice to have a more "standard" experience of actually contributing executables. 15:39:37
@maralorn:maralorn.demaralorn
In reply to @mangoiv.:matrix.org

on this topic, I actually have a question: would it generally be accepted to upstream haskell executables in that way? i.e. by using a package definition like so:

{haskellPackages, ...}: haskellPackages.callPackage {...}
Yes, that exists.
15:49:49
@joaomoreira:matrix.orgJoão Moreira

After cabal2nix on a cabal repo which generated a default.nix, I've changed default.nix to add on my NixOS repo:

{ lib
, stdenv
, fetchFromGitHub
, ansi-terminal
, base
, containers
, directory
, filepath
, hs-highlight
, mtl
, parsec
}:

stdenv.mkDerivation rec {
  pname = "kind-lang";
  version = "unstable-2024-12-09";

  src = fetchFromGitHub {
    owner = "higherorderco";
    repo = "kind";
    rev = "5cfff210b3aeed01ebd73b2364cf9e5d2df658af";
    hash = "sha256-gHJ+eruwsybjRc5f1VWsof2jWQjuO/9nhOMKAvuMl7w=";
  };

  isLibrary = true;
  libraryHaskellDepends = [
    ansi-terminal
    base
    containers
    directory
    filepath
    hs-highlight
    mtl
    parsec
  ];

  isExecutable = true;
  executableHaskellDepends = [
    ansi-terminal
    base
    directory
    filepath
    hs-highlight
    mtl
  ];

  meta = with lib; {
    description = "A modern proof language";
    homepage = "https://github.com/higherorderco/kind";
    changelog = "https://github.com/higherorderco/kind/blob/${src.rev}/CHANGELOG.md";
    license = licenses.mit;
    maintainers = with maintainers; [ ];
  };
}

but

nix-build -E 'with import <nixpkgs> {}; haskellPackages.callPackage ./default.nix {}'
this derivation will be built:
  /nix/store/h8lp8csvwv90b38yj3nb36258i9vhjp7-kind-lang-unstable-2024-12-09.drv
building '/nix/store/h8lp8csvwv90b38yj3nb36258i9vhjp7-kind-lang-unstable-2024-12-09.drv'...
Running phase: unpackPhase
unpacking source archive /nix/store/g46qdc00anivc5fl16rb4xiwy73z512b-source
source root is source
Running phase: patchPhase
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: configurePhase
no configure script, doing nothing
Running phase: buildPhase
no Makefile or custom buildPhase, doing nothing
Running phase: installPhase
no Makefile or custom installPhase, doing nothing
Running phase: fixupPhase
error: builder for '/nix/store/h8lp8csvwv90b38yj3nb36258i9vhjp7-kind-lang-unstable-2024-12-09.drv' failed to produce output path for output 'out' at '/nix/store/h8lp8csvwv90b38yj3nb36258i9vhjp7-kind-lang-unstable-2024-12-09.drv.chroot/root/nix/store/bwh8lqpgh54jmi3f3x0nbm4v06x380vj-kind-lang-unstable-2024-12-09'

is cabal2nix really supposed to be used like this outside a cabal repo project? or this needs some fixing still?

17:36:11
@joaomoreira:matrix.orgJoão Moreira *

After cabal2nix on a cabal repo which generated a default.nix, I've changed default.nix to add to my NixOS repo/config:

{ lib
, stdenv
, fetchFromGitHub
, ansi-terminal
, base
, containers
, directory
, filepath
, hs-highlight
, mtl
, parsec
}:

stdenv.mkDerivation rec {
  pname = "kind-lang";
  version = "unstable-2024-12-09";

  src = fetchFromGitHub {
    owner = "higherorderco";
    repo = "kind";
    rev = "5cfff210b3aeed01ebd73b2364cf9e5d2df658af";
    hash = "sha256-gHJ+eruwsybjRc5f1VWsof2jWQjuO/9nhOMKAvuMl7w=";
  };

  isLibrary = true;
  libraryHaskellDepends = [
    ansi-terminal
    base
    containers
    directory
    filepath
    hs-highlight
    mtl
    parsec
  ];

  isExecutable = true;
  executableHaskellDepends = [
    ansi-terminal
    base
    directory
    filepath
    hs-highlight
    mtl
  ];

  meta = with lib; {
    description = "A modern proof language";
    homepage = "https://github.com/higherorderco/kind";
    changelog = "https://github.com/higherorderco/kind/blob/${src.rev}/CHANGELOG.md";
    license = licenses.mit;
    maintainers = with maintainers; [ ];
  };
}

but

nix-build -E 'with import <nixpkgs> {}; haskellPackages.callPackage ./default.nix {}'
this derivation will be built:
  /nix/store/h8lp8csvwv90b38yj3nb36258i9vhjp7-kind-lang-unstable-2024-12-09.drv
building '/nix/store/h8lp8csvwv90b38yj3nb36258i9vhjp7-kind-lang-unstable-2024-12-09.drv'...
Running phase: unpackPhase
unpacking source archive /nix/store/g46qdc00anivc5fl16rb4xiwy73z512b-source
source root is source
Running phase: patchPhase
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: configurePhase
no configure script, doing nothing
Running phase: buildPhase
no Makefile or custom buildPhase, doing nothing
Running phase: installPhase
no Makefile or custom installPhase, doing nothing
Running phase: fixupPhase
error: builder for '/nix/store/h8lp8csvwv90b38yj3nb36258i9vhjp7-kind-lang-unstable-2024-12-09.drv' failed to produce output path for output 'out' at '/nix/store/h8lp8csvwv90b38yj3nb36258i9vhjp7-kind-lang-unstable-2024-12-09.drv.chroot/root/nix/store/bwh8lqpgh54jmi3f3x0nbm4v06x380vj-kind-lang-unstable-2024-12-09'

is cabal2nix really supposed to be used like this outside a cabal repo project? or this needs some fixing still?

17:36:35
@sternenseemann:systemli.orgsterni (he/him) stdenv.mkDerivation doesn’t understand how to build Haskell projects 17:56:05
@sternenseemann:systemli.orgsterni (he/him) cabal2nix purposely generates an mkDerivation argument and uses that which is provided by the haskellPackages scope 17:56:49
@joaomoreira:matrix.orgJoão Moreira sterni: Gotcha, thank you very much! 17:59:07
@srestegosaurio:tchncs.de@srestegosaurio:tchncs.de left the room.18:01:26
@joaomoreira:matrix.orgJoão Moreiraghc-internal is marked as broken and packages like base depend on it. Did anyone notice this?20:12:20
@maralorn:maralorn.demaralornI would expect that it is impossible to build ghc-internal independently of ghc.22:31:47
@maralorn:maralorn.demaralornThe haskell library ghc-internal is a core package and thus included in the package db from our ghc derivation.22:32:41
@maralorn:maralorn.demaralornWhat is most likely broken is building the nix derivation for an independent ghc-internal package.22:33:34
@maralorn:maralorn.demaralornBut that has no use anyway because it is either the bundled version or an incompatible version.22:34:09
@maralorn:maralorn.demaralorn Because of this there should be a ghc-internal = null; file in a configuration-ghc-....nix file in nixpkgs. 22:35:16
@maralorn:maralorn.demaralorn * Because of this there should be a ghc-internal = null; override in a configuration-ghc-....nix file in nixpkgs. 22:35:30
@maralorn:maralorn.demaralorn João Moreira: How did you encounter the breakage? 22:36:09
7 Jan 2025
@joaomoreira:matrix.orgJoão Moreira
In reply to @maralorn:maralorn.de
João Moreira: How did you encounter the breakage?

I made this derivation

{ lib
, mkDerivation
, fetchFromGitHub
, haskellPackages
}:

mkDerivation rec {
  pname = "kind-lang";
  version = "unstable-2024-12-09";

  src = fetchFromGitHub {
    owner = "higherorderco";
    repo = "kind";
    rev = "5cfff210b3aeed01ebd73b2364cf9e5d2df658af";
    hash = "sha256-gHJ+eruwsybjRc5f1VWsof2jWQjuO/9nhOMKAvuMl7w=";
  };

  postPatch = ''
    substituteInPlace kind-lang.cabal \
      --replace "==" "^>="
  '';

  isLibrary = false;
  isExecutable = true;

  libraryHaskellDepends = with haskellPackages; [
    ansi-terminal_1_1_1
    base_4_20_0_1
    containers_0_7
    directory_1_3_9_0
    filepath_1_5_3_0
    hs-highlight
    mtl_2_3_1
    parsec_3_1_17_0
  ];

  executableHaskellDepends = with haskellPackages; [
    ansi-terminal_1_1_1
    base_4_20_0_1
    directory_1_3_9_0
    filepath_1_5_3_0
    hs-highlight
    mtl_2_3_1
  ];

  # Test suite does nothing.
  doCheck = false;

  description = "A modern proof language";
  mainProgram = "kind";
  homepage = "https://github.com/higherorderco/kind";
  changelog = "https://github.com/higherorderco/kind/blob/${src.rev}/CHANGELOG.md";
  license = lib.licenses.mit;
  platforms = lib.platforms.linux;
  maintainers = with lib.maintainers; [ ];
}

then

nix-build -E 'with import <nixpkgs> {}; haskell.lib.compose.justStaticExecutables (haskellPackages.callPackage ./default.nix {})'
error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:34:12:
           33|
           34|   strict = derivationStrict drvAttrs;
             |            ^
           35|

       … while evaluating derivation 'kind-lang-unstable-2024-12-09'
         whose name attribute is located at /nix/store/c9wv7i0af6mysmy65x6nvyfw5izzxv4g-source/pkgs/stdenv/generic/make-derivation.nix:336:7

       … while evaluating attribute 'buildInputs' of derivation 'kind-lang-unstable-2024-12-09'
         at /nix/store/c9wv7i0af6mysmy65x6nvyfw5izzxv4g-source/pkgs/stdenv/generic/make-derivation.nix:383:7:
          382|       depsHostHost                = elemAt (elemAt dependencies 1) 0;
          383|       buildInputs                 = elemAt (elemAt dependencies 1) 1;
             |       ^
          384|       depsTargetTarget            = elemAt (elemAt dependencies 2) 0;

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: Package ‘ghc-internal-9.1001.0’ in /nix/store/c9wv7i0af6mysmy65x6nvyfw5izzxv4g-source/pkgs/development/haskell-modules/hackage-packages.nix:121205 is marked as broken, refusing to evaluate.

Then I looked into https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/haskell-modules/hackage-packages.nix#L121214

AND

  • https://hydra.nixos.org/job/nixpkgs/haskell-updates/haskellPackages.ghc-internal.x86_64-linux#tabs-status
  • https://cache.nixos.org/log/bxhkzb647jdfnr228kw4hrkrwz9bcm9k-ghc-internal-9.1001.0.drv
Error: Setup: Encountered missing or private dependencies:
ghc-prim >=0.11 && <0.12

But maybe that specific error not valid anymore

nix search nixpkgs#haskellPackages ghc-prim
* legacyPackages.x86_64-linux.haskellPackages.ghc-prim_0_11_0 (0.11.0)
00:18:16

Show newer messages


Back to Room ListRoom Version: 6