Skip to content

Commit

Permalink
Merge pull request #326 from a-h/document-filesize
Browse files Browse the repository at this point in the history
docs: add diskSize flake example
  • Loading branch information
Lassulus authored Mar 27, 2024
2 parents 2b3720c + 26d89ad commit 1e2a04b
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,63 @@ on the generated NixOS build.
- vmware

Example (20GB disk):
```

```bash
nixos-generate -c <your_config.nix> -f <format> --disk-size 20480
```

To set the disk size in `flake.nix`, set `diskSize` in the `specialArgs` argument of the `nixosGenerate` function.

```nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
xc = {
url = "github:joerdav/xc";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { nixpkgs, nixos-generators, xc, ... }:
let
pkgsForSystem = system: import nixpkgs {
inherit system;
overlays = [
(final: prev: { xc = xc.packages.${system}.xc; })
];
};
allVMs = [ "x86_64-linux" "aarch64-linux" ];
forAllVMs = f: nixpkgs.lib.genAttrs allVMs (system: f {
inherit system;
pkgs = pkgsForSystem system;
});
in
{
packages = forAllVMs ({ system, pkgs }: {
vm = nixos-generators.nixosGenerate {
system = system;
specialArgs = {
pkgs = pkgs;
diskSize = 20 * 1024;
};
modules = [
# Pin nixpkgs to the flake input, so that the packages installed
# come from the flake inputs.nixpkgs.url.
({ ... }: { nix.registry.nixpkgs.flake = nixpkgs; })
# Apply the rest of the config.
./configuration.nix
];
format = "raw";
};
});
};
}
```

## Cross Compiling

To cross compile nixos images for other architectures you have to configure
Expand Down

0 comments on commit 1e2a04b

Please sign in to comment.