Merge pull request #231283 from nikstur/filesystems-erofs

nixos/filesystems: init erofs
This commit is contained in:
Ryan Lahfa 2023-05-14 18:54:37 +02:00 committed by GitHub
commit 1ee11b8a31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 120 additions and 44 deletions

View file

@ -1374,6 +1374,7 @@
./tasks/filesystems/cifs.nix ./tasks/filesystems/cifs.nix
./tasks/filesystems/ecryptfs.nix ./tasks/filesystems/ecryptfs.nix
./tasks/filesystems/envfs.nix ./tasks/filesystems/envfs.nix
./tasks/filesystems/erofs.nix
./tasks/filesystems/exfat.nix ./tasks/filesystems/exfat.nix
./tasks/filesystems/ext.nix ./tasks/filesystems/ext.nix
./tasks/filesystems/f2fs.nix ./tasks/filesystems/f2fs.nix

View file

@ -293,6 +293,9 @@ checkFS() {
# Skip fsck for inherently readonly filesystems. # Skip fsck for inherently readonly filesystems.
if [ "$fsType" = squashfs ]; then return 0; fi if [ "$fsType" = squashfs ]; then return 0; fi
# Skip fsck.erofs because it is still experimental.
if [ "$fsType" = erofs ]; then return 0; fi
# If we couldn't figure out the FS type, then skip fsck. # If we couldn't figure out the FS type, then skip fsck.
if [ "$fsType" = auto ]; then if [ "$fsType" = auto ]; then
echo 'cannot check filesystem with type "auto"!' echo 'cannot check filesystem with type "auto"!'

View file

@ -0,0 +1,21 @@
{ config, lib, pkgs, ... }:
let
inInitrd = lib.any (fs: fs == "erofs") config.boot.initrd.supportedFilesystems;
inSystem = lib.any (fs: fs == "erofs") config.boot.supportedFilesystems;
in
{
config = lib.mkIf (inInitrd || inSystem) {
system.fsPackages = [ pkgs.erofs-utils ];
boot.initrd.availableKernelModules = lib.mkIf inInitrd [ "erofs" ];
# fsck.erofs is currently experimental and should not be run as a
# privileged user. Thus, it is not included in the initrd.
};
}

View file

@ -1,6 +1,14 @@
import ./make-test-python.nix ({ lib, pkgs, ... }: { system ? builtins.currentSystem
, config ? { }
, pkgs ? import ../.. { inherit system config; }
}:
with import ../lib/testing-python.nix { inherit system pkgs; };
with pkgs.lib;
{ {
name = "non-default-filesystems"; btrfs = makeTest
{
name = "non-default-filesystems-btrfs";
nodes.machine = nodes.machine =
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
@ -52,4 +60,47 @@ import ./make-test-python.nix ({ lib, pkgs, ... }:
machine.succeed("grep -E '/dev/vda / btrfs rw,relatime,space_cache=v2,subvolid=[0-9]+,subvol=/root 0 0' /proc/mounts") machine.succeed("grep -E '/dev/vda / btrfs rw,relatime,space_cache=v2,subvolid=[0-9]+,subvol=/root 0 0' /proc/mounts")
machine.succeed("grep -E '/dev/vda /home btrfs rw,relatime,space_cache=v2,subvolid=[0-9]+,subvol=/home 0 0' /proc/mounts") machine.succeed("grep -E '/dev/vda /home btrfs rw,relatime,space_cache=v2,subvolid=[0-9]+,subvol=/home 0 0' /proc/mounts")
''; '';
}) };
erofs =
let
fsImage = "/tmp/non-default-filesystem.img";
in
makeTest {
name = "non-default-filesystems-erofs";
nodes.machine = _: {
virtualisation.qemu.drives = [{
name = "non-default-filesystem";
file = fsImage;
}];
virtualisation.fileSystems."/non-default" = {
device = "/dev/vdb";
fsType = "erofs";
neededForBoot = true;
};
};
testScript = ''
import subprocess
import tempfile
with tempfile.TemporaryDirectory() as tmp_dir:
with open(f"{tmp_dir}/filesystem", "w") as f:
f.write("erofs")
subprocess.run([
"${pkgs.erofs-utils}/bin/mkfs.erofs",
"${fsImage}",
tmp_dir,
])
machine.start()
machine.wait_for_unit("default.target")
file_contents = machine.succeed("cat /non-default/filesystem")
assert "erofs" in file_contents
'';
};
}