melodypond/flake.nix

71 lines
1.9 KiB
Nix

{
description = "my project description";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
flake-utils.url = "github:numtide/flake-utils";
colmena.url = "github:zhaofengli/colmena";
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
};
outputs = inputs@{self, nixpkgs, flake-utils, ...}:
flake-utils.lib.eachDefaultSystem (system:
let
# nixpkgs for native system.
pkgs = import nixpkgs {
inherit system;
overlays = [
inputs.colmena.overlay
];
};
# Native VM config.
riversong = nixpkgs.lib.nixosSystem {
inherit pkgs;
modules = [
./citrus.nix
"${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix"
./platforms/riversong.nix
];
};
in rec {
# Install colmena in dev shell for deployment.
devShell = pkgs.mkShell {
packages = with pkgs; [ colmena ];
};
# Run testing VM using `nix run`
packages.default = riversong.config.system.build.vm;
}) // (let
# Target device (RPi4 aarch64) nixpkgs.
pkgs = import nixpkgs {
system = "aarch64-linux";
overlays = [
(final: super: {
makeModulesClosure = x:
super.makeModulesClosure (x // { allowMissing = true; });
})
];
};
# Modules for colmena and sd card image are the same.
modules = [
./citrus.nix
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
./platforms/melodypond.nix
inputs.nixos-hardware.nixosModules.raspberry-pi-4
];
in {
# Colmena deploy manifest
colmena = {
meta.nixpkgs = pkgs;
melodypond = {
deployment.targetUser = "geekygay";
imports = modules;
};
};
# SD card image build.
melodypond = (nixpkgs.lib.nixosSystem {
inherit pkgs modules;
}).config.system.build.sdImage;
});
}