| 6 Jan 2025 |
João Moreira | well 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-mkderivation | 14:55:50 |
maralorn | You will most likely want to use cabal2nix. | 14:57:25 |
João Moreira | maralorn: thanks, looking into that! | 15:06:11 |
MangoIV | 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 | because 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 | 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 |
Joã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 |
Joã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 |
sterni | stdenv.mkDerivation doesn’t understand how to build Haskell projects | 17:56:05 |
sterni | cabal2nix purposely generates an mkDerivation argument and uses that which is provided by the haskellPackages scope | 17:56:49 |
João Moreira | sterni: Gotcha, thank you very much! | 17:59:07 |
| @srestegosaurio:tchncs.de left the room. | 18:01:26 |
João Moreira | ghc-internal is marked as broken and packages like base depend on it. Did anyone notice this? | 20:12:20 |
maralorn | I would expect that it is impossible to build ghc-internal independently of ghc. | 22:31:47 |
maralorn | The haskell library ghc-internal is a core package and thus included in the package db from our ghc derivation. | 22:32:41 |
maralorn | What is most likely broken is building the nix derivation for an independent ghc-internal package. | 22:33:34 |
maralorn | But that has no use anyway because it is either the bundled version or an incompatible version. | 22:34:09 |
maralorn | Because of this there should be a ghc-internal = null; file in a configuration-ghc-....nix file in nixpkgs. | 22:35:16 |
maralorn | * Because of this there should be a ghc-internal = null; override in a configuration-ghc-....nix file in nixpkgs. | 22:35:30 |
maralorn | João Moreira: How did you encounter the breakage? | 22:36:09 |
| 7 Jan 2025 |
Joã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 |
Joã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
121202: "ghc-internal" = callPackage
121203- ({ mkDerivation, ghc-bignum, ghc-prim, rts }:
121204- mkDerivation {
121205- pname = "ghc-internal";
121206- version = "9.1001.0";
121207- sha256 = "0z38v4gnyis99r3rli2g3dyg948d98lhd1ylz5irbghnvrn8myhl";
121208- revision = "1";
121209- editedCabalFile = "1rx55yc51xaarcyj8mgrdn6pmr8ri2n962h813dy5vc1pj49g8yz";
121210- libraryHaskellDepends = [ ghc-bignum ghc-prim rts ];
121211- description = "Basic libraries";
121212- license = lib.licenses.bsd3;
121213- hydraPlatforms = lib.platforms.none;
121214- broken = true;
121215- }) {};
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:22:07 |
João Moreira | hm no, still error on the same thing
nix build --print-build-logs '~/nixpkgs/master#haskellPackages.ghc-internal'
ghc-internal> trying https://hackage.haskell.org/package/ghc-internal-9.1001.0/revision/1.cabal
ghc-internal> % Total % Received % Xferd Average Speed Time Time Time Current
ghc-internal> Dload Upload Total Spent Left Speed
ghc-internal> 100 15281 0 15281 0 0 7052 0 --:--:-- 0:00:02 --:--:-- 7054
ghc-internal> Running phase: setupCompilerEnvironmentPhase
ghc-internal> Build with /nix/store/pb9lljj3m0i6m3x30759k80pq5cf4sqi-ghc-9.6.6.
ghc-internal> Running phase: unpackPhase
ghc-internal> unpacking source archive /nix/store/xm2kz91j6cfpa05afd2ql4m0ywc3bvg2-ghc-internal-9.1001.0.tar.gz
ghc-internal> source root is ghc-internal-9.1001.0
ghc-internal> setting SOURCE_DATE_EPOCH to timestamp 1000000000 of file ghc-internal-9.1001.0/src/GHC/Internal/Word.hs
ghc-internal> Running phase: patchPhase
ghc-internal> Replace Cabal file with edited version from mirror://hackage/ghc-internal-9.1001.0/revision/1.cabal.
ghc-internal> Running phase: compileBuildDriverPhase
ghc-internal> setupCompileFlags: -package-db=/build/tmp.q8BpJrEO8y/setup-package.conf.d -threaded
ghc-internal> [1 of 2] Compiling Main ( Setup.hs, /build/tmp.q8BpJrEO8y/Main.o )
ghc-internal> [2 of 2] Linking Setup
ghc-internal> Running phase: updateAutotoolsGnuConfigScriptsPhase
ghc-internal> Running phase: configurePhase
ghc-internal> configureFlags: --verbose --prefix=/nix/store/xs0nnkzmqqcwh027zfipq7rxaw6i456r-ghc-internal-9.1001.0 --libdir=$prefix/lib/$compiler/lib --libsubdir=$abi/$libname --docdir=/nix/store/d7x4vnaxjpwvvxff9n8ydm81zsg0vchm-ghc-internal-9.1001.0-doc/share/doc/ghc-internal-9.1001.0 --with-gcc=gcc --package-db=/build/tmp.q8BpJrEO8y/package.conf.d --ghc-option=-j4 --ghc-option=+RTS --ghc-option=-A64M --ghc-option=-RTS --enable-library-profiling --profiling-detail=exported-functions --disable-profiling --enable-shared --disable-coverage --enable-static --disable-executable-dynamic --enable-tests --disable-benchmarks --enable-library-vanilla --disable-library-for-ghci --enable-split-sections --enable-library-stripping --enable-executable-stripping --ghc-option=-haddock --extra-lib-dirs=/nix/store/wm1qn5jqrxpcjkc640gq8a90ns5gw3cn-ncurses-6.4.20221231/lib --extra-lib-dirs=/nix/store/r04wysx6yl7ys1rdv1b1lih6in1810r0-libffi-3.4.6/lib --extra-lib-dirs=/nix/store/wkysiv0sxqs6wn44nb46bbyig4plzsy4-elfutils-0.192/lib --extra-lib-dirs=/nix/store/ghb61mqc90qf1nx6kyahhhagicyxvcyg-gmp-with-cxx-6.3.0/lib
ghc-internal> Using Parsec parser
ghc-internal> Configuring ghc-internal-9.1001.0...
ghc-internal> CallStack (from HasCallStack):
ghc-internal> withMetadata, called at libraries/Cabal/Cabal/src/Distribution/Simple/Utils.hs:368:14 in Cabal-3.10.3.0:Distribution.Simple.Utils
ghc-internal> Error: Setup: Encountered missing or private dependencies:
ghc-internal> ghc-prim >=0.11 && <0.12
error: builder for '/nix/store/lbh2vgpqn9i7spr8hzzi3c72pva4pymm-ghc-internal-9.1001.0.drv' failed with exit code 1;
last 22 log lines:
> Running phase: setupCompilerEnvironmentPhase
> Build with /nix/store/pb9lljj3m0i6m3x30759k80pq5cf4sqi-ghc-9.6.6.
> Running phase: unpackPhase
> unpacking source archive /nix/store/xm2kz91j6cfpa05afd2ql4m0ywc3bvg2-ghc-internal-9.1001.0.tar.gz
> source root is ghc-internal-9.1001.0
> setting SOURCE_DATE_EPOCH to timestamp 1000000000 of file ghc-internal-9.1001.0/src/GHC/Internal/Word.hs
> Running phase: patchPhase
> Replace Cabal file with edited version from mirror://hackage/ghc-internal-9.1001.0/revision/1.cabal.
> Running phase: compileBuildDriverPhase
> setupCompileFlags: -package-db=/build/tmp.q8BpJrEO8y/setup-package.conf.d -threaded
> [1 of 2] Compiling Main ( Setup.hs, /build/tmp.q8BpJrEO8y/Main.o )
> [2 of 2] Linking Setup
> Running phase: updateAutotoolsGnuConfigScriptsPhase
> Running phase: configurePhase
> configureFlags: --verbose --prefix=/nix/store/xs0nnkzmqqcwh027zfipq7rxaw6i456r-ghc-internal-9.1001.0 --libdir=$prefix/lib/$compiler/lib --libsubdir=$abi/$libname --docdir=/nix/store/d7x4vnaxjpwvvxff9n8ydm81zsg0vchm-ghc-internal-9.1001.0-doc/share/doc/ghc-internal-9.1001.0 --with-gcc=gcc --package-db=/build/tmp.q8BpJrEO8y/package.conf.d --ghc-option=-j4 --ghc-option=+RTS --ghc-option=-A64M --ghc-option=-RTS --enable-library-profiling --profiling-detail=exported-functions --disable-profiling --enable-shared --disable-coverage --enable-static --disable-executable-dynamic --enable-tests --disable-benchmarks --enable-library-vanilla --disable-library-for-ghci --enable-split-sections --enable-library-stripping --enable-executable-stripping --ghc-option=-haddock --extra-lib-dirs=/nix/store/wm1qn5jqrxpcjkc640gq8a90ns5gw3cn-ncurses-6.4.20221231/lib --extra-lib-dirs=/nix/store/r04wysx6yl7ys1rdv1b1lih6in1810r0-libffi-3.4.6/lib --extra-lib-dirs=/nix/store/wkysiv0sxqs6wn44nb46bbyig4plzsy4-elfutils-0.192/lib --extra-lib-dirs=/nix/store/ghb61mqc90qf1nx6kyahhhagicyxvcyg-gmp-with-cxx-6.3.0/lib
> Using Parsec parser
> Configuring ghc-internal-9.1001.0...
> CallStack (from HasCallStack):
> withMetadata, called at libraries/Cabal/Cabal/src/Distribution/Simple/Utils.hs:368:14 in Cabal-3.10.3.0:Distribution.Simple.Utils
> Error: Setup: Encountered missing or private dependencies:
> ghc-prim >=0.11 && <0.12
>
For full logs, run 'nix log /nix/store/lbh2vgpqn9i7spr8hzzi3c72pva4pymm-ghc-internal-9.1001.0.drv'.
| 00:35:36 |
maralorn | Manually specifying the dependency versions in your nix derivation is probably a bad idea. | 00:35:59 |
maralorn | You are overriding the base version. That is not gonna work. | 00:37:24 |
maralorn | You get this specific error because you are picking base_4_20 which is apparently a derivation which exists in nixpkgs but currently has no use and depends on the broken ghc-internal. | 00:38:33 |
João Moreira | maralorn: that did it, thank you very much! I've been trying to find it, but couldn't... so is there a standard way to override default ghc version/package in cabal2nix? | 01:35:11 |
João Moreira | * maralorn: that did it, thank you very much! I've been trying to find it, but couldn't... so is there a standard way to override default ghc package in cabal2nix | 01:35:53 |
João Moreira | * maralorn: that did it, thank you very much! I've been trying to find it, but couldn't... so is there a standard way to override default ghc package in cabal2nix (i need to use a different version e.g. haskell.compiler.ghc98. | 01:37:19 |
João Moreira | * maralorn: that did it, thank you very much! I've been trying to find it, but couldn't... so is there a standard way to override default ghc package in cabal2nix (i need to use a different version e.g. haskell.compiler.ghc98) | 01:37:26 |