nix - 以下 cmdline 参数的最短 `shell.nix` 等价物是什么?

标签 nix nixos nix-shell

以下 cmdline 参数的最短 shell.nix 等价物是什么?

nix-shell -p "haskell.packages.ghc865.ghcWithPackages (p: [p.ghci-pretty])"

这行得通,但是很冗长:

# contents of shell.nix file
# run with the following cmd:
# nix-shell shell.nix
{ nixpkgs ? import <nixpkgs> {} }:
let
  inherit nixpkgs;
  inherit (nixpkgs) haskellPackages;
  haskellDeps = a: with a; [
    ipprint
    base
    hscolour
    ghci-pretty
  ];
  ghc = nixpkgs.haskellPackages.ghcWithPackages haskellDeps;

  nixPackages = [
    haskellPackages.cabal-install
    ghc
  ];
in
nixpkgs.stdenv.mkDerivation {
  name = "profile_name";
  buildInputs = nixPackages;
}

最佳答案

您可以像这样逐字复制命令行:

{ pkgs ? import <nixpkgs> {} }:
let
  ghc = pkgs.haskell.packages.ghc865.ghcWithPackages (p: [ p.ghci-pretty ]);
in
pkgs.mkShell {
  buildInputs = [ ghc ];
}

关于nix - 以下 cmdline 参数的最短 `shell.nix` 等价物是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58270109/

相关文章:

macos - 在没有 T2 芯片的 Mac 上的 FileVault 加密启动卷上,在 macOS Catalina 和 Big Sur 上安装 Nix 时出错

shell - 是否可以将很长的 `#! nix-shell -p` 行分成多行?

nix - 在 nix 包中设置标志

linux - 使用取消共享并仍在执行原始功能

haskell - 在 nix-shell 中找不到模块

bash - 不需要的 bash 换行符 nixos

nixos - 如何将二进制文件安装到 NixOS 中

Nix:派生如何在不调用构建器的情况下在 nix-shell 中设置 PATH?

nix - 如何运行 `corepack enable` 来安装 Yarn berry?