# Using nixos-generate-config with zfs

**URL:** https://discourse.nixos.org/t/using-nixos-generate-config-with-zfs/73114
**Category:** Help
**Created:** [December 11, 2025, 12:25am UTC](https://discourse.nixos.org/t/using-nixos-generate-config-with-zfs/73114 "2025-12-11T00:25:25Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Roo](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/r/90db22/32.png) [@Roo](https://discourse.nixos.org/u/Roo)
#### Post date: [December 11, 2025, 12:25am UTC](https://discourse.nixos.org/t/using-nixos-generate-config-with-zfs/73114/1 "2025-12-11T00:25:25Z")

</div>

I’m running a NixOS system with a ZFS data array (RAIDZ1).

I recently re-ran `nixos-generate-config` which should be safe - and it seemed so, but my ZFS data array was now listed as a filesystem in my `/etc/nixos/hardware-configuration.nix`file

This seemed fine, until I tried to reboot the machine. It got hung up

```auto
Dec 10 14:03:29 lead zfs-import-dpool-start\[1005\]: importing ZFS pool “dpool”…Successfully imported dpool
Dec 10 14:03:29 lead systemd\[1\]: Finished Import ZFS pool “dpool”.
Dec 10 14:03:29 lead systemd\[1\]: Reached target ZFS pool import target.
Dec 10 14:03:29 lead systemd\[1\]: Mounting /data…
Dec 10 14:03:29 lead systemd\[1\]: Starting Mount ZFS filesystems…
Dec 10 14:03:29 lead mount\[1223\]: filesystem ‘dpool’ cannot be mounted using ‘mount’.
Dec 10 14:03:29 lead mount\[1223\]: Use ‘zfs set mountpoint=legacy’ or ‘zfs mount dpool’.
Dec 10 14:03:29 lead mount\[1223\]: See zfs(8) for more information.

```

This is because in the `/etc/nixos/hardware-configuration.nix` file I have

```auto
  fileSystems."/data" =
    { device = "dpool";
      fsType = "zfs";
    };

  fileSystems."/data/backup" =
    { device = "dpool/backup";
      fsType = "zfs";
    };

```

By commenting this section out of my `hardware-configuration.nix` – and doing a `nixos-rebuild-switch` followed by a reboot.. I’m back just fine

Is this a bug? In my `/etc/nixos/configuration.nix` file I have

```auto
  # Load up the zfs filesystem
  boot.zfs.extraPools = ["dpool"];

```

which causes my zfs filesystem to get mounted..

It feels a bit like `nixos-generate-config` should ignore zfs filesystems.. or I’m doing something wrong.

---

<div class="post-metadata">

### Author: ![Michael-C-Buckley](https://discourse.nixos.org/user_avatar/discourse.nixos.org/michael-c-buckley/32/32551_2.png) [@Michael-C-Buckley](https://discourse.nixos.org/u/Michael-C-Buckley)
#### Post date: [December 11, 2025, 4:17am UTC](https://discourse.nixos.org/t/using-nixos-generate-config-with-zfs/73114/2 "2025-12-11T04:17:16Z")

</div>

That command is an easy footgun and all outputs must be checked when you use it. Presumably you’re using ZFS’ automount which means you won’t be adding the results to your config, which is reasonable. However the logic isn’t that advanced, it just scans and add things. It’s a hella of an output if you ran that on a system with impermanence, as the litany of bind mounts would be inappropriately added as well.

---

<div class="post-metadata">

### Author: ![Mapybara](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/m/8dc957/32.png) [@Mapybara](https://discourse.nixos.org/u/Mapybara)
#### Post date: [December 11, 2025, 4:17am UTC](https://discourse.nixos.org/t/using-nixos-generate-config-with-zfs/73114/3 "2025-12-11T04:17:18Z")

</div>

> [@Roo](#):
>
> It feels a bit like `nixos-generate-config` should ignore zfs filesystems

Whether it should or not depends, among other things, on whether you’ve got them configured (in ZFS) as legacy mounts or not. I feel like it’s an insoluble problem because there are roughly equal pros and cons of having NixOS or ZFS configure the mounting of your datasets.

Personally, I find that a partial solution is to put all my mounting into my main configuration.nix file, and delete ALL mounting from hardware-configuration.nix by hand every time I re-run nixos-generate-config. That’s clearly not ideal, but it has the huge advantage of reminding me of what I’ve got configured each time. And it’s simple.

---

<div class="post-metadata">

### Author: ![Roo](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/r/90db22/32.png) [@Roo](https://discourse.nixos.org/u/Roo)
#### Post date: [December 12, 2025, 2:10pm UTC](https://discourse.nixos.org/t/using-nixos-generate-config-with-zfs/73114/4 "2025-12-12T14:10:38Z")

</div>

> [@Michael-C-Buckley](#):
>
> That command is an easy footgun and all outputs must be checked when you use it.

I’ve tagged @Michael-C-Buckley’s post as the solution, this runs counter to the other ‘advice’ I’ve seen posted saying that it is safe to run `nix-generate-config` multiple times and just “trust it”. I will say that I particularly liked the “footgun” comment.

I will thank @Mapybara for their comment on this post as well, which appears to share the same guidance but with additional details on how they manage using the command.

**In summary:** Yes - it is “safe” to run `nix-generate-config` multiple times, it will not over-write your `/etc/nixos/configuration.nix` file if it detects one. However, you do need to be aware that it may capture elements of your system (say mounted zfs file systems that are not legacy mounts) which you do not want included.

---

<div class="post-metadata">

### Author: ![Michael-C-Buckley](https://discourse.nixos.org/user_avatar/discourse.nixos.org/michael-c-buckley/32/32551_2.png) [@Michael-C-Buckley](https://discourse.nixos.org/u/Michael-C-Buckley)
#### Post date: [December 12, 2025, 2:12pm UTC](https://discourse.nixos.org/t/using-nixos-generate-config-with-zfs/73114/5 "2025-12-12T14:12:33Z")

</div>

Trust, but verify! Especially inherently impure boundaries like physical hardware and network/filesystems.
