summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--modules/by-name/ba/back/module.nix17
-rw-r--r--pkgs/by-name/ba/back/contrib/config.json.license10
-rw-r--r--pkgs/by-name/ba/back/src/cli.rs11
-rw-r--r--pkgs/by-name/ba/back/src/config/mod.rs11
-rw-r--r--pkgs/by-name/ba/back/src/main.rs13
5 files changed, 59 insertions, 3 deletions
diff --git a/modules/by-name/ba/back/module.nix b/modules/by-name/ba/back/module.nix
index 2bc5159..2ff0768 100644
--- a/modules/by-name/ba/back/module.nix
+++ b/modules/by-name/ba/back/module.nix
@@ -2,10 +2,18 @@
   config,
   lib,
   vhackPackages,
+  pkgs,
   ...
 }: let
   cfg = config.vhack.back;
 
+  mkConfigFile = repoPath:
+    (pkgs.formats.json {}).generate "config.json"
+    {
+      inherit (cfg) source_code_repository_url;
+      repository_path = repoPath;
+    };
+
   mkUnit = repoPath: port: {
     description = "Back service for ${repoPath}";
     wants = ["network-online.target"];
@@ -14,11 +22,10 @@
 
     environment = {
       ROCKET_PORT = builtins.toString port;
-      BACK_SOURCE_CODE_REPOSITORY_URL = "https://git.vhack.eu/vhack.eu/nixos-server/tree/pkgs/by-name/ba/back";
     };
 
     serviceConfig = {
-      ExecStart = "${lib.getExe vhackPackages.back} ${lib.strings.escapeShellArg repoPath}";
+      ExecStart = "${lib.getExe vhackPackages.back} ${mkConfigFile repoPath}";
 
       # Ensure that the service can read the repository
       # FIXME(@bpeetz): This has the implied assumption, that all the exposed git
@@ -78,6 +85,12 @@ in {
   options.vhack.back = {
     enable = lib.mkEnableOption "Back issue tracker (inspired by tvix's panettone)";
 
+    source_code_repository_url = lib.mkOption {
+      description = "The url to the source code of this instance of back";
+      default = "https://git.foss-syndicate.org/vhack.eu/nixos-server/tree/pkgs/by-name/ba/back";
+      type = lib.types.str;
+    };
+
     repositories = lib.mkOption {
       description = "An attibute set of repos to launch `back` services for.";
       type = lib.types.attrsOf (lib.types.submodule {
diff --git a/pkgs/by-name/ba/back/contrib/config.json.license b/pkgs/by-name/ba/back/contrib/config.json.license
new file mode 100644
index 0000000..9c92e8d
--- /dev/null
+++ b/pkgs/by-name/ba/back/contrib/config.json.license
@@ -0,0 +1,10 @@
+Back - An extremely simple git issue tracking system. Inspired by tvix's
+panettone
+
+Copyright (C) 2024 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+SPDX-License-Identifier: AGPL-3.0-or-later
+
+This file is part of Back.
+
+You should have received a copy of the License along with this program.
+If not, see <https://www.gnu.org/licenses/agpl.txt>.
diff --git a/pkgs/by-name/ba/back/src/cli.rs b/pkgs/by-name/ba/back/src/cli.rs
index 1820bf3..79f0d63 100644
--- a/pkgs/by-name/ba/back/src/cli.rs
+++ b/pkgs/by-name/ba/back/src/cli.rs
@@ -1,3 +1,14 @@
+// Back - An extremely simple git issue tracking system. Inspired by tvix's
+// panettone
+//
+// Copyright (C) 2024 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+// SPDX-License-Identifier: AGPL-3.0-or-later
+//
+// This file is part of Back.
+//
+// You should have received a copy of the License along with this program.
+// If not, see <https://www.gnu.org/licenses/agpl.txt>.
+
 use std::path::PathBuf;
 
 use clap::Parser;
diff --git a/pkgs/by-name/ba/back/src/config/mod.rs b/pkgs/by-name/ba/back/src/config/mod.rs
index 4986a41..a680b90 100644
--- a/pkgs/by-name/ba/back/src/config/mod.rs
+++ b/pkgs/by-name/ba/back/src/config/mod.rs
@@ -1,3 +1,14 @@
+// Back - An extremely simple git issue tracking system. Inspired by tvix's
+// panettone
+//
+// Copyright (C) 2024 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+// SPDX-License-Identifier: AGPL-3.0-or-later
+//
+// This file is part of Back.
+//
+// You should have received a copy of the License along with this program.
+// If not, see <https://www.gnu.org/licenses/agpl.txt>.
+
 use std::{
     fs,
     path::{Path, PathBuf},
diff --git a/pkgs/by-name/ba/back/src/main.rs b/pkgs/by-name/ba/back/src/main.rs
index 009bdb6..b75737a 100644
--- a/pkgs/by-name/ba/back/src/main.rs
+++ b/pkgs/by-name/ba/back/src/main.rs
@@ -9,6 +9,8 @@
 // You should have received a copy of the License along with this program.
 // If not, see <https://www.gnu.org/licenses/agpl.txt>.
 
+use std::process;
+
 use clap::Parser;
 use config::BackConfig;
 use rocket::routes;
@@ -21,8 +23,17 @@ mod error;
 pub mod git_bug;
 mod web;
 
+fn main() -> Result<(), String> {
+    if let Err(err) = rocket_main() {
+        eprintln!("Error {err}");
+        process::exit(1);
+    } else {
+        Ok(())
+    }
+}
+
 #[rocket::main]
-async fn main() -> Result<(), error::Error> {
+async fn rocket_main() -> Result<(), error::Error> {
     let args = cli::Cli::parse();
 
     let config = BackConfig::from_config_file(&args.config_file)?;