diff --git a/flake.nix b/flake.nix index 060ae42..afaee98 100644 --- a/flake.nix +++ b/flake.nix @@ -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 @@ ]; }; }; + }; } diff --git a/modules/sysupdate.nix b/modules/sysupdate.nix index ed9cf21..949fbcb 100644 --- a/modules/sysupdate.nix +++ b/modules/sysupdate.nix @@ -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";