Skip to content

Commit

Permalink
Implement disko as a module
Browse files Browse the repository at this point in the history
This allows us to build it independently when bootstraping a system
  • Loading branch information
Baitinq committed Aug 25, 2022
1 parent 6d2e193 commit 278ba42
Showing 1 changed file with 63 additions and 44 deletions.
107 changes: 63 additions & 44 deletions hosts/luna/disks.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ inputs, pkgs, ... }:
{ inputs, lib, config, pkgs, ... }:
let
partitionsConfig = {
type = "devices";
Expand Down Expand Up @@ -99,60 +99,79 @@ let
};
in
{
fileSystems."/" = {
device = "none";
fsType = "tmpfs";
};
config = {

boot.initrd.luks.devices."encrypted_boot" = {
device = "/dev/disk/by-uuid/4f5ba100-5c69-49ce-b0cf-2f219a5e9e51";
preLVM = true;
};
fileSystems."/" = {
device = "none";
fsType = "tmpfs";
};

fileSystems."/boot" = {
device = "/dev/mapper/encrypted_boot";
fsType = "vfat";
};
boot.initrd.luks.devices."encrypted_boot" = {
device = "/dev/disk/by-uuid/4f5ba100-5c69-49ce-b0cf-2f219a5e9e51";
preLVM = true;
};

fileSystems."/boot/efi" = {
device = "/dev/disk/by-uuid/BD51-1431";
fsType = "vfat";
};
fileSystems."/boot" = {
device = "/dev/mapper/encrypted_boot";
fsType = "vfat";
};

boot.initrd.luks.devices."encrypted_nix".device = "/dev/disk/by-uuid/596e43d3-ccda-4f06-bce9-58d6a8c0dd79";
fileSystems."/boot/efi" = {
device = "/dev/disk/by-uuid/BD51-1431";
fsType = "vfat";
};

fileSystems."/nix" = {
device = "/dev/mapper/encrypted_nix";
fsType = "btrfs";
neededForBoot = true;
options = [ "subvol=nix" "compress-force=zstd" "noatime" ];
};
boot.initrd.luks.devices."encrypted_nix".device = "/dev/disk/by-uuid/596e43d3-ccda-4f06-bce9-58d6a8c0dd79";

boot.initrd.luks.devices."encrypted_home_and_persist".device = "/dev/disk/by-uuid/47a8ddde-1237-4a0f-84c4-f17fbd22ea3f";
fileSystems."/nix" = {
device = "/dev/mapper/encrypted_nix";
fsType = "btrfs";
neededForBoot = true;
options = [ "subvol=nix" "compress-force=zstd" "noatime" ];
};

fileSystems."/persist" = {
device = "/dev/mapper/encrypted_home_and_persist";
fsType = "btrfs";
neededForBoot = true;
options = [ "subvol=persist" "compress-force=zstd" "noatime" ];
};
boot.initrd.luks.devices."encrypted_home_and_persist".device = "/dev/disk/by-uuid/47a8ddde-1237-4a0f-84c4-f17fbd22ea3f";

fileSystems."/home" = {
device = "/dev/mapper/encrypted_home_and_persist";
fsType = "btrfs";
options = [ "subvol=home" "compress-force=zstd" ];
};
fileSystems."/persist" = {
device = "/dev/mapper/encrypted_home_and_persist";
fsType = "btrfs";
neededForBoot = true;
options = [ "subvol=persist" "compress-force=zstd" "noatime" ];
};

fileSystems."/home" = {
device = "/dev/mapper/encrypted_home_and_persist";
fsType = "btrfs";
options = [ "subvol=home" "compress-force=zstd" ];
};

services.btrfs.autoScrub.enable = true;
services.btrfs.autoScrub.enable = true;

swapDevices = [ ];
swapDevices = [ ];

zramSwap.enable = true;
zramSwap.enable = true;


environment.systemPackages = [
config.disko-create
config.disko-mount
];
};

options.disko-create = with lib; mkOption {
type = types.package;
default = pkgs.buildEnv {
name = "disko-create";
paths = [ (pkgs.writeScriptBin "disko-create" (inputs.disko.lib.create partitionsConfig)) pkgs.parted ];
};
};

options.disko-mount = with lib; mkOption {
type = types.package;
default = pkgs.buildEnv {
name = "disko-mount";
paths = [ (pkgs.writeScriptBin "disko-mount" (inputs.disko.lib.mount partitionsConfig)) pkgs.parted ];
};
};

environment.systemPackages = with pkgs;[
parted
(pkgs.writeScriptBin "disko-create" (inputs.disko.lib.create partitionsConfig))
(pkgs.writeScriptBin "disko-mount" (inputs.disko.lib.mount partitionsConfig))
];
}

0 comments on commit 278ba42

Please sign in to comment.