home lab init
This commit is contained in:
commit
7278922625
65 changed files with 27336 additions and 0 deletions
77
nixos/modules/docker-host.nix
Normal file
77
nixos/modules/docker-host.nix
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
# ── Adjust these to your NAS settings ──────────────────────────────────────────
|
||||
nasServer = "192.168.1.100"; # your NAS IP or hostname
|
||||
nasExportPath = "/export/docker-volumes"; # path on the NAS
|
||||
nasMountPoint = "/mnt/nas"; # where to mount inside VM
|
||||
|
||||
# ── Where we drop your Compose file and run it ────────────────────────────────
|
||||
composeDir = "/etc/docker-compose-app";
|
||||
composeText = lib.readFile ./docker-compose.yml;
|
||||
in {
|
||||
##############################################################################
|
||||
# A) NETWORKING
|
||||
# (If you want DHCP, remove this block and let cloud-init assign an IP.)
|
||||
##############################################################################
|
||||
# networking.interfaces.enp0s25 = {
|
||||
# useDHCP = false;
|
||||
# ipv4.addresses = [{
|
||||
# address = "192.168.1.50";
|
||||
# prefixLength = 24;
|
||||
# }];
|
||||
# ipv4.gateway = "192.168.1.1";
|
||||
# # optional: ipv4.dns = [ "1.1.1.1" "8.8.8.8" ];
|
||||
# };
|
||||
|
||||
##############################################################################
|
||||
# B) MOUNT YOUR NAS VIA NFS
|
||||
##############################################################################
|
||||
# fileSystems."${nasMountPoint}" = {
|
||||
# device = "${nasServer}:${nasExportPath}";
|
||||
# fsType = "nfs";
|
||||
# options = [ "defaults" "nofail" "x-systemd.requires=network-online.target" ];
|
||||
# };
|
||||
# fileSystems."${nasMountPoint}".requiredForBoot = false;
|
||||
|
||||
##############################################################################
|
||||
# C) INSTALL DOCKER & DOCKER-COMPOSE
|
||||
##############################################################################
|
||||
environment.systemPackages = with pkgs; [
|
||||
docker
|
||||
docker-compose
|
||||
];
|
||||
services.docker.enable = true;
|
||||
|
||||
##############################################################################
|
||||
# D) DROP IN YOUR docker-compose.yml
|
||||
##############################################################################
|
||||
# systemd.tmpfiles.rules = [
|
||||
# # Ensure directory exists before we write the file.
|
||||
# "D! ${composeDir} 0755 root root - -"
|
||||
# ];
|
||||
# environment.etc."docker-compose-app/docker-compose.yml".text = composeText;
|
||||
|
||||
##############################################################################
|
||||
# E) RUN DOCKER-COMPOSE AS A SYSTEMD SERVICE
|
||||
##############################################################################
|
||||
# systemd.services.dockerComposeApp = {
|
||||
# description = "Auto-start Docker-Compose stack for home server";
|
||||
# after = [ "network-online.target" "docker.service" ];
|
||||
# wants = [ "network-online.target" "docker.service" ];
|
||||
|
||||
# serviceConfig = {
|
||||
# WorkingDirectory = composeDir;
|
||||
# ExecStart = "${pkgs.docker-compose}/bin/docker-compose -f ${composeDir}/docker-compose.yml up";
|
||||
# ExecStop = "${pkgs.docker-compose}/bin/docker-compose -f ${composeDir}/docker-compose.yml down";
|
||||
# Restart = "always";
|
||||
# RestartSec = 10;
|
||||
# };
|
||||
|
||||
# wantedBy = [ "multi-user.target" ];
|
||||
# };
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue