Description
I'm trying to add some packages to my development environment that aren't actually dependencies of my project, they're just handy to have access to during development.
The documentation describes the shellFor
function having an argument called additional
:
Similar to
packages
, but the selected packages are built and included inghc-pkg list
(not just their dependencies).
This sounded like it would do what I wanted, but when I tried I always got a missing attribute error. So I stuck in a trace to see what names were available. (e.g. additional = pkgs: builtins.trace (builtins.attrNames pkgs) [ ... ]
). And the list of names available seems to be a very small set just containing what my project already depended on.
For example, with this minimal setup:
-- test-additional.cabal
cabal-version: 3.0
name: test-additional
version: 0.1.0.0
build-type: Simple
executable test-additional
main-is: Main.hs
build-depends: base ^>=4.14.3.0
hs-source-dirs: app
default-language: Haskell2010
# default.nix
let
sources = {
haskellNix = builtins.fetchTarball "https://github.com/input-output-hk/haskell.nix/archive/986ebab4075d4c1ecac1270a9304e65e7ef715bc.tar.gz";
};
haskellNix = import sources.haskellNix {};
pkgs = import
haskellNix.sources.nixpkgs-unstable
haskellNix.nixpkgsArgs;
in pkgs.haskell-nix.project {
src = pkgs.haskell-nix.haskellLib.cleanGit {
name = "haskell-nix-project";
src = ./.;
};
compiler-nix-name = "ghc8107";
}
# shell.nix
(import ./default.nix).shellFor {
additional = pkgs: builtins.trace (builtins.attrNames pkgs) [
pkgs.neat-interpolation
];
}
I see this output:
trace: [ "BNFC" "Cabal" "GLFW-b" "Sit" "Win32" "X11" "array" "base" "binary" "bindings-GLFW" "bitvec" "buildPackages" "bytestring" "cabal-install" "clock" "closed" "conduit" "containers" "cpphs" "cryptonite-openssl" "deepseq" "directory" "discount" "filepath" "ghc" "ghc-boot" "ghc-boot-th" "ghc-heap" "ghc-lib-parser" "ghc-prim" "ghcWithHoogle" "ghcWithPackages" "ghci" "ghcide" "ghcjs-prim" "ghcjs-th" "hnix" "hpc" "hscolour" "integer-gmp" "integer-simple" "iserv" "iserv-proxy" "language-c" "libiserv" "llvm-hs" "makeConfigFiles" "mintty" "network" "odbc" "pcap" "polyparse" "pretty" "remote-iserv" "rts" "shellFor" "streaming-commons" "template-haskell" "terminfo" "test-additional" "time" "transformers" "unix" "x509-system" ]
error: attribute 'neat-interpolation' missing
If I add neat-interpolation
as a dependency in my .cabal file, then the list of packages available to additional
gets larger and it works. But then of course I wouldn't need additional
.
I'm genuinely unsure if I'm misunderstanding what additional
is supposed to be for, or if it isn't working correctly.