diff options
| author | Christian Krinitsin <mail@krinitsin.com> | 2025-04-21 20:41:13 +0200 |
|---|---|---|
| committer | Christian Krinitsin <mail@krinitsin.com> | 2025-04-21 20:41:13 +0200 |
| commit | b93fc1d7a5bc15bdeb3f6fe1899f46db4dcc4de2 (patch) | |
| tree | ad9278d473adb0ede6c977a42c7483082c9b7254 | |
| parent | 6d0d5aa759aad5b607674b29b830994cefb1ef8f (diff) | |
| download | nosix-b93fc1d7a5bc15bdeb3f6fe1899f46db4dcc4de2.tar.gz nosix-b93fc1d7a5bc15bdeb3f6fe1899f46db4dcc4de2.zip | |
add own shopping-list service, written in go
| -rw-r--r-- | modules/shopping-list.nix | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/modules/shopping-list.nix b/modules/shopping-list.nix new file mode 100644 index 0000000..8c25316 --- /dev/null +++ b/modules/shopping-list.nix @@ -0,0 +1,63 @@ +{ config, pkgs, lib, ... }: + +let + shopping-list = pkgs.buildGoModule rec { + pname = "shopping-list"; + version = "0.1"; + + src = pkgs.fetchFromGitHub { + owner = "ckrinitsin"; + repo = "shopping-list"; + rev = "1e974f70a6c262d0b5db8b177ebb02b46446bfb0"; + hash = "sha256-QtLOYo7shRoBpExUh4zvkroEjcmfqStRXELQqeAcMs8="; + }; + + vendorHash = "sha256-Q8UzufKbUMnpduciwu9uyHq8WpjgSQWmcJGVdlxs0kk="; + }; + + port = 10000; + base_path = "/shopping/"; +in +{ + environment.systemPackages = [ + shopping-list + ]; + + systemd.services.shopping-list = { + description = "shopping-list"; + wantedBy = [ "multi-user.target" ]; + environment = { + GIN_MODE = "release"; + PORT = "${toString port}"; + BASE_PATH = "${base_path}"; + }; + + serviceConfig = { + ExecStart = "${shopping-list}/bin/shopping-list"; + WorkingDirectory = "/var/lib/shopping-list/"; + Restart = "always"; + User = "shopping-list"; + }; + + }; + + # Create the system user for the service + users.users.shopping-list = { + isSystemUser = true; + group = "shopping-list"; + }; + users.groups.shopping-list = {}; + + services.nginx = { + virtualHosts = { + "krinitsin.com" = { + locations.${base_path} = { + basicAuthFile = "/secret/shopping_auth"; + proxyPass = "http://localhost:${toString port}/"; + recommendedProxySettings = true; + }; + }; + }; + }; +} + |