From 983b89a5f44e12ad87256bc4f34534853edd69f3 Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Wed, 29 Jan 2025 22:15:35 +0100 Subject: [PATCH] Add disko --- flake.lock | 21 ++++++++++++ flake.nix | 7 ++++ hosts/perso-desktop/configuration.nix | 14 ++------ hosts/perso-desktop/disko-config.nix | 33 +++++++++++++++++++ .../perso-desktop/hardware-configuration.nix | 11 ------- hosts/perso-laptop/configuration.nix | 1 + hosts/perso-laptop/disko-config.nix | 33 +++++++++++++++++++ hosts/perso-laptop/hardware-configuration.nix | 13 +------- 8 files changed, 98 insertions(+), 35 deletions(-) create mode 100644 hosts/perso-desktop/disko-config.nix create mode 100644 hosts/perso-laptop/disko-config.nix diff --git a/flake.lock b/flake.lock index 9880ba2..05158e3 100644 --- a/flake.lock +++ b/flake.lock @@ -64,6 +64,26 @@ "type": "github" } }, + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1738148035, + "narHash": "sha256-KYOATYEwaKysL3HdHdS5kbQMXvzS4iPJzJrML+3TKAo=", + "owner": "nix-community", + "repo": "disko", + "rev": "18d0a984cc2bc82cf61df19523a34ad463aa7f54", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, "doom-emacs": { "flake": false, "locked": { @@ -703,6 +723,7 @@ "root": { "inputs": { "agenix": "agenix", + "disko": "disko", "flake-utils": "flake-utils", "home-manager": "home-manager", "lanzaboote": "lanzaboote", diff --git a/flake.nix b/flake.nix index 763240f..ea10206 100644 --- a/flake.nix +++ b/flake.nix @@ -52,6 +52,11 @@ url = "github:nix-community/lanzaboote/v0.4.2"; inputs.nixpkgs.follows = "nixpkgs"; }; + + disko = { + url = "github:nix-community/disko"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = inputs@{ @@ -60,6 +65,7 @@ home-manager, agenix, lanzaboote, + disko, ... }: let @@ -93,6 +99,7 @@ home-manager.nixosModules.home-manager agenix.nixosModules.default lanzaboote.nixosModules.lanzaboote + disko.nixosModules.disko { nixpkgs.overlays = overlays; } { home-manager.useGlobalPkgs = true; diff --git a/hosts/perso-desktop/configuration.nix b/hosts/perso-desktop/configuration.nix index 69efd70..cc2c8ea 100644 --- a/hosts/perso-desktop/configuration.nix +++ b/hosts/perso-desktop/configuration.nix @@ -11,21 +11,11 @@ # Include the results of the hardware scan. ./hardware-configuration.nix + ./disko-config.nix ]; # Bootloader. - # For lanzaboote see https://github.com/nix-community/lanzaboote/blob/master/docs/QUICK_START.md - boot.loader.systemd-boot.enable = lib.mkForce false; - boot.lanzaboote = { - enable = true; - pkiBundle = "/var/lib/sbctl"; - }; - boot.loader.systemd-boot.windows = { - "11-pro" = { - title = "Windows 11 Pro"; - efiDeviceHandle = "HD1b"; - }; - }; + boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; # Limit the number of generations to keep diff --git a/hosts/perso-desktop/disko-config.nix b/hosts/perso-desktop/disko-config.nix new file mode 100644 index 0000000..798d854 --- /dev/null +++ b/hosts/perso-desktop/disko-config.nix @@ -0,0 +1,33 @@ +{ + disko.devices = { + disk = { + main = { + device = "/dev/nvme0n1"; + type = "disk"; + content = { + type = "gpt"; + partitions = { + ESP = { + type = "EF00"; + size = "500M"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0077" ]; + }; + }; + root = { + size = "100%"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + }; + }; + }; + }; + }; + }; + }; +} \ No newline at end of file diff --git a/hosts/perso-desktop/hardware-configuration.nix b/hosts/perso-desktop/hardware-configuration.nix index 017c436..4c179c5 100644 --- a/hosts/perso-desktop/hardware-configuration.nix +++ b/hosts/perso-desktop/hardware-configuration.nix @@ -13,17 +13,6 @@ boot.kernelModules = [ "kvm-amd" ]; boot.extraModulePackages = [ ]; - fileSystems."/" = - { device = "/dev/disk/by-uuid/b10668d4-6394-4e00-b6ec-54fe688484d2"; - fsType = "ext4"; - }; - - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/FACE-AC18"; - fsType = "vfat"; - options = [ "fmask=0077" "dmask=0077" ]; - }; - swapDevices = [ { device = "/var/lib/swapfile"; size = 8*1024; } ]; diff --git a/hosts/perso-laptop/configuration.nix b/hosts/perso-laptop/configuration.nix index d4420d8..e378ea1 100644 --- a/hosts/perso-laptop/configuration.nix +++ b/hosts/perso-laptop/configuration.nix @@ -11,6 +11,7 @@ # Include the results of the hardware scan. ./hardware-configuration.nix + ./disko-config.nix ]; # Bootloader. diff --git a/hosts/perso-laptop/disko-config.nix b/hosts/perso-laptop/disko-config.nix new file mode 100644 index 0000000..798d854 --- /dev/null +++ b/hosts/perso-laptop/disko-config.nix @@ -0,0 +1,33 @@ +{ + disko.devices = { + disk = { + main = { + device = "/dev/nvme0n1"; + type = "disk"; + content = { + type = "gpt"; + partitions = { + ESP = { + type = "EF00"; + size = "500M"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0077" ]; + }; + }; + root = { + size = "100%"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + }; + }; + }; + }; + }; + }; + }; +} \ No newline at end of file diff --git a/hosts/perso-laptop/hardware-configuration.nix b/hosts/perso-laptop/hardware-configuration.nix index a01b89e..2d315c4 100644 --- a/hosts/perso-laptop/hardware-configuration.nix +++ b/hosts/perso-laptop/hardware-configuration.nix @@ -13,19 +13,8 @@ boot.kernelModules = [ "kvm-intel" ]; boot.extraModulePackages = [ ]; - fileSystems."/" = - { device = "/dev/disk/by-uuid/e0c9f32c-0a05-4fec-a3d5-5507b9c0b3c2"; - fsType = "ext4"; - }; - - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/3F81-54F0"; - fsType = "vfat"; - options = [ "fmask=0077" "dmask=0077" ]; - }; - swapDevices = - [ { device = "/dev/disk/by-uuid/b0aedbe7-9ffe-4039-9151-4d64a13b133d"; } + [ { device = "/var/lib/swapfile"; size = 8*1024; } ]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking