nix-community / NixOS-WSL

NixOS on WSL(2) [maintainer=@nzbr]
Apache License 2.0
1.75k stars 114 forks source link

How-To Doc #441

Open JasonGoemaat opened 6 months ago

JasonGoemaat commented 6 months ago

Very new to Nix, love this repository but had a hard time figuring out how to just add packages to the global configuration.nix. I saw there was a space for a howto doc that wasn't created so I decided to add some examples.

0xLunch commented 5 months ago

You'll want to do a bunch of googling on different setups since there are multiple ways to get your programs installed. I'll give a quick rundown here but this is more a question for Nix communities directly and not specific to NixOS-WSL.

For global system-wide packages that will exist for every user, every system, etc you can use environment.systemPackages inside your etc/nixos/configuration.nix file example:

  # System Packages
  environment.systemPackages = with pkgs; [
    zsh
    wget
    htop
    tmux
  ];

When you sudo nixos-rebuild switch these will be included systemwide.

Another way is to simply enable a program that's in nixpkgs, ie: programs.zsh.enable = true. This can be done in your general configuration, or more preferably within your home-manager config so it applies to your specific user and not the entire system.

Hope this points you in the right direction.