feat(docker): arion -> khepri
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-07-24 15:49:31 -04:00
parent acd4ebc1e2
commit 827bf6ba8c
75 changed files with 284 additions and 279 deletions

View file

@ -22,7 +22,7 @@ in
npmDepsHash = "sha256-qpnQSJNl68LrsU8foJYxdBXpoFj7VKQahC9DFmleWTs=";
runtimeInputs = [
(callPackage ../../modules/arion/updateImage.nix {})
(callPackage ../../modules/docker/updateImage.nix {})
mozilla-addons-to-nix.packages.${system}.default
];
nativeBuildInputs = [makeWrapper];

View file

@ -30,7 +30,7 @@ export const updateFlakeInputs = () => {
export const updateDocker = () => {
let updates = '';
const FILE = `${FLAKE}/devices/nos/modules/arion`;
const FILE = `${FLAKE}/devices/nos/modules/docker`;
readdirSync(FILE, { withFileTypes: true, recursive: true }).forEach((path) => {
if (path.name === 'compose.nix') {

View file

@ -16,7 +16,6 @@
home-manager.nixosModules.home-manager
../modules/arion
../modules/borgbackup
];

View file

@ -1,4 +1,8 @@
{config, ...}: let
{
config,
self,
...
}: let
inherit (config.vars) mainUser hostName;
in {
# ------------------------------------------------
@ -11,12 +15,14 @@ in {
../../modules/sshd.nix
../../modules/tailscale.nix
./modules/arion
./modules/docker
./modules/jellyfin
./modules/mergerfs.nix
./modules/qbittorrent
./modules/snapraid.nix
./modules/subtitles
self.nixosModules.docker
];
# State Version: DO NOT CHANGE

View file

@ -1,5 +1,5 @@
{...}: let
configPath = "/var/lib/arion";
configPath = "/var/lib/docker";
in {
imports = [
./forgejo/compose.nix
@ -24,13 +24,11 @@ in {
./media/sonarr/compose.nix
];
arion = {
enable = true;
khepri = {
rwDataDir = configPath;
};
services.borgbackup.configs.arion = {
services.borgbackup.configs.docker = {
paths = [configPath];
exclude = ["**/lineageos*"];
};
}

View file

@ -1,12 +1,16 @@
{config, ...}: let
{
config,
pkgs,
...
}: let
inherit (config.sops) secrets;
inherit (config.arion) rwDataDir;
inherit (config.khepri) rwDataDir;
rwPath = rwDataDir + "/forgejo";
in {
arion.projects."forgejo" = {
khepri.compositions."forgejo".services = {
"forgejo" = {
image = ./images/forgejo.nix;
image = import ./images/forgejo.nix pkgs;
ports = [
# Redirect WAN port 22 to this port
@ -15,9 +19,9 @@ in {
];
restart = "always";
depends_on = ["forgejo-db"];
dependsOn = ["forgejo-db"];
env_file = [secrets.forgejo.path];
environmentFiles = [secrets.forgejo.path];
environment = {
APP_NAME = "Gitea";
@ -27,8 +31,8 @@ in {
ROOT_URL = "https://git.nelim.org";
SSH_DOMAIN = "git.nelim.org";
SSH_PORT = 22;
HTTP_PORT = 3000;
SSH_PORT = "22";
HTTP_PORT = "3000";
};
volumes = [
@ -39,32 +43,31 @@ in {
};
"forgejo-db" = {
image = ./images/postgres.nix;
image = import ./images/postgres.nix pkgs;
restart = "always";
env_file = [secrets.forgejo-db.path];
environmentFiles = [secrets.forgejo-db.path];
volumes = ["${rwPath}/db:/var/lib/postgresql/data"];
};
"act_runner" = {
image = ./images/act_runner.nix;
image = import ./images/act_runner.nix pkgs;
privileged = true;
restart = "always";
depends_on = ["forgejo"];
dependsOn = ["forgejo"];
env_file = [secrets.forgejo-runner.path];
environmentFiles = [secrets.forgejo-runner.path];
environment = {
GITEA_INSTANCE_URL = "https://git.nelim.org";
GITEA_RUNNER_NAME = "DinD";
};
volumes = ["${rwPath}/act:/data"];
dns = ["1.0.0.1"];
extra_hosts = [
extraHosts = [
"git.nelim.org=10.0.0.130"
];
};

View file

@ -4,17 +4,17 @@
...
}: let
inherit (config.sops) secrets;
inherit (config.arion) rwDataDir;
inherit (config.khepri) rwDataDir;
rwPath = rwDataDir + "/freshrss";
in {
arion.projects."freshrss" = {
khepri.compositions."freshrss".services = {
"freshrss" = {
image = ./images/freshrss.nix;
image = import ./images/freshrss.nix pkgs;
restart = "always";
ports = ["2800:80"];
extra_hosts = [
extraHosts = [
"drss.nelim.org=10.0.0.130"
"bridge.nelim.org=10.0.0.130"
];
@ -39,7 +39,7 @@ in {
"${rss-bridge}/xExtension-RssBridge:/var/www/FreshRSS/extensions/xExtension-RssBridge:ro"
];
env_file = [secrets.freshrss.path];
environmentFiles = [secrets.freshrss.path];
environment = {
TZ = "America/New_York";
@ -48,14 +48,14 @@ in {
};
"freshrss-db" = {
image = ./images/postgres.nix;
image = import ./images/postgres.nix pkgs;
restart = "always";
volumes = [
"${rwPath}/db:/var/lib/postgresql/data"
];
env_file = [secrets.freshrss.path];
environmentFiles = [secrets.freshrss.path];
environment = {
POSTGRES_DB = "\${DB_BASE:-freshrss}";
@ -65,13 +65,13 @@ in {
};
"docker-hub-rss" = {
image = ./images/docker-hub-rss.nix;
image = import ./images/docker-hub-rss.nix pkgs;
restart = "always";
ports = ["3007:3000"];
};
"rss-bridge" = {
image = ./images/rss-bridge.nix;
image = import ./images/rss-bridge.nix pkgs;
restart = "always";
volumes = [

View file

@ -1,12 +1,16 @@
{config, ...}: let
{
config,
pkgs,
...
}: let
inherit (config.sops) secrets;
in {
arion.projects."gameyfin"."gameyfin" = {
image = ./images/gameyfin.nix;
khepri.compositions."gameyfin".services."gameyfin" = {
image = import ./images/gameyfin.nix pkgs;
restart = "always";
user = "1000:1000";
env_file = [secrets.gameyfin.path];
environmentFiles = [secrets.gameyfin.path];
environment.GAMEYFIN_USER = "mathis";
volumes = [

View file

@ -1,6 +1,6 @@
{...}: {
arion.projects."hauk"."hauk" = {
image = ./images/hauk.nix;
{pkgs, ...}: {
khepri.compositions."hauk".services."hauk" = {
image = import ./images/hauk.nix pkgs;
restart = "always";
ports = ["3003:80"];

View file

@ -6,17 +6,17 @@
inherit (config.sops) secrets;
inherit (pkgs.writers) writeYAML;
in {
arion.projects."homepage"."homepage" = {
image = ./images/homepage.nix;
khepri.compositions."homepage".services."homepage" = {
image = import ./images/homepage.nix pkgs;
restart = "always";
ports = [
"3020:3000"
];
extra_hosts = ["lan.nelim.org=10.0.0.130"];
extraHosts = ["lan.nelim.org=10.0.0.130"];
env_file = [secrets.homepage.path];
environmentFiles = [secrets.homepage.path];
volumes = let
services = writeYAML "services.yaml" (import ./services.nix);

View file

@ -1,15 +1,19 @@
{config, ...}: let
{
config,
pkgs,
...
}: let
inherit (config.sops) secrets;
inherit (config.arion) rwDataDir;
inherit (config.khepri) rwDataDir;
rwPath = rwDataDir + "/immich";
UPLOAD_LOCATION = "${rwPath}/data";
in {
arion.projects."immich" = {
khepri.compositions."immich".services = {
"immich_server" = {
image = ./images/server.nix;
env_file = [
image = import ./images/server.nix pkgs;
environmentFiles = [
"${./env}"
secrets.immich.path
];
@ -21,16 +25,16 @@ in {
"2283:3001"
];
depends_on = ["immich_redis" "immich_postgres"];
dependsOn = ["immich_redis" "immich_postgres"];
restart = "always";
environment.NODE_ENV = "production";
};
"immich_machine_learning" = {
image = ./images/machine-learning.nix;
image = import ./images/machine-learning.nix pkgs;
restart = "always";
env_file = [
environmentFiles = [
"${./env}"
secrets.immich.path
];
@ -41,19 +45,19 @@ in {
};
"immich_redis" = {
image = ./images/redis.nix;
image = import ./images/redis.nix pkgs;
restart = "always";
tmpfs = ["/data"];
env_file = [
environmentFiles = [
"${./env}"
secrets.immich.path
];
};
"immich_postgres" = {
image = ./images/postgres.nix;
image = import ./images/postgres.nix pkgs;
restart = "always";
env_file = [
environmentFiles = [
"${./env}"
secrets.immich.path
];

View file

@ -1,10 +1,14 @@
{config, ...}: let
inherit (config.arion) rwDataDir;
{
config,
pkgs,
...
}: let
inherit (config.khepri) rwDataDir;
rwPath = rwDataDir + "/media/bazarr";
in {
arion.projects."bazarr"."bazarr" = {
image = ./images/bazarr.nix;
khepri.compositions."bazarr".services."bazarr" = {
image = import ./images/bazarr.nix pkgs;
restart = "always";
environment = {
@ -13,7 +17,7 @@ in {
TZ = "America/New_York";
};
extra_hosts = ["lan.nelim.org=10.0.0.130"];
extraHosts = ["lan.nelim.org=10.0.0.130"];
ports = [
"6767:6767"
];
@ -23,8 +27,6 @@ in {
"/data:/data"
];
extraOptions = {
deploy.resources.limits.cpus = "2";
};
cpus = 2;
};
}

View file

@ -1,11 +1,15 @@
{config, ...}: let
inherit (config.arion) rwDataDir;
{
config,
pkgs,
...
}: let
inherit (config.khepri) rwDataDir;
rwPath = rwDataDir + "/media/calibre";
in {
arion.projects."calibre" = {
khepri.compositions."calibre".services = {
"calibre" = {
image = ./images/calibre.nix;
image = import ./images/calibre.nix pkgs;
restart = "always";
environment = {
@ -21,7 +25,7 @@ in {
volumes = ["${rwPath}/data-db:/config"];
extra_hosts = ["lan.nelim.org=10.0.0.130"];
extraHosts = ["lan.nelim.org=10.0.0.130"];
ports = [
"8580:8080"
#"8081:8081"
@ -30,7 +34,7 @@ in {
};
"calibre-web" = {
image = ./images/calibre-web.nix;
image = import ./images/calibre-web.nix pkgs;
restart = "always";
environment = {
@ -45,7 +49,7 @@ in {
"${rwPath}/data-db/Calibre Library:/books"
];
extra_hosts = ["lan.nelim.org=10.0.0.130"];
extraHosts = ["lan.nelim.org=10.0.0.130"];
ports = ["8083:8083"];
};
};

View file

@ -1,17 +1,21 @@
{config, ...}: let
inherit (config.arion) rwDataDir;
{
config,
pkgs,
...
}: let
inherit (config.khepri) rwDataDir;
rwPath = rwDataDir + "/media/joal";
in {
arion.projects."joal"."joal" = {
image = ./images/joal.nix;
khepri.compositions."joal".services."joal" = {
image = import ./images/joal.nix pkgs;
restart = "always";
volumes = ["${rwPath}/data:/data"];
extra_hosts = ["lan.nelim.org=10.0.0.130"];
extraHosts = ["lan.nelim.org=10.0.0.130"];
ports = ["5656:5656"];
command = [
cmd = [
"--joal-conf=/data"
"--spring.main.web-environment=true"
"--server.port=5656"

View file

@ -1,11 +1,15 @@
{config, ...}: let
inherit (config.arion) rwDataDir;
{
config,
pkgs,
...
}: let
inherit (config.khepri) rwDataDir;
rwPath = rwDataDir + "/media/prowlarr";
in {
arion.projects."prowlarr" = {
khepri.compositions."prowlarr".services = {
"prowlarr" = {
image = ./images/prowlarr.nix;
image = import ./images/prowlarr.nix pkgs;
restart = "always";
environment = {
@ -15,12 +19,12 @@ in {
};
volumes = ["${rwPath}/data:/config"];
extra_hosts = ["lan.nelim.org=10.0.0.130"];
extraHosts = ["lan.nelim.org=10.0.0.130"];
ports = ["9696:9696"];
};
"flaresolverr" = {
image = ./images/flaresolverr.nix;
image = import ./images/flaresolverr.nix pkgs;
restart = "always";
environment = {
@ -30,10 +34,10 @@ in {
TZ = "America/New_York";
};
extra_hosts = ["lan.nelim.org=10.0.0.130"];
extraHosts = ["lan.nelim.org=10.0.0.130"];
ports = ["8191:8191"];
depends_on = ["prowlarr"];
dependsOn = ["prowlarr"];
};
};
}

View file

@ -1,13 +1,17 @@
{config, ...}: let
inherit (config.arion) rwDataDir;
{
config,
pkgs,
...
}: let
inherit (config.khepri) rwDataDir;
rwPath = rwDataDir + "/media/radarr";
in {
arion.projects."radarr"."radarr" = {
image = ./images/radarr.nix;
khepri.compositions."radarr".services."radarr" = {
image = import ./images/radarr.nix pkgs;
restart = "always";
extra_hosts = ["lan.nelim.org=10.0.0.130"];
extraHosts = ["lan.nelim.org=10.0.0.130"];
ports = ["7878:7878"];
environment = {
@ -21,8 +25,6 @@ in {
"/data:/data"
];
extraOptions = {
deploy.resources.limits.cpus = "0.5";
};
cpus = 0.5;
};
}

View file

@ -1,13 +1,17 @@
{config, ...}: let
inherit (config.arion) rwDataDir;
{
config,
pkgs,
...
}: let
inherit (config.khepri) rwDataDir;
rwPath = rwDataDir + "/media/sabnzbd";
in {
arion.projects."sabnzbd"."sabnzbd" = {
image = ./images/sabnzbd.nix;
khepri.compositions."sabnzbd".services."sabnzbd" = {
image = import ./images/sabnzbd.nix pkgs;
restart = "always";
extra_hosts = ["lan.nelim.org=10.0.0.130"];
extraHosts = ["lan.nelim.org=10.0.0.130"];
ports = ["8382:8082"];
environment = {
@ -21,8 +25,6 @@ in {
"/data:/data"
];
extraOptions = {
deploy.resources.limits.cpus = "2";
};
cpus = 2;
};
}

View file

@ -1,10 +1,14 @@
{config, ...}: let
inherit (config.arion) rwDataDir;
{
config,
pkgs,
...
}: let
inherit (config.khepri) rwDataDir;
rwPath = rwDataDir + "/media/seerr";
in {
arion.projects."seerr"."seerr" = {
image = ./images/jellyseerr.nix;
khepri.compositions."seerr".services."seerr" = {
image = import ./images/jellyseerr.nix pkgs;
restart = "always";
environment = {
@ -16,7 +20,7 @@ in {
"${rwPath}/data:/app/config"
];
extra_hosts = ["lan.nelim.org=10.0.0.130"];
extraHosts = ["lan.nelim.org=10.0.0.130"];
ports = ["5055:5055"];
};
}

View file

@ -1,13 +1,17 @@
{config, ...}: let
inherit (config.arion) rwDataDir;
{
config,
pkgs,
...
}: let
inherit (config.khepri) rwDataDir;
rwPath = rwDataDir + "/media/sonarr";
in {
arion.projects."sonarr"."sonarr" = {
image = ./images/sonarr.nix;
khepri.compositions."sonarr".services."sonarr" = {
image = import ./images/sonarr.nix pkgs;
restart = "always";
extra_hosts = ["lan.nelim.org=10.0.0.130"];
extraHosts = ["lan.nelim.org=10.0.0.130"];
ports = ["8989:8989"];
environment = {
@ -21,8 +25,6 @@ in {
"/data:/data"
];
extraOptions = {
deploy.resources.limits.cpus = "0.5";
};
cpus = 0.5;
};
}

View file

@ -1,12 +1,16 @@
{config, ...}: let
inherit (config.arion) rwDataDir;
{
config,
pkgs,
...
}: let
inherit (config.khepri) rwDataDir;
rwPath = rwDataDir + "/music/jbots";
in {
arion.projects."jbots" = {
khepri.compositions."jbots".services = {
"musicbot_be" = {
container_name = "benis";
image = ./images/jmusicbot.nix;
containerName = "be";
image = import ./images/jmusicbot.nix pkgs;
restart = "always";
volumes = [
@ -16,8 +20,8 @@ in {
};
"musicbot_br" = {
container_name = "bruh";
image = ./images/jmusicbot.nix;
containerName = "br";
image = import ./images/jmusicbot.nix pkgs;
restart = "always";
volumes = [

View file

@ -4,16 +4,17 @@
pkgs,
...
}: let
inherit (config.sops) secrets;
inherit (config.arion) rwDataDir;
inherit (lib) concatStrings;
inherit (config.sops) secrets;
inherit (config.khepri) rwDataDir;
mainContainerName = "app-server";
rwPath = rwDataDir + "/nextcloud";
in {
arion.projects."nextcloud" = {
khepri.compositions."nextcloud".services = {
"${mainContainerName}" = {
image = ./images/nextcloud.nix;
image = import ./images/nextcloud.nix pkgs;
restart = "always";
expose = [
@ -26,7 +27,7 @@ in {
"/data/docs:/var/www/drive"
];
env_file = [secrets.nextcloud.path];
environmentFiles = [secrets.nextcloud.path];
environment = {
POSTGRES_DB = "nextcloud";
@ -38,7 +39,7 @@ in {
};
"onlyoffice-document-server" = {
image = ./images/onlyoffice.nix;
image = import ./images/onlyoffice.nix pkgs;
restart = "always";
environment.JWT_ENABLED = "false";
@ -77,7 +78,7 @@ in {
};
"nginx-server" = {
image = ./images/nginx.nix;
image = import ./images/nginx.nix pkgs;
restart = "always";
ports = ["8042:80"];
volumes = [
@ -87,9 +88,9 @@ in {
};
"nextcloud-db" = {
image = ./images/postgres.nix;
image = import ./images/postgres.nix pkgs;
restart = "always";
env_file = [secrets.nextcloud.path];
environmentFiles = [secrets.nextcloud.path];
volumes = [
"${rwPath}/database:/var/lib/postgresql/data"
"/etc/localtime:/etc/localtime:ro"
@ -97,12 +98,12 @@ in {
};
"nextcloud-cache" = {
image = ./images/redis.nix;
image = import ./images/redis.nix pkgs;
restart = "always";
#mem_limit = "2048m";
#mem_reservation = "512m";
env_file = [secrets.nextcloud.path];
command = ''/bin/sh -c "redis-server --requirepass $$REDIS_HOST_PASSWORD"'';
environmentFiles = [secrets.nextcloud.path];
cmd = [''/bin/sh -c "redis-server --requirepass $$REDIS_HOST_PASSWORD"''];
tmpfs = [
"/data"
];
@ -119,8 +120,8 @@ in {
};
systemd.services.nextcloud-cron = {
description = "Nextcloud Cron";
requires = ["arion-nextcloud.service"];
after = ["arion-nextcloud.service"];
requires = ["docker-nextcloud_app-server.service"];
after = ["docker-nextcloud_app-server.service"];
serviceConfig = {
Type = "oneshot";

View file

@ -1,12 +1,16 @@
{config, ...}: let
{
config,
pkgs,
...
}: let
inherit (config.sops) secrets;
inherit (config.arion) rwDataDir;
inherit (config.khepri) rwDataDir;
rwPath = rwDataDir + "/resume";
in {
arion.projects."resume" = {
khepri.compositions."resume".services = {
"postgres" = {
image = ./images/postgres.nix;
image = import ./images/postgres.nix pkgs;
restart = "always";
ports = ["5432:5432"];
@ -15,18 +19,18 @@ in {
"${rwPath}/db:/var/lib/postgresql/data"
];
env_file = [secrets.resume.path];
environmentFiles = [secrets.resume.path];
};
"server" = {
image = ./images/resume-server.nix;
image = import ./images/resume-server.nix pkgs;
restart = "always";
ports = ["3100:3100"];
depends_on = ["postgres"];
dependsOn = ["postgres"];
env_file = [secrets.resume.path];
environmentFiles = [secrets.resume.path];
environment = {
PUBLIC_URL = "https://resume.nelim.org";
@ -35,12 +39,12 @@ in {
};
"client" = {
image = ./images/resume-client.nix;
image = import ./images/resume-client.nix pkgs;
restart = "always";
ports = ["3060:3000"];
depends_on = ["server"];
dependsOn = ["server"];
environment = {
PUBLIC_URL = "https://resume.nelim.org";

View file

@ -1,11 +1,15 @@
{config, ...}: let
inherit (config.arion) rwDataDir;
{
config,
pkgs,
...
}: let
inherit (config.khepri) rwDataDir;
rwPath = rwDataDir + "/vaultwarden";
in {
arion.projects."vaultwarden" = {
khepri.compositions."vaultwarden".services = {
"public-vault" = {
image = ./images/vaultwarden.nix;
image = import ./images/vaultwarden.nix pkgs;
restart = "always";
ports = ["8781:80"];
@ -14,7 +18,7 @@ in {
};
"private-vault" = {
image = ./images/vaultwarden.nix;
image = import ./images/vaultwarden.nix pkgs;
restart = "always";
ports = ["8780:80"];

View file

@ -1,22 +1,26 @@
{config, ...}: let
inherit (config.arion) rwDataDir;
{
config,
pkgs,
...
}: let
inherit (config.khepri) rwDataDir;
rwPath = rwDataDir + "/wg-easy";
in {
arion.projects."wg-easy"."wg-easy" = {
image = ./images/wg-easy.nix;
khepri.compositions."wg-easy".services."wg-easy" = {
image = import ./images/wg-easy.nix pkgs;
restart = "always";
privileged = true;
capabilities = {
NET_ADMIN = true;
SYS_MODULE = true;
};
capAdd = [
"NET_ADMIN"
"SYS_MODULE"
];
sysctls = {
"net.ipv4.ip_forward" = 1;
"net.ipv4.conf.all.src_valid_mark" = 1;
};
sysctls = [
"net.ipv4.ip_forward=1"
"net.ipv4.conf.all.src_valid_mark=1"
];
dns = ["1.0.0.1"];

View file

@ -1,13 +1,17 @@
{config, ...}: let
{
config,
pkgs,
...
}: let
jellyService = config.systemd.services.jellyfin.serviceConfig;
in {
systemd.services."arion-jfa-go" = {
systemd.services."docker-jfa-go_jfa-go" = {
after = ["jellyfin.service"];
partOf = ["jellyfin.service"];
};
arion.projects."jfa-go"."jfa-go" = {
image = ./images/jfa-go.nix;
khepri.compositions."jfa-go".services."jfa-go" = {
image = import ./images/jfa-go.nix pkgs;
restart = "always";
ports = ["8056:8056"];

View file

@ -1,4 +1,8 @@
{config, ...}: let
{
config,
self,
...
}: let
inherit (config.vars) mainUser hostName;
in {
# ------------------------------------------------
@ -15,6 +19,8 @@ in {
./modules/binary-cache.nix
./modules/minecraft.nix
./modules/nfs.nix
self.nixosModules.docker
];
# State Version: DO NOT CHANGE
@ -63,5 +69,5 @@ in {
# ------------------------------------------------
# `Self` Modules configuration
# ------------------------------------------------
arion.enable = true;
# ...
}

View file

@ -58,6 +58,7 @@
nixosModules = {
adb = import ./modules/adb.nix;
desktop = import ./modules/desktop;
docker = import ./modules/docker;
nvidia = import ./modules/nvidia.nix;
plymouth = import ./modules/plymouth.nix;
};

Binary file not shown.

BIN
flake.nix

Binary file not shown.

View file

@ -91,9 +91,9 @@ let
};
nosInputs = {
arion = mkDep {
owner = "hercules-ci";
repo = "arion";
khepri = mkDep {
owner = "matt1432";
repo = "khepri";
};
jellyfin-flake = mkDep {

View file

@ -1,103 +0,0 @@
{
arion,
config,
lib,
pkgs,
...
}: let
inherit
(lib)
filterAttrs
hasAttr
mapAttrs
mkEnableOption
mkForce
mkIf
mkOption
optionalAttrs
types
;
inherit (config.vars) mainUser;
cfg = config.arion;
in {
imports = [arion.nixosModules.arion];
options.arion = {
enable = mkEnableOption "My custom arion config layer module";
rwDataDir = mkOption {
default = "/var/lib/arion";
type = types.str;
description = ''
Directory to place persistent data in
'';
};
projects = mkOption {
default = {};
description = ''
Declarative specification of docker-compose in nix.
'';
type = types.attrs;
};
};
config = mkIf cfg.enable {
users.extraUsers.${mainUser}.extraGroups = ["docker"];
virtualisation = {
docker = {
enable = true;
storageDriver = "btrfs";
};
arion = {
backend = "docker";
projects =
mapAttrs (n: v: {
# https://docs.hercules-ci.com/arion/options
settings = {
enableDefaultNetwork = v.enableDefaultNetwork or true;
networks =
optionalAttrs (hasAttr "networks" v)
v.networks;
services =
mapAttrs (n': v': {
# https://github.com/hercules-ci/arion/issues/169#issuecomment-1301370634
build.image = let
importImage = file: pkgs.callPackage file pkgs;
in
mkForce (importImage v'.image);
service =
(filterAttrs (attrName: _:
attrName != "image" && attrName != "extraOptions")
v')
# By default set the container_name to the attrset's name
// (optionalAttrs (! hasAttr "container_name" v') {
container_name = n';
});
out.service =
optionalAttrs
(hasAttr "extraOptions" v')
v'.extraOptions;
})
v;
};
})
cfg.projects;
};
};
# Script for updating the images of all images of a compose.nix file
environment.systemPackages = with pkgs; [
(callPackage ./updateImage.nix {})
];
};
}

View file

@ -4,7 +4,7 @@
services.borgbackup = {
existingRepos = [
{
name = "arion";
name = "docker";
authorizedKeys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPijoxuSwH9IrS4poewzHHwe64UoX4QY7Qix5VhEdqKR root@servivi"
];

View file

@ -1,9 +1,10 @@
{config, ...}: let
inherit (config.sops) secrets;
inherit (config.arion) rwDataDir;
inherit (config.khepri) rwDataDir;
rwPath = rwDataDir + "/projectName";
in {
arion.projects."projectName" = {
khepri.compositions."projectName" = {
services = {};
};
}

View file

@ -0,0 +1,41 @@
{
config,
khepri,
lib,
pkgs,
...
}: let
inherit (lib) mkOption types;
inherit (config.vars) mainUser;
in {
imports = [khepri.nixosModules.default];
options.khepri = {
rwDataDir = mkOption {
default = "/var/lib/docker";
type = types.str;
description = ''
Directory to place persistent data in.
'';
};
};
config = {
users.extraUsers.${mainUser}.extraGroups = ["docker"];
virtualisation = {
docker = {
enable = true;
storageDriver = "btrfs";
};
# khepri uses oci-containers under the hood and it must be set to docker to work
oci-containers.backend = "docker";
};
# Script for updating the images of all images of a compose.nix file
environment.systemPackages = with pkgs; [
(callPackage ./updateImage.nix {})
];
};
}