Skip to content

Instantly share code, notes, and snippets.

@srl295
Created December 29, 2023 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srl295/d9b20a10ab1488de228ec0a64caf705e to your computer and use it in GitHub Desktop.
Save srl295/d9b20a10ab1488de228ec0a64caf705e to your computer and use it in GitHub Desktop.
disko-images test
# configuration.nix
{ config, modulesPath, pkgs, lib, ... }:
{
## imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
# networking.hostName = "nix";
networking.useDHCP = true;
boot.kernelParams = ["console=ttyAMA0,115200n8" "console=tty0"];
boot.consoleLogLevel = lib.mkDefault 7;
boot.growPartition = true;
# not sure if needed
# boot.initrd.kernelModules = [ "nvme" ];
boot.loader.grub = {
efiSupport = true;
efiInstallAsRemovable = true;
device = "nodev";
};
fileSystems."/" = { device = "/dev/sda2"; fsType = "ext4"; };
fileSystems."/boot" = { device = "/dev/sda1"; fsType = "vfat"; };
nixpkgs.localSystem.system = "x86_64-linux";
# system.build.image = import <nixpkgs/nixos/lib/make-disk-image.nix> {
# diskSize = 8192;
# format = "qcow2"; # qcow2-compressed
# installBootLoader = true;
# partitionTableType = "efi";
# inherit config lib pkgs;
# };
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It‘s perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "22.11"; # Did you read the comment?
}
#disko.nix
!{
disko.devices = {
disk = {
my-disk = {
device = "/dev/sda";
type = "disk";
content = {
type = "gpt";
partitions = {
ESP = {
size = "500M";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
root = {
size = "100%";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
};
};
};
};
};
};
}
# 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
];
};
};
}
@srl295
Copy link
Author

srl295 commented Dec 29, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment