From d12ca3fb0ed3aec53c822566bcefe8f00a65f2ac Mon Sep 17 00:00:00 2001 From: Richie Cahill Date: Sat, 3 Aug 2024 13:26:50 -0400 Subject: [PATCH] create arch_mirror.nix --- .vscode/settings.json | 11 ++ flake.lock | 158 ++++++++++++++++++++++++++-- flake.nix | 5 + systems/jeeves-jr/arch_mirror.nix | 29 +++++ systems/jeeves-jr/configuration.nix | 1 + systems/jeeves-jr/docker/web.nix | 13 --- systems/jeeves/arch_mirror.nix | 29 +++++ systems/jeeves/configuration.nix | 1 + systems/jeeves/docker/web.nix | 10 -- users/richie/home/programs.nix | 1 + 10 files changed, 227 insertions(+), 31 deletions(-) create mode 100644 systems/jeeves-jr/arch_mirror.nix create mode 100644 systems/jeeves/arch_mirror.nix diff --git a/.vscode/settings.json b/.vscode/settings.json index edc48c7..c7bc55b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,6 +12,7 @@ "alsa", "amdgpu", "amdvlk", + "archlinux", "artemision", "asrouter", "auditd", @@ -48,6 +49,7 @@ "datareporting", "davidanson", "dbus", + "deadnix", "dearrow", "debugpy", "devicemap", @@ -114,10 +116,15 @@ "KRNL", "kuma", "libexec", + "libglvnd", + "libmysqlclient", + "libsodium", + "libssh", "libvirtd", "localtime", "LOGG", "louislam", + "lsdir", "lsnew", "luks", "lynis", @@ -153,9 +160,11 @@ "oderwat", "oneshot", "openpgp", + "opensearch", "optimumwifi", "optoutstudies", "overscroll", + "oxalica", "pavucontrol", "pbmode", "pciutils", @@ -214,6 +223,7 @@ "spotifyd", "sqltools", "sshconfig", + "stdenv", "subresource", "substituters", "supermaven", @@ -262,6 +272,7 @@ "zerotierone", "zhaofengli", "zoxide", + "zstd", "ztkubnet" ] } diff --git a/flake.lock b/flake.lock index ed5e373..3c29e3f 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,27 @@ { "nodes": { + "arch_mirror": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ], + "poetry2nix": "poetry2nix" + }, + "locked": { + "lastModified": 1722704786, + "narHash": "sha256-M9ejTqXVtcXJt4oM6wa+NMSjBJX8KYrqjr0XxFWqV0o=", + "owner": "RichieCahill", + "repo": "arch_mirror", + "rev": "fcef4d3b95267e67cfaf1733a062d5cc7a82362c", + "type": "github" + }, + "original": { + "owner": "RichieCahill", + "repo": "arch_mirror", + "type": "github" + } + }, "attic": { "inputs": { "crane": "crane", @@ -130,6 +152,24 @@ } }, "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { "inputs": { "systems": [ "systems" @@ -149,9 +189,9 @@ "type": "github" } }, - "flake-utils_2": { + "flake-utils_3": { "inputs": { - "systems": "systems" + "systems": "systems_3" }, "locked": { "lastModified": 1710146030, @@ -277,6 +317,28 @@ } }, "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "arch_mirror", + "poetry2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1703863825, + "narHash": "sha256-rXwqjtwiGKJheXB43ybM8NwWB8rO2dSRrEqes0S7F5Y=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "5163432afc817cf8bd1f031418d1869e4c9d5547", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, + "nix-github-actions_2": { "inputs": { "nixpkgs": [ "server_tools", @@ -456,17 +518,45 @@ "poetry2nix": { "inputs": { "flake-utils": [ - "server_tools", + "arch_mirror", "flake-utils" ], "nix-github-actions": "nix-github-actions", "nixpkgs": [ - "server_tools", + "arch_mirror", "nixpkgs" ], "systems": "systems_2", "treefmt-nix": "treefmt-nix" }, + "locked": { + "lastModified": 1722515463, + "narHash": "sha256-6FVPz1WzHak65xJQg8tRjVyFEWMesGxfskKaCxDUnRk=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "8c25e871bba3f472e1569bbf6c0f52dcc34bf2a4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "poetry2nix", + "type": "github" + } + }, + "poetry2nix_2": { + "inputs": { + "flake-utils": [ + "server_tools", + "flake-utils" + ], + "nix-github-actions": "nix-github-actions_2", + "nixpkgs": [ + "server_tools", + "nixpkgs" + ], + "systems": "systems_4", + "treefmt-nix": "treefmt-nix_2" + }, "locked": { "lastModified": 1721039874, "narHash": "sha256-XANsG9GYHip8pxZpbqKf/YGv8tIa0xTh289Y+WNBNfw=", @@ -510,12 +600,13 @@ }, "root": { "inputs": { + "arch_mirror": "arch_mirror", "attic": "attic", "fenix": "fenix", "firefox-addons": "firefox-addons", "flake-compat": "flake-compat", "flake-parts": "flake-parts", - "flake-utils": "flake-utils", + "flake-utils": "flake-utils_2", "home-manager": "home-manager", "hyprland-contrib": "hyprland-contrib", "nix": "nix", @@ -529,7 +620,7 @@ "rust-overlay": "rust-overlay", "server_tools": "server_tools", "sops-nix": "sops-nix", - "systems": "systems_3", + "systems": "systems_5", "wired-notify": "wired-notify" } }, @@ -597,11 +688,11 @@ }, "server_tools": { "inputs": { - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils_3", "nixpkgs": [ "nixpkgs" ], - "poetry2nix": "poetry2nix" + "poetry2nix": "poetry2nix_2" }, "locked": { "lastModified": 1722039234, @@ -684,7 +775,58 @@ "type": "github" } }, + "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "id": "systems", + "type": "indirect" + } + }, + "systems_5": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "arch_mirror", + "poetry2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1719749022, + "narHash": "sha256-ddPKHcqaKCIFSFc/cvxS14goUhCOAwsM1PbMr0ZtHMg=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "8df5ff62195d4e67e2264df0b7f5e8c9995fd0bd", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, + "treefmt-nix_2": { "inputs": { "nixpkgs": [ "server_tools", diff --git a/flake.nix b/flake.nix index d9ca153..46cbae4 100644 --- a/flake.nix +++ b/flake.nix @@ -29,6 +29,11 @@ nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.05"; systems.url = "github:nix-systems/default"; + arch_mirror = { + url = "github:RichieCahill/arch_mirror"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + attic = { url = "github:zhaofengli/attic"; inputs = { diff --git a/systems/jeeves-jr/arch_mirror.nix b/systems/jeeves-jr/arch_mirror.nix new file mode 100644 index 0000000..32b5be8 --- /dev/null +++ b/systems/jeeves-jr/arch_mirror.nix @@ -0,0 +1,29 @@ +{ inputs, pkgs, ... }: +let + vars = import ./vars.nix; +in +{ + virtualisation.oci-containers.containers.arch_mirror = { + image = "ubuntu/apache2:latest"; + volumes = [ + "${../../users/richie/global/docker_templates}/file_server/sites/:/etc/apache2/sites-enabled/" + "${vars.main_mirror}:/data" + ]; + ports = [ "800:80" ]; + extraOptions = [ "--network=web" ]; + autoStart = true; + }; + + systemd.services.sync_mirror = { + requires = [ "network-online.target" ]; + after = [ "network-online.target" ]; + wantedBy = [ "multi-user.target" ]; + description = "validates startup"; + path = [ pkgs.rsync ]; + serviceConfig = { + Environment = "MIRROR_DIR=${vars.main_mirror}/archlinux/"; + Type = "simple"; + ExecStart = "${inputs.arch_mirror.packages.x86_64-linux.default}/bin/sync_mirror"; + }; + }; +} diff --git a/systems/jeeves-jr/configuration.nix b/systems/jeeves-jr/configuration.nix index 935acf6..efa8bb8 100644 --- a/systems/jeeves-jr/configuration.nix +++ b/systems/jeeves-jr/configuration.nix @@ -3,6 +3,7 @@ imports = [ ../../users/richie/global/ssh.nix ../../users/richie/global/zerotier.nix + ./arch_mirror.nix ./docker ./services.nix ]; diff --git a/systems/jeeves-jr/docker/web.nix b/systems/jeeves-jr/docker/web.nix index 631121c..c518459 100644 --- a/systems/jeeves-jr/docker/web.nix +++ b/systems/jeeves-jr/docker/web.nix @@ -1,19 +1,6 @@ { config, ... }: -let - vars = import ../vars.nix; -in { virtualisation.oci-containers.containers = { - arch_mirror = { - image = "ubuntu/apache2:latest"; - volumes = [ - "${../../../users/richie/global/docker_templates}/file_server/sites/:/etc/apache2/sites-enabled/" - "${vars.main_mirror}:/data" - ]; - ports = [ "800:80" ]; - extraOptions = [ "--network=web" ]; - autoStart = true; - }; haproxy = { image = "haproxy:latest"; user = "600:600"; diff --git a/systems/jeeves/arch_mirror.nix b/systems/jeeves/arch_mirror.nix new file mode 100644 index 0000000..cb96e05 --- /dev/null +++ b/systems/jeeves/arch_mirror.nix @@ -0,0 +1,29 @@ +{ inputs, pkgs, ... }: +let + vars = import ./vars.nix; +in +{ + virtualisation.oci-containers.containers.arch_mirror = { + image = "ubuntu/apache2:latest"; + volumes = [ + "${../../users/richie/global/docker_templates}/file_server/sites/:/etc/apache2/sites-enabled/" + "${vars.media_mirror}:/data" + ]; + ports = [ "800:80" ]; + extraOptions = [ "--network=web" ]; + autoStart = true; + }; + + systemd.services.sync_mirror = { + requires = [ "network-online.target" ]; + after = [ "network-online.target" ]; + wantedBy = [ "multi-user.target" ]; + description = "validates startup"; + path = [ pkgs.rsync ]; + serviceConfig = { + Environment = "MIRROR_DIR=${vars.media_mirror}/archlinux/"; + Type = "simple"; + ExecStart = "${inputs.arch_mirror.packages.x86_64-linux.default}/bin/sync_mirror"; + }; + }; +} diff --git a/systems/jeeves/configuration.nix b/systems/jeeves/configuration.nix index b6b1d88..9564cc2 100644 --- a/systems/jeeves/configuration.nix +++ b/systems/jeeves/configuration.nix @@ -7,6 +7,7 @@ in ../../users/richie/global/ssh.nix ../../users/richie/global/syncthing_base.nix ../../users/richie/global/zerotier.nix + ./arch_mirror.nix ./docker ./programs.nix ./services.nix diff --git a/systems/jeeves/docker/web.nix b/systems/jeeves/docker/web.nix index ed8ce3a..1ba62ef 100644 --- a/systems/jeeves/docker/web.nix +++ b/systems/jeeves/docker/web.nix @@ -20,16 +20,6 @@ in extraOptions = [ "--network=web" ]; autoStart = true; }; - arch_mirror = { - image = "ubuntu/apache2:latest"; - volumes = [ - "${../../../users/richie/global/docker_templates}/file_server/sites/:/etc/apache2/sites-enabled/" - "${vars.media_mirror}:/data" - ]; - ports = [ "800:80" ]; - extraOptions = [ "--network=web" ]; - autoStart = true; - }; haproxy = { image = "haproxy:latest"; user = "600:600"; diff --git a/users/richie/home/programs.nix b/users/richie/home/programs.nix index c48fdd9..a049c80 100644 --- a/users/richie/home/programs.nix +++ b/users/richie/home/programs.nix @@ -44,5 +44,6 @@ nix-tree nixpkgs-fmt inputs.server_tools.packages.x86_64-linux.default + inputs.arch_mirror.packages.x86_64-linux.default ]; }