【问题标题】:How can I combine two lists in Nix?如何在 Nix 中合并两个列表?
【发布时间】:2019-05-10 13:09:51
【问题描述】:

我目前有一个列表定义为:

   environment.systemPackages = with pkgs; [
     acpi
     ag
     alacritty
     audacity
     awscli
     bash
     breeze-gtk
     cabal-install
    ];

我将如何定义两个列表,然后将它们合并以设置 environment.systemPackages 值?

我想拆分列表,以便更轻松地管理相关包组。

【问题讨论】:

    标签: nix nixos


    【解决方案1】:

    https://nixos.org/nix/manual/#sec-language-operators

    ++ 运算符:

    nix-repl> [1 2 3]  ++ [5 6]
    [ 1 2 3 5 6 ]
    

    代码示例:

    let
      unstable = import <unstable> {
        config = config.nixpkgs.config; 
      };
      examplePkgs = with pkgs; [
        bash
      ];
    in
    {
    
       environment.systemPackages = with pkgs; [
         google-chrome
       ]
       ++ examplePkgs;
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-16
    • 1970-01-01
    • 1970-01-01
    • 2016-01-17
    • 2011-04-29
    • 2015-10-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多