at 23.11-pre 1.8 kB view raw
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 = lib.mkIf (!config.boot.initrd.systemd.enable) '' 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 = lib.mkIf (!config.boot.initrd.systemd.enable) '' 20 # Hacky!!! fuse hard-codes the path to mount 21 mkdir -p /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${pkgs.util-linux.name}-bin/bin 22 ln -s $(which mount) /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${pkgs.util-linux.name}-bin/bin 23 ln -s $(which umount) /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${pkgs.util-linux.name}-bin/bin 24 ''; 25 26 boot.initrd.systemd.extraBin = { 27 "mount.fuse" = "${pkgs.fuse}/bin/mount.fuse"; 28 "unionfs" = "${pkgs.unionfs-fuse}/bin/unionfs"; 29 "mount.unionfs-fuse" = pkgs.runCommand "mount.unionfs-fuse" {} '' 30 substitute ${pkgs.unionfs-fuse}/sbin/mount.unionfs-fuse $out \ 31 --replace '${pkgs.bash}/bin/bash' /bin/sh \ 32 --replace '${pkgs.fuse}/sbin' /bin \ 33 --replace '${pkgs.unionfs-fuse}/bin' /bin 34 ''; 35 }; 36 }) 37 38 (lib.mkIf (lib.any (fs: fs == "unionfs-fuse") config.boot.supportedFilesystems) { 39 system.fsPackages = [ pkgs.unionfs-fuse ]; 40 }) 41 42 ]; 43}