Skip to content

Commit 1c0bf92

Browse files
committed
chore: move disko to each host directory
1 parent be78055 commit 1c0bf92

File tree

3 files changed

+69
-4
lines changed

3 files changed

+69
-4
lines changed

flake.nix

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88
url = "github:nix-community/home-manager/master";
99
inputs.nixpkgs.follows = "nixpkgs";
1010
};
11-
hyprland.url = "github:hyprwm/Hyprland";
11+
hyprland = {
12+
url = "github:hyprwm/Hyprland";
13+
inputs.nixpkgs.follows = "nixpkgs";
14+
};
15+
hyprland-plugins = {
16+
url = "github:hyprwm/hyprland-plugins";
17+
inputs.hyprland.follows = "hyprland";
18+
};
1219
disko.url = "github:nix-community/disko";
1320
stylix.url = "github:danth/stylix";
1421
font-flake.url = "github:redyf/font-flake";
@@ -42,7 +49,8 @@
4249
...
4350
}@inputs:
4451
let
45-
inherit (nixpkgs.lib) nixosSystem;
52+
lib = nixpkgs.lib;
53+
inherit (lib) nixosSystem;
4654
supportedSystems = [
4755
"x86_64-linux"
4856
"x86_64-darwin"
@@ -87,6 +95,10 @@
8795
./hosts/${hostname}/configuration.nix
8896
{ networking.hostName = hostname; }
8997
]
98+
++ lib.optionals (builtins.pathExists ./hosts/${hostname}/disko.nix) [
99+
disko.nixosModules.disko
100+
./hosts/${hostname}/disko.nix
101+
]
90102
++ modules;
91103
};
92104

@@ -130,7 +142,6 @@
130142
username = "redyf";
131143
hostname = "desktop";
132144
modules = [
133-
disko.nixosModules.disko
134145
hyprland.nixosModules.default
135146
stylix.nixosModules.stylix
136147
];
@@ -140,7 +151,6 @@
140151
username = "selene";
141152
hostname = "selene";
142153
modules = [
143-
disko.nixosModules.disko
144154
hyprland.nixosModules.default
145155
stylix.nixosModules.stylix
146156
];

hosts/selene/disko.nix

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# If you'd saved this configuration in ./disks/default.nix, and wanted to create a disk named /dev/nvme0n1, you would run the following command to partition, format and mount the disk.
2+
# sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko -- --mode disko ./disks/default.nix --arg device '"/dev/nvme0n1"'
3+
{
4+
lib,
5+
device ? throw "Set this to your disk device, e.g. /dev/sda",
6+
...
7+
}:
8+
{
9+
disko = {
10+
# Do not let Disko manage fileSystems.* config for NixOS.
11+
# Reason is that Disko mounts partitions by GPT partition names, which are
12+
# easily overwritten with tools like fdisk. When you fail to deploy a new
13+
# config in this case, the old config that comes with the disk image will
14+
# not boot either.
15+
enableConfig = true;
16+
devices = {
17+
disk.main = {
18+
type = "disk";
19+
device = "/dev/nvme0n1";
20+
content = {
21+
type = "gpt";
22+
partitions = {
23+
# Compared to MBR, GPT partition table doesn't reserve space for MBR
24+
# boot record. We need to reserve the first 1MB for MBR boot record,
25+
# so Grub can be installed here.
26+
boot = {
27+
name = "boot";
28+
size = "1M";
29+
type = "EF02";
30+
};
31+
esp = {
32+
name = "ESP";
33+
size = "1024M";
34+
type = "EF00";
35+
content = {
36+
type = "filesystem";
37+
format = "vfat";
38+
mountpoint = "/boot";
39+
};
40+
};
41+
root = {
42+
name = "root";
43+
size = "100%";
44+
content = {
45+
type = "filesystem";
46+
format = "ext4";
47+
mountpoint = "/";
48+
};
49+
};
50+
};
51+
};
52+
};
53+
};
54+
};
55+
}

0 commit comments

Comments
 (0)