{ description = "A very basic flake"; inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05"; colmena = { url = "github:zhaofengli/colmena"; inputs.nixpkgs.follows = "nixpkgs"; }; nixos-generators = { url = "github:nix-community/nixos-generators"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { self, nixpkgs, colmena, nixos-generators, ... }: let pkgs = nixpkgs.legacyPackages.x86_64-linux; machine = name: machineTagged name [ ]; machineTagged = name: tags: { imports = [ "${./.}/machines/${name}" ]; deployment = { targetHost = "${name}.lxd"; tags = tags; }; }; in { packages.x86_64-linux.hello = pkgs.hello; packages.x86_64-linux.default = colmena.packages.x86_64-linux.colmena; packages.x86_64-linux.register = let lxc = nixos-generators.nixosGenerate { pkgs = pkgs; modules = [ ./machines/base ]; format = "lxc"; }; metadata = nixos-generators.nixosGenerate { pkgs = pkgs; modules = [ ./machines/base ]; format = "lxc-metadata"; }; in with import nixpkgs { system = "x86_64-linux"; }; stdenv.mkDerivation { name = "register-lxc-container"; buildInputs = [ ]; src = self; buildPhase = "mkdir -p $out; ln -s ${lxc} $out/lxc; ln -s ${metadata} $out/metadata"; installPhase = '' ln -s $out/lxc/tarball/nixos-system-x86_64-linux.tar.xz $out/lxc.tar.xz; ln -s $out/metadata/tarball/nixos-system-x86_64-linux.tar.xz $out/metadata.tar.xz; ''; }; packages.x86_64-linux.vm = let vm = nixos-generators.nixosGenerate { pkgs = pkgs; modules = [ ./machines/base ]; format = "qcow"; }; metadata = nixos-generators.nixosGenerate { pkgs = pkgs; modules = [ ./machines/base ]; format = "lxc-metadata"; }; in with import nixpkgs { system = "x86_64-linux"; }; stdenv.mkDerivation { name = "make-nixos-vm"; buildInputs = [ ]; src = self; buildPhase = "mkdir -p $out; ln -s ${vm} $out/vm; ln -s ${metadata} $out/metadata"; installPhase = "ln -s $out/vm/nixos.qcow2 $out/nixos.qcow2;ln -s $out/metadata/tarball/nixos-system-x86_64-linux.tar.xz $out/metadata.tar.xz;"; }; colmena = { meta = { nixpkgs = import nixpkgs { system = "x86_64-linux"; }; }; nginx = { imports = [ ./machines/nginx ]; deployment = { targetHost = "nginx.lxd"; tags = [ "website" ]; }; }; postgres = { imports = [ ./machines/postgres ]; deployment = { targetHost = "postgres.lxd"; tags = [ "database" ]; }; }; gitea = { imports = [ ./machines/gitea ]; deployment = { targetUser = "jdejeu"; targetHost = "gitea.lxd"; tags = [ "website" "system" ]; }; }; vault = { imports = [ ./machines/vault ]; deployment = { targetHost = "vault.lxd"; tags = [ "website" "system" ]; }; }; minio = { imports = [ ./machines/minio ]; deployment = { targetHost = "minio.lxd"; tags = [ "system" ]; }; }; registry = { imports = [ ./machines/registry ]; deployment = { targetHost = "registry.lxd"; tags = [ "system" ]; }; }; vaultwarden = { imports = [ ./machines/vaultwarden ]; deployment = { targetHost = "vaultwarden.lxd"; tags = [ "system" ]; }; }; misskey = { imports = [ ./machines/misskey ]; deployment = { targetHost = "misskey.lxd"; tags = [ ]; }; }; grafana = { imports = [ ./machines/grafana ]; deployment = { targetHost = "grafana.lxd"; tags = [ ]; }; }; prometheus = machine "prometheus"; }; devShells.x86_64-linux.default = pkgs.mkShell { buildInputs = [ colmena.packages.x86_64-linux.colmena pkgs.jq pkgs.bundix pkgs.nix-prefetch-git ]; }; }; }