pass inputs in container friendly way

This commit is contained in:
zuckerberg 2021-09-24 13:53:36 -04:00
parent de9c03977b
commit b7f6576d64
6 changed files with 32 additions and 26 deletions

View File

@ -1,4 +1,4 @@
{ lib, pkgs, config, inputs, ... }: { lib, pkgs, config, ... }:
with lib; with lib;
let let
cfg = config.nix.flakes; cfg = config.nix.flakes;
@ -15,7 +15,7 @@ in {
''; '';
# pin nixpkgs for system commands such as "nix shell" # pin nixpkgs for system commands such as "nix shell"
registry.nixpkgs.flake = inputs.nixpkgs; registry.nixpkgs.flake = config.inputs.nixpkgs;
}; };
}; };
} }

View File

@ -1,4 +1,4 @@
{ config, pkgs, lib, inputs, ... }: { config, pkgs, lib, ... }:
let let
cfg = config.services.drastikbot; cfg = config.services.drastikbot;
@ -9,9 +9,9 @@ let
format = "other"; format = "other";
srcs = [ srcs = [
inputs.drastikbot config.inputs.drastikbot
inputs.drastikbot_modules config.inputs.drastikbot_modules
inputs.dailybuild_modules config.inputs.dailybuild_modules
]; ];
nativeBuildInputs = [ pkgs.makeWrapper ]; nativeBuildInputs = [ pkgs.makeWrapper ];

View File

@ -1,8 +1,8 @@
{ config, pkgs, lib, inputs, system, ... }: { config, pkgs, lib, ... }:
let let
cfg = config.services.radio; cfg = config.services.radio;
radioPackage = inputs.radio.packages.${system}.radio; radioPackage = config.inputs.radio.packages.${builtins.currentSystem}.radio;
in { in {
options.services.radio = { options.services.radio = {
enable = lib.mkEnableOption "enable radio"; enable = lib.mkEnableOption "enable radio";
@ -47,7 +47,7 @@ in {
services.nginx.virtualHosts.${cfg.host} = lib.mkIf cfg.nginx { services.nginx.virtualHosts.${cfg.host} = lib.mkIf cfg.nginx {
enableACME = true; enableACME = true;
forceSSL = true; forceSSL = true;
locations."/".root = inputs.radio-web; locations."/".root = config.inputs.radio-web;
}; };
users.users.${cfg.user} = { users.users.${cfg.user} = {

View File

@ -35,9 +35,12 @@
inputs.agenix.nixosModules.age inputs.agenix.nixosModules.age
{ {
environment.systemPackages = [ inputs.agenix.defaultPackage.${system} ]; environment.systemPackages = [ inputs.agenix.defaultPackage.${system} ];
# because nixos specialArgs doesn't work for containers... need to pass in inputs a different way
options.inputs = lib.mkOption { default = inputs; };
} }
]; ];
specialArgs = { inherit inputs; inherit system; }; # specialArgs = {};
}; };
in in
{ {

View File

@ -1,4 +1,4 @@
{ config, pkgs, lib, inputs, ... }: { config, pkgs, lib, ... }:
let let
mta-sts-web = { mta-sts-web = {
@ -145,10 +145,14 @@ in {
config = { config = {
imports = [ imports = [
../../common/common.nix ../../common/common.nix
config.inputs.agenix.nixosModules.age
]; ];
pia.enable = true; pia.enable = true;
nixpkgs.pkgs = pkgs; nixpkgs.pkgs = pkgs;
# because nixos specialArgs doesn't work for containers... need to pass in inputs a different way
options.inputs = lib.mkOption { default = config.inputs; };
services.drastikbot.enable = true; services.drastikbot.enable = true;
services.radio = { services.radio = {
enable = true; enable = true;
@ -159,23 +163,19 @@ in {
# load the secret on behalf of the container # load the secret on behalf of the container
age.secrets."pia-login.conf".file = ../../secrets/pia-login.conf; age.secrets."pia-login.conf".file = ../../secrets/pia-login.conf;
# icecast endpoint # icecast endpoint + website
services.nginx.virtualHosts."radio.neet.space" = { services.nginx.virtualHosts."radio.neet.space" = {
enableACME = true; enableACME = true;
forceSSL = true; forceSSL = true;
locations."/stream.mp3" = { locations = {
"/stream.mp3" = {
proxyPass = "http://172.16.100.2:8001/stream.mp3"; proxyPass = "http://172.16.100.2:8001/stream.mp3";
extraConfig = '' extraConfig = ''
add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Origin *;
''; '';
}; };
"/".root = config.inputs.radio-web;
}; };
# radio website
services.nginx.virtualHosts."radio.neet.space" = {
enableACME = true;
forceSSL = true;
locations."/".root = inputs.radio-web;
}; };
services.nginx.virtualHosts."paradigminteractive.agency" = { services.nginx.virtualHosts."paradigminteractive.agency" = {

View File

@ -1,4 +1,4 @@
{ config, pkgs, lib, inputs, ... }: { config, pkgs, lib, ... }:
{ {
imports =[ imports =[
@ -47,11 +47,14 @@
config = { config = {
imports = [ imports = [
../../common/common.nix ../../common/common.nix
inputs.agenix.nixosModules.age config.inputs.agenix.nixosModules.age
]; ];
pia.enable = true; pia.enable = true;
nixpkgs.pkgs = pkgs; nixpkgs.pkgs = pkgs;
# because nixos specialArgs doesn't work for containers... need to pass in inputs a different way
options.inputs = lib.mkOption { default = config.inputs; };
services.radarr.enable = true; services.radarr.enable = true;
services.radarr.openFirewall = true; services.radarr.openFirewall = true;
services.bazarr.enable = true; services.bazarr.enable = true;