Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify a size range for partitions #600

Open
cfitz25 opened this issue Apr 11, 2024 · 2 comments
Open

Specify a size range for partitions #600

cfitz25 opened this issue Apr 11, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@cfitz25
Copy link

cfitz25 commented Apr 11, 2024

Would it be possible to set a drive size with a minimum and a maximum value?
This would make it easier to use the same disko layout on different drive/partition sizes.
eg, for separate /nix partition of 100GB on a 1TB+ drive but 10GB on a smaller VM drive

@Lassulus
Copy link
Collaborator

hmm, not really. I guess you would need to get the disk data into nix first and then do some detection on it. Another possibility would be to generate multiple different disko configs and execute a different one depending on a script you write yourself. Something like:

environment.systemPackages = [
  (pkgs.writeScriptBin "multidisko" ''
    device_to_format=$1
    if [ $(fdisk -x "$device_to_format" | grep '[0-9]* bytes, | sed 's/ bytes,//') -lt 1000000 ]; then
      ${nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          { disko.devices = {
             disk = {
               device = "$device_to_format"; #not sure if this works, it should in theory
               content = {
                 type = "filesystem";
                 format = "ext4";
                 mountpoint = "/";
               };
             };
          };
        ];
      }.config.system.build.diskoScript}
     else
      ${nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          { disko.devices = {
             disk = {
               device = "$device_to_format"; #not sure if this works, it should in theory
               content = {
                 type = "filesystem";
                 format = "xfs";
                 mountpoint = "/";
               };
             };
          };
        ];
      }.config.system.build.diskoScript}
    fi
 
  '')
];

@iFreilicht iFreilicht changed the title Size range Specify a size range for partitions Oct 1, 2024
@iFreilicht iFreilicht added the enhancement New feature or request label Oct 1, 2024
@iFreilicht
Copy link
Contributor

This would become feasible with #789

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants