Files
homelab-config/virtual-machines/vm-test/flake.nix
T
2026-09-26 01:32:45 -05:00

46 lines
1.2 KiB
Nix

{
description = "Flake to run services on a VM powered by incus";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
postgresql-db = {
url = "path:../../homelab-services/postgresql-db";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
postgresql-db,
}@inputs:
let
credentialMap = builtins.listToAttrs (
map (filename: {
name = builtins.replaceStrings [ ".env" ] [ "-env" ] filename;
value = nixpkgs.runCommand "sops-decrypt-${filename}" { } ''
${nixpkgs.sops}/bin/sops -d ${./secrets}/${filename} > $out
'';
}) (builtins.attrNames (builtins.readDir ./secrets))
);
in
{
nixosConfigurations = {
vm = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
credentials = credentialMap;
};
modules = [
./virtual.nix
postgresql-db.nixosModules.postgresql-db
# declare the vm output
"${inputs.nixpkgs}/nixos/modules/virtualisation/incus-virtual-machine.nix"
];
};
};
};
}