From 1013fb31ed0702522c2903282cb048e87516a8e7 Mon Sep 17 00:00:00 2001 From: Daniel Lundin Date: Thu, 12 Sep 2024 22:34:19 +0200 Subject: [PATCH] Add justfile --- flake.nix | 111 ++++++++++++++++++++++++++++-------------------------- justfile | 16 ++++++++ 2 files changed, 74 insertions(+), 53 deletions(-) create mode 100644 justfile diff --git a/flake.nix b/flake.nix index d62d9c3..060ae42 100644 --- a/flake.nix +++ b/flake.nix @@ -5,66 +5,71 @@ 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 - ]; + 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 + ''; }; - 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 = + devShells.x86_64-linux.default = 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 "$@" - ''; + pkgs.mkShell { + packages = [ + pkgs.just + self.packages.x86_64-linux.qemu-efi + ]; }; - }; - nixosConfigurations = { - patos = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./base.nix - ]; + 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 + ]; + }; }; }; - }; } diff --git a/justfile b/justfile new file mode 100644 index 0000000..cd8f0fd --- /dev/null +++ b/justfile @@ -0,0 +1,16 @@ +set shell := ["/usr/bin/env", "bash", "-euo", "pipefail", "-c"] + +[private] +default: + @just --list + +# Update nix flake +update: + nix flake update + +# Build all targets +build: build-image + +# Build PatOS image +build-image: + nix build .#patos_image