strato-infra/nixos/flake.nix

148 lines
4.2 KiB
Nix
Raw Normal View History

2022-05-19 15:03:13 +02:00
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-21.11";
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;
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;
2022-05-19 21:10:04 +02:00
modules = [ ./machines/base ];
2022-05-19 15:03:13 +02:00
format = "lxc";
};
metadata = nixos-generators.nixosGenerate {
pkgs = pkgs;
2022-05-19 21:10:04 +02:00
modules = [ ./machines/base ];
2022-05-19 15:03:13 +02:00
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";
2022-05-19 15:12:01 +02:00
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;
'';
2022-05-19 15:03:13 +02:00
};
2022-05-21 21:59:14 +02:00
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;";
};
2022-05-19 15:03:13 +02:00
colmena = {
meta = { nixpkgs = import nixpkgs { system = "x86_64-linux"; }; };
nginx = {
2022-05-19 17:47:41 +02:00
imports = [ ./machines/nginx ];
deployment = {
targetHost = "nginx.lxd";
tags = [ "website" ];
};
2022-05-19 15:03:13 +02:00
};
2022-05-19 17:47:41 +02:00
postgres = {
imports = [ ./machines/postgres ];
deployment = {
targetHost = "postgres.lxd";
tags = [ "database" ];
};
2022-05-19 15:03:13 +02:00
};
2022-05-19 21:10:04 +02:00
gitea = {
imports = [ ./machines/gitea ];
deployment = {
targetUser = "jdejeu";
targetHost = "gitea.lxd";
tags = [ "website" "system" ];
};
};
2022-05-20 22:06:13 +02:00
2022-05-20 23:57:58 +02:00
vault = {
imports = [ ./machines/vault ];
2022-05-20 22:06:13 +02:00
deployment = {
2022-05-20 23:57:58 +02:00
targetHost = "vault.lxd";
tags = [ "website" "system" ];
2022-05-20 22:06:13 +02:00
};
};
2022-05-20 23:57:58 +02:00
2022-05-21 21:59:14 +02:00
minio = {
imports = [ ./machines/minio ];
deployment = {
targetHost = "minio.lxd";
tags = [ "system" ];
keys."minioSettings" = {
keyCommand = [ "vault" "kv" "get" "-field=settings" "kv/minio" ];
destDir = "/var/lib/keys";
user = "minio";
group = "minio";
};
};
};
registry = {
imports = [ ./machines/registry ];
deployment = {
targetHost = "registry.lxd";
tags = [ "system" ];
};
};
2022-05-22 12:09:12 +02:00
vaultwarden = {
imports = [ ./machines/vaultwarden ];
deployment = {
targetHost = "vaultwarden.lxd";
tags = [ "system" ];
};
};
2022-05-20 23:57:58 +02:00
# k3s = {
# imports = [ ./machines/k3s ];
# deployment = {
# targetHost = "k3s.lxd";
# tags = [ "k3s" ];
# };
# };
2022-05-19 15:03:13 +02:00
};
devShells.x86_64-linux.default = pkgs.mkShell {
buildInputs = [ colmena.packages.x86_64-linux.colmena ];
};
};
}