commit 3c941b4ce2b8dabcb400fca937ff0b70a2927a90
parent 243295aab8d75a79b7db28dd2a06d7db7b2252e3
Author: Daniel Barlow <dan@telent.net>
Date: Sun, 7 Jan 2024 16:43:43 +0000
partial btrfs support
doesn't actually know how to make the filesystem, just
kernel config and accept it as a valid option
Diffstat:
3 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/examples/rotuer.nix b/examples/rotuer.nix
@@ -43,8 +43,11 @@ in rec {
../modules/bridge
../modules/ntp
../modules/ssh
+ ../modules/outputs/btrfs.nix
+
];
hostname = "rotuer";
+ rootfsType = "btrfs";
services.hostap = svc.hostapd.build {
interface = config.hardware.networkInterfaces.wlan;
diff --git a/modules/base.nix b/modules/base.nix
@@ -40,6 +40,7 @@ in {
rootfsType = mkOption {
default = "squashfs";
type = types.enum [
+ "btrfs"
"ext4"
"jffs2"
"squashfs"
diff --git a/modules/outputs/btrfs.nix b/modules/outputs/btrfs.nix
@@ -0,0 +1,37 @@
+{
+ config
+, pkgs
+, lib
+, ...
+}:
+let
+ inherit (lib) mkIf mkOption types;
+ o = config.system.outputs;
+in
+{
+ imports = [
+ ./initramfs.nix
+ ];
+ config = mkIf (config.rootfsType == "btrfs") {
+ kernel.config = {
+ BTRFS_FS = "y";
+ };
+ boot.initramfs.enable = true;
+ system.outputs = {
+ rootfs =
+ let
+ inherit (pkgs.pkgsBuildBuild) runCommand e2fsprogs;
+ in runCommand "mkfs.btrfs" {
+ depsBuildBuild = [ e2fsprogs ];
+ } ''
+ tree=${o.bootablerootdir}
+ size=$(du -s --apparent-size --block-size 1024 $tree |cut -f1)
+ # add 25% for filesystem overhead
+ size=$(( 5 * $size / 4))
+ dd if=/dev/zero of=$out bs=1024 count=$size
+ echo "not implemented" ; exit 1
+ # mke2fs -t ext4 -j -d $tree $out
+ '';
+ };
+ };
+}