forked from Bos55/nix-config
Compare commits
7 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 58f2ea9b74 | |||
| 687b85eeef | |||
| 84c94afda4 | |||
| 04b4254a72 | |||
| 2a392b0581 | |||
| d2a0da648c | |||
| bdb4ad8160 |
6 changed files with 280 additions and 66 deletions
48
.github/workflows/build.yml
vendored
48
.github/workflows/build.yml
vendored
|
|
@ -1,48 +0,0 @@
|
||||||
name: "Build"
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
push:
|
|
||||||
|
|
||||||
env:
|
|
||||||
RUNNER_TOOL_CACHE: /toolcache
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
determine-hosts:
|
|
||||||
name: "Determining hosts to build"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: catthehacker/ubuntu:act-latest
|
|
||||||
outputs:
|
|
||||||
hosts: ${{ steps.hosts.outputs.hostnames }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v5
|
|
||||||
- uses: https://github.com/cachix/install-nix-action@v31
|
|
||||||
with:
|
|
||||||
nix_path: nixpkgs=channel:nixos-unstable
|
|
||||||
- name: "Determine hosts"
|
|
||||||
id: hosts
|
|
||||||
run: |
|
|
||||||
hostnames="$(nix eval .#nixosConfigurations --apply builtins.attrNames --json)"
|
|
||||||
printf "hostnames=%s\n" "${hostnames}" >> "${GITHUB_OUTPUT}"
|
|
||||||
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: catthehacker/ubuntu:act-latest
|
|
||||||
needs: determine-hosts
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
hostname: [
|
|
||||||
Development
|
|
||||||
Testing
|
|
||||||
]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v5
|
|
||||||
- uses: https://github.com/cachix/install-nix-action@v31
|
|
||||||
with:
|
|
||||||
nix_path: nixpkgs=channel:nixos-unstable
|
|
||||||
- name: "Build host"
|
|
||||||
run: |
|
|
||||||
nix build ".#nixosConfigurations.${{ matrix.hostname }}.config.system.build.toplevel"
|
|
||||||
|
|
||||||
17
.github/workflows/test.yml
vendored
17
.github/workflows/test.yml
vendored
|
|
@ -1,17 +0,0 @@
|
||||||
name: "Test"
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
push:
|
|
||||||
jobs:
|
|
||||||
tests:
|
|
||||||
if: false
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: catthehacker/ubuntu:act-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v5
|
|
||||||
- uses: https://github.com/cachix/install-nix-action@v31
|
|
||||||
with:
|
|
||||||
nix_path: nixpkgs=channel:nixos-unstable
|
|
||||||
- name: "My custom step"
|
|
||||||
run: nix run nixpkgs#hello
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,2 +1 @@
|
||||||
.idea
|
.idea
|
||||||
result
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
};
|
};
|
||||||
traefik.enable = true;
|
traefik.enable = true;
|
||||||
plex.enable = true;
|
plex.enable = true;
|
||||||
|
solidtime.enable = true;
|
||||||
};
|
};
|
||||||
virtualisation.guest.enable = true;
|
virtualisation.guest.enable = true;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
./homepage
|
./homepage
|
||||||
./jellyfin
|
./jellyfin
|
||||||
./plex
|
./plex
|
||||||
|
./solidtime
|
||||||
./speedtest
|
./speedtest
|
||||||
./technitium-dns
|
./technitium-dns
|
||||||
./traefik
|
./traefik
|
||||||
|
|
|
||||||
278
modules/apps/solidtime/default.nix
Normal file
278
modules/apps/solidtime/default.nix
Normal file
|
|
@ -0,0 +1,278 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.homelab.apps.solidtime;
|
||||||
|
|
||||||
|
networkName = "solidtime";
|
||||||
|
internalNetworkName = "solidtime-internal";
|
||||||
|
proxyNet = config.homelab.apps.traefiik.sharedNetworkName;
|
||||||
|
|
||||||
|
user = "1000:1000";
|
||||||
|
|
||||||
|
# dbExternalPort = ...;
|
||||||
|
dbInternalPort = 5432;
|
||||||
|
|
||||||
|
gotenbergPort = 3000;
|
||||||
|
|
||||||
|
inherit (config.virtualisation.oci-containers) containers;
|
||||||
|
|
||||||
|
solidtimeImageName = "solidtime/solidtime";
|
||||||
|
version = "0.10.0";
|
||||||
|
solidtimeImage = "${solidtimeImageName}:${version}";
|
||||||
|
solidtimeImageFile = pkgs.dockerTools.pullImage {
|
||||||
|
imageName = solidtimeImageName;
|
||||||
|
finalImageTag = version;
|
||||||
|
imageDigest = "sha256:817d3a366ecc39f0473d7154372afa82dd4e6e50c66d70be45804892c8421cbb";
|
||||||
|
sha256 = "sha256-h5aCKaquUF/EVsOHaLOHrn1HAoXZYPhAbJ+e4cmjSA8=";
|
||||||
|
};
|
||||||
|
|
||||||
|
volumes = [
|
||||||
|
"solidtime-storage:/var/www/html/storage"
|
||||||
|
"solidtime-logs:/var/www/html/storage/logs"
|
||||||
|
"solidtime-app:/var/www/html/storage/app"
|
||||||
|
];
|
||||||
|
|
||||||
|
# laravel.env
|
||||||
|
laravelEnv = {
|
||||||
|
APP_NAME = "Solidtime";
|
||||||
|
VITE_APP_NAME = laravelEnv.APP_NAME;
|
||||||
|
APP_ENV = "production";
|
||||||
|
APP_DEBUG = "false";
|
||||||
|
APP_URL = "http://localhost:${toString cfg.port}";
|
||||||
|
APP_FORCE_HTTPS = "false";
|
||||||
|
APP_ENABLE_REGISTRATION = "false";
|
||||||
|
TRUSTED_PROXIES = "0.0.0.0/0,2000:0:0:0:0:0:0:0/3";
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
LOG_CHANNEL = "stderr_daily";
|
||||||
|
LOG_LEVEL = "debug";
|
||||||
|
|
||||||
|
# Database
|
||||||
|
DB_CONNECTION = "pgsql";
|
||||||
|
DB_HOST = containers.solidtimeDb.hostname;
|
||||||
|
DB_PORT = toString dbInternalPort;
|
||||||
|
DB_SSL_MODE = "require";
|
||||||
|
DB_DATABASE = "solidtime";
|
||||||
|
DB_USERNAME = "solidtime";
|
||||||
|
DB_PASSWORD = "ChangeMe";
|
||||||
|
|
||||||
|
# Mail
|
||||||
|
#MAIL_MAILER = "smtp";
|
||||||
|
#MAIL_HOST = "smtp.gmail.com";
|
||||||
|
#MAIL_PORT = "465";
|
||||||
|
#MAIL_ENCRYPTION = "tls";
|
||||||
|
#MAIL_FROM_ADDRESS = "no-reply@time.depeuter.dev";
|
||||||
|
MAIL_FROM_NAME = laravelEnv.APP_NAME;
|
||||||
|
#MAIL_USERNAME = "kmtl.hugo@gmail.com";
|
||||||
|
#MAIL_PASSWORD = "fhfxoequhhqidrhd";
|
||||||
|
|
||||||
|
# Queue
|
||||||
|
QUEUE_CONNECTION = "database";
|
||||||
|
|
||||||
|
# File storage
|
||||||
|
FILESYSTEM_DISK = "local";
|
||||||
|
PUBLIC_FILESYSTEM_DISK = "public";
|
||||||
|
|
||||||
|
# Services
|
||||||
|
GOTENBERG_URL = "http://${containers.solidtimeGotenberg.hostname}:${toString gotenbergPort}";
|
||||||
|
};
|
||||||
|
|
||||||
|
in {
|
||||||
|
options.homelab.apps.solidtime = {
|
||||||
|
enable = lib.mkEnableOption "Solidtime time tracker using Docker";
|
||||||
|
port = lib.mkOption {
|
||||||
|
type = lib.types.int;
|
||||||
|
default = 8000;
|
||||||
|
description = "Solidtime WebUI port";
|
||||||
|
};
|
||||||
|
exposePort = lib.mkEnableOption "Expose Soldtime port";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
homelab.virtualisation.containers.enable = true;
|
||||||
|
|
||||||
|
# Make sure the Docker network exists.
|
||||||
|
systemd.services = {
|
||||||
|
"docker-${networkName}-create-network" = {
|
||||||
|
description = "Create Docker network for ${networkName}";
|
||||||
|
requiredBy = [
|
||||||
|
"${containers.solidtime.serviceName}.service"
|
||||||
|
];
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
RemainAfterExit = true;
|
||||||
|
};
|
||||||
|
script = ''
|
||||||
|
if ! ${pkgs.docker}/bin/docker network ls | grep -q ${networkName}; then
|
||||||
|
${pkgs.docker}/bin/docker network create ${networkName}
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
"docker-${internalNetworkName}-create-network" = {
|
||||||
|
description = "Create Docker network for ${internalNetworkName}";
|
||||||
|
requiredBy = [
|
||||||
|
"${containers.solidtime.serviceName}.service"
|
||||||
|
"${containers.solidtimeScheduler.serviceName}.service"
|
||||||
|
"${containers.solidtimeQueue.serviceName}.service"
|
||||||
|
"${containers.solidtimeDb.serviceName}.service"
|
||||||
|
"${containers.solidtimeGotenberg.serviceName}.service"
|
||||||
|
];
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
RemainAfterExit = true;
|
||||||
|
};
|
||||||
|
script = ''
|
||||||
|
if ! ${pkgs.docker}/bin/docker network ls | grep -q ${internalNetworkName}; then
|
||||||
|
${pkgs.docker}/bin/docker network create ${internalNetworkName}
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
virtualisation.oci-containers.containers = {
|
||||||
|
solidtime = {
|
||||||
|
hostname = "solidtime";
|
||||||
|
image = solidtimeImage;
|
||||||
|
imageFile = solidtimeImageFile;
|
||||||
|
inherit user;
|
||||||
|
autoStart = true;
|
||||||
|
dependsOn = [
|
||||||
|
"solidtimeDb"
|
||||||
|
];
|
||||||
|
ports = [
|
||||||
|
# Open ports if you don't use Traefik
|
||||||
|
"${toString cfg.port}:8000"
|
||||||
|
];
|
||||||
|
networks = [
|
||||||
|
networkName
|
||||||
|
internalNetworkName
|
||||||
|
];
|
||||||
|
extraOptions = [
|
||||||
|
# Healthecks
|
||||||
|
# test: [ "CMD", "curl", "--fail", "http://localhost:8000/health-check/up" ]
|
||||||
|
''--health-cmd=curl --fail http://localhost:8000/health-check/up''
|
||||||
|
];
|
||||||
|
inherit volumes;
|
||||||
|
labels = {
|
||||||
|
"traefik.enable" = "true";
|
||||||
|
"traefik.http.routers.solidtime.rule" = "Host(`time.${config.networking.hostName}.depeuter.dev`)";
|
||||||
|
"traefik.http.services.solidtime.loadbalancer.server.port" = toString cfg.port;
|
||||||
|
};
|
||||||
|
environmentFiles = [
|
||||||
|
"/home/admin/.solidtime.env"
|
||||||
|
];
|
||||||
|
environment = laravelEnv // {
|
||||||
|
CONTAINER_MODE = "http";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
solidtimeScheduler = {
|
||||||
|
hostname = "scheduler";
|
||||||
|
image = solidtimeImage;
|
||||||
|
imageFile = solidtimeImageFile;
|
||||||
|
inherit user;
|
||||||
|
autoStart = true;
|
||||||
|
dependsOn = [
|
||||||
|
"solidtimeDb"
|
||||||
|
];
|
||||||
|
networks = [
|
||||||
|
internalNetworkName
|
||||||
|
];
|
||||||
|
extraOptions = [
|
||||||
|
# Healthchecks
|
||||||
|
# test: [ "CMD", "healthcheck" ]
|
||||||
|
''--health-cmd="healthcheck"''
|
||||||
|
];
|
||||||
|
inherit volumes;
|
||||||
|
environmentFiles = [
|
||||||
|
"/home/admin/.solidtime.env"
|
||||||
|
];
|
||||||
|
environment = laravelEnv // {
|
||||||
|
CONTAINER_MODE = "scheduler";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
solidtimeQueue = {
|
||||||
|
hostname = "queue";
|
||||||
|
image = solidtimeImage;
|
||||||
|
imageFile = solidtimeImageFile;
|
||||||
|
inherit user;
|
||||||
|
autoStart = true;
|
||||||
|
networks = [
|
||||||
|
internalNetworkName
|
||||||
|
];
|
||||||
|
extraOptions = [
|
||||||
|
# Healthchecks
|
||||||
|
# test: [ "CMD", "healthcheck" ]
|
||||||
|
''--health-cmd="healthcheck"''
|
||||||
|
];
|
||||||
|
inherit volumes;
|
||||||
|
dependsOn = [
|
||||||
|
"solidtimeDb"
|
||||||
|
];
|
||||||
|
environmentFiles = [
|
||||||
|
"/home/admin/.solidtime.env"
|
||||||
|
];
|
||||||
|
environment = laravelEnv // {
|
||||||
|
CONTAINER_MODE = "worker";
|
||||||
|
WORKER_COMMAND = "php /var/www/html/artisan queue:work";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
solidtimeDb = let
|
||||||
|
imageName = "postgres";
|
||||||
|
finalImageTag = "15";
|
||||||
|
in {
|
||||||
|
hostname = "database";
|
||||||
|
image = "${imageName}:${finalImageTag}";
|
||||||
|
imageFile = pkgs.dockerTools.pullImage {
|
||||||
|
inherit imageName finalImageTag;
|
||||||
|
imageDigest = "sha256:98fe06b500b5eb29e45bf8c073eb0ca399790ce17b1d586448edc4203627d342";
|
||||||
|
sha256 = "sha256-AZ4VkOlROX+nR/MjDjsA4xdHzmtKjiBAtsp2Q6IdOvg=";
|
||||||
|
};
|
||||||
|
autoStart = true;
|
||||||
|
ports = [
|
||||||
|
# "${toString dbExternalPort}:${toString dbInternalPort}"
|
||||||
|
];
|
||||||
|
networks = [
|
||||||
|
internalNetworkName
|
||||||
|
];
|
||||||
|
extraOptions = [
|
||||||
|
# Healthchecks
|
||||||
|
# test: - CMD - pg_isready - '-q' - '-d' - '${DB_DATABASE}' - '-U' - '${DB_USERNAME}' retries: 3 timeout: 5s
|
||||||
|
''--health-cmd="pg_isready -q -d ${laravelEnv.DB_DATABASE} -U ${laravelEnv.DB_USERNAME}"''
|
||||||
|
"--health-retries=3"
|
||||||
|
"--health-timeout=5s"
|
||||||
|
];
|
||||||
|
volumes = [
|
||||||
|
"solidtime-db:/var/lib/postgresql/data"
|
||||||
|
];
|
||||||
|
environment = {
|
||||||
|
PGPASSWORD = laravelEnv.DB_PASSWORD;
|
||||||
|
POSTGRES_DB = laravelEnv.DB_DATABASE;
|
||||||
|
POSTGRES_USER = laravelEnv.DB_USERNAME;
|
||||||
|
POSTGRES_PASSWORD = laravelEnv.DB_PASSWORD;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
solidtimeGotenberg = let
|
||||||
|
imageName = "gotenberg/gotenberg";
|
||||||
|
finalImageTag = "8.26.0";
|
||||||
|
in {
|
||||||
|
hostname = "gotenberg";
|
||||||
|
image = "${imageName}:${finalImageTag}";
|
||||||
|
imageFile = pkgs.dockerTools.pullImage {
|
||||||
|
inherit imageName finalImageTag;
|
||||||
|
imageDigest = "sha256:328551506b3dec3ff6381dd47e5cd72a44def97506908269e201a8fbfa1c12c0";
|
||||||
|
sha256 = "sha256-1zz4xDAgXxHUnkCVIfjHTgXb82EFEx+5am6Cu9+eZj4=";
|
||||||
|
};
|
||||||
|
autoStart = true;
|
||||||
|
networks = [
|
||||||
|
internalNetworkName
|
||||||
|
];
|
||||||
|
extraOptions = [
|
||||||
|
# Healthchecks
|
||||||
|
# test: [ "CMD", "curl", "--silent", "--fail", "http://localhost:3000/health" ]
|
||||||
|
''--health-cmd="curl --silent --fail http://localhost:${toString gotenbergPort}/health"''
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue