|
| 1 | +{ |
| 2 | + config, |
| 3 | + lib, |
| 4 | + ... |
| 5 | +}: let |
| 6 | + optionName = "softserve"; |
| 7 | + containerName = "soft-serve"; |
| 8 | + cfg = config.meadow.stacks.${optionName}; |
| 9 | + storage = "${config.meadow.stacks.storageBaseDir}/${containerName}"; |
| 10 | +in { |
| 11 | + options.meadow.stacks.${optionName} = { |
| 12 | + enable = lib.mkEnableOption containerName; |
| 13 | + repos = lib.mkOption { |
| 14 | + type = lib.types.attrsOf lib.types.str; |
| 15 | + default = {}; |
| 16 | + description = "Repositories to mirror into Soft Serve (name = clone URL)."; |
| 17 | + }; |
| 18 | + initialAdminPublicKey = lib.mkOption { |
| 19 | + type = lib.types.nullOr lib.types.str; |
| 20 | + default = null; |
| 21 | + description = "SSH public key used for Soft Serve first-run admin bootstrap."; |
| 22 | + }; |
| 23 | + initialAdminPublicKeyFile = lib.mkOption { |
| 24 | + type = lib.types.nullOr lib.types.str; |
| 25 | + default = null; |
| 26 | + description = "Path to SSH public key file for Soft Serve first-run admin bootstrap."; |
| 27 | + }; |
| 28 | + syncInterval = lib.mkOption { |
| 29 | + type = lib.types.str; |
| 30 | + default = "30m"; |
| 31 | + description = "How often to sync public GitHub repositories into Soft Serve."; |
| 32 | + }; |
| 33 | + }; |
| 34 | + |
| 35 | + config = lib.mkIf cfg.enable { |
| 36 | + services.podman.containers.${containerName} = { |
| 37 | + image = "docker.io/charmcli/soft-serve:latest"; |
| 38 | + volumes = [ |
| 39 | + "${storage}/data:/data" |
| 40 | + ] ++ lib.optional (cfg.initialAdminPublicKeyFile != null) "${cfg.initialAdminPublicKeyFile}:/tmp/initial_admin_key.pub:ro"; |
| 41 | + ports = ["22:23231"]; |
| 42 | + environment = |
| 43 | + { |
| 44 | + SOFT_SERVE_DATA_PATH = "/data"; |
| 45 | + } |
| 46 | + // lib.optionalAttrs (cfg.initialAdminPublicKey != null) { |
| 47 | + SOFT_SERVE_INITIAL_ADMIN_KEYS = cfg.initialAdminPublicKey; |
| 48 | + } |
| 49 | + // lib.optionalAttrs (cfg.initialAdminPublicKeyFile != null) { |
| 50 | + SOFT_SERVE_INITIAL_ADMIN_KEYS = "/tmp/initial_admin_key.pub"; |
| 51 | + }; |
| 52 | + stack = containerName; |
| 53 | + homepage = { |
| 54 | + category = "Utilities"; |
| 55 | + name = "Soft Serve"; |
| 56 | + settings = { |
| 57 | + description = "Self-hosted Git over SSH"; |
| 58 | + icon = "github"; |
| 59 | + }; |
| 60 | + }; |
| 61 | + }; |
| 62 | + }; |
| 63 | +} |
0 commit comments