Merge pull request 'feat-mkupdate' (#1) from feat-mkupdate into main

Reviewed-on: #1
This commit is contained in:
Daniel Lundin 2024-09-27 18:33:42 +00:00
commit a069860ec4
2 changed files with 23 additions and 3 deletions

View file

@ -9,6 +9,25 @@
{ self, nixpkgs }:
{
lib = {
# Prepare an update package for the system.
mkUpdate =
nixos:
let
config = nixos.config;
pkgs = nixpkgs.legacyPackages.x86_64-linux.pkgs;
in
nixos.pkgs.runCommand "update-${config.system.image.version}"
{
nativeBuildInputs = with pkgs; [ xz ];
}
''
mkdir -p $out
xz -1 -cz ${config.system.build.uki}/${config.system.boot.loader.ukiFile} \
> $out/${config.system.boot.loader.ukiFile}.xz
xz -1 -cz ${config.system.build.image}/${config.boot.uki.name}_${config.system.image.version}.store.raw \
> $out/${config.boot.uki.name}_${config.system.image.version}.img.xz
'';
# Prepare a ready-to-boot disk image.
mkInstallImage =
nixos:
@ -39,8 +58,8 @@
packages.x86_64-linux = {
default = self.packages.x86_64-linux.patos_image;
patos_image = self.lib.mkInstallImage self.nixosConfigurations.patos;
patos_update = self.lib.mkUpdate self.nixosConfigurations.patos;
# A helper script to run the disk images above.
qemu-efi =
@ -71,5 +90,6 @@
];
};
};
};
}

View file

@ -36,7 +36,7 @@
"20-store" = {
Source = {
MatchPattern = [
"store_@v.img.xz"
"${config.boot.uki.name}_@v.img.xz"
];
# Path = "https://download.example.com/";
# Type = "url-file";
@ -52,7 +52,7 @@
# Path = "auto";
Path = "/dev/sda";
MatchPattern = "store_@v";
MatchPattern = "${config.boot.uki.name}_@v";
Type = "partition";
ReadOnly = "yes";