From c50d274ae16c1de8611e020165f7b94b07589223 Mon Sep 17 00:00:00 2001 From: yukkop Date: Thu, 4 Jun 2026 18:58:03 +0000 Subject: [PATCH] feat: `lab`: +attic cache --- nixos/module/hectic/service/attic.nix | 67 +++++++++++++++++++++++++ nixos/system/hectic-lab/attic.nix | 17 +++++++ nixos/system/hectic-lab/hectic-lab.nix | 18 ++++--- nixos/system/hectic-lab/mechabellum.nix | 1 - nixos/system/hectic-lab/sentinèlla.nix | 4 +- 5 files changed, 97 insertions(+), 10 deletions(-) create mode 100644 nixos/module/hectic/service/attic.nix create mode 100644 nixos/system/hectic-lab/attic.nix diff --git a/nixos/module/hectic/service/attic.nix b/nixos/module/hectic/service/attic.nix new file mode 100644 index 00000000..702fd4d0 --- /dev/null +++ b/nixos/module/hectic/service/attic.nix @@ -0,0 +1,67 @@ +{ ... }: { + pkgs, + lib, + config, + ... +}: let + cfg = config.hectic.services.attic; + environmentFile = "/var/lib/atticd/credentials.env"; +in { + options.hectic.services.attic = { + enable = lib.mkEnableOption "Attic binary cache server"; + + hostName = lib.mkOption { + type = lib.types.str; + description = "Public hostname used by clients to reach this Attic server."; + }; + + listenAddress = lib.mkOption { + type = lib.types.str; + default = "127.0.0.1"; + description = "Local address atticd binds to behind the reverse proxy."; + }; + + port = lib.mkOption { + type = lib.types.port; + default = 8080; + description = "Local port atticd binds to behind the reverse proxy."; + }; + + }; + + config = lib.mkIf cfg.enable { + systemd.services.atticd-credentials = { + description = "Generate persistent atticd credentials"; + before = [ "atticd.service" ]; + wantedBy = [ "atticd.service" ]; + serviceConfig = { + Type = "oneshot"; + StateDirectory = "atticd"; + UMask = "0077"; + }; + script = '' + if [ -s ${environmentFile} ]; then + exit 0 + fi + + install -m 0700 -d /var/lib/atticd + secret="$(${lib.getExe pkgs.openssl} genrsa -traditional 4096 | ${pkgs.coreutils}/bin/base64 -w0)" + cat > ${environmentFile} <