[Nix-dev] The .nixpkgs/config.nix file and user configuration

Guillaume Maudoux (Layus) layus.on at gmail.com
Wed May 3 16:47:35 CEST 2017


Hi John,

I guess the reason you are not receiving many answers is that your 
question highlights some misconceptions, and some design issues with nix.

There does not exist any declarative configuration file for user 
environments. /etc/nixos/configuration.nix is amazing, but has not been 
parted to user environments. Installing user packages is done with 
nix-env, in an imperative fashion, and updates are based on packages 
names (nix-env -u) as explained on the [wiki]. Please see the discussion 
on [GitHub](1) about that precise topic.

To get declarative user environments, you can look at the pull-request 
for [NixUP] (nix user profiles), or use a trick to manage packages 
declaratively in a custom environment. The [wiki] has such an example. I 
personally maintain a [~/.nixpkgs/packages.nix] that I edit, install and 
activate with the following one-liner. The command replaces all the 
installed packages with the given ones (-ir). I could alias it to 
nixuser-rebuild ;-).

     vim ~/.nixpkgs/packages.nix && nix-env -f ~/.nixpkgs/packages.nix 
-ir -Qk && i3-msg restart

NixUP and/or the coming update to nix (1.12) /should/ make this 
management easier.

I hope this makes it clearer!

Regards,

-- Layus.


[NixUP]: https://github.com/NixOS/nixpkgs/pull/9250
[1]: https://github.com/NixOS/nixpkgs/issues/1750
[wiki]: 
https://nixos.org/wiki/Howto_keep_multiple_packages_up_to_date_at_once
[~/nixpkgs/packages.nix]: 
https://gist.github.com/layus/427356ab4e7f46565d984686a311ca91#file-packages-nix

On 03/05/17 08:29, John Ramsden wrote:
> I've been looking for some information about how exactly the 
> $HOME/.nixpkgs/config.nix file works. How exactly is it intended to be 
> used? Up until now I've been managing my entire system from 
> /etc/nixos, but it would be nice to have a place where I can add 
> something that happens only to a single user. For example, setting up 
> dotfiles, or use our services. Can the config.nix file be used for 
> that? Is it effectively a /etc/nixos/configuration.nix that is 
> intended to be used for a single user?
>
> I have found little bits of information about it here and there, for 
> example in the nix pills. but nothing that really explains what it is 
> used for in detail. Could someone point me where I can find this 
> information?
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.science.uu.nl/pipermail/nix-dev/attachments/20170503/a8fca75a/attachment.html>


More information about the nix-dev mailing list