Compare commits
No commits in common. "66788cff0c745b8118fedfddd7fb0a2858ecc23c" and "7d94ffda857a13a5ceef591651da7d601f7593ce" have entirely different histories.
66788cff0c
...
7d94ffda85
5 changed files with 11 additions and 82 deletions
|
@ -1,36 +0,0 @@
|
||||||
{ lib, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
ways.registry.static = { depot, pkgs, ... }: pkgs.writeTextDir "flake-registry.json" (let
|
|
||||||
flakes = {
|
|
||||||
depot = {
|
|
||||||
type = "tarball";
|
|
||||||
url = "https://forge.${depot.lib.meta.domain}/${depot.lib.meta.domain}/depot/archive/master.tar.gz";
|
|
||||||
};
|
|
||||||
depot-nixpkgs = {
|
|
||||||
type = "github";
|
|
||||||
owner = "NixOS";
|
|
||||||
repo = "nixpkgs";
|
|
||||||
inherit (depot.inputs.nixpkgs.sourceInfo) rev narHash lastModified;
|
|
||||||
};
|
|
||||||
blank = {
|
|
||||||
type = "github";
|
|
||||||
owner = "divnix";
|
|
||||||
repo = "blank";
|
|
||||||
inherit (depot.inputs.blank.sourceInfo) rev narHash lastModified;
|
|
||||||
};
|
|
||||||
} // import ./extra-flakes.nix;
|
|
||||||
in builtins.toJSON {
|
|
||||||
version = 2;
|
|
||||||
flakes = lib.pipe flakes [
|
|
||||||
(lib.attrsToList)
|
|
||||||
(map (f: {
|
|
||||||
from = {
|
|
||||||
type = "indirect";
|
|
||||||
id = f.name;
|
|
||||||
};
|
|
||||||
to = f.value;
|
|
||||||
}))
|
|
||||||
];
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
let
|
|
||||||
github = owner: repo: {
|
|
||||||
type = "github";
|
|
||||||
inherit owner repo;
|
|
||||||
};
|
|
||||||
in {
|
|
||||||
# own
|
|
||||||
hyprspace = github "hyprspace" "hyprspace";
|
|
||||||
ai = github "nixified-ai" "flake";
|
|
||||||
nix-super = github "privatevoid-net" "nix-super";
|
|
||||||
nixpak = github "nixpak" "nixpak";
|
|
||||||
|
|
||||||
# other
|
|
||||||
nix = github "NixOS" "nix";
|
|
||||||
flake-parts = github "hercules-ci" "flake-parts";
|
|
||||||
home-manager = github "nix-community" "home-manager";
|
|
||||||
dream2nix = github "nix-community" "dream2nix";
|
|
||||||
}
|
|
|
@ -1,15 +1,11 @@
|
||||||
{ cluster, config, depot, lib, pkgs, ... }:
|
{ cluster, config, lib, pkgs, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
externalWays = lib.filterAttrs (_: cfg: !cfg.internal) cluster.config.ways;
|
externalWays = lib.filterAttrs (_: cfg: !cfg.internal) cluster.config.ways;
|
||||||
|
|
||||||
internalWays = lib.filterAttrs (_: cfg: cfg.internal) cluster.config.ways;
|
internalWays = lib.filterAttrs (_: cfg: cfg.internal) cluster.config.ways;
|
||||||
|
|
||||||
byMode = lib.pipe cluster.config.ways [
|
consulServiceWays = lib.filterAttrs (_: cfg: cfg.useConsul) cluster.config.ways;
|
||||||
(lib.attrsToList)
|
|
||||||
(lib.groupBy (way: way.value.mode))
|
|
||||||
(lib.mapAttrs (n: v: lib.listToAttrs v))
|
|
||||||
];
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -29,13 +25,7 @@ in
|
||||||
];
|
];
|
||||||
locations = lib.mkMerge [
|
locations = lib.mkMerge [
|
||||||
{
|
{
|
||||||
"/" = if cfg.mode == "static" then {
|
"/" = if cfg.grpc then {
|
||||||
root = cfg.static {
|
|
||||||
inherit depot;
|
|
||||||
inherit pkgs;
|
|
||||||
inherit (pkgs) system;
|
|
||||||
};
|
|
||||||
} else if cfg.grpc then {
|
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
set $nix_proxy_grpc_target ${cfg.target};
|
set $nix_proxy_grpc_target ${cfg.target};
|
||||||
grpc_pass $nix_proxy_grpc_target;
|
grpc_pass $nix_proxy_grpc_target;
|
||||||
|
@ -57,7 +47,7 @@ in
|
||||||
};
|
};
|
||||||
}) cluster.config.ways;
|
}) cluster.config.ways;
|
||||||
|
|
||||||
appendHttpConfig = lib.mkIf (byMode.consul != {}) ''
|
appendHttpConfig = lib.mkIf (consulServiceWays != {}) ''
|
||||||
include /run/consul-template/nginx-ways-*.conf;
|
include /run/consul-template/nginx-ways-*.conf;
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
@ -77,7 +67,7 @@ in
|
||||||
value.distributed.enable = true;
|
value.distributed.enable = true;
|
||||||
}) externalWays;
|
}) externalWays;
|
||||||
|
|
||||||
services.consul-template.instances.ways = lib.mkIf (byMode.consul != {}) {
|
services.consul-template.instances.ways = lib.mkIf (consulServiceWays != {}) {
|
||||||
user = "nginx";
|
user = "nginx";
|
||||||
group = "nginx";
|
group = "nginx";
|
||||||
settings = {
|
settings = {
|
||||||
|
@ -96,7 +86,7 @@ in
|
||||||
{{ else }}
|
{{ else }}
|
||||||
# upstream ${cfg.nginxUpstreamName} (${cfg.consulService}): no servers available
|
# upstream ${cfg.nginxUpstreamName} (${cfg.consulService}): no servers available
|
||||||
{{ end }}
|
{{ end }}
|
||||||
'') byMode.consul;
|
'') consulServiceWays;
|
||||||
in pkgs.writeText "ways-upstreams.ctmpl" (lib.concatStringsSep "\n" (lib.unique upstreams));
|
in pkgs.writeText "ways-upstreams.ctmpl" (lib.concatStringsSep "\n" (lib.unique upstreams));
|
||||||
destination = "/run/consul-template/nginx-ways-upstreams.conf";
|
destination = "/run/consul-template/nginx-ways-upstreams.conf";
|
||||||
exec.command = lib.singleton (pkgs.writeShellScript "ways-reload" ''
|
exec.command = lib.singleton (pkgs.writeShellScript "ways-reload" ''
|
||||||
|
|
|
@ -58,10 +58,6 @@ with lib;
|
||||||
type = types.str;
|
type = types.str;
|
||||||
};
|
};
|
||||||
|
|
||||||
static = mkOption {
|
|
||||||
type = with types; functionTo (coercedTo package (package: "${package.webroot or package}") str);
|
|
||||||
};
|
|
||||||
|
|
||||||
healthCheckPath = mkOption {
|
healthCheckPath = mkOption {
|
||||||
type = types.path;
|
type = types.path;
|
||||||
default = "/.well-known/ways/internal-health-check";
|
default = "/.well-known/ways/internal-health-check";
|
||||||
|
@ -73,10 +69,10 @@ with lib;
|
||||||
default = "https://${name}.${config.domainSuffix}";
|
default = "https://${name}.${config.domainSuffix}";
|
||||||
};
|
};
|
||||||
|
|
||||||
mode = mkOption {
|
useConsul = mkOption {
|
||||||
type = types.enum [ "simple" "consul" "static" ];
|
type = types.bool;
|
||||||
internal = true;
|
internal = true;
|
||||||
default = "simple";
|
default = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
nginxUpstreamName = mkOption {
|
nginxUpstreamName = mkOption {
|
||||||
|
@ -109,15 +105,12 @@ with lib;
|
||||||
|
|
||||||
config = lib.mkMerge [
|
config = lib.mkMerge [
|
||||||
(lib.mkIf options.consulService.isDefined {
|
(lib.mkIf options.consulService.isDefined {
|
||||||
mode = "consul";
|
useConsul = true;
|
||||||
nginxUpstreamName = "ways_upstream_${builtins.hashString "md5" options.consulService.value}";
|
nginxUpstreamName = "ways_upstream_${builtins.hashString "md5" options.consulService.value}";
|
||||||
target = "${if config.grpc then "grpc" else "http"}://${options.nginxUpstreamName.value}";
|
target = "${if config.grpc then "grpc" else "http"}://${options.nginxUpstreamName.value}";
|
||||||
})
|
})
|
||||||
(lib.mkIf options.bucket.isDefined {
|
(lib.mkIf options.bucket.isDefined {
|
||||||
consulService = "garage-web";
|
consulService = "garage-web";
|
||||||
})
|
})
|
||||||
(lib.mkIf options.static.isDefined {
|
|
||||||
mode = "static";
|
|
||||||
})
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
experimental-features = nix-command flakes cgroups
|
experimental-features = nix-command flakes cgroups
|
||||||
use-cgroups = true
|
use-cgroups = true
|
||||||
builders-use-substitutes = true
|
builders-use-substitutes = true
|
||||||
flake-registry = https://registry.${depot.lib.meta.domain}/flake-registry.json
|
flake-registry = https://git.${depot.lib.meta.domain}/private-void/registry/-/raw/master/registry.json
|
||||||
|
|
||||||
# For Hercules CI agent
|
# For Hercules CI agent
|
||||||
narinfo-cache-negative-ttl = 0
|
narinfo-cache-negative-ttl = 0
|
||||||
|
|
Loading…
Reference in a new issue