Skip to content
This repository has been archived by the owner on Nov 25, 2023. It is now read-only.

feat: use disko for disk management #55

Open
realeinherjar opened this issue Sep 25, 2023 · 0 comments
Open

feat: use disko for disk management #55

realeinherjar opened this issue Sep 25, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@realeinherjar
Copy link
Owner

disko is an automated disk partitioning and formatting for NixOS.

Install via flakes:

{
  inputs.disko.url = "github:nix-community/disko";
  inputs.disko.inputs.nixpkgs.follows = "nixpkgs";

  outputs = { self, nixpkgs, disko }: {
    # change `yourhostname` to your actual hostname
    nixosConfigurations.yourhostname = nixpkgs.lib.nixosSystem {
      # change to your system:
      system = "x86_64-linux";
      modules = [
        ./configuration.nix
        disko.nixosModules.disko
      ];
    };
  };
}

Then add the following:

{ disks ? [ "/dev/vda" ], ... }: {
  # checkout the example folder for how to configure different disko layouts
  disko.devices = {
    disk = {
      vbd = {
        device = builtins.elemAt disks 0;
        type = "disk";
        content = {
          type = "table";
          format = "gpt";
          partitions = [
            {
              name = "ESP";
              start = "1MiB";
              end = "512MiB";
              type = "EF00";
              bootable = true;
              content = {
                type = "filesystem";
                format = "vfat";
                mountpoint = "/boot";
                mountOptions = [
                  "defaults"
                ];
              };
            }
            {
              name = "luks";
              start = "512MiB";
              end = "100%";
              part-type = "primary";
              bootable = true;
              content = {
                type = "luks";
                name = "crypted";
                type = "btrfs";
                extraOpenArgs = [ "-f" "--allow-discards" ];
                passwordFile = config.age.secrets.luks.path;
                subvolumes = {
                  "/nix" = {
                    mountOptions = [ "compress=zstd" "noatime" ];
                    mountpoint = "/nix";
                  };
                };
              };
            }
          ];
        };
      };
    };
    nodev = {
      "/" = {
        fsType = "tmpfs";
        mountOptions = [
          "defaults"
          "size=12G"
          "mode=755"
        ];
      };
    };
  };
}

secrets.nix add an entry:

"luks.age".publicKeys = [ einherjar ];

hosts/laptop/wayland/default.nix:

age.secrets = {
  ...
  luks.file = ../../../secrets/luks.age;
};

Additionally this script might help you: https://github.com/Ruixi-rebirth/flakes/blob/main/scripts/disko.sh

@realeinherjar realeinherjar added the enhancement New feature or request label Oct 30, 2023
@realeinherjar realeinherjar self-assigned this Oct 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant