From 6d0dd33ff1aff5f13207df67f25ad3c349b98c6f Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 28 Jul 2023 16:37:10 +0200 Subject: [PATCH] install-iso: use disko.makeDiskImage --- flake-parts/packages.nix | 3 ++- flake.lock | 21 +++++++++++++++++++ flake.nix | 2 ++ modules/installer.nix | 44 ++++++++++++++++++++++++++++++++++++++-- 4 files changed, 67 insertions(+), 3 deletions(-) diff --git a/flake-parts/packages.nix b/flake-parts/packages.nix index 7b6c70af..c379078e 100644 --- a/flake-parts/packages.nix +++ b/flake-parts/packages.nix @@ -6,11 +6,12 @@ modules = [ self.nixosModules.installer self.inputs.nixos-generators.nixosModules.all-formats + self.inputs.disko.nixosModules.disko ]; }; in { - install-iso = installer.config.formats.install-iso; + install-iso = self.inputs.disko.lib.lib.makeDiskImage { nixosConfig = installer; }; install-vm-nogui = installer.config.formats.vm-nogui; install-vm = installer.config.formats.vm; }; diff --git a/flake.lock b/flake.lock index d230d18a..23167f53 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,25 @@ { "nodes": { + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1690548222, + "narHash": "sha256-EcVjLOpbAuL/y55fLlEl3BNM4FP5Pwtp+6DbTiL6FDM=", + "owner": "nix-community", + "repo": "disko", + "rev": "43f17a8b31c49f6696b8b258d317161afdc7e36b", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -74,6 +94,7 @@ }, "root": { "inputs": { + "disko": "disko", "flake-parts": "flake-parts", "nixos-generators": "nixos-generators", "nixpkgs": "nixpkgs", diff --git a/flake.nix b/flake.nix index 2644215f..9e9f9057 100644 --- a/flake.nix +++ b/flake.nix @@ -3,6 +3,8 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + disko.url = "github:nix-community/disko"; + disko.inputs.nixpkgs.follows = "nixpkgs"; nixos-generators.url = "github:nix-community/nixos-generators"; nixos-generators.inputs.nixpkgs.follows = "nixpkgs"; flake-parts.url = "github:hercules-ci/flake-parts"; diff --git a/modules/installer.nix b/modules/installer.nix index b1aa8154..e691c8ed 100644 --- a/modules/installer.nix +++ b/modules/installer.nix @@ -1,10 +1,16 @@ { lib , pkgs +, modulesPath , ... }: { systemd.tmpfiles.rules = [ "d /var/shared 0777 root root - -" ]; + imports = [ + (modulesPath + "/profiles/installation-device.nix") + (modulesPath + "/profiles/all-hardware.nix") + (modulesPath + "/profiles/base.nix") + ]; services.openssh.settings.PermitRootLogin = "yes"; system.activationScripts.root-password = '' mkdir -p /var/shared @@ -34,7 +40,41 @@ cat /var/shared/qrcode.utf8 fi ''; - formatConfigs.install-iso = { - isoImage.squashfsCompression = "zstd -Xcompression-level 1"; + boot.loader.grub.efiInstallAsRemovable = true; + boot.loader.grub.efiSupport = true; + disko.devices = { + disk = { + stick = { + type = "disk"; + device = "/vda"; + imageSize = "3G"; + content = { + type = "gpt"; + partitions = { + boot = { + size = "1M"; + type = "EF02"; # for grub MBR + }; + ESP = { + size = "100M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + }; + root = { + size = "100%"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + }; + }; + }; + }; + }; + }; }; }