[Nix-dev] Nix User Profile (NixUP)
Thomas Strobel
ts468 at cam.ac.uk
Wed Nov 25 13:08:41 CET 2015
Hi!
I'm very happy to say that a new version of NixUP is available for
testing. You can find the latest version at [1]. Please read
NIXUP_README.md for help on how to test NixUP.
What is Nix User Profile (NixUP)? NixUP is a declarative configuration
for the user environment. It is an equivalent to the NixOS configuration
method that is based around 'nixos-rebuild' and
'/etc/nixos/configuration.nix'. NixUP provides a module system for
configuring the user environment and is intended as a replacement for
the imperative 'nix-env' commands. NixUP allows to, e.g., install
packages, manage user defined services and to manage resources.
NixUP consists of a new program, called 'nixup' and a declarative
configuration rooted at '$XDG_CONFIG_HOME/nixup/profile.nix' (e.g.
~/.config/nixup/profile.nix). Basically, the workflow for managing the
NixUP user profile is the same as how the NixOS system configuration is
being managed. The 'profile.nix' is edited by the user, and then turned
into an active environment through 'nixup'.
The important commands for using 'nixup' are:
nixup build
-- Builds a user profile. By default the profile is defined
in $XDG_CONFIG_HOME/nixup/profile.nix.
nixup login
-- Builds a user profile that will be activated on the next login.
That is similar to nixos-rebuild boot.
nixup switch
-- Builds a user profile and immediately switches to it.
nixup edit
-- Opens an editor with the current configuration.
NixUP also brings an small program that helps to install and to remove
software packages. If 'config.imperativeNix.enable=true' is set in the
'profile.nix' configuration, then a program 'nix-package' becomes
available that manages a list of packages to be installed into the user
environment. By default the list is maintained at
'$XDG_CONFIG_HOME/nixup/packages.nix', from where the list is read by a
module of the NixUP system.
The commands for using 'nix-package' are:
nix-package install hello
nix-package remove hello
Note that the packages are not pinned at a particular version but are
linked to the currently active nixpkgs channel. A way to pin a package
will be provided later.
Besides managing software packages, NixUP also provides a way to manage
user controlled services. NixUP allows to define services for 'systemd
--user', similarly to how NixOS allows to define services for 'systemd'.
That means that the feature of managing services within NixUP is bound
very tightly to 'systemd', and will not be available on other platforms
like OSX or Windows.
The last interesting feature of NixUP is that is allows to manage
resources. That means, it allows to define files in 'profile.nix' that
are then linked into the $HOME directory of a user, or into any
sub-directory of $HOME. The necessary sub-directories and links are
created as needed, and automatically removed when the 'profile.nix'
changes. Automatically created sub-directories are removed if they are
empty after all links have been removed. So NixUP has a built-in way for
managing, e.g., dot-files.
The plan is now to test NixUP and hopefully merge NixUP into NixOS. The
next step then will then be to extend NixOS and NixUP so that the same
configuration can be written into the NixOS user declaration of
'configuration.nix' and into the user's NixUP 'profile.nix'. After that,
we could generalize the NixOS modules of those services that could also
run as user services and make them available for both NixOS and NixUP.
In the long run, NixUP should be developed into an extensive collection
of user modules that allow to declaratively configure and manage user
applications and user services.
Please let me know what you think, and please try to test NixUP! :)
Best regards,
Thomas
[1] https://github.com/NixOS/nixpkgs/pull/9250
More information about the nix-dev
mailing list