1{ config, pkgs, lib, ... }:
2
3{
4 config = lib.mkMerge [
5
6 (lib.mkIf (lib.any (fs: fs == "unionfs-fuse") config.boot.initrd.supportedFilesystems) {
7 boot.initrd.kernelModules = [ "fuse" ];
8
9 boot.initrd.extraUtilsCommands = ''
10 copy_bin_and_libs ${pkgs.fuse}/sbin/mount.fuse
11 copy_bin_and_libs ${pkgs.unionfs-fuse}/bin/unionfs
12 substitute ${pkgs.unionfs-fuse}/sbin/mount.unionfs-fuse $out/bin/mount.unionfs-fuse \
13 --replace '${pkgs.bash}/bin/bash' /bin/sh \
14 --replace '${pkgs.fuse}/sbin' /bin \
15 --replace '${pkgs.unionfs-fuse}/bin' /bin
16 chmod +x $out/bin/mount.unionfs-fuse
17 '';
18
19 boot.initrd.postDeviceCommands = ''
20 # Hacky!!! fuse hard-codes the path to mount
21 mkdir -p /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${pkgs.utillinux.name}-bin/bin
22 ln -s $(which mount) /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${pkgs.utillinux.name}-bin/bin
23 ln -s $(which umount) /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${pkgs.utillinux.name}-bin/bin
24 '';
25 })
26
27 (lib.mkIf (lib.any (fs: fs == "unionfs-fuse") config.boot.supportedFilesystems) {
28 system.fsPackages = [ pkgs.unionfs-fuse ];
29 })
30
31 ];
32}