注意:

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

Difference between revisions of "Package:Nix"

From Funtoo
Jump to navigation Jump to search
(basic skeleton of nix package management wiki package page)
 
 
Line 1: Line 1:
'''Nix''' is a functional package manager for the nixos linux operating system.  By default nixos uses systemd.
'''Nix''' is a functional package manager for the nixos linux operating system.  By default nixos uses systemd.


*merge nixos nix package management:
= Setup =
*Merge nixos nix package management:
{{console|body=###i## emerge -av nix}}
{{console|body=###i## emerge -av nix}}


*Set nix daemon to run at boot & start immediately:
*Set nix daemon to run at boot & start immediately:
{{console|body=###i## rc-update add nix-daemon && /etc/init.d/nix-daemon start}}
{{console|body=###i## rc-update add nix-daemon && /etc/init.d/nix-daemon start}}
*Add the nixpkgs channel
{{console|body=
$##i## nix-channel --add https://nixos.org/channels/nixpkgs-unstable
$##i## 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.
{{console|body=$##i## mkdir -p ~/.local/state/nix/profiles}}
For more information about Nix profiles and why they are needed, consult [https://nixos.org/manual/nix/stable/package-management/profiles.html the manual].
= Configuration =
*Enable flakes
{{file|name=~/.config/nix/nix.conf|body=
experimental-features = nix-command flakes
}}
{{Fancynote|Flakes are currently considered '''experimental''' and such, support is not enabled by default. For more information, consult [https://nixos.wiki/wiki/Flakes the wiki].}}
*Allow unfree packages
{{file|name=~/.config/nixpkgs/config.nix|body=
{ allowUnfree = true; }
}}
=GPU Acceleration=
Since nix graphic applications are built with NixOS OpenGL/Vulkan drivers, you will need to use [https://github.com/guibou/nixGL nixGL] to run GPU accelerated software on non-NixOS systems.
= Home Manager =
[https://nix-community.github.io/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:
{{console|body=$##i## source ~/.nix-profile/etc/profile.d/hm-session-vars.sh}}
{{Fancynote|You can add this command at the end of your {{f|~/.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.

Latest revision as of 13:02, September 3, 2023

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.