Files
homelab-config/virtual-machines/vm-test/flake.nix
T

55 lines
1.5 KiB
Nix
Raw Normal View History

2026-09-03 23:21:05 -05:00
{
description = "Flake to run services on a VM powered by incus";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
2026-09-26 00:47:00 -05:00
postgresql-db = {
url = "path:../../homelab-services/postgresql-db";
inputs.nixpkgs.follows = "nixpkgs";
};
2026-09-03 23:21:05 -05:00
};
outputs =
{
2026-09-15 22:35:50 -05:00
self,
nixpkgs,
2026-09-15 22:46:31 -05:00
postgresql-db,
2026-09-15 22:35:50 -05:00
}@inputs:
2026-09-26 01:32:45 -05:00
let
2026-09-26 01:48:56 -05:00
system = "x86_64-linux";
2026-09-27 01:35:57 -05:00
pkgs = import nixpkgs {
inherit system;
};
credentials = builtins.listToAttrs (
map (filename: {
name = builtins.replaceStrings [ ".env" ] [ "-env" ] filename;
2026-09-27 01:42:38 -05:00
value =
pkgs.runCommand "sops-decrypt-${filename}"
{
2026-09-27 02:00:15 -05:00
# Use special separate injectable key that can only decrypt these dummy secrets
SOPS_AGE_KEY_FILE = "~/.config/sops/age/virtual-key.txt";
2026-09-27 01:42:38 -05:00
}
''
${pkgs.sops}/bin/sops -d ${./secrets}/${filename} > $out
'';
2026-09-27 01:35:57 -05:00
}) (builtins.attrNames (builtins.readDir ./secrets))
);
2026-09-26 01:32:45 -05:00
in
2026-09-15 22:35:50 -05:00
{
nixosConfigurations = {
2026-09-17 21:58:31 -05:00
vm = nixpkgs.lib.nixosSystem {
2026-09-26 02:04:03 -05:00
system = system;
2026-09-27 01:35:57 -05:00
specialArgs = {
inherit credentials;
};
2026-09-15 22:35:50 -05:00
modules = [
./virtual.nix
2026-09-15 22:46:31 -05:00
postgresql-db.nixosModules.postgresql-db
# declare the vm output
"${inputs.nixpkgs}/nixos/modules/virtualisation/incus-virtual-machine.nix"
2026-09-15 22:35:50 -05:00
];
};
};
2026-09-03 23:21:05 -05:00
};
}