Compare commits
46 Commits
22282c1a2f
...
hostbuilde
| Author | SHA1 | Date | |
|---|---|---|---|
| af11810935 | |||
| 81f73a0704 | |||
| 7730163b84 | |||
| 725efc3e0a | |||
| 724f14cfcd | |||
| cf3bfa1784 | |||
| c71d7959f2 | |||
| 155e78b519 | |||
| c54f04cb62 | |||
| 197a8427b7 | |||
| 1877f6dc9c | |||
| c47e93170f | |||
| eea5d6924d | |||
| 468106677c | |||
| df4d769f82 | |||
| 249eebf164 | |||
| e3bcd250e0 | |||
| 1b871f3860 | |||
| 3564436dfe | |||
| 4744324385 | |||
| 88ef307a65 | |||
| dec968a4db | |||
| 283dc51d67 | |||
|
|
f4a6c40cd2 | ||
|
|
23caa27d4e | ||
|
|
d6aee8657b | ||
|
|
e7e05327e4 | ||
| 1fc3538e03 | |||
|
|
1ebee6d886 | ||
|
|
94e439bf0b | ||
|
|
e50f3349ba | ||
|
|
18b747a7df | ||
|
|
ea6e019b64 | ||
|
|
8581f762a2 | ||
|
|
b223f0cb0c | ||
|
|
9ba607ce16 | ||
|
|
34c2661c53 | ||
|
|
211799b6b9 | ||
|
|
543c4ed49e | ||
|
|
27085dd3e6 | ||
|
|
8076956982 | ||
| 26829f9255 | |||
| 0d93cad9d4 | |||
| 02a57d98d0 | |||
| 4553c2c069 | |||
| 3f3dca3c7f |
@@ -43,6 +43,7 @@ let
|
||||
defaultModules = baseModules;
|
||||
|
||||
makeMicroVM = hostName: ipv4Addr: macAddr: modules: [
|
||||
self.nixosModules.malobeo.metrics
|
||||
{
|
||||
microvm = {
|
||||
hypervisor = "cloud-hypervisor";
|
||||
@@ -79,6 +80,13 @@ let
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
malobeo.metrics = {
|
||||
enable = true;
|
||||
enablePromtail = true;
|
||||
logNginx = false;
|
||||
lokiHost = "10.0.0.14";
|
||||
};
|
||||
|
||||
systemd.network.enable = true;
|
||||
|
||||
@@ -179,11 +187,19 @@ in
|
||||
];
|
||||
};
|
||||
|
||||
overwatch = nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
specialArgs.inputs = inputs;
|
||||
specialArgs.self = self;
|
||||
modules = makeMicroVM "overwatch" "10.0.0.14" "D0:E5:CA:F0:D7:E0" [
|
||||
./overwatch/configuration.nix
|
||||
];
|
||||
};
|
||||
|
||||
testvm = nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
specialArgs.inputs = inputs;
|
||||
specialArgs.self = self;
|
||||
modules = defaultModules ++ [ ./testvm ];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ with lib;
|
||||
networking = {
|
||||
hostName = mkDefault "durruti";
|
||||
useDHCP = false;
|
||||
nameservers = [ "1.1.1.1" ];
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ 8080 ];
|
||||
|
||||
@@ -53,7 +53,7 @@ in
|
||||
};
|
||||
|
||||
services.malobeo.microvm.enableHostBridge = true;
|
||||
services.malobeo.microvm.deployHosts = [ "infradocs" "nextcloud" ];
|
||||
services.malobeo.microvm.deployHosts = [ "infradocs" "nextcloud" "overwatch" ];
|
||||
|
||||
networking = {
|
||||
firewall = {
|
||||
|
||||
@@ -6,7 +6,6 @@ with lib;
|
||||
networking = {
|
||||
hostName = mkDefault "infradocs";
|
||||
useDHCP = false;
|
||||
nameservers = [ "1.1.1.1" ];
|
||||
};
|
||||
|
||||
imports = [
|
||||
@@ -15,6 +14,12 @@ with lib;
|
||||
../modules/sshd.nix
|
||||
];
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ 9002 ];
|
||||
|
||||
malobeo.metrics.logNginx = lib.mkForce true;
|
||||
|
||||
users.users.promtail.extraGroups = [ "nginx" "systemd-journal" ];
|
||||
|
||||
system.stateVersion = "22.11"; # Did you read the comment?
|
||||
}
|
||||
|
||||
|
||||
56
machines/modules/malobeo/metrics.nix
Normal file
56
machines/modules/malobeo/metrics.nix
Normal file
@@ -0,0 +1,56 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
cfg = config.malobeo.metrics;
|
||||
in
|
||||
{
|
||||
options.malobeo.metrics = {
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Enable sharing metrics";
|
||||
};
|
||||
enablePromtail = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "Enable sharing logs";
|
||||
};
|
||||
logNginx = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Share nginx logs";
|
||||
};
|
||||
lokiHost = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "10.0.0.14";
|
||||
description = "Address of loki host";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf (cfg.enable) {
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ 9002 ];
|
||||
|
||||
services.prometheus = {
|
||||
exporters = {
|
||||
node = {
|
||||
enable = true;
|
||||
enabledCollectors = [ "systemd" "processes" ];
|
||||
port = 9002;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.promtail = {
|
||||
enable = cfg.enablePromtail;
|
||||
configFile = import ./promtail_config.nix {
|
||||
lokiAddress = cfg.lokiHost;
|
||||
logNginx = cfg.logNginx;
|
||||
config = config;
|
||||
pkgs = pkgs;
|
||||
};
|
||||
};
|
||||
|
||||
users.users.promtail.extraGroups = [ "systemd-journal" ] ++ (lib.optionals cfg.logNginx [ "nginx" ]) ;
|
||||
|
||||
};
|
||||
}
|
||||
@@ -86,6 +86,12 @@ in
|
||||
in
|
||||
builtins.listToAttrs (map mapperFunc cfg.deployHosts);
|
||||
|
||||
systemd.tmpfiles.rules = builtins.concatLists (map (name: [
|
||||
"d /var/lib/microvms/${name}/var 0755 root root - -"
|
||||
"d /var/lib/microvms/${name}/etc 0755 root root - -"
|
||||
"d /${name} 0755 root root - -"
|
||||
]) cfg.deployHosts);
|
||||
|
||||
systemd.services = builtins.foldl' (services: name: services // {
|
||||
"microvm-update@${name}" = {
|
||||
description = "Update MicroVMs automatically";
|
||||
|
||||
49
machines/modules/malobeo/promtail_config.nix
Normal file
49
machines/modules/malobeo/promtail_config.nix
Normal file
@@ -0,0 +1,49 @@
|
||||
{ logNginx, lokiAddress, config, pkgs, ... }:
|
||||
|
||||
let
|
||||
basecfg = ''
|
||||
server:
|
||||
http_listen_port: 9080
|
||||
grpc_listen_port: 0
|
||||
|
||||
positions:
|
||||
filename: /tmp/positions.yaml
|
||||
|
||||
clients:
|
||||
- url: http://${lokiAddress}:3100/loki/api/v1/push
|
||||
'';
|
||||
|
||||
withNginx = ''
|
||||
scrape_configs:
|
||||
- job_name: journal
|
||||
journal:
|
||||
max_age: 12h
|
||||
labels:
|
||||
job: systemd-journal
|
||||
host: ${config.networking.hostName}
|
||||
relabel_configs:
|
||||
- source_labels: ["__journal__systemd_unit"]
|
||||
target_label: "unit"
|
||||
- job_name: nginx
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost
|
||||
labels:
|
||||
job: nginx
|
||||
__path__: /var/log/nginx/*log
|
||||
'';
|
||||
|
||||
withoutNginx = ''
|
||||
scrape_configs:
|
||||
- job_name: journal
|
||||
journal:
|
||||
max_age: 12h
|
||||
labels:
|
||||
job: systemd-journal
|
||||
host: ${config.networking.hostName}
|
||||
relabel_configs:
|
||||
- source_labels: ["__journal__systemd_unit"]
|
||||
target_label: "unit"
|
||||
'';
|
||||
in
|
||||
pkgs.writeText "promtailcfg.yaml" (if logNginx then ''${basecfg}${withNginx}'' else ''${basecfg}${withoutNginx}'')
|
||||
115
machines/overwatch/configuration.nix
Normal file
115
machines/overwatch/configuration.nix
Normal file
@@ -0,0 +1,115 @@
|
||||
{ config, lib, pkgs, inputs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
networking = {
|
||||
hostName = mkDefault "overwatch";
|
||||
useDHCP = false;
|
||||
};
|
||||
|
||||
imports = [
|
||||
../modules/malobeo_user.nix
|
||||
../modules/sshd.nix
|
||||
];
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ 80 9080 9001 3100 ];
|
||||
|
||||
services.grafana = {
|
||||
enable = true;
|
||||
domain = "grafana.malobeo.org";
|
||||
port = 2342;
|
||||
addr = "127.0.0.1";
|
||||
|
||||
provision.datasources.settings = {
|
||||
apiVersion = 1;
|
||||
|
||||
datasources = [
|
||||
{
|
||||
name = "loki";
|
||||
type = "loki";
|
||||
access = "proxy";
|
||||
uid = "eeakiack8nqwwc";
|
||||
url = "http://localhost:3100";
|
||||
editable = false;
|
||||
}
|
||||
{
|
||||
name = "prometheus";
|
||||
type = "prometheus";
|
||||
access = "proxy";
|
||||
uid = "feakib1gq7ugwc";
|
||||
url = "http://localhost:9001";
|
||||
editable = false;
|
||||
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
provision.dashboards.settings = {
|
||||
apiVersion = 1;
|
||||
providers = [{
|
||||
name = "default";
|
||||
options.path = ./dashboards;
|
||||
}];
|
||||
};
|
||||
};
|
||||
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
virtualHosts.${config.services.grafana.domain} = {
|
||||
locations."/" = {
|
||||
proxyPass = "http://127.0.0.1:${toString config.services.grafana.port}";
|
||||
proxyWebsockets = true;
|
||||
|
||||
extraConfig = ''
|
||||
proxy_set_header Host $host;
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.prometheus = {
|
||||
enable = true;
|
||||
port = 9001;
|
||||
|
||||
scrapeConfigs = [
|
||||
{
|
||||
job_name = "overwatch";
|
||||
static_configs = [{
|
||||
targets = [ "127.0.0.1:9002" ];
|
||||
}];
|
||||
}
|
||||
{
|
||||
job_name = "durruti";
|
||||
static_configs = [{
|
||||
targets = [ "10.0.0.5:9002" ];
|
||||
}];
|
||||
}
|
||||
{
|
||||
job_name = "infradocs";
|
||||
static_configs = [{
|
||||
targets = [ "10.0.0.11:9002" ];
|
||||
}];
|
||||
}
|
||||
{
|
||||
job_name = "nextcloud";
|
||||
static_configs = [{
|
||||
targets = [ "10.0.0.13:9002" ];
|
||||
}];
|
||||
}
|
||||
# add vpn - check how to reach it first. most probably 10.100.0.1
|
||||
];
|
||||
};
|
||||
|
||||
services.loki = {
|
||||
enable = true;
|
||||
configFile = ./loki.yaml;
|
||||
};
|
||||
|
||||
users.users.promtail.extraGroups = [ "nginx" "systemd-journal" ];
|
||||
|
||||
|
||||
|
||||
system.stateVersion = "22.11"; # Did you read the comment?
|
||||
}
|
||||
|
||||
1218
machines/overwatch/dashboards/main.json
Normal file
1218
machines/overwatch/dashboards/main.json
Normal file
File diff suppressed because it is too large
Load Diff
23804
machines/overwatch/dashboards/node_full.json
Normal file
23804
machines/overwatch/dashboards/node_full.json
Normal file
File diff suppressed because it is too large
Load Diff
60
machines/overwatch/loki.yaml
Normal file
60
machines/overwatch/loki.yaml
Normal file
@@ -0,0 +1,60 @@
|
||||
auth_enabled: false
|
||||
|
||||
server:
|
||||
http_listen_port: 3100
|
||||
grpc_listen_port: 9096
|
||||
log_level: debug
|
||||
grpc_server_max_concurrent_streams: 1000
|
||||
|
||||
common:
|
||||
instance_addr: 127.0.0.1
|
||||
path_prefix: /tmp/loki
|
||||
storage:
|
||||
filesystem:
|
||||
chunks_directory: /tmp/loki/chunks
|
||||
rules_directory: /tmp/loki/rules
|
||||
replication_factor: 1
|
||||
ring:
|
||||
kvstore:
|
||||
store: inmemory
|
||||
|
||||
query_range:
|
||||
results_cache:
|
||||
cache:
|
||||
embedded_cache:
|
||||
enabled: true
|
||||
max_size_mb: 100
|
||||
|
||||
schema_config:
|
||||
configs:
|
||||
- from: 2020-10-24
|
||||
store: tsdb
|
||||
object_store: filesystem
|
||||
schema: v13
|
||||
index:
|
||||
prefix: index_
|
||||
period: 24h
|
||||
|
||||
pattern_ingester:
|
||||
enabled: true
|
||||
metric_aggregation:
|
||||
loki_address: localhost:3100
|
||||
|
||||
ruler:
|
||||
alertmanager_url: http://localhost:9093
|
||||
|
||||
frontend:
|
||||
encoding: protobuf
|
||||
|
||||
# By default, Loki will send anonymous, but uniquely-identifiable usage and configuration
|
||||
# analytics to Grafana Labs. These statistics are sent to https://stats.grafana.org/
|
||||
#
|
||||
# Statistics help us better understand how Loki is used, and they show us performance
|
||||
# levels for most users. This helps us prioritize features and documentation.
|
||||
# For more information on what's sent, look at
|
||||
# https://github.com/grafana/loki/blob/main/pkg/analytics/stats.go
|
||||
# Refer to the buildReport method to see what goes into a report.
|
||||
#
|
||||
# If you would like to disable reporting, uncomment the following lines:
|
||||
analytics:
|
||||
reporting_enabled: false
|
||||
29
machines/overwatch/promtail.yaml
Normal file
29
machines/overwatch/promtail.yaml
Normal file
@@ -0,0 +1,29 @@
|
||||
server:
|
||||
http_listen_port: 9080
|
||||
grpc_listen_port: 0
|
||||
|
||||
positions:
|
||||
filename: /tmp/positions.yaml
|
||||
|
||||
clients:
|
||||
- url: http://10.0.0.13:3100/loki/api/v1/push
|
||||
|
||||
|
||||
scrape_configs:
|
||||
- job_name: journal
|
||||
journal:
|
||||
max_age: 12h
|
||||
labels:
|
||||
job: systemd-journal
|
||||
host: overwatch
|
||||
relabel_configs:
|
||||
- source_labels: ["__journal__systemd_unit"]
|
||||
target_label: "unit"
|
||||
- job_name: nginx
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost
|
||||
labels:
|
||||
job: nginx
|
||||
__path__: /var/log/nginx/*log
|
||||
|
||||
@@ -6,7 +6,6 @@ with lib;
|
||||
networking = {
|
||||
hostName = mkDefault "uptimekuma";
|
||||
useDHCP = false;
|
||||
nameservers = [ "1.1.1.1" ];
|
||||
};
|
||||
|
||||
imports = [
|
||||
|
||||
@@ -17,6 +17,7 @@ with lib;
|
||||
};
|
||||
|
||||
imports = [
|
||||
inputs.self.nixosModules.malobeo.vpn
|
||||
../modules/malobeo_user.nix
|
||||
../modules/sshd.nix
|
||||
../modules/minimal_tools.nix
|
||||
|
||||
171
outputs.nix
171
outputs.nix
@@ -12,6 +12,97 @@
|
||||
let filter_system = name: if name == utils.lib.system.i686-linux then false else true;
|
||||
in (utils.lib.eachSystem (builtins.filter filter_system utils.lib.defaultSystems) ( system:
|
||||
let
|
||||
baseModules = [
|
||||
# make flake inputs accessiable in NixOS
|
||||
{ _module.args.inputs = inputs; }
|
||||
{
|
||||
imports = [
|
||||
({ pkgs, ... }: {
|
||||
nix = {
|
||||
extraOptions = ''
|
||||
experimental-features = nix-command flakes
|
||||
'';
|
||||
|
||||
settings = {
|
||||
substituters = [
|
||||
"https://cache.dynamicdiscord.de"
|
||||
"https://cache.nixos.org/"
|
||||
];
|
||||
trusted-public-keys = [
|
||||
"cache.dynamicdiscord.de:DKueZicqi2NhJJXz9MYgUbiyobMs10fTyHCgAUibRP4="
|
||||
];
|
||||
trusted-users = [ "root" "@wheel" ];
|
||||
};
|
||||
};
|
||||
})
|
||||
sops-nix.nixosModules.sops
|
||||
#microvm.nixosModules.microvm
|
||||
];
|
||||
}
|
||||
];
|
||||
defaultModules = baseModules;
|
||||
|
||||
makeMicroVM = hostName: ipv4Addr: macAddr: modules: [
|
||||
self.nixosModules.malobeo.metrics
|
||||
{
|
||||
microvm = {
|
||||
hypervisor = "cloud-hypervisor";
|
||||
mem = 2560;
|
||||
shares = [
|
||||
{
|
||||
source = "/nix/store";
|
||||
mountPoint = "/nix/.ro-store";
|
||||
tag = "store";
|
||||
proto = "virtiofs";
|
||||
socket = "store.socket";
|
||||
}
|
||||
{
|
||||
source = "/var/lib/microvms/${hostName}/etc";
|
||||
mountPoint = "/etc";
|
||||
tag = "etc";
|
||||
proto = "virtiofs";
|
||||
socket = "etc.socket";
|
||||
}
|
||||
{
|
||||
source = "/var/lib/microvms/${hostName}/var";
|
||||
mountPoint = "/var";
|
||||
tag = "var";
|
||||
proto = "virtiofs";
|
||||
socket = "var.socket";
|
||||
}
|
||||
];
|
||||
|
||||
interfaces = [
|
||||
{
|
||||
type = "tap";
|
||||
id = "vm-${hostName}";
|
||||
mac = "${macAddr}";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
malobeo.metrics = {
|
||||
enable = true;
|
||||
enablePromtail = true;
|
||||
logNginx = false;
|
||||
lokiHost = "10.0.0.14";
|
||||
};
|
||||
|
||||
systemd.network.enable = true;
|
||||
|
||||
systemd.network.networks."20-lan" = {
|
||||
matchConfig.Type = "ether";
|
||||
networkConfig = {
|
||||
Address = [ "${ipv4Addr}/24" ];
|
||||
Gateway = "10.0.0.1";
|
||||
DNS = ["1.1.1.1"];
|
||||
DHCP = "no";
|
||||
};
|
||||
};
|
||||
}
|
||||
] ++ defaultModules ++ modules;
|
||||
|
||||
|
||||
pkgs-unstable = nixpkgs-unstable.legacyPackages."${system}";
|
||||
pkgs = nixpkgs.legacyPackages."${system}";
|
||||
|
||||
@@ -20,7 +111,17 @@ in (utils.lib.eachSystem (builtins.filter filter_system utils.lib.defaultSystems
|
||||
mem = pkgs.lib.mkForce 4096;
|
||||
hypervisor = pkgs.lib.mkForce "qemu";
|
||||
socket = pkgs.lib.mkForce null;
|
||||
shares = pkgs.lib.mkForce ([
|
||||
|
||||
|
||||
#needed for hosts that deploy imperative microvms (for example fanny)
|
||||
writableStoreOverlay = pkgs.lib.mkIf options.writableStore "/nix/.rw-store";
|
||||
volumes = pkgs.lib.mkIf options.writableStore [ {
|
||||
image = "nix-store-overlay.img";
|
||||
mountPoint = self.nixosConfigurations.${hostname}.config.microvm.writableStoreOverlay;
|
||||
size = 2048;
|
||||
} ];
|
||||
|
||||
shares = pkgs.lib.mkForce (pkgs.lib.optionals (!options.writableStore) [
|
||||
{
|
||||
tag = "ro-store";
|
||||
source = "/nix/store";
|
||||
@@ -34,11 +135,18 @@ in (utils.lib.eachSystem (builtins.filter filter_system utils.lib.defaultSystems
|
||||
tag = "var";
|
||||
}
|
||||
]);
|
||||
|
||||
interfaces = pkgs.lib.mkIf (!options.withNetworking) (pkgs.lib.mkForce [{
|
||||
type = "user";
|
||||
id = "eth0";
|
||||
mac = "02:23:de:ad:be:ef";
|
||||
}]);
|
||||
|
||||
#if networking is disabled forward port 80 to still have access to webservices
|
||||
forwardPorts = pkgs.lib.mkIf (!options.withNetworking) (pkgs.lib.mkForce [
|
||||
{ from = "host"; host.port = 8080; guest.port = 80; }
|
||||
]);
|
||||
|
||||
};
|
||||
|
||||
fileSystems = {
|
||||
@@ -86,15 +194,59 @@ in (utils.lib.eachSystem (builtins.filter filter_system utils.lib.defaultSystems
|
||||
}];
|
||||
};
|
||||
|
||||
buildVM = host: networking: sopsDummy: disableDisko: varPath: (self.nixosConfigurations.${host}.extendModules {
|
||||
buildVM = host: networking: sopsDummy: disableDisko: varPath: writableStore: (self.nixosConfigurations.${host}.extendModules {
|
||||
modules = [
|
||||
(vmMicroVMOverwrites host { withNetworking = networking; varPath = "${varPath}"; })
|
||||
(vmMicroVMOverwrites host {
|
||||
withNetworking = networking;
|
||||
varPath = "${varPath}";
|
||||
writableStore = writableStore; })
|
||||
(if sopsDummy then (vmSopsOverwrites host) else {})
|
||||
(if disableDisko then vmDiskoOverwrites else {})
|
||||
] ++ pkgs.lib.optionals (! self.nixosConfigurations.${host}.config ? microvm) [
|
||||
microvm.nixosModules.microvm
|
||||
];
|
||||
}).config.microvm.declaredRunner;
|
||||
#microvm.nixosModules.microvm
|
||||
] ++ pkgs.lib.optionals (self.nixosConfigurations.${host}.config ? services.malobeo.microvm.deployHosts) [
|
||||
#microvm.nixosModules.host
|
||||
{
|
||||
services.malobeo.microvm.deployHosts = pkgs.lib.mkForce [];
|
||||
systemd.tmpfiles.rules = builtins.concatLists (map (name: [
|
||||
"q /var/lib/microvms/${name}/var 0755 root root - -"
|
||||
"q /var/lib/microvms/${name}/etc 0755 root root - -"
|
||||
"q /var/${name}/wow/it/works 0755 root root - -"
|
||||
"q /var/lib/${name} 0755 root root - -"
|
||||
"d /${name} 0755 root root - -"
|
||||
]) self.nixosConfigurations.${host}.config.services.malobeo.microvm.deployHosts);
|
||||
|
||||
|
||||
microvm.vms =
|
||||
let
|
||||
# Map the values to each hostname to then generate an Attrset using listToAttrs
|
||||
mapperFunc = name: { inherit name; value = {
|
||||
#pkgs = import self.nixosConfigurations.${name}.config.nixpkgs;
|
||||
|
||||
#pkgs = (buildVM name networking sopsDummy false "" false).config.nixpkgs;
|
||||
#config = (buildVM name networking sopsDummy false "" false);
|
||||
#pkgs = pkgs;
|
||||
#config = self.nixosConfigurations.${name};
|
||||
specialArgs.inputs = inputs;
|
||||
specialArgs.self = self;
|
||||
config = {
|
||||
imports = (makeMicroVM "${name}" "10.0.0.11" "D0:E5:CA:F0:D7:E7" [
|
||||
|
||||
#(vmMicroVMOverwrites name {
|
||||
# withNetworking = true;
|
||||
# varPath = "";
|
||||
# writableStore = false; })
|
||||
(if sopsDummy then (vmSopsOverwrites name) else {})
|
||||
|
||||
|
||||
]);
|
||||
|
||||
};
|
||||
}; };
|
||||
in
|
||||
builtins.listToAttrs (map mapperFunc self.nixosConfigurations.${host}.config.services.malobeo.microvm.deployHosts);
|
||||
}];
|
||||
});
|
||||
in
|
||||
{
|
||||
devShells.default =
|
||||
@@ -157,6 +309,7 @@ in (utils.lib.eachSystem (builtins.filter filter_system utils.lib.defaultSystems
|
||||
echo "--networking setup interfaces. requires root and hostbridge enabled on the host"
|
||||
echo "--dummy-secrets run vm with dummy sops secrets"
|
||||
echo "--no-disko disable disko and initrd secrets. needed for real hosts like fanny"
|
||||
echo "--writable-store enables writable store. necessary for host with nested imperative microvms like fanny"
|
||||
echo "--var path to directory that should be shared as /var. may require root otherwise some systemd units fail within vm. if dir is empty vm will populate"
|
||||
exit 1
|
||||
}
|
||||
@@ -172,6 +325,7 @@ in (utils.lib.eachSystem (builtins.filter filter_system utils.lib.defaultSystems
|
||||
NETWORK=false
|
||||
DUMMY_SECRETS=false
|
||||
NO_DISKO=false
|
||||
RW_STORE=false
|
||||
VAR_PATH=""
|
||||
|
||||
# check argws
|
||||
@@ -181,6 +335,7 @@ in (utils.lib.eachSystem (builtins.filter filter_system utils.lib.defaultSystems
|
||||
--networking) NETWORK=true ;;
|
||||
--dummy-secrets) DUMMY_SECRETS=true ;;
|
||||
--no-disko) NO_DISKO=true ;;
|
||||
--writable-store) RW_STORE=true ;;
|
||||
--var)
|
||||
if [[ -n "$2" && ! "$2" =~ ^- ]]; then
|
||||
VAR_PATH="$2"
|
||||
@@ -198,11 +353,12 @@ in (utils.lib.eachSystem (builtins.filter filter_system utils.lib.defaultSystems
|
||||
echo "enable networking: $NETWORK"
|
||||
echo "deploy dummy secrets: $DUMMY_SECRETS"
|
||||
echo "disable disko and initrd secrets: $NO_DISKO"
|
||||
echo "use writable store: $RW_STORE"
|
||||
if [ -n "$VAR_PATH" ]; then
|
||||
echo "sharing var directory: $VAR_PATH"
|
||||
fi
|
||||
|
||||
${pkgs.nix}/bin/nix run --show-trace --impure --expr "((builtins.getFlake \"$(pwd)\").vmBuilder.x86_64-linux \"$HOSTNAME\" $NETWORK $DUMMY_SECRETS $NO_DISKO \"$VAR_PATH\")"
|
||||
${pkgs.nix}/bin/nix run --show-trace --impure --expr "((builtins.getFlake \"$(pwd)\").vmBuilder.x86_64-linux \"$HOSTNAME\" $NETWORK $DUMMY_SECRETS $NO_DISKO \"$VAR_PATH\" $RW_STORE).config.microvm.declaredRunner"
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -240,6 +396,7 @@ in (utils.lib.eachSystem (builtins.filter filter_system utils.lib.defaultSystems
|
||||
microvm.imports = [ ./machines/modules/malobeo/microvm_host.nix ];
|
||||
vpn.imports = [ ./machines/modules/malobeo/wireguard.nix ];
|
||||
initssh.imports = [ ./machines/modules/malobeo/initssh.nix ];
|
||||
metrics.imports = [ ./machines/modules/malobeo/metrics.nix ];
|
||||
disko.imports = [ ./machines/modules/disko ];
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user