abstraction :)
This commit is contained in:
parent
c95b924af7
commit
edba60c4ec
45
host.nix
45
host.nix
|
@ -1,30 +1,39 @@
|
|||
{ pkgs, ... }:
|
||||
let gitea = {
|
||||
host = "10.10.0.1";
|
||||
local = "10.10.0.2";
|
||||
};
|
||||
secrets = import ./secrets/secrets.nix;
|
||||
let secrets = import ./secrets/secrets.nix;
|
||||
services = import ./services.nix;
|
||||
lib = import ./lib.nix;
|
||||
in
|
||||
|
||||
lib.foldMap ({ name, ip, config, ... }:
|
||||
{
|
||||
# [CONTAINERS]
|
||||
containers.gitea = {
|
||||
containers.${name} = {
|
||||
autoStart = true;
|
||||
ephemeral = true;
|
||||
privateNetwork = true;
|
||||
hostAddress = gitea.host;
|
||||
localAddress = gitea.local;
|
||||
config = ./guests/gitea.nix;
|
||||
hostAddress = ip.host;
|
||||
localAddress = ip.local;
|
||||
config = config;
|
||||
};
|
||||
}
|
||||
) services
|
||||
|
||||
//
|
||||
|
||||
{
|
||||
# [NGINX]
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
recommendedProxySettings = true;
|
||||
virtualHosts = {
|
||||
"localhost" = {
|
||||
locations."/".proxyPass = "http://${gitea.local}:3001";
|
||||
};
|
||||
};
|
||||
virtualHosts =
|
||||
lib.foldMap ({ ip, port, hosts, ... }:
|
||||
lib.foldMap (host:
|
||||
{
|
||||
"${host}" = {
|
||||
locations."/".proxyPass = "http://${ip.local}:${builtins.toString port}";
|
||||
};
|
||||
}
|
||||
) hosts
|
||||
) services;
|
||||
};
|
||||
|
||||
# [NETWORK]
|
||||
|
@ -32,12 +41,12 @@ in
|
|||
networking.firewall.allowedUDPPorts = [ ];
|
||||
|
||||
# VM test user
|
||||
users.users.admin.isSystemUser = true ;
|
||||
users.users.admin.hashedPassword = builtins.readFile ./secrets/admin_password;
|
||||
users.users.admin.isNormalUser = true;
|
||||
users.users.admin.hashedPassword = pkgs.lib.removeSuffix "\n"
|
||||
(builtins.readFile ./secrets/admin_password);
|
||||
users.users.admin.group = "admin";
|
||||
users.groups.admin = {};
|
||||
|
||||
|
||||
system.stateVersion = "23.11";
|
||||
|
||||
}
|
||||
|
|
3
lib.nix
Normal file
3
lib.nix
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
foldMap = (f: list: builtins.foldl' (acc: elem: acc // elem) {} (builtins.map f list));
|
||||
}
|
14
services.nix
Normal file
14
services.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
# List of attrsets defining
|
||||
# name, ip.host, ip.local, config, hosts
|
||||
[
|
||||
{
|
||||
name = "gitea";
|
||||
ip = {
|
||||
host = "10.10.0.1";
|
||||
local = "10.10.0.2";
|
||||
};
|
||||
config = ./guests/gitea.nix;
|
||||
port = 3001;
|
||||
hosts = [ "localhost" ];
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue
Block a user