Giter VIP home page Giter VIP logo

Comments (13)

phaer avatar phaer commented on June 16, 2024

Did you try it and ran into an error? Hooks shouldn't be constrained to zfs, if they are it's probably a bug

from disko.

hmanhng avatar hmanhng commented on June 16, 2024

Did you try it and ran into an error? Hooks shouldn't be constrained to zfs, if they are it's probably a bug

I tried it and it got an error

from disko.

phaer avatar phaer commented on June 16, 2024

Could you post the error?

from disko.

hmanhng avatar hmanhng commented on June 16, 2024

i tried it yesterday and the error was option not found
i also tried looking at the source code and it seems only zfs has this option

from disko.

hmanhng avatar hmanhng commented on June 16, 2024

I found my mistake.
I feel so stupid, I'm so sorry everyone!

from disko.

TimJones avatar TimJones commented on June 16, 2024

@hmanhng Apologies for posting in a closed issue, but can you actually post what your mistake/solution was? I am running into the same issue but don't understand the disko source as well as you 😃

from disko.

phaer avatar phaer commented on June 16, 2024

We might be able to improve the docs if one of you could post us the actual error message :D

from disko.

TimJones avatar TimJones commented on June 16, 2024

Sorry, you're right, with my disk config being

{
  disko.devices.disk.main = {
    type = "disk";
    device = "/dev/disk/by-id/nvme-WD_BLACK_SN850X_4000GB_23270P802370";
    content = {
      type = "gpt";
      partitions = {
        ESP = {
	  type = "EF00";
	  size = "500M";
	  priority = 1;
	  content = {
	    type = "filesystem";
	    format = "vfat";
	    mountpoint = "/boot";
	  };
	};
	OS = {
	  size = "100%";
	  content = {
	    type = "btrfs";
	    subvolumes = {
	      "SYSTEM" = {};
	      "SYSTEM/rootfs" = {
	        mountpoint = "/";
	        mountOptions = [ "compress=zstd" "noatime" "nodiratime" ];
                postCreateHook = ''
                  btrfs subvolume snapshot create -r ...
                '';
	      };
	      "SYSTEM/nix" = {
	        mountpoint = "/nix";
	        mountOptions = [ "compress=zstd" "noatime" "nodiratime" ];
	      };
	      "SYSTEM/swap" = {
	        mountpoint = "/swap";
		swap = {
		  swapfile.size = "48G";
		};
  	      };
	      "DATA" = {};
	      "DATA/home" = {
	        mountpoint = "/home";
	        mountOptions = [ "compress=zstd" "noatime" "nodiratime" ];
	      };
	      "DATA/persistence" = {
	        mountpoint = "/persist";
	        mountOptions = [ "compress=zstd" "noatime" "nodiratime" ];
	      };
	    };
	  };
	};
      };
    };
  };

  fileSystems."/persist".neededForBoot = true;
}

I get the error

error: The option `disko.devices.disk.main.content.partitions.OS.content.subvolumes."SYSTEM/rootfs".postCreateHook' does not exist.

(possible copy-paste errors in the above as I'm re-writing it from the terminal of one machine to another)

from disko.

hmanhng avatar hmanhng commented on June 16, 2024

We might be able to improve the docs if one of you could post us the actual error message :D

I was confused about it but after reading the source code I got it fixed.
I no longer have it so thank you for your help

from disko.

hmanhng avatar hmanhng commented on June 16, 2024

@TimJones
This is my configuration and it works fine.

{disk ? "nvme0n1", ...}: {
  disko.devices = {
    disk = {
      ${disk} = {
        device = "/dev/${disk}";
        type = "disk";
        content = {
          type = "table";
          format = "gpt";
          partitions = [
            {
              name = "esp";
              start = "1MiB";
              end = "512MiB";
              bootable = true;
              content = {
                type = "filesystem";
                format = "vfat";
                extraArgs = ["-F 32"];
                mountpoint = "/boot";
                mountOptions = [
                  "defaults"
                ];
              };
            }
            {
              name = "root";
              start = "512MiB";
              end = "70%";
              content = {
                type = "luks";
                name = "crypted";
                extraOpenArgs = ["--allow-discards"];
                passwordFile = "/tmp/secret.key";
                content = {
                  type = "lvm_pv";
                  vg = "pool";
                };
              };
            }
          ];
        };
      };
    };
    lvm_vg = {
      pool = {
        type = "lvm_vg";
        lvs = {
          root = {
            size = "100%FREE";
            content = {
              type = "btrfs";
              extraArgs = ["-f"];
              mountOptions = [
                "defaults"
                "lazytime"
              ];
              postCreateHook = ''
                MNTPOINT=$(mktemp -d)
                mount "/dev/mapper/pool-root" "$MNTPOINT" -o subvol=/
                trap 'umount $MNTPOINT; rm -rf $MNTPOINT' EXIT
                btrfs subvolume snapshot -r $MNTPOINT/rootfs $MNTPOINT/rootfs-blank
              '';
              subvolumes = {
                "rootfs" = {
                  mountpoint = "/";
                };
                "/nix" = {
                  mountpoint = "/nix";
                  mountOptions = ["compress=zstd" "noatime"];
                };
                "/home" = {
                  mountpoint = "/home";
                  mountOptions = ["compress=zstd"];
                };
              };
            };
          };
        };
      };
    };
  };
}

from disko.

hmanhng avatar hmanhng commented on June 16, 2024

@TimJones You need to set postCreateHook to the same level as subvolumes
I also made the same mistake.

The process of creating a btrfs volume is different from zfs so it may require a bit of hacking.

from disko.

TimJones avatar TimJones commented on June 16, 2024

@hmanhng Thanks for the info. I am very new to nix so reading the source still wasn't clear to me. Your example helps a lot!

from disko.

hmanhng avatar hmanhng commented on June 16, 2024

You're welcome.

from disko.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.