feat: adding a license for pushing to repo
This commit is contained in:
parent
59c3b1ce59
commit
ea8d1fab75
|
@ -0,0 +1,8 @@
|
|||
The MIT License (MIT) Copyright (c) 2023 - present, Efim Nefedov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
|
@ -175,6 +175,7 @@ oh, but if i'm using nginx i'll need my own certificate, that makes sence
|
|||
*** maybe things are ok?
|
||||
let's try to plaintext deploy?
|
||||
|
||||
|
||||
** TODO add docker image from nix
|
||||
*** TODO add cli for port and host
|
||||
** TODO add readme and comments
|
||||
|
|
47
flake.nix
47
flake.nix
|
@ -42,8 +42,8 @@
|
|||
nixosModules.auth-pocketbase-attempt = { config, pkgs, ... }:
|
||||
let
|
||||
cfg = config.services.${pname};
|
||||
lib = pkgs.lib;
|
||||
shortName = "pb-auth-example-group";
|
||||
lib = nixpkgs.lib;
|
||||
shortName = "pb-auth-example-app";
|
||||
in {
|
||||
options.services.${pname} = {
|
||||
enable = lib.mkEnableOption
|
||||
|
@ -71,16 +71,20 @@
|
|||
"Whether pocketbase should serve on https and issue own certs. Main case for true - when not under nginx";
|
||||
};
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
users.groups."${shortName}-group" = { };
|
||||
users.users."${shortName}-user" = {
|
||||
isSystemUser = true;
|
||||
group = "${shortName}-group";
|
||||
config = let
|
||||
username = "${shortName}-user";
|
||||
groupname = "${shortName}-group";
|
||||
in lib.mkIf cfg.enable {
|
||||
users.groups."${groupname}" = { };
|
||||
users.users."${username}" = {
|
||||
isNormalUser = true; # needed to allow for home dir
|
||||
group = "${groupname}";
|
||||
};
|
||||
systemd.services.${shortName} = let
|
||||
protocol = if cfg.usePbTls then "https" else "http";
|
||||
serverHost = if cfg.useNginx then "127.0.0.1" else cfg.host;
|
||||
servedAddress = "${protocol}://${serverHost}:${cfg.port}";
|
||||
serveCliArg =
|
||||
"--${protocol} ${serverHost}:${toString cfg.port}";
|
||||
in {
|
||||
description = "Exercise app ${pname}";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
@ -89,12 +93,31 @@
|
|||
startLimitBurst = 10;
|
||||
serviceConfig = {
|
||||
ExecStart =
|
||||
"${packages.auth-pocketbase-attempt}/bin/${pname} serve ${servedAddress} --dir=/home/${
|
||||
config.users.users."${shortName}-user"
|
||||
"${packages.auth-pocketbase-attempt}/bin/${pname} serve ${serveCliArg} --dir=/home/${
|
||||
"${username}"
|
||||
}";
|
||||
Restart = "on-failure";
|
||||
User = "${shortName}-user";
|
||||
Group = "${shortName}-group";
|
||||
User = "${username}";
|
||||
Group = "${groupname}";
|
||||
};
|
||||
};
|
||||
services.nginx = lib.mkIf cfg.useNginx {
|
||||
virtualHosts.${cfg.host}.locations."/" = {
|
||||
proxyPass =
|
||||
"http://127.0.0.1:${toString cfg.port}";
|
||||
# taken from https://pocketbase.io/docs/going-to-production/
|
||||
extraConfig = ''
|
||||
# check http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive
|
||||
proxy_set_header Connection ''';
|
||||
proxy_http_version 1.1;
|
||||
proxy_read_timeout 360s;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
'';
|
||||
# TODO doesn't include tls sadly
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue