16

I've currently got a list defined as:

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

How would I go about defining two lists and then merging them to set the environment.systemPackages value?

I'd like to split the list so it's easier to manage groups of related packages.

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286

1 Answers1

25

https://nixos.org/manual/nix/stable/expressions/language-operators.html

The ++ operator:

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

Code example:

let
  unstable = import <unstable> {
    config = config.nixpkgs.config; 
  };
  examplePkgs = with pkgs; [
    bash
  ];
in
{

   environment.systemPackages = with pkgs; [
     google-chrome
   ]
   ++ examplePkgs;
JaviMerino
  • 619
  • 10
  • 18
Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
  • 1
    The link is outdated. New link: https://nixos.org/manual/nix/stable/expressions/language-operators.html – Yajo Feb 22 '22 at 09:40
  • [lib.lists.unique](https://ryantm.github.io/nixpkgs/functions/library/lists/#function-library-lib.lists.unique) can be useful here – milahu Aug 15 '23 at 07:10