This commit is contained in:
Aleksandr Lebedev 2025-08-11 14:23:54 +02:00
parent a2c4f7385b
commit 764d5dd68c
9 changed files with 4996 additions and 18 deletions

View file

@ -0,0 +1,47 @@
{
lib,
pkgs,
inputs,
namespace,
system,
target,
format,
virtual,
systems,
config,
...
}:
with lib;
with lib.${namespace}; let
cfg = config.${namespace}.presets.disko.ext4;
in {
options.${namespace}.presets.disko.ext4 = with types; {
enable = mkBoolOpt false "Enable preset";
device = mkOpt' str "/dev/nvme0n1";
mountpoint = mkOpt' path "/";
};
config = mkIf cfg.enable {
disko.devices = {
disk = {
"${cfg.device}" = {
inherit device;
type = "disk";
content = {
type = "gpt";
partitions = {
root = {
size = "100%";
content = {
type = "filesystem";
format = "ext4";
inherit (cfg) mountpoint;
};
};
};
};
};
};
};
};
}

View file

@ -0,0 +1,85 @@
{
lib,
pkgs,
inputs,
namespace,
system,
target,
format,
virtual,
systems,
config,
...
}:
with lib;
with lib.${namespace}; let
cfg = config.${namespace}.presets.disko.ext4Swap;
in {
options.${namespace}.presets.disko.ext4Swap = with types; {
enable = mkBoolOpt false "Enable preset";
device = mkOpt' str "/dev/nvme0n1";
swapSize = mkOpt' int 32;
mountpoint = mkOpt' path "/";
};
config = mkIf cfg.enable {
disko.devices = {
disk.${cfg.device} = {
type = "disk";
inherit device;
content = {
type = "gpt"; # Initialize the disk with a GPT partition table
partitions = {
ESP = {
# Setup the EFI System Partition
type = "EF00"; # Set the partition type
size = "1000M"; # Make the partition a gig
content = {
type = "filesystem";
format = "vfat"; # Format it as a FAT32 filesystem
mountpoint = "/boot"; # Mount it to /boot
};
};
primary = {
# Setup the LVM partition
size = "100%"; # Fill up the rest of the drive with it
content = {
type = "lvm_pv"; # pvcreate
vg = "vg1";
};
};
};
};
};
lvm_vg = {
# vgcreate
vg1 = {
# /dev/vg1
type = "lvm_vg";
lvs = {
# lvcreate
swap = {
# Logical Volume = "swap", /dev/vg1/swap
size = "${builtins.toString cfg.swapSize}G";
content = {
type = "swap";
};
};
root = {
# Logical Volume = "root", /dev/vg1/root
size = "100%FREE"; # Use the remaining space in the Volume Group
content = {
type = "filesystem";
format = "ext4";
inherit (cfg) mountpoint;
mountOptions = [
"defaults"
];
};
};
};
};
};
};
};
}

View file

@ -0,0 +1,37 @@
{
lib,
pkgs,
inputs,
namespace,
system,
target,
format,
virtual,
systems,
config,
...
}:
with lib;
with lib.${namespace}; let
username = "andrej";
admin = false;
extraGroups = ["networkmanager"];
trustedSshKeys = [];
cfg = config.${namespace}.users.${username};
in {
options.${namespace}.users.${username} = with types; {
enable = mkBoolOpt false "Enable ${username} user";
config = mkOpt types.attrs {} "Additional home manager config for ${username}";
};
config = mkUser {
inherit config;
inherit (cfg) enable;
homeConfig = cfg.config;
inherit username;
inherit admin;
inherit extraGroups;
inherit trustedSshKeys;
};
}