Re-use existing home (migrating from ubuntu)


#1

I am moving from ubuntu to nixos. I would like to keep my previous home directory which is on another disk.

I installed nixos successfully. Then I added

fileSystems."/home" = {
  device= "/dev/disk/by-uuid/123...;
  fsType = "ext4";
};

to configuration.nix, which seems to mount the disk correctly.

However, I cannot login to kde with my user anymore. It is

users.users.manuel = {
  isNormalUser = true;
  uid = 1000; # all files in /home/manuel have uid 1000
  home=/home/manuel;
  extraGroups = [ "wheel" "networkmanager ];
};

The group does not match:

> ll /home
drwxr-rxr-x 55 manuel 1000 4.0K Mar 7 16:58 manuel/

The user can login into console and also write into /home/manuel. But its home ~ is at /nix/store/1gr0...-manuel.

Is createHome = true; always required? If yes, I suppose I should create the group 1000 and add my user to it!?

I posted this question previously at superuser.


#2

Try to replace this line

home=/home/manuel;

with

home = "/home/manuel";

/home/manuel is a “path” in nix’s syntax and will be resolved to a path under /nix/store, you should use a string instead, see the manual


#3

Thanks, that solved it. Didn’t see my mistake.


#4

:stuck_out_tongue: Glad I can help. Welcome to the nix community.


#5

Actually, this problem disclosed a real issue. We have passwordFile options in many modules, and looks like when someone uses “path” for passwordFile, it get’s copied to /nix/store:

services.gitea.database.passwordFile = /run/keys/gitea-dbpassword;

It is unexpected that this will copy password file to public /nix/store.

cc @lheckemann @samueldr

I’ve made a fix for this issue (which includes fix for your usecase):


#6

This is often desirable to reduce statefulness. It’s a tradeoff of course, but one that should remain an option IMHO. What would be nice though is having a better way to distinguish “copied-to-store” paths and “verbatim” paths than quotes.


#7

@lheckemann This isn’t desirable for passwordFile-style options and stateDir. So probably we have to make a separate option type for those ones. types.mutablePath sounds ok? It is always possible to convert to immutable store path with builtins.toFile "bla" and builtins.filterSource (_: _: true)