Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chrillefkr/disko-images
Create disk image files from NixOS + disko configuration.
https://github.com/chrillefkr/disko-images
Last synced: 7 days ago
JSON representation
Create disk image files from NixOS + disko configuration.
- Host: GitHub
- URL: https://github.com/chrillefkr/disko-images
- Owner: chrillefkr
- Created: 2023-05-18T22:05:21.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-29T15:34:12.000Z (11 months ago)
- Last Synced: 2024-02-17T15:34:35.303Z (9 months ago)
- Language: Nix
- Size: 7.81 KB
- Stars: 34
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Disko Images
Create disk image files from NixOS + [disko](https://github.com/nix-community/disko) configuration.
This is done by running `disko-create`, `disko-mount`and then`nixos-install` in a VM, where
each `config.disko.devices.disk` is mounted as a qcow2 image.It heavily relies on qcow2 as to not create too large image files. Compression is optional.
## Usage
Add disko-images as a NixOS module (using flakes):
```nix
# flake.nix
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-22.11";
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
disko-images.url = "github:chrillefkr/disko-images";
};
outputs = { self, nixpkgs, disko, disko-images, ... } @inputs:
let
pkgs = import nixpkgs {
system = "x86_64-linux";
config.allowUnfree = true;
};
in
{
nixosConfigurations.my-machine = nixpkgs.lib.nixosSystem {
inherit pkgs;
specialArgs.inputs = inputs;
modules = [
./configuration.nix
./disko.nix
disko.nixosModules.disko
disko-images.nixosModules.disko-images
];
};
};
}
```Build disko images using `nix build '.#nixosConfigurations.my-machine.config.system.build.diskoImages'`.
Your disk image files appear at `./results/*.qcow2`.
## About
First of all, this is a very simple (but working) way of creating disk images from NixOS + disko configuration.
I've used it mainly to create Raspberry Pi SD card images.Inspired by:
* https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/installer/sd-card/sd-image-aarch64.nix
* https://nixos.wiki/wiki/NixOps/Virtualization## TODO
* [ ] Ensure support for
* [X] zfs
* [ ] btrfs
* [ ] lvm
* [ ] Individual disk size (`config.diskoImages.diskAllocSizes`)
* [ ] Create tests
* [ ] Create examples## Known issues
### Raspberry Pi Linux kernel
The Raspberry Pi 4 Linux kernel (`pkgs.linuxPackages_rpi4`) (and problably kernels for the older boards) doesn't seem to work, as
the kernel seems to lack support for 9pnet_virtio. It gives me the error message `9pnet_virtio: no channels available for device `
when it attemts to mount the nix store.A fix is to use official Linux kernel, e.g.:
`boot.kernelPackages = pkgs.linuxPackages;`## Contribution
Please help. I'm quite new to Nix and NixOS, so any PR or issue is appreciated.