diff --git a/.gitignore b/.gitignore index b421d08..76db1ad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ result sd-card.img +clementine.qcow2 diff --git a/configuration.nix b/citrus.nix similarity index 72% rename from configuration.nix rename to citrus.nix index 0833ded..ee610bd 100644 --- a/configuration.nix +++ b/citrus.nix @@ -1,17 +1,13 @@ {pkgs, ... }: { - boot.loader.raspberryPi.version = 3; - boot.initrd.kernelModules = [ "vc4" "bcm2835_dma" "i2c_bcm2835" ]; - - networking.hostName = "orange"; - nixpkgs.hostPlatform.system = "aarch64-linux"; system.stateVersion = "23.05"; + nix.settings.experimental-features = [ "nix-command" "flakes" ]; - + hardware.opengl.enable = true; environment.systemPackages = with pkgs; [ - graphfix xorg.xauth xorg.xinit + xorg.xauth xorg.xinit ]; users = { diff --git a/flake.nix b/flake.nix index 3ea38bd..0b8d187 100644 --- a/flake.nix +++ b/flake.nix @@ -6,7 +6,7 @@ flake-utils.url = "github:numtide/flake-utils"; colmena.url = "github:zhaofengli/colmena"; - graphfix.url = "git+https://git.sr.ht/~mtxyz/graphfix"; + graphfix.url = "sourcehut:~mtxyz/graphfix"; graphfix.inputs.nixpkgs.follows = "nixpkgs"; }; @@ -15,62 +15,42 @@ let pkgs = import nixpkgs { inherit system; - overlays = [ inputs.colmena.overlay ]; + overlays = [ + inputs.graphfix.overlay + inputs.colmena.overlay + ]; }; - crossPkgs = pkgs.pkgsCross.aarch64-multiplatform; - in - { + clementine = nixpkgs.lib.nixosSystem { + inherit pkgs; + modules = [ + ./citrus.nix + ./platforms/clementine.nix + ]; + }; + in rec { devShell = pkgs.mkShell { packages = with pkgs; [ colmena ]; }; - apps.default = { - type = "app"; - program = self.outputs.packages.${system}.vmscript + "/bin/vmscript"; - }; - packages.vmscript = pkgs.writeScriptBin "vmscript" '' - #!${pkgs.runtimeShell} -e - img=./sd-card.img - ${pkgs.zstd}/bin/zstd -k -d ${self.outputs.image}/sd-image/orange.img.zst -o $img - chmod 640 $img - truncate -s 16G $img - ${pkgs.qemu}/bin/qemu-system-aarch64 \ - -machine raspi3b \ - -kernel "${crossPkgs.ubootRaspberryPi3_64bit}/u-boot.bin" \ - -cpu max \ - -m 1G \ - -smp 4 \ - -drive file="$img",format=raw \ - -nographic \ - -serial null \ - -serial mon:stdio - ''; + packages.default = clementine.config.system.build.vm; }) // (let pkgs = import nixpkgs { system = "aarch64-linux"; overlays = [ inputs.graphfix.overlay ]; }; - in rec { + modules = [ + ./citrus.nix + "${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix" + ./platforms/orange.nix + ]; + in { colmena = { - meta = { - nixpkgs = pkgs; - }; + meta.nixpkgs = pkgs; orange = { - imports = [ - ./configuration.nix - "${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix" - ]; + imports = modules; }; }; - nixosConfigurations.orange = nixpkgs.lib.nixosSystem { - modules = [ - ./configuration.nix - "${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix" - { - nixpkgs.overlays = [inputs.graphfix.overlay]; - sdImage.imageName = "orange.img"; - } - ]; - }; - image = nixosConfigurations.orange.config.system.build.sdImage; + orange = (nixpkgs.lib.nixosSystem { + inherit pkgs modules; + }).config.system.build.sdImage; }); } diff --git a/platforms/clementine.nix b/platforms/clementine.nix new file mode 100644 index 0000000..d238799 --- /dev/null +++ b/platforms/clementine.nix @@ -0,0 +1,4 @@ +{pkgs, ...}: +{ + networking.hostName = "clementine"; +} diff --git a/platforms/orange.nix b/platforms/orange.nix new file mode 100644 index 0000000..a8a5098 --- /dev/null +++ b/platforms/orange.nix @@ -0,0 +1,10 @@ +{pkgs, ...}: +{ + nixpkgs.hostPlatform.system = "aarch64-linux"; + sdImage.imageName = "orange.img"; + + boot.loader.raspberryPi.version = 3; + boot.initrd.kernelModules = [ "vc4" "bcm2835_dma" "i2c_bcm2835" ]; + + networking.hostName = "orange"; +}