{ description = "PatOS is a minimal, immutable Linux distribution specialized for the Patagia Platform."; inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; }; outputs = { self, nixpkgs }: { lib = { # Prepare a ready-to-boot disk image. mkInstallImage = nixos: let config = nixos.config; pkgs = nixpkgs.legacyPackages.x86_64-linux.pkgs; in nixos.pkgs.runCommand "update-${config.system.image.version}" { nativeBuildInputs = with pkgs; [ qemu ]; } '' mkdir -p $out qemu-img convert -f raw -O qcow2 -C ${config.system.build.image}/${config.boot.uki.name}_${config.system.image.version}.raw $out/disk.qcow2 ''; }; devShells.x86_64-linux.default = let pkgs = nixpkgs.legacyPackages.x86_64-linux; in pkgs.mkShell { packages = [ self.packages.x86_64-linux.qemu-efi ]; }; packages.x86_64-linux = { default = self.packages.x86_64-linux.patos_image; patos_image = self.lib.mkInstallImage self.nixosConfigurations.patos; # A helper script to run the disk images above. qemu-efi = let pkgs = nixpkgs.legacyPackages.x86_64-linux; in pkgs.writeShellApplication { name = "qemu-efi"; runtimeInputs = [ pkgs.qemu_kvm ]; text = '' qemu-system-x86_64 \ -smp 2 -m 2048 -machine q35,accel=kvm \ -bios ${pkgs.OVMF.fd}/FV/OVMF.fd \ -snapshot \ -display none \ -serial stdio "$@" ''; }; }; nixosConfigurations = { patos = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ ./base.nix ]; }; }; }; }