I have a user called james
declared in my configuration.nix
. What's not clear to me is how I customize those users' environments and config files. For example, can I declare that james
should have
pkgs.git
, installed and available just to him..gitconfig
in his home directory with such-and-such contents in it. (Or, more generally, an arbitrary set of files to be put in the home directory.)On the second point, I suppose ideally this kind of config should be done by Nix expressions in the same way as global config files are. But there are always going to be custom things that are not covered by the options in configuration.nix
, so I would expect there to be a lower-level way to declaratively manage those things. Is it currently possible?
configuration.nix
doesn't manage user environments. If you want to configure that user's environment, then the standard way to do it is to log in as james
and install the appropriate packages by running nix-env
.
There are some (largely amorphous) thoughts about user nixos, but for now this is not supported.
I'm a Debian user and I want to migrate to NixOS. I tought that I can:
This issue seems like feature I need.
Or maybe there is some other way that help me do the migration to NixOS?
@kamilchm so right now, NixOS differs from NixPkgs in that NixPkgs only provides compiled packages and NixOS provides "modules" which create configuration files for those packages.
If you're using Nix on Debian, you're using NixPkgs. The set of installed packages is determined by what is under /nix/var/nix/profiles/per-user/kamilchm/default
, and it is influenced by your .nixpkgs/config.nix
if you have it.
If you want to copy your environment to a fresh NixOS install, you need to copy the entire closure, either via ssh with nix-copy-closure
or manually by transferring the result of nix-store --query --requisites ~/.nix-profile
.
Easiest is of course to simply use the same nix store.
I'm running nixos in a subdirectory of my Debian if that is of any interest
for you. So without re-partitioning and without installing grub in the mbr,
I can choose at boot time whether I want to boot into debian or into nixos.
Yet you can use your data in debian from a mountpoint inside nixos. I'm not
using debian since several months at all.
On Mon, Aug 18, 2014 at 3:10 PM, wmertens [email protected] wrote:
@kamilchm https://github.com/kamilchm so right now, NixOS differs from
NixPkgs in that NixPkgs only provides compiled packages and NixOS provides
"modules" which create configuration files for those packages.
If you're using Nix on Debian, you're using NixPkgs. The set of installed
packages is determined by what is under
/nix/var/nix/profiles/per-user/kamilchm/default, and it is influenced by
your .nixpkgs/config.nix if you have it.
If you want to copy your environment to a fresh NixOS install, you need to
copy the entire closure, either via ssh with nix-copy-closure or manually
by transferring the result of nix-store --query --requisites
~/.nix-profile.
Easiest is of course to simply use the same nix store.—
Reply to this email directly or view it on GitHub
https://github.com/NixOS/nixpkgs/issues/1750#issuecomment-52489331.
www.debian.org - The Universal Operating System
As I understand NixOS I want to end up with configuration.nix like https://github.com/chaoflow/nixos-configurations/blob/master/configuration-eve.nix but build list of all systemPackages
now using only Nix with my current Debian.
@lethalman could you tell something more about NixOS in subdirectory of Debian? How can I install and run it that way?
NixOS is all or nothing. It's better you don't mess with nixos
configuration inside debian. That is, the simplest option is to install nix
in debian so that you can use the nixpkgs packages. But not nixos services.
About nixos in a subdirectory, I run a patched nixpkgs with this PR which
is still wip: https://github.com/NixOS/nixpkgs/pull/3143
Basically, you install nixos in a subdir like /nixos, nixos initrd will
mount your /dev/sdaX in something like /mnt/real-root and then
/mnt/real-root/nixos will be bind-mounted to /. It requires a little of
knowledge of linux and basic nixos.
If you are willing to do this setup I can help, however I highly suggest
you to first try out nixos in a VM or such if it's your first time.
On Mon, Aug 18, 2014 at 5:50 PM, Kamil Chmielewski <[email protected]
wrote:
As I understand NixOS I want to end up with configuration.nix like
https://github.com/chaoflow/nixos-configurations/blob/master/configuration-eve.nix
but build list of all systemPackages now using only Nix with my current
Debian.
@lethalman https://github.com/lethalman could you tell something more
about NixOS in subdirectory of Debian? How can I install and run it that
way?—
Reply to this email directly or view it on GitHub
https://github.com/NixOS/nixpkgs/issues/1750#issuecomment-52511634.
www.debian.org - The Universal Operating System
OK, so I'll stick with VM as I started. Migration should be easy enough after I build my VM as I like. Thx for info :)
Prototype implementation: https://github.com/NixOS/nixpkgs/pull/9250
This would be huge.
Right now most nixos users are also root on their machines and thus tend to encode everything on a system level. As a non-root user it's hard to port all of my config to another machine. It would great if instead I could port a set of nix expressions and have everything installed with a single command.
Declarative user enviroment was the biggest benefit of using NixOS that I thought I would get after moving to NixOS.
Because of that this was my first target as NixOS user.
I found package collections on https://nixos.org/wiki/Howto_keep_multiple_packages_up_to_date_at_once and started to do it that way, ended with https://github.com/kamilchm/.nixpkgs where I declare all packages and configs I need.
So if I'll need to move to different machine everything I need is just git clone ...
and nix-env -i all
.
Maybe I don't understand this PR correctly, but I can _port all of my config to another machine_ now without this PR.
But it would be great if we get standard solution with separate command design exactly for this :+1:
That's really cool. Thanks a lot for the example !
@kamilchm I don't quite follow how your setup works for dotfiles. For example, does your .bashrc file end up in your home directory? It seems to be installed in $out/userHome
, which presumably is a path in /nix/store
- so how does bash know to look there for its config file?
Yoou're right, it's not complete,
I've done one thing after nix-env -i all
:
find .nix-profile/userHome/ | sed "s/.nix-profile\/userHome\///g" | grep -v "^$" | xargs -I {} echo "ln -s ~/nix.profile/userHome/{} ~/{}"
See http://nix-cookbook.readthedocs.io/en/latest/faq.html#how-can-i-manage-dotfiles-in-home-with-nix
An alternative to sheenobu/nix-home (mentioned in the nix-cookbook FAQ) is rycee/home-manager.
Most helpful comment
Declarative user enviroment was the biggest benefit of using NixOS that I thought I would get after moving to NixOS.
Because of that this was my first target as NixOS user.
I found package collections on https://nixos.org/wiki/Howto_keep_multiple_packages_up_to_date_at_once and started to do it that way, ended with https://github.com/kamilchm/.nixpkgs where I declare all packages and configs I need.
So if I'll need to move to different machine everything I need is just
git clone ...
andnix-env -i all
.Maybe I don't understand this PR correctly, but I can _port all of my config to another machine_ now without this PR.
But it would be great if we get standard solution with separate command design exactly for this :+1: