Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I combine two lists in Nix?

Tags:

nix

nixos

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.

like image 252
Chris Stryczynski Avatar asked Dec 09 '18 11:12

Chris Stryczynski


1 Answers

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;
like image 169
Chris Stryczynski Avatar answered Nov 07 '22 10:11

Chris Stryczynski