liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

btrfs.nix (839B)


      1 {
      2   config
      3 , pkgs
      4 , lib
      5 , ...
      6 }:
      7 let
      8   inherit (lib) mkIf mkOption types;
      9   o = config.system.outputs;
     10 in
     11 {
     12   imports = [
     13     ./initramfs.nix
     14   ];
     15   config = mkIf (config.rootfsType == "btrfs") {
     16     kernel.config = {
     17       BTRFS_FS = "y";
     18     };
     19     boot.initramfs.enable = true;
     20     system.outputs = {
     21       rootfs =
     22         let
     23           inherit (pkgs.pkgsBuildBuild) runCommand e2fsprogs;
     24         in runCommand "mkfs.btrfs" {
     25           depsBuildBuild = [ e2fsprogs ];
     26         } ''
     27           tree=${o.bootablerootdir}
     28           size=$(du -s --apparent-size --block-size 1024 $tree |cut -f1)
     29           # add 25% for filesystem overhead
     30           size=$(( 5 * $size / 4))
     31           dd if=/dev/zero of=$out bs=1024 count=$size
     32           echo "not implemented" ; exit 1
     33           # mke2fs -t ext4 -j -d $tree $out
     34         '';
     35     };
     36   };
     37 }