feat: use nixos-rebuild build-image instead of nixosGenerators

This commit is contained in:
2026-02-21 02:05:30 +01:00
parent ffcbcbdea5
commit 507a138cde
5 changed files with 20 additions and 64 deletions

37
flake.lock generated
View File

@@ -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",

View File

@@ -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 {

View File

@@ -1,7 +1,14 @@
{ pkgs, lib, ... }:
{
# Use zstd instead of xz for compressing the liveUSB image, it's 6x faster and 15% bigger.
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 = {

View File

@@ -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:

View File

@@ -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; };
}