diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index c444204c0b6..ed93c1dd570 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -316,11 +316,12 @@ ./system/upstart/upstart.nix ./tasks/cpu-freq.nix ./tasks/encrypted-devices.nix + ./tasks/filesystems.nix ./tasks/filesystems/btrfs.nix + ./tasks/filesystems/cifs.nix ./tasks/filesystems/ext.nix ./tasks/filesystems/f2fs.nix ./tasks/filesystems/nfs.nix - ./tasks/filesystems.nix ./tasks/filesystems/reiserfs.nix ./tasks/filesystems/unionfs-fuse.nix ./tasks/filesystems/vfat.nix diff --git a/nixos/modules/system/boot/stage-1.nix b/nixos/modules/system/boot/stage-1.nix index 01558b8f9b2..327f11bc698 100644 --- a/nixos/modules/system/boot/stage-1.nix +++ b/nixos/modules/system/boot/stage-1.nix @@ -23,22 +23,6 @@ let }; - needsCifsUtils = kernelPackages.kernel ? features - && kernelPackages.kernel.features ? needsCifsUtils - && kernelPackages.kernel.features.needsCifsUtils - && any (fs: fs.fsType == "cifs") fileSystems; - - busybox = - if needsCifsUtils - then pkgs.busybox.override { - extraConfig = '' - CONFIG_FEATURE_MOUNT_CIFS n - CONFIG_FEATURE_MOUNT_HELPERS y - ''; - } - else pkgs.busybox; - - # Some additional utilities needed in stage 1, like mount, lvm, fsck # etc. We don't want to bring in all of those packages, so we just # copy what we need. Instead of using statically linked binaries, @@ -62,7 +46,7 @@ let cp -pv ${pkgs.gcc.gcc}/lib*/libgcc_s.so.* $out/lib # Copy BusyBox. - cp -rvd ${busybox}/{bin,sbin} $out/ + cp -rvd ${pkgs.busybox}/{bin,sbin} $out/ chmod -R u+w $out # Copy some utillinux stuff. @@ -91,11 +75,6 @@ let cp -v ${pkgs.kmod}/bin/kmod $out/bin/ ln -s kmod $out/bin/modprobe - # Maybe copy cifs utils - ${optionalString needsCifsUtils '' - cp -v ${pkgs.cifs_utils}/sbin/mount.cifs $out/bin - ''} - ${config.boot.initrd.extraUtilsCommands} # Strip binaries further than normal. diff --git a/nixos/modules/tasks/filesystems.nix b/nixos/modules/tasks/filesystems.nix index 4de16a776d4..4b189a801b2 100644 --- a/nixos/modules/tasks/filesystems.nix +++ b/nixos/modules/tasks/filesystems.nix @@ -137,7 +137,7 @@ in system.fsPackages = [ pkgs.dosfstools ]; environment.systemPackages = - [ pkgs.ntfs3g pkgs.cifs_utils pkgs.fuse ] + [ pkgs.ntfs3g pkgs.fuse ] ++ config.system.fsPackages; environment.etc.fstab.text = diff --git a/nixos/modules/tasks/filesystems/cifs.nix b/nixos/modules/tasks/filesystems/cifs.nix new file mode 100644 index 00000000000..c60f175db84 --- /dev/null +++ b/nixos/modules/tasks/filesystems/cifs.nix @@ -0,0 +1,25 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + inInitrd = any (fs: fs == "cifs") config.boot.initrd.supportedFilesystems; + +in + +{ + config = { + + system.fsPackages = [ pkgs.cifs_utils ]; + + boot.initrd.availableKernelModules = mkIf inInitrd + [ "cifs" "nls_utf8" "hmac" "md4" "ecb" "des_generic" "sha256" ]; + + boot.initrd.extraUtilsCommands = mkIf inInitrd + '' + cp -v ${pkgs.cifs_utils}/sbin/mount.cifs $out/bin + ''; + + }; +} diff --git a/pkgs/os-specific/linux/busybox/default.nix b/pkgs/os-specific/linux/busybox/default.nix index 9e81508080d..98fedb2d3f4 100644 --- a/pkgs/os-specific/linux/busybox/default.nix +++ b/pkgs/os-specific/linux/busybox/default.nix @@ -28,6 +28,10 @@ let nixConfig = '' CONFIG_PREFIX "$out" CONFIG_INSTALL_NO_USR y + + # Use the external mount.cifs program. + CONFIG_FEATURE_MOUNT_CIFS n + CONFIG_FEATURE_MOUNT_HELPERS y ''; staticConfig = stdenv.lib.optionalString enableStatic '' @@ -49,8 +53,8 @@ stdenv.mkDerivation rec { ${configParser} cat << EOF | parseconfig ${staticConfig} - ${extraConfig} ${nixConfig} + ${extraConfig} $extraCrossConfig EOF make oldconfig