From 507a138cde1a2afe309b0be3c8e9f13087adbc39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Jane=C5=BEi=C4=8D?= Date: Sat, 21 Feb 2026 02:05:30 +0100 Subject: [PATCH] feat: use nixos-rebuild build-image instead of nixosGenerators --- flake.lock | 37 -------------------------------- flake.nix | 20 +++++------------ hosts/live-iso/configuration.nix | 16 ++++++++------ justfile | 2 +- lib/mkHost.nix | 9 ++++---- 5 files changed, 20 insertions(+), 64 deletions(-) diff --git a/flake.lock b/flake.lock index c4c28fe..3ff9356 100644 --- a/flake.lock +++ b/flake.lock @@ -329,42 +329,6 @@ "type": "github" } }, - "nixlib": { - "locked": { - "lastModified": 1736643958, - "narHash": "sha256-tmpqTSWVRJVhpvfSN9KXBvKEXplrwKnSZNAoNPf/S/s=", - "owner": "nix-community", - "repo": "nixpkgs.lib", - "rev": "1418bc28a52126761c02dd3d89b2d8ca0f521181", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nixpkgs.lib", - "type": "github" - } - }, - "nixos-generators": { - "inputs": { - "nixlib": "nixlib", - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1769813415, - "narHash": "sha256-nnVmNNKBi1YiBNPhKclNYDORoHkuKipoz7EtVnXO50A=", - "owner": "nix-community", - "repo": "nixos-generators", - "rev": "8946737ff703382fda7623b9fab071d037e897d5", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nixos-generators", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1771207753, @@ -484,7 +448,6 @@ "home-manager": "home-manager", "lanzaboote": "lanzaboote", "neovim-nightly-overlay": "neovim-nightly-overlay", - "nixos-generators": "nixos-generators", "nixpkgs": "nixpkgs_2", "nixpkgs-master": "nixpkgs-master", "nixpkgs-unstable": "nixpkgs-unstable", diff --git a/flake.nix b/flake.nix index 89ee80c..d11c634 100644 --- a/flake.nix +++ b/flake.nix @@ -17,11 +17,6 @@ flake-utils.url = "github:numtide/flake-utils"; - nixos-generators = { - url = "github:nix-community/nixos-generators"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - home-manager = { url = "github:nix-community/home-manager/release-25.11"; inputs.nixpkgs.follows = "nixpkgs"; @@ -51,7 +46,6 @@ inputs@{ nixpkgs, flake-utils, - nixos-generators, ... }: @@ -73,15 +67,6 @@ { lib = my-lib; - # nix build .#iso - # dd bs=4M if=result/iso/my-nixos-live.iso of=/dev/sdX status=progress oflag=sync - live-iso = nixos-generators.nixosGenerate { - system = "x86_64-linux"; - format = "install-iso"; - specialArgs = { inherit inputs; }; - modules = [ ./hosts/live-iso/configuration.nix ]; - }; - nixosConfigurations = { matej-nixos = mkHost "matej-nixos" { system = "x86_64-linux"; @@ -92,6 +77,11 @@ users = [ "matej" ]; }; + # nixos-rebuild build-image --image-variant install-iso --flake .#live-iso + live-iso = mkHost "live-iso" { + system = "x86_64-linux"; + users = [ ]; + }; }; nixosModules = import ./modules/nixos { diff --git a/hosts/live-iso/configuration.nix b/hosts/live-iso/configuration.nix index fffecce..c8fe496 100644 --- a/hosts/live-iso/configuration.nix +++ b/hosts/live-iso/configuration.nix @@ -1,7 +1,14 @@ { pkgs, lib, ... }: { - # Use zstd instead of xz for compressing the liveUSB image, it's 6x faster and 15% bigger. - isoImage.squashfsCompression = "zstd -Xcompression-level 6"; + image.modules.iso-installer = { + isoImage.squashfsCompression = "zstd -Xcompression-level 6"; + }; + + fileSystems."/" = lib.mkDefault { + device = "/dev/disk/by-label/nixos"; + fsType = "ext4"; + }; + boot.loader.grub.device = lib.mkDefault "/dev/sda"; services.openssh = { enable = true; @@ -14,10 +21,7 @@ }; }; - networking = { - useDHCP = true; - firewall.allowedTCPPorts = [ 22 ]; - }; + networking.firewall.allowedTCPPorts = [ 22 ]; users = { groups.matej = { diff --git a/justfile b/justfile index d180820..c1909ef 100644 --- a/justfile +++ b/justfile @@ -19,7 +19,7 @@ bump: update switch # build installation iso iso: - nix build .#live-iso + nixos-rebuild build-image --image-variant iso-installer --flake .#live-iso # garbage collect old generations clean: diff --git a/lib/mkHost.nix b/lib/mkHost.nix index b17168d..efd2078 100644 --- a/lib/mkHost.nix +++ b/lib/mkHost.nix @@ -13,25 +13,25 @@ name: let hostConfig = ../hosts/${name}/configuration.nix; hostHWConfig = ../hosts/${name}/hardware-configuration.nix; + hasHWConfig = builtins.pathExists hostHWConfig; userHMConfigs = nixpkgs.lib.genAttrs users ( user: import ../users/${user}/home-manager.nix { inherit inputs; } ); in - nixpkgs.lib.nixosSystem { inherit system; modules = [ - ../nix.nix { nixpkgs.overlays = overlays; } { nixpkgs.config.allowUnfree = true; } hostConfig - hostHWConfig - + ] + ++ nixpkgs.lib.optional hasHWConfig hostHWConfig + ++ [ inputs.home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; @@ -39,7 +39,6 @@ nixpkgs.lib.nixosSystem { home-manager.users = userHMConfigs; home-manager.extraSpecialArgs = { inherit inputs; }; } - ]; specialArgs = { inherit inputs; }; }