注意:

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Package:Nix

From Funtoo
Jump to navigation Jump to search

Nix is a functional package manager for the nixos linux operating system. By default nixos uses systemd.

Setup

  • Merge nixos nix package management:
root # emerge -av nix
  • Set nix daemon to run at boot & start immediately:
root # rc-update add nix-daemon && /etc/init.d/nix-daemon start
  • Add the nixpkgs channel
user $ nix-channel --add https://nixos.org/channels/nixpkgs-unstable
user $ nix-channel --update

You might want to create the following directory to allow Nix to setup profiles on your local user. This is required for installing home-manager.

user $ mkdir -p ~/.local/state/nix/profiles

For more information about Nix profiles and why they are needed, consult the manual.

Configuration

  • Enable flakes
   ~/.config/nix/nix.conf
experimental-features = nix-command flakes
   Note

Flakes are currently considered experimental and such, support is not enabled by default. For more information, consult the wiki.

  • Allow unfree packages
   ~/.config/nixpkgs/config.nix
{ allowUnfree = true; }

GPU Acceleration

Since nix graphic applications are built with NixOS OpenGL/Vulkan drivers, you will need to use nixGL to run GPU accelerated software on non-NixOS systems.

Home Manager

Home Manager is a system that manages your user environment using Nix and nixpkgs libraries. It can be used to install user-level packages, manage dotfiles, setup X sessions, and much more. Everything should work out out-of-the-box except user service management, as it heavily relies on systemd to work.

Caveats

  • For environment variables set by Home Manager to take effect, you need to run the following command:
user $ source ~/.nix-profile/etc/profile.d/hm-session-vars.sh
   Note

You can add this command at the end of your ~/.bash_profile so it takes effect every log-in.

  • The Home Manager user services only work on systemd, which is not supported by Funtoo. Service configurations will simply not take effect, leaving the rest of the system functional.