nix-community / impermanence

Modules to help you handle persistent state on systems with ephemeral root storage [maintainer=@talyz]
MIT License
1.1k stars 81 forks source link

Does the nixos module work with paths or only a root device? #12

Closed mogorman closed 4 years ago

mogorman commented 4 years ago

I tried following the blog post

On my machine I get the following error when trying to switch

[root@dent:/etc/nixos]# nixos-rebuild boot --show-trace
building Nix...
building the system configuration...
error: while evaluating the attribute 'config.system.build.toplevel' at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/top-level.nix:275:5:
while evaluating 'foldr' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:52:20, called from /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/top-level.nix:139:12:
while evaluating 'fold'' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:55:15, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:59:8:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/top-level.nix:132:50, called from undefined position:
while evaluating the attribute 'assertion' at /nix/store/26s6bkfh6gvq0zg0a9lgjs6p4i66r1hx-source/nixos.nix:190:11:
while evaluating 'markedNeededForBoot' at /nix/store/26s6bkfh6gvq0zg0a9lgjs6p4i66r1hx-source/nixos.nix:168:37, called from /nix/store/26s6bkfh6gvq0zg0a9lgjs6p4i66r1hx-source/nixos.nix:190:23:
while evaluating the attribute 'fileSystems."/nix/persist".neededForBoot' at undefined position:
attribute '/nix/persist' missing, at /nix/store/26s6bkfh6gvq0zg0a9lgjs6p4i66r1hx-source/nixos.nix:168:42

my machine is setup that /nix is filesystem and /nix/persist is a folder inside of it.

This config from the blog post is working with the home-manager module but not with the nixos one.

Is there a way to make this work without making my persist dir the root dir of a filesystem?

talyz commented 4 years ago

It looks like your issue is that you have

{
  fileSystems."/nix/persist".neededForBoot = true;
}

in your config, but /nix/persist isn't a file system. Just removing this line should make it work. /nix should already be marked neededForBoot, so you shouldn't have to care about that :)

mogorman commented 4 years ago

I don't have that set in my config, and if i had tried it would have failed as its not valid without a device.

building Nix...
building the system configuration...
error: while evaluating the attribute 'config.system.build.toplevel' at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/top-level.nix:280:5:
while evaluating 'foldr' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:52:20, called from /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/top-level.nix:130:12:
while evaluating 'fold'' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:55:15, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:59:8:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/top-level.nix:123:50, called from undefined position:
while evaluating the attribute 'assertion' at /nix/store/26s6bkfh6gvq0zg0a9lgjs6p4i66r1hx-source/nixos.nix:190:11:
while evaluating 'markedNeededForBoot' at /nix/store/26s6bkfh6gvq0zg0a9lgjs6p4i66r1hx-source/nixos.nix:168:37, called from /nix/store/26s6bkfh6gvq0zg0a9lgjs6p4i66r1hx-source/nixos.nix:190:23:
while evaluating the attribute 'fileSystems."/nix/persist".neededForBoot' at undefined position:
attribute '/nix/persist' missing, at /nix/store/26s6bkfh6gvq0zg0a9lgjs6p4i66r1hx-source/nixos.nix:168:42

and the included configuration.nix

talyz commented 4 years ago

Oh, whoops, it's actually because of an assertion we're making. That should be fixed.

talyz commented 4 years ago

I've opened #13 which should fix this. Please try it out :)

mogorman commented 4 years ago

tried it out, fixes the problem. thank you.