1
0
Fork 0

Start playing around with Disko again

This commit is contained in:
Aires 2024-06-28 16:06:23 -04:00
parent fd47e52c2d
commit e2da50c9d4
3 changed files with 135 additions and 4 deletions

View file

@ -21,6 +21,26 @@
"type": "github" "type": "github"
} }
}, },
"disko": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1719582740,
"narHash": "sha256-s4WsLu2L8EzF5Hg2TkelFLVhKGL108AySnlw8voPe5U=",
"owner": "nix-community",
"repo": "disko",
"rev": "115311bc395f24c1b553338fec4b3aa28cbf5ae2",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "disko",
"type": "github"
}
},
"flake-compat": { "flake-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -138,11 +158,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1719438532, "lastModified": 1719588253,
"narHash": "sha256-/Vmso2ZMoFE3M7d1MRsQ2K5sR8CVKnrM6t1ys9Xjpz4=", "narHash": "sha256-A03i8xiVgP14DCmV5P7VUv37eodCjY4e1iai0b2EuuM=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "1a4f12ae0bda877ec4099b429cf439aad897d7e9", "rev": "7e68e55d2e16d3a1e92a679430728c35a30fd24e",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -339,6 +359,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"disko": "disko",
"home-manager": "home-manager", "home-manager": "home-manager",
"lanzaboote": "lanzaboote", "lanzaboote": "lanzaboote",
"lix-module": "lix-module", "lix-module": "lix-module",

View file

@ -38,12 +38,17 @@
flake = false; flake = false;
}; };
# TODO: Add Disko - https://github.com/nix-community/disko # Disko support https://github.com/nix-community/disko
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
outputs = outputs =
inputs@{ inputs@{
self, self,
disko,
home-manager, home-manager,
lanzaboote, lanzaboote,
lix-module, lix-module,
@ -65,6 +70,7 @@
defaultModules = [ defaultModules = [
./modules/autoimport.nix ./modules/autoimport.nix
(import nix-secrets) (import nix-secrets)
disko.nixosModules.disko
lix-module.nixosModules.default lix-module.nixosModules.default
lanzaboote.nixosModules.lanzaboote lanzaboote.nixosModules.lanzaboote
nix-flatpak.nixosModules.nix-flatpak nix-flatpak.nixosModules.nix-flatpak

104
hosts/Shura/disko.nix Normal file
View file

@ -0,0 +1,104 @@
{ lib, config, ... }:
let
cfg = config.disko;
standardMountOpts = [
"compress=zstd"
"noatime"
];
in
{
options = {
disko = {
enable = lib.mkEnableOption (lib.mdDoc "Enables Disko for disk & partition management.");
primaryDisk = lib.mkOption {
type = lib.types.attrs;
description = "The disk to format using Disko.";
default = {
name = "nvme0n1";
id = "";
};
};
enableTPM = lib.mkOption {
type = lib.types.bool;
description = "Enables TPM2 support.";
default = true;
};
swapFile = {
enable = lib.mkEnableOption (lib.mdDoc "Enables the creation of swap files.");
size = lib.mkOption {
type = lib.types.str;
description = "The size of the swap file to create (defaults to 8G, or 8 gigabytes).";
default = "8G";
};
};
};
};
config = lib.mkIf cfg.enable {
# Disk management
disko.enableConfig = false;
disko.devices = {
disk = {
main = {
type = "disk";
device = "/dev/disk/by-id/${cfg.primaryDisk.id}";
content = {
type = "gpt";
partitions = {
ESP = {
priority = 1;
name = "ESP";
label = "boot";
size = "1G";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
luks = {
size = "100%";
label = "nixos";
content = {
type = "luks";
name = "cryptroot";
settings = {
allowDiscards = true;
crypttabExtraOpts = lib.mkIf cfg.enableTPM [ "tpm2-device=auto" ];
};
content = {
type = "btrfs";
extraArgs = [ "-f" ]; # Override existing partitions.
# Unless otherwise specified, the subvolume name equals the mount name.
subvolumes = {
"/root" = {
mountpoint = "/";
mountOptions = standardMountOpts;
};
"/home" = {
mountOptions = standardMountOpts;
};
"/nix" = {
mountOptions = standardMountOpts;
};
"/swap" = lib.mkIf cfg.swapFile.enable {
mountpoint = "/.swap";
swap.swapfile.size = cfg.swapFile.size;
};
"/log" = {
mountpoint = "/var/log";
mountOptions = standardMountOpts;
};
};
};
};
};
};
};
};
};
};
};
}