commit 9b735df8711206d5610cf3e590d097a37c47febe
parent 57db548d1994905e83ac0a5852fbe40152fe073a
Author: maydayv7 <maydayv7@gmail.com>
Date: Sun, 28 Jun 2026 15:28:07 +0530
feat: Use `disko`
Diffstat:
21 files changed, 512 insertions(+), 317 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
@@ -2,6 +2,7 @@
### June
+- Use [`disko`](https://github.com/nix-community/disko) for declarative disk partitioning
- Disable keyless SSH Access
- Declaratively configure a Windows 11 VM
- Fix and document VFIO
diff --git a/README.md b/README.md
@@ -96,7 +96,8 @@ It also builds and deploys my website to [maydayv7.cc](https://maydayv7.cc).
- Automatically builds and deploys my [Website](./site)
- Credentials management using the [`sops-nix`](https://github.com/Mic92/sops-nix) module and [`gnupg`](https://gnupg.org/) keys
- Comprehensive User Configuration using the [`home-manager`](https://github.com/nix-community/home-manager) module
-- Ephemeral, Opt-In filesystem state using the [`impermanence`](https://github.com/nix-community/impermanence) module and [ZFS](https://zfsonlinux.org/)
+- Ephemeral, opt-in filesystem state using the [`impermanence`](https://github.com/nix-community/impermanence) module and [ZFS](https://zfsonlinux.org/)
+- Declarative disk partitioning and installation using [`disko`](https://github.com/nix-community/disko)
- Support for Secure Boot using [`lanzaboote`](https://github.com/nix-community/lanzaboote)
- Multiple development [`shells`](./shells) integrated with [`direnv`](https://direnv.net/) and [`lorri`](https://github.com/nix-community/lorri)
- Automatic `packages` updates using [`update.sh`](./packages/update.sh)
@@ -115,7 +116,7 @@ It also builds and deploys my website to [maydayv7.cc](https://maydayv7.cc).
| Shells | [`bash`](https://www.gnu.org/software/bash/), [`zsh`](https://www.zsh.org) |
| Terminal | [Ghostty](https://ghostty.org/), [Kitty](https://sw.kovidgoyal.net/kitty/) |
| Browser | [Firefox](https://www.mozilla.org/en-US/firefox/) |
-| Desktops | [GNOME](https://www.gnome.org), [Hyprland](https://hypr.land/) |
+| Desktops | [GNOME](https://www.gnome.org), [Hyprland](https://hypr.land/), [Niri](https://github.com/YaLTeR/niri) |
## Structure
@@ -269,7 +270,7 @@ To use my configuration as-is for a fresh NixOS installation, you can try the fo
_Replace_ **_PATH_** _with the path to the `secret`_
<pre><code>sops --config <i>/path/to/<b>secrets.yaml</b></i> -i <b><i>PATH</i></b></code></pre>
-6. Add device-specific configuration by creating a new file in [`modules/hosts`](./modules/hosts). Do keep in mind that the filesystems must be appropriately created and labeled as defined [here](./modules/system/filesystem.nix).
+6. Add device-specific configuration by creating a new file in [`modules/hosts`](./modules/hosts), setting its `system.fs` options. The disk layout is then handled by [`disko`](./modules/system/filesystem.nix), which expects the partitions to carry the `ESP`, `System` and `swap` labels.
7. Finally, run `nixos-rebuild switch --flake /etc/nixos#HOSTNAME` (as `root`) to switch to the configuration!
@@ -310,17 +311,18 @@ _Replace_ **_DEVICE_** _with the name of Device to build_
#### Partition Scheme
-_The `install` script handles partition creation and labeling, so it is recommended to create only the partition table and ensure sufficient free space_
+> [!WARNING]
+> The `install` script **erases the entire target disk** and creates the layout below automatically.
-| Name | Label | Format | Size (minimum) |
-| :------------- | :----: | :----: | :------------: |
-| BOOT Partition | ESP | vfat | 500M |
-| ROOT Partition | System | ZFS | 50G |
-| SWAP Area | swap | swap | 8G |
-| DATA Partition | Files | ZFS | 10G |
+| Partition | Label | Format | Size |
+| :--------- | :----: | :-------------------------------------------- | :------------------------------ |
+| EFI System | ESP | `vfat` | 1 GiB |
+| SWAP Area | swap | `swap` | `system.fs.swap` (8GiB default) |
+| System | System | `ext4` (`simple`) / ZFS `fspool` (`advanced`) | Remaining space |
> [!NOTE]
-> For the `advanced` filesystem scheme only
+> The layout is derived from the device's `system.fs.scheme`.
+> The `advanced` scheme additionally creates the encrypted `fspool` datasets - `system/root` (opt-in state), `system/nix`, `data` and `reserve`
#### Procedure
diff --git a/files/vscode/settings.json b/files/vscode/settings.json
@@ -59,6 +59,6 @@
"editor.defaultFormatter": "ms-python.black-formatter"
},
"[xml]": {
- "editor.defaultFormatter": "DotJoshJohnson.xml"
+ "editor.defaultFormatter": "redhat.vscode-xml"
}
}
diff --git a/flake.lock b/flake.lock
@@ -228,6 +228,27 @@
"type": "github"
}
},
+ "disko": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1768920986,
+ "narHash": "sha256-CNzzBsRhq7gg4BMBuTDObiWDH/rFYHEuDRVOwCcwXw4=",
+ "owner": "nix-community",
+ "repo": "disko",
+ "rev": "de5708739256238fb912c62f03988815db89ec9a",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-community",
+ "ref": "v1.13.0",
+ "repo": "disko",
+ "type": "github"
+ }
+ },
"filters": {
"locked": {
"lastModified": 1757882181,
@@ -1824,6 +1845,7 @@
"inputs": {
"boot": "boot",
"catppuccin": "catppuccin",
+ "disko": "disko",
"filters": "filters",
"flake-parts": "flake-parts",
"flatpak": "flatpak",
diff --git a/flake.nix b/flake.nix
@@ -116,6 +116,12 @@
inputs.nixpkgs.follows = "unstable";
};
+ # Declarative Disk Partitioning
+ disko = {
+ url = "github:nix-community/disko/v1.13.0";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+
# Filesystem State Handler
impermanence = {
url = "github:nix-community/impermanence";
diff --git a/modules/README.md b/modules/README.md
@@ -46,6 +46,7 @@ An overview of every configuration module in this repository.
| ---------- | ---- | ------------------------- |
| `gnome` | Both | GNOME desktop environment |
| `hyprland` | Both | Hyprland window manager |
+| `niri` | Both | Niri window manager |
### [`games`](./games)
@@ -158,6 +159,8 @@ The following are the custom configuration options exposed by the modules above:
- `scheme`: Supported Boot Firmware Scheme - `null / "mbr" / "efi" / "secure"`
- `fs` -
- `scheme`: Disk Filesystem Scheme - `null / "simple" / "advanced"`
+ - `swap`: Size of SWAP Partition - Ex. `"8G"`
+ - `disk`: Target Disk for Installation (Use `ls -l /dev/disk/by-id`) - Ex. `"/dev/disk/by-id/nvme-..."`
- `persist`: System Files to preserve across reboots (while using the `advanced` File System Layout)
- `nix` -
- `index`: Enable Package Indexer - `true / false`
diff --git a/modules/apps/notes.nix b/modules/apps/notes.nix
@@ -81,8 +81,8 @@ in {
{
pkg = pkgs.custom.obsidian-style-settings;
settings = lib.mkIf isWM {
- "catppuccin-theme-dark" = "ctp-macchiato";
- "catppuccin-theme-accents" = "ctp-accent-blue";
+ "catppuccin-theme-settings@@catppuccin-theme-dark" = "ctp-macchiato";
+ "catppuccin-theme-settings@@catppuccin-theme-accents" = "ctp-accent-blue";
};
}
];
diff --git a/modules/apps/vscode/_profile.nix b/modules/apps/vscode/_profile.nix
@@ -25,6 +25,13 @@ with files.vscode; {
(lib.mkIf isWM {
"terminal.external.linuxExec" = "kitty";
})
+ (let
+ lemminx = "${pkgs.lemminx}/bin/lemminx";
+ in {
+ "xml.server.preferBinary" = true;
+ "xml.server.binary.path" = lemminx;
+ "xml.server.binary.trustedHashes" = [(builtins.hashFile "sha256" lemminx)];
+ })
];
## Editor Extensions
diff --git a/modules/hosts/futura.nix b/modules/hosts/futura.nix
@@ -50,7 +50,10 @@ in {
system = {
kernel = "lts";
scheme = "efi";
- fs.scheme = "simple";
+ fs = {
+ scheme = "simple";
+ disk = "/dev/disk/by-id/disko-placeholder";
+ };
};
hardware.cpu = {
diff --git a/modules/hosts/valkyrie/_asus/asusd.ron b/modules/hosts/valkyrie/_asus/asusd.ron
@@ -1,15 +1,24 @@
(
- boot_sound: false,
- change_throttle_policy_on_ac: true,
- change_throttle_policy_on_battery: true,
- charge_control_end_threshold: 95,
- disable_nvidia_powerd_on_battery: true,
- mini_led_mode: false,
- panel_od: false,
- throttle_balanced_epp: BalancePower,
- throttle_performance_epp: Performance,
- throttle_policy_linked_epp: true,
- throttle_policy_on_ac: Performance,
- throttle_policy_on_battery: Quiet,
- throttle_quiet_epp: Power,
+ charge_control_end_threshold: 95,
+ base_charge_control_end_threshold: 95,
+ disable_nvidia_powerd_on_battery: true,
+ ac_command: "",
+ bat_command: "",
+ platform_profile_linked_epp: true,
+ platform_profile_on_battery: Quiet,
+ change_platform_profile_on_battery: true,
+ platform_profile_on_ac: Performance,
+ change_platform_profile_on_ac: true,
+ profile_quiet_epp: Power,
+ profile_balanced_epp: BalancePower,
+ profile_custom_epp: Performance,
+ profile_performance_epp: Performance,
+ ac_profile_tunings: {},
+ dc_profile_tunings: {
+ Quiet: (
+ enabled: false,
+ group: {},
+ ),
+ },
+ armoury_settings: {},
)
\ No newline at end of file
diff --git a/modules/hosts/valkyrie/_asus/aura.ron b/modules/hosts/valkyrie/_asus/aura.ron
@@ -1,99 +1,99 @@
(
- config_name: "Keyboard Aura",
- brightness: Med,
- current_mode: Static,
- builtins: {
- Static: (
- mode: Static,
- zone: None,
- colour1: (
- r: 255,
- g: 255,
- b: 255,
- ),
- colour2: (
- r: 0,
- g: 0,
- b: 0,
- ),
- speed: Med,
- direction: Right,
+ config_name: "aura_19b6.ron",
+ brightness: Low,
+ current_mode: Static,
+ builtins: {
+ Static: (
+ mode: Static,
+ zone: r#None,
+ colour1: (
+ r: 30,
+ g: 120,
+ b: 228,
+ ),
+ colour2: (
+ r: 0,
+ g: 0,
+ b: 0,
+ ),
+ speed: Med,
+ direction: Right,
+ ),
+ Breathe: (
+ mode: Breathe,
+ zone: r#None,
+ colour1: (
+ r: 166,
+ g: 0,
+ b: 0,
+ ),
+ colour2: (
+ r: 0,
+ g: 0,
+ b: 0,
+ ),
+ speed: Med,
+ direction: Right,
+ ),
+ RainbowCycle: (
+ mode: RainbowCycle,
+ zone: r#None,
+ colour1: (
+ r: 166,
+ g: 0,
+ b: 0,
+ ),
+ colour2: (
+ r: 0,
+ g: 0,
+ b: 0,
+ ),
+ speed: Med,
+ direction: Right,
+ ),
+ RainbowWave: (
+ mode: RainbowWave,
+ zone: r#None,
+ colour1: (
+ r: 166,
+ g: 0,
+ b: 0,
+ ),
+ colour2: (
+ r: 0,
+ g: 0,
+ b: 0,
+ ),
+ speed: Med,
+ direction: Right,
+ ),
+ Pulse: (
+ mode: Pulse,
+ zone: r#None,
+ colour1: (
+ r: 166,
+ g: 0,
+ b: 0,
+ ),
+ colour2: (
+ r: 0,
+ g: 0,
+ b: 0,
+ ),
+ speed: Med,
+ direction: Right,
+ ),
+ },
+ multizone_on: false,
+ enabled: (
+ states: [
+ (
+ zone: Keyboard,
+ boot: true,
+ awake: true,
+ sleep: false,
+ shutdown: false,
+ ),
+ ],
),
- Breathe: (
- mode: Breathe,
- zone: None,
- colour1: (
- r: 255,
- g: 255,
- b: 255,
- ),
- colour2: (
- r: 0,
- g: 0,
- b: 0,
- ),
- speed: Med,
- direction: Right,
- ),
- RainbowCycle: (
- mode: RainbowCycle,
- zone: None,
- colour1: (
- r: 255,
- g: 255,
- b: 255,
- ),
- colour2: (
- r: 0,
- g: 0,
- b: 0,
- ),
- speed: Med,
- direction: Right,
- ),
- RainbowWave: (
- mode: RainbowWave,
- zone: None,
- colour1: (
- r: 255,
- g: 255,
- b: 255,
- ),
- colour2: (
- r: 0,
- g: 0,
- b: 0,
- ),
- speed: Med,
- direction: Right,
- ),
- Pulse: (
- mode: Pulse,
- zone: None,
- colour1: (
- r: 255,
- g: 255,
- b: 255,
- ),
- colour2: (
- r: 0,
- g: 0,
- b: 0,
- ),
- speed: Med,
- direction: Right,
- ),
- },
- multizone_on: false,
- enabled: (
- states: [
- (
- zone: Keyboard,
- boot: true,
- awake: true,
- sleep: false,
- shutdown: false,
- ),
- ],
- ),
-)
+)
+\ No newline at end of file
diff --git a/modules/hosts/valkyrie/_asus/default.nix b/modules/hosts/valkyrie/_asus/default.nix
@@ -28,6 +28,7 @@ _: {
enable = true;
asusdConfig.text = builtins.readFile ./asusd.ron;
auraConfigs."19b6".text = builtins.readFile ./aura.ron;
+ fanCurvesConfig.text = builtins.readFile ./fan_curves.ron;
};
};
};
diff --git a/modules/hosts/valkyrie/_asus/fan_curves.ron b/modules/hosts/valkyrie/_asus/fan_curves.ron
@@ -0,0 +1,47 @@
+(
+ profiles: (
+ balanced: [
+ (
+ fan: CPU,
+ pwm: (2, 33, 76, 81, 112, 130, 150, 255),
+ temp: (50, 55, 60, 64, 74, 78, 82, 97),
+ enabled: false,
+ ),
+ (
+ fan: GPU,
+ pwm: (2, 28, 45, 81, 107, 130, 150, 232),
+ temp: (50, 55, 60, 64, 74, 78, 82, 97),
+ enabled: false,
+ ),
+ ],
+ performance: [
+ (
+ fan: CPU,
+ pwm: (33, 81, 112, 130, 150, 188, 229, 255),
+ temp: (41, 56, 61, 66, 71, 76, 80, 97),
+ enabled: false,
+ ),
+ (
+ fan: GPU,
+ pwm: (28, 81, 107, 130, 150, 186, 237, 237),
+ temp: (41, 56, 61, 66, 71, 76, 80, 97),
+ enabled: false,
+ ),
+ ],
+ quiet: [
+ (
+ fan: CPU,
+ pwm: (2, 33, 45, 81, 81, 81, 130, 255),
+ temp: (64, 68, 72, 76, 76, 76, 95, 97),
+ enabled: false,
+ ),
+ (
+ fan: GPU,
+ pwm: (2, 28, 40, 81, 81, 81, 130, 232),
+ temp: (64, 68, 72, 76, 76, 76, 95, 97),
+ enabled: false,
+ ),
+ ],
+ custom: [],
+ ),
+)
+\ No newline at end of file
diff --git a/modules/hosts/valkyrie/_vm/default.nix b/modules/hosts/valkyrie/_vm/default.nix
@@ -3,15 +3,43 @@
{inputs}: {
nixos = {pkgs, ...}: {
imports = [inputs.nixvirt.nixosModules.default];
+
+ disko.devices.zpool.fspool.datasets = {
+ "vm" = {
+ type = "zfs_fs";
+ options = {
+ canmount = "off";
+ mountpoint = "none";
+ };
+ };
+ "vm/windows" = {
+ type = "zfs_volume";
+ size = "128G";
+ options = {
+ volblocksize = "16k";
+ refreservation = "none";
+ };
+ };
+ };
+
virtualisation.libvirt = {
enable = true;
package = pkgs.libvirt;
- connections."qemu:///system".domains = [
- {
- definition = ./windows.xml;
- active = null;
- }
- ];
+ connections."qemu:///system" = {
+ networks = [
+ {
+ definition = ./default.xml;
+ active = true;
+ }
+ ];
+
+ domains = [
+ {
+ definition = ./windows.xml;
+ active = null;
+ }
+ ];
+ };
};
};
}
diff --git a/modules/hosts/valkyrie/_vm/default.xml b/modules/hosts/valkyrie/_vm/default.xml
@@ -0,0 +1,11 @@
+<network>
+ <name>default</name>
+ <uuid>58cbf612-f961-4b33-a3f4-127b1e562eaf</uuid>
+ <forward mode='nat'/>
+ <bridge name='virbr0' stp='on' delay='0'/>
+ <ip address='192.168.122.1' netmask='255.255.255.0'>
+ <dhcp>
+ <range start='192.168.122.2' end='192.168.122.254'/>
+ </dhcp>
+ </ip>
+</network>
diff --git a/modules/hosts/valkyrie/default.nix b/modules/hosts/valkyrie/default.nix
@@ -82,7 +82,10 @@ in {
system = {
scheme = "secure";
- fs.scheme = "advanced";
+ fs = {
+ scheme = "advanced";
+ disk = "/dev/disk/by-id/nvme-eui.00000000000000000026b7686ab56005";
+ };
# Kernel
kernel = "zen";
diff --git a/modules/hosts/vortex.nix b/modules/hosts/vortex.nix
@@ -58,7 +58,11 @@ in {
system = {
scheme = "secure";
- fs.scheme = "advanced";
+ fs = {
+ scheme = "advanced";
+ disk = "/dev/disk/by-id/disko-placeholder";
+ };
+
kernel = "xanmod";
kernelModules = [
"nvme"
diff --git a/modules/system/filesystem.nix b/modules/system/filesystem.nix
@@ -27,9 +27,10 @@ in {
types
;
inherit (builtins) listToAttrs map;
- inherit (config.system.fs) scheme;
+ cfg = config.system.fs;
in {
imports = [
+ inputs.disko.nixosModules.disko
inputs.impermanence.nixosModule
(
mkAliasOptionModule
@@ -51,19 +52,35 @@ in {
)
];
- options.system.fs.scheme = mkOption {
- description = "Disk Filesystem Scheme";
- type = with types;
- nullOr (enum [
- "simple"
- "advanced"
- ]);
- default = null;
+ options.system.fs = {
+ scheme = mkOption {
+ description = "Disk Filesystem Scheme";
+ type = with types;
+ nullOr (enum [
+ "simple"
+ "advanced"
+ ]);
+ default = null;
+ };
+
+ disk = mkOption {
+ description = "Target Disk for Installation";
+ type = types.str;
+ default = "/dev/disk/by-id/disko-placeholder";
+ example = "/dev/disk/by-id/nvme-eui.0123456789abcdef";
+ };
+
+ swap = mkOption {
+ description = "Size of SWAP Partition";
+ type = types.str;
+ default = "8G";
+ example = "16G";
+ };
};
config = mkMerge [
{
- warnings = optional (scheme == null) "Disk Filesystem Scheme is unset";
+ warnings = optional (cfg.scheme == null) "Disk Filesystem Scheme is unset";
boot = {
supportedFilesystems = {
ntfs = true;
@@ -72,25 +89,129 @@ in {
};
zfs.forceImportRoot = false;
};
- }
- ## Common Partitions
- (mkIf (scheme != null) {
- programs.fuse.userAllowOther = true;
+ environment.persist.enable = mkDefault false;
+ system.fs.persist.enable = mkDefault false;
- # EFI System Partition
- fileSystems."/boot" = {
- device = "/dev/disk/by-partlabel/ESP";
- fsType = "vfat";
- };
+ ## Disk Layout
+ disko.devices = mkMerge [
+ (mkIf (cfg.scheme != null) {
+ disk.main = {
+ type = "disk";
+ device = cfg.disk;
+ content = {
+ type = "gpt";
+ partitions = {
+ # EFI System Partition
+ ESP = {
+ label = "ESP";
+ type = "EF00";
+ size = "1024M";
+ content = {
+ type = "filesystem";
+ format = "vfat";
+ mountpoint = "/boot";
+ mountOptions = ["umask=0077"];
+ };
+ };
+
+ # SWAP Partition
+ swap = {
+ label = "swap";
+ size = cfg.swap;
+ content = {
+ type = "swap";
+ resumeDevice = true;
+ };
+ };
+
+ # System Partition
+ System = {
+ label = "System";
+ size = "100%";
+ content =
+ if cfg.scheme == "advanced"
+ then {
+ type = "zfs";
+ pool = "fspool";
+ }
+ else {
+ type = "filesystem";
+ format = "ext4";
+ mountpoint = "/";
+ };
+ };
+ };
+ };
+ };
+ })
+
+ (mkIf (cfg.scheme == "advanced") {
+ zpool.fspool = {
+ type = "zpool";
+ options.cachefile = "none";
+ rootFsOptions = {
+ compression = "zstd";
+ encryption = "on";
+ keyformat = "passphrase";
+ keylocation = "prompt";
+ mountpoint = "none";
+ xattr = "sa";
+ acltype = "posixacl";
+ };
+
+ datasets = {
+ # ROOT Dataset
+ "system/root" = {
+ type = "zfs_fs";
+ mountpoint = "/";
+ options.mountpoint = "legacy";
+ postCreateHook = "zfs snapshot fspool/system/root@blank";
+ };
+
+ # NIX Store Dataset
+ "system/nix" = {
+ type = "zfs_fs";
+ mountpoint = "/nix";
+ options = {
+ mountpoint = "legacy";
+ atime = "off";
+ };
+ };
- # SWAP Partition
- swapDevices = [{device = "/dev/disk/by-partlabel/swap";}];
- boot.kernel.sysctl."vm.swappiness" = 1;
+ # Persisted Dataset
+ "data" = {
+ type = "zfs_fs";
+ mountpoint = files.path.data;
+ options = {
+ mountpoint = "legacy";
+ "com.sun:auto-snapshot" = "true";
+ };
+ };
+
+ # Reserved space
+ # ? # Free with 'zfs set refreservation=none fspool/reserve'
+ "reserve" = {
+ type = "zfs_fs";
+ options = {
+ canmount = "off";
+ mountpoint = "none";
+ refreservation = "1G";
+ };
+ };
+ };
+ };
+ })
+ ];
+ }
+
+ (mkIf (cfg.scheme != null) {
+ programs.fuse.userAllowOther = true;
+ boot.kernel.sysctl."vm.swappiness" = 1; # SWAP Behaviour
system.activationScripts.dotfiles = with files.path; let
path =
- if scheme == "advanced"
+ if cfg.scheme == "advanced"
then "${persist}/"
else "";
dir = "${path}${system}";
@@ -100,22 +221,8 @@ in {
'';
})
- ## Simple File System Configuration using EXT4 ##
- (mkIf (scheme == "simple") {
- # ROOT Partition
- fileSystems."/" = {
- device = "/dev/disk/by-partlabel/System";
- fsType = "ext4";
- };
- })
-
- {
- environment.persist.enable = mkDefault false;
- system.fs.persist.enable = mkDefault false;
- }
-
## Advanced File System Configuration using ZFS ##
- (mkIf (scheme == "advanced") (
+ (mkIf (cfg.scheme == "advanced") (
let
rollback = ''
zfs rollback -r fspool/system/root@blank && echo "Rollback Complete!"
@@ -123,22 +230,7 @@ in {
in {
fileSystems =
{
- # ROOT Partition
- "/" = {
- device = "fspool/system/root";
- fsType = "zfs";
- };
- # NIX Partition
- "/nix" = {
- device = "fspool/system/nix";
- fsType = "zfs";
- };
- # PERSISTENT Partition
- "${files.path.data}" = {
- device = "fspool/data";
- fsType = "zfs";
- neededForBoot = true;
- };
+ "${files.path.data}".neededForBoot = true;
}
// filterAttrs (name: _: hasPrefix "/etc" name) (
listToAttrs (
@@ -157,12 +249,10 @@ in {
# Early Boot Requirements
boot = {
- resumeDevice = "/dev/disk/by-partlabel/swap";
# Boot Settings
kernelParams = ["elevator=none"];
zfs = {
forceImportAll = false;
- unsafeAllowHibernation = true;
devNodes = "/dev/disk/by-partlabel/System";
};
diff --git a/packages/_module.nix b/packages/_module.nix
@@ -36,6 +36,7 @@ in {
config = nixpkgsConfig;
};
+ disko = disko.packages."${system}";
spicetify = spicetify.legacyPackages."${system}";
hyprworld = hyprland.packages."${system}" // hyprsplit.packages."${system}" // hyprcursors.packages."${system}";
})
diff --git a/scripts/install.nix b/scripts/install.nix
@@ -6,90 +6,6 @@
}:
with files.path; let
inherit (lib) licenses recursiveUpdate;
-
- # File System Operations
- partitions = ''
- partition_disk() {
- read -rp "Enter Path to Disk: /dev/" DISK
- if [ -z "$DISK" ]
- then
- error "Path to Disk cannot be empty. If unsure, use the command 'fdisk -l'"
- fi
-
- echo "Deleting Partitions..."
- dd if=/dev/zero of=/dev/"$DISK" bs=512 count=1
- if [[ "$DISK" == nvme* ]]
- then
- parted /dev/"$DISK" --script mklabel gpt
- else
- parted /dev/"$DISK" --script mklabel msdos
- fi
-
- echo "Creating Partitions..."
- parted /dev/"$DISK" -- mkpart ESP fat32 1MiB 1024MiB
- parted /dev/"$DISK" -- set 1 esp on
- parted /dev/"$DISK" -- name 1 ESP
- mkfs.fat -F 32 /dev/disk/by-partlabel/ESP
-
- parted /dev/"$DISK" -- mkpart primary 1025MiB -8GiB
- parted /dev/"$DISK" -- name 2 System
-
- parted /dev/"$DISK" -- mkpart primary linux-swap -8GiB 100%
- parted /dev/"$DISK" -- name 3 swap
- mkswap /dev/disk/by-partlabel/swap
-
- mkdir -p /mnt
- }
-
- create_ext4() {
- echo "Creating 'EXT4' Partition..."
- mkfs.ext4 /dev/disk/by-partlabel/System
- }
-
- mount_ext4() {
- echo "Mounting 'EXT4' Partition..."
- mount /dev/disk/by-partlabel/System /mnt
- }
-
- create_zfs() {
- echo "Creating 'ZFS' Volumes..."
- read -rp "Enter Password for Pool Encryption: " PASS
- echo "$PASS" | zpool create -f fspool -O compression=zstd -O encryption=on -O keyformat=passphrase /dev/disk/by-partlabel/System
-
- zfs create -p -o mountpoint=legacy -o xattr=sa -o acltype=posixacl fspool/system/root
- zfs snapshot fspool/system/root@blank
- zfs create -o mountpoint=legacy -o atime=off fspool/system/nix
-
- zfs create -p -o mountpoint=legacy -o xattr=sa -o acltype=posixacl -o com.sun:auto-snapshot=true fspool/data
-
- # Use 'zfs set refreservation=none fspool/reserve' to free space
- zfs create -o canmount=off -o refreservation=1G fspool/reserve
- }
-
- mount_zfs() {
- echo "Mounting 'ZFS' Volumes..."
- zpool import -f fspool
- mount -t zfs fspool/system/root /mnt
- mkdir -p /mnt/{nix,data}
- mount -t zfs fspool/system/nix /mnt/nix
- mkdir -p /mnt${persist}
- mount -t zfs fspool/data /mnt${data}
- }
-
- mount_other() {
- echo "Mounting Other Partitions..."
- mkdir -p /mnt/boot
- mount -t vfat /dev/disk/by-partlabel/ESP /mnt/boot
- swapoff --all
- swapon /dev/disk/by-partlabel/swap
- }
-
- unmount_all () {
- echo "Unmounting All Partitions..."
- umount -l /mnt
- zpool export fspool
- }
- '';
in
recursiveUpdate
{
@@ -106,20 +22,41 @@ in
name = "os-install";
runtimeInputs = with pkgs; [
coreutils
- dosfstools
+ disko.disko
git
- gparted
+ gptfdisk
+ netcat
nixFlakes
- ntfs3g
- parted
+ nixos-install-tools
util-linux
zfs
];
text = ''
- set +eu
+ set -euo pipefail
${files.scripts.commands}
- ${partitions}
+
+ TRIES=5
+
+ cleanup() {
+ umount -R /mnt 2> /dev/null || true
+ zpool export fspool 2> /dev/null || true
+ }
+
+ install_system() {
+ local attempt=0
+ while [ "$attempt" -lt "$TRIES" ]
+ do
+ attempt=$((attempt + 1))
+ if nixos-install --no-root-passwd --root /mnt --flake "$URL#$HOST"
+ then
+ return 0
+ fi
+ newline
+ info "Couldn't finish installation (attempt $attempt/$TRIES)"
+ done
+ return 1
+ }
internet
if [ "$EUID" -ne 0 ]
@@ -127,56 +64,74 @@ in
error "This Command must be Executed as 'root'"
fi
- warn "Disk will be Completely Wiped for Automatic Partitioning"
- read -rp "Do you want to Automatically Create the Partitions? (Y/*): " choice
- case $choice in
- [Yy]*) partition_disk;;
- *) warn "You must Create, Format and Label the Partitions on your own"; gparted &> /dev/null;;
- esac
- newline
- read -rp "Select Filesystem to use for Disk (simple/advanced): " choice
- case $choice in
- 1|[Ss]*)
- read -rp "Do you want to Create and Format the EXT4 Partitions? (Y/*): " choice
- case $choice in
- [Yy]*) create_ext4; mount_ext4;;
- *) warn "Assuming that Required EXT4 Partition has already been Created"; mount_ext4;;
- esac
- ;;
- 2|[Aa]*)
- read -rp "Do you want to Create the ZFS Pool and Datasets? (Y/*): " choice
- case $choice in
- [Yy]*) create_zfs; mount_zfs;;
- *) warn "Assuming that Required ZFS Pool and Datasets have already been Created"; mount_zfs;;
- esac
- ;;
- *) error "Choose (1)simple or (2)advanced";;
- esac
- newline
-
- mount_other
- systemd-machine-id-setup --root=/mnt
- newline
-
+ # Target Device and Repository
read -rp "Enter Name of Device to Install: " HOST
+ if [ -z "$HOST" ]
+ then
+ error "Device name cannot be empty"
+ fi
+
read -rp "Enter Path to Repository (path/URL): " URL
if [ -z "$URL" ]
then
URL=${flake}
fi
- echo "Installing System from '$URL'..."
- until nixos-install --no-root-passwd --root /mnt --flake "$URL"#"$HOST"
+
+ # Target Disk
+ echo "Resolving target disk for '$HOST'..."
+ if ! DISK=$(nix eval --raw "$URL#nixosConfigurations.$HOST.config.system.fs.disk" 2> /dev/null)
+ then
+ error "Couldn't resolve 'system.fs.disk' for '$HOST'"
+ fi
+ if [ ! -b "$DISK" ]
+ then
+ error "'$DISK' is not a valid block device" "Set 'system.fs.disk' for '$HOST' to this device's disk"
+ fi
+
+ # Confirm Destructive Wipe
+ warn "ALL DATA on '$DISK' will be PERMANENTLY ERASED for Automatic Partitioning"
+ read -rp "Type the Disk path to confirm: " CONFIRM
+ if [ "$CONFIRM" != "$DISK" ]
+ then
+ error "Confirmation did not match '$DISK', aborting"
+ fi
+
+ # Wipe Stale Signatures
+ echo "Wiping existing signatures on '$DISK'..."
+ swapoff --all 2> /dev/null || true
+ zpool labelclear -f "$DISK" 2> /dev/null || true
+ for part in "$DISK"*
do
- newline
- info "Couldn't finish installation. Trying again..."
+ if [ -b "$part" ]
+ then
+ zpool labelclear -f "$part" 2> /dev/null || true
+ fi
done
+ wipefs --all --force "$DISK" 2> /dev/null || true
+ sgdisk --zap-all "$DISK" 2> /dev/null || true
+ newline
+
+ # Partition, Format and Mount Target
+ echo "Partitioning and formatting '$DISK'..."
+ disko --mode destroy,format,mount --flake "$URL#$HOST"
newline
- unmount_all
+ # Install
+ echo "Installing System '$HOST' from '$URL' onto '$DISK'..."
+ newline
+ until install_system
+ do
+ read -rp "Installation failed after $TRIES attempts. Try again? (Y/*): " choice
+ case $choice in
+ [Yy]*) newline; info "Retrying installation...";;
+ *) cleanup; error "Installation cancelled by user";;
+ esac
+ done
newline
+ cleanup
info "Run 'nixos setup' after rebooting to finish the install"
- info "Select the (Recovery) boot menu option and run the above script as the 'recovery' user"
+ info "Select the (recovery) boot menu option and run the above script as the 'recovery' user"
restart
'';
}
diff --git a/site/static/js/katex.js b/site/static/js/katex.js
@@ -9613,7 +9613,7 @@
? ((this.tokenRegex.lastIndex = t.length),
this.settings.reportNonstrict(
"commentAtEnd",
- "% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)",
+ "% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (Eg. $)",
))
: (this.tokenRegex.lastIndex = s + 1),
this.lex()