Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

Merge pull request #141122 from Luflosi/add-apfs-nixos-module

authored by

Maciej Krüger and committed by
GitHub
8bb7bec7 0628dd52

+90 -1
+6
nixos/doc/manual/from_md/release-notes/rl-2205.section.xml
··· 81 81 </listitem> 82 82 <listitem> 83 83 <para> 84 + <link xlink:href="https://github.com/linux-apfs/linux-apfs-rw">apfs</link>, 85 + a kernel module for mounting the Apple File System (APFS). 86 + </para> 87 + </listitem> 88 + <listitem> 89 + <para> 84 90 <link xlink:href="https://frrouting.org/">FRRouting</link>, a 85 91 popular suite of Internet routing protocol daemons (BGP, BFD, 86 92 OSPF, IS-IS, VVRP and others). Available as
+2
nixos/doc/manual/release-notes/rl-2205.section.md
··· 27 27 28 28 - [filebeat](https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-overview.html), a lightweight shipper for forwarding and centralizing log data. Available as [services.filebeat](#opt-services.filebeat.enable). 29 29 30 + - [apfs](https://github.com/linux-apfs/linux-apfs-rw), a kernel module for mounting the Apple File System (APFS). 31 + 30 32 - [FRRouting](https://frrouting.org/), a popular suite of Internet routing protocol daemons (BGP, BFD, OSPF, IS-IS, VVRP and others). Available as [services.frr](#opt-services.ffr.babel.enable) 31 33 32 34 - [heisenbridge](https://github.com/hifi/heisenbridge), a bouncer-style Matrix IRC bridge. Available as [services.heisenbridge](options.html#opt-services.heisenbridge.enable).
+1
nixos/modules/module-list.nix
··· 1164 1164 ./tasks/cpu-freq.nix 1165 1165 ./tasks/encrypted-devices.nix 1166 1166 ./tasks/filesystems.nix 1167 + ./tasks/filesystems/apfs.nix 1167 1168 ./tasks/filesystems/bcachefs.nix 1168 1169 ./tasks/filesystems/btrfs.nix 1169 1170 ./tasks/filesystems/cifs.nix
+3
nixos/modules/system/boot/stage-1-init.sh
··· 282 282 # Don't check resilient COWs as they validate the fs structures at mount time 283 283 if [ "$fsType" = btrfs -o "$fsType" = zfs -o "$fsType" = bcachefs ]; then return 0; fi 284 284 285 + # Skip fsck for apfs as the fsck utility does not support repairing the filesystem (no -a option) 286 + if [ "$fsType" = apfs ]; then return 0; fi 287 + 285 288 # Skip fsck for nilfs2 - not needed by design and no fsck tool for this filesystem. 286 289 if [ "$fsType" = nilfs2 ]; then return 0; fi 287 290
+1 -1
nixos/modules/tasks/filesystems.nix
··· 250 250 251 251 environment.etc.fstab.text = 252 252 let 253 - fsToSkipCheck = [ "none" "bindfs" "btrfs" "zfs" "tmpfs" "nfs" "vboxsf" "glusterfs" ]; 253 + fsToSkipCheck = [ "none" "bindfs" "btrfs" "zfs" "tmpfs" "nfs" "vboxsf" "glusterfs" "apfs" ]; 254 254 skipCheck = fs: fs.noCheck || fs.device == "none" || builtins.elem fs.fsType fsToSkipCheck; 255 255 # https://wiki.archlinux.org/index.php/fstab#Filepath_spaces 256 256 escape = string: builtins.replaceStrings [ " " "\t" ] [ "\\040" "\\011" ] string;
+22
nixos/modules/tasks/filesystems/apfs.nix
··· 1 + { config, lib, pkgs, ... }: 2 + 3 + with lib; 4 + 5 + let 6 + 7 + inInitrd = any (fs: fs == "apfs") config.boot.initrd.supportedFilesystems; 8 + 9 + in 10 + 11 + { 12 + config = mkIf (any (fs: fs == "apfs") config.boot.supportedFilesystems) { 13 + 14 + system.fsPackages = [ pkgs.apfsprogs ]; 15 + 16 + boot.extraModulePackages = [ config.boot.kernelPackages.apfs ]; 17 + 18 + boot.initrd.kernelModules = mkIf inInitrd [ "apfs" ]; 19 + 20 + # Don't copy apfsck into the initramfs since it does not support repairing the filesystem 21 + }; 22 + }
+1
nixos/tests/all-tests.nix
··· 35 35 agda = handleTest ./agda.nix {}; 36 36 airsonic = handleTest ./airsonic.nix {}; 37 37 amazon-init-shell = handleTest ./amazon-init-shell.nix {}; 38 + apfs = handleTest ./apfs.nix {}; 38 39 apparmor = handleTest ./apparmor.nix {}; 39 40 atd = handleTest ./atd.nix {}; 40 41 atop = handleTest ./atop.nix {};
+54
nixos/tests/apfs.nix
··· 1 + import ./make-test-python.nix ({ pkgs, ... }: { 2 + name = "apfs"; 3 + meta.maintainers = with pkgs.lib.maintainers; [ Luflosi ]; 4 + 5 + machine = { pkgs, ... }: { 6 + virtualisation.emptyDiskImages = [ 1024 ]; 7 + 8 + boot.supportedFilesystems = [ "apfs" ]; 9 + }; 10 + 11 + testScript = '' 12 + machine.wait_for_unit("basic.target") 13 + machine.succeed("mkdir /tmp/mnt") 14 + 15 + with subtest("mkapfs refuses to work with a label that is too long"): 16 + machine.fail( "mkapfs -L '000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F' /dev/vdb") 17 + 18 + with subtest("mkapfs works with the maximum label length"): 19 + machine.succeed("mkapfs -L '000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7' /dev/vdb") 20 + 21 + with subtest("Enable case sensitivity and normalization sensitivity"): 22 + machine.succeed( 23 + "mkapfs -s -z /dev/vdb", 24 + # Triggers a bug, see https://github.com/linux-apfs/linux-apfs-rw/issues/15 25 + # "mount -o cknodes,readwrite /dev/vdb /tmp/mnt", 26 + "mount -o readwrite /dev/vdb /tmp/mnt", 27 + "echo 'Hello World 1' > /tmp/mnt/test.txt", 28 + "[ ! -f /tmp/mnt/TeSt.TxT ] || false", # Test case sensitivity 29 + "echo 'Hello World 1' | diff - /tmp/mnt/test.txt", 30 + "echo 'Hello World 2' > /tmp/mnt/\u0061\u0301.txt", 31 + "echo 'Hello World 2' | diff - /tmp/mnt/\u0061\u0301.txt", 32 + "[ ! -f /tmp/mnt/\u00e1.txt ] || false", # Test Unicode normalization sensitivity 33 + "umount /tmp/mnt", 34 + "apfsck /dev/vdb", 35 + ) 36 + with subtest("Disable case sensitivity and normalization sensitivity"): 37 + machine.succeed( 38 + "mkapfs /dev/vdb", 39 + "mount -o readwrite /dev/vdb /tmp/mnt", 40 + "echo 'bla bla bla' > /tmp/mnt/Test.txt", 41 + "echo -n 'Hello World' > /tmp/mnt/test.txt", 42 + "echo ' 1' >> /tmp/mnt/TEST.TXT", 43 + "umount /tmp/mnt", 44 + "apfsck /dev/vdb", 45 + "mount -o readwrite /dev/vdb /tmp/mnt", 46 + "echo 'Hello World 1' | diff - /tmp/mnt/TeSt.TxT", # Test case insensitivity 47 + "echo 'Hello World 2' > /tmp/mnt/\u0061\u0301.txt", 48 + "echo 'Hello World 2' | diff - /tmp/mnt/\u0061\u0301.txt", 49 + "echo 'Hello World 2' | diff - /tmp/mnt/\u00e1.txt", # Test Unicode normalization 50 + "umount /tmp/mnt", 51 + "apfsck /dev/vdb", 52 + ) 53 + ''; 54 + })