Nix使用〜/ .nixpkgs / config.nix安装不稳定的软件包

时间:2019-08-19 11:25:11

标签: nix

如何使用nix-env -i all通过~/.nixpkgs/config.nix从不稳定的频道安装软件包?

1 个答案:

答案 0 :(得分:2)

~/.nixpkgs/config.nix的开头添加以下部分:

let unstable = import <nixpkgs> {}; in

nixpkgs是不稳定通道的名称(请通过nix-channel --list检查其名称)。

并使用unstable.在不稳定的情况下为要安装的软件包添加前缀。

示例-还可以访问不稳定对象,以用于nix-env -i

let
  config = {
    allowUnfree = true;

    packageOverrides = pkgs: with pkgs; 
      let jdk = openjdk11; in rec {
      unstable = import <nixpkgs-unstable> { inherit config; };

      all = pkgs.buildEnv {
        name = "all";

        paths = [
          htop
          nox
          nix-info
          nix-index
          haskell.compiler.ghc864
          haskellPackages.cabal-install
          unstable.haskellPackages.stack
          haskellPackages.hoogle
          haskellPackages.ghcid
          unstable.haskellPackages.cabal2nix
        ];
      };
    };
  };
in config

或者您也可以这样做:

let unstable = import <nixpkgs> {}; in
{
  allowUnfree = true;

  packageOverrides = pkgs_: with pkgs_;
    let jdk = openjdk11; in {

    all = with pkgs; buildEnv {
      name = "all";

      paths = [
        htop
        nox
        nix-info
        nix-index
        haskell.compiler.ghc864
        haskellPackages.cabal-install
        unstable.haskellPackages.stack # this comes from the unstable channel
        haskellPackages.hoogle
        haskellPackages.ghcid
        unstable.haskellPackages.cabal2nix
      ];
    };
  };
}