diff --git a/flake.lock b/flake.lock index 79d9aab..6755d8e 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,25 @@ { "nodes": { + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1684003056, + "narHash": "sha256-zl11zyRNKzAW7YLvTkxmFjSBqxZbEvfwZqNCT91ELfU=", + "owner": "nix-community", + "repo": "disko", + "rev": "8f95856432e091e5ac56fea2df81e905ddd02d27", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -38,6 +58,7 @@ }, "root": { "inputs": { + "disko": "disko", "flake-parts": "flake-parts", "nixpkgs": "nixpkgs", "srvos": "srvos", diff --git a/flake.nix b/flake.nix index 1fbeb54..af87ea4 100644 --- a/flake.nix +++ b/flake.nix @@ -8,6 +8,9 @@ treefmt-nix.url = "github:numtide/treefmt-nix"; treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; + disko.url = "github:nix-community/disko"; + disko.inputs.nixpkgs.follows = "nixpkgs"; + srvos.url = "github:numtide/srvos"; # Use the version of nixpkgs that has been tested to work with SrvOS srvos.inputs.nixpkgs.follows = "nixpkgs"; diff --git a/modules/flake-module.nix b/modules/flake-module.nix index 5681a9a..53f09c3 100644 --- a/modules/flake-module.nix +++ b/modules/flake-module.nix @@ -3,6 +3,7 @@ hcloud.imports = [ inputs.srvos.nixosModules.server inputs.srvos.nixosModules.hardware-hetzner-cloud + ./single-disk.nix ]; nixos-wiki.imports = [ diff --git a/modules/single-disk.nix b/modules/single-disk.nix new file mode 100644 index 0000000..57c42d9 --- /dev/null +++ b/modules/single-disk.nix @@ -0,0 +1,51 @@ +{ self, ... }: +let + partitions = [ + { + name = "grub"; + end = "1M"; + part-type = "primary"; + flags = [ "bios_grub" ]; + } + { + name = "ESP"; + start = "1MiB"; + end = "500MiB"; + bootable = true; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + } + { + name = "root"; + start = "100MiB"; + end = "100%"; + part-type = "primary"; + bootable = true; + content = { + type = "filesystem"; + # We use xfs because it has support for compression and has a quite good performance for databases + format = "xfs"; + mountpoint = "/"; + }; + } + ]; +in +{ + imports = [ + self.inputs.disko.nixosModules.disko + ]; + disko.devices = { + disk.sda = { + type = "disk"; + device = "/dev/sda"; + content = { + type = "table"; + format = "gpt"; + inherit partitions; + }; + }; + }; +}