Skip to content

Commit

Permalink
nixos/lyratris: working image build
Browse files Browse the repository at this point in the history
  • Loading branch information
makuru-dd committed Nov 24, 2024
1 parent 76a7687 commit ac7ff3b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 26 deletions.
7 changes: 4 additions & 3 deletions nixos/modules/virtualisation/lyratris-config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ with lib;
{
imports = [ ../profiles/qemu-guest.nix ];

services.openssh = {
services.openssh = {
enable = true;

settings.PermitRootLogin = "prohibit-password";
Expand All @@ -19,12 +19,13 @@ with lib;

fileSystems."/" = {
fsType = "btrfs";
device = "/dev/vda2";
device = "/dev/disk/by-label/nixos";
autoResize = true;
autoFormat = true;
};
fileSystems."/boot" = {
fsType = "vfat";
device = "/dev/vda1";
device = "/dev/disk/by-label/bootNixos";
};

services.cloud-init.enable = lib.mkDefault true;
Expand Down
56 changes: 33 additions & 23 deletions nixos/modules/virtualisation/lyratris-image.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,54 @@

with lib;
let
cfg = config.virtualisation.linodeImage;
defaultConfigFile = pkgs.writeText "configuration.nix" ''
_: {
imports = [
<nixpkgs/nixos/modules/virtualisation/lyratris-image.nix>
];
}
'';
efiArch = pkgs.stdenv.hostPlatform.efiArch;
in
{
imports = [
./lyratris-config.nix
./disk-size-option.nix
"virtualisation"
"diskSize"
# ./disk-size-option.nix
../image/repart.nix
];

options.virtualisation.lyratrisImage.configFile = mkOption {
type = with types; nullOr str;
default = null;
type = types.path;
default = ./lyratris-config.nix;
description = ''
A path to a configuration file which will be placed at `/etc/nixos/configuration.nix`
and be used when switching to a new configuration.
If set to `null`, a default configuration is used, where the only import is
`<nixpkgs/nixos/modules/virtualisation/linode-image.nix>`
`<nixpkgs/nixos/modules/virtualisation/lyratris-image.nix>`
'';
};

config = {
system.build.lyratrisImage = import ../../lib/make-disk-image.nix {
name = "lyratris-image";
format = "qcow2-compressed";
partitionTableType = "none";
configFile = if cfg.configFile == null then defaultConfigFile else cfg.configFile;
inherit (config.virtualisation) diskSize;
inherit config lib pkgs;
config.image.repart = {
name = "lyratrisNixos";
seed = "310eaabc-d44a-4f6e-b9a2-5dd8558e4380";
# sectorSize = 4096;
partitions = {
"00-esp" = {
contents = {
"/EFI/BOOT/BOOT${lib.toUpper efiArch}.EFI".source = "${pkgs.systemd}/lib/systemd/boot/efi/systemd-boot${efiArch}.efi";
"/EFI/Linux/${config.system.boot.loader.ukiFile}".source = config.system.build.uki;
};
repartConfig = {
Type = "esp";
Format = "vfat";
Label = "nixosBoot";
SizeMinBytes = "2G";
};
};
"50-root" = {
storePaths = [ config.system.build.toplevel ];
stripNixStorePrefix = true;
repartConfig = {
Type = "root";
Format = "btrfs";
Label = "nixos";
Minimize = "guess";
};
};
};
};

meta.maintainers = with maintainers; [ makuru ];
}

0 comments on commit ac7ff3b

Please sign in to comment.