mirror of
https://github.com/phfroidmont/self-hosting.git
synced 2025-12-25 05:36:59 +01:00
Start migrating config to NixOS modules
This commit is contained in:
parent
c1211cb4e5
commit
c0d929be0b
11 changed files with 283 additions and 183 deletions
|
|
@ -1,32 +1,40 @@
|
|||
{ config, ... }:
|
||||
{ config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.custom.services.binary-cache;
|
||||
in
|
||||
{
|
||||
options.custom.services.binary-cache = {
|
||||
|
||||
sops.secrets = {
|
||||
nixCacheKey = {
|
||||
key = "nix/cache_secret_key";
|
||||
enable = mkEnableOption "binary-cache";
|
||||
|
||||
secretKeyFile = mkOption {
|
||||
type = types.path;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
services.nix-serve = {
|
||||
enable = true;
|
||||
port = 1500;
|
||||
secretKeyFile = config.sops.secrets.nixCacheKey.path;
|
||||
};
|
||||
config = mkIf cfg.enable {
|
||||
services.nix-serve = {
|
||||
enable = true;
|
||||
port = 1500;
|
||||
secretKeyFile = config.sops.secrets.nixCacheKey.path;
|
||||
};
|
||||
|
||||
services.nginx = {
|
||||
virtualHosts = {
|
||||
"cache.${config.networking.domain}" = {
|
||||
services.nginx = {
|
||||
virtualHosts = {
|
||||
"cache.${config.networking.domain}" = {
|
||||
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
|
||||
locations."/".extraConfig = ''
|
||||
proxy_pass http://localhost:${toString config.services.nix-serve.port};
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
'';
|
||||
locations."/".extraConfig = ''
|
||||
proxy_pass http://localhost:${toString config.services.nix-serve.port};
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue