diff --git a/assets/favicon.svg b/assets/favicon.svg new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/assets/favicon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/favicon.svg b/favicon.svg new file mode 100644 index 0000000..405ec3c --- /dev/null +++ b/favicon.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/flake.nix b/flake.nix index 8cdf623..1736249 100644 --- a/flake.nix +++ b/flake.nix @@ -16,24 +16,21 @@ ); in { overlay = final: prev: { - fragify = with final; python3Packages.buildPythonApplication { + fragify = with final; python3Packages.buildPythonApplication rec { pname = "fragify"; version = "0.0.1"; format = "other"; src = self; - dependencies = with python3Packages; [ - python - falcon - requests - jinja2 - ]; + dontBuild = true; + + dependencies = with python3Packages; [ falcon requests jinja2 ]; installPhase = '' install -Dm755 ${./fragify.py} $out/bin/fragify mkdir -p $out/share/fragify - cp -r ${./templates} $out/share/fragify/ + cp -r ${./templates} $out/share/fragify/templates # Provide a WSGI entry file for uWSGI to load install -Dm644 ${./fragify.py} $out/share/fragify/fragify_wsgi.py # Install built assets if present @@ -42,6 +39,8 @@ fi ''; + passthru.pythonPath = python3Packages.makePythonPath dependencies; + meta.mainProgram = "fragify"; }; }; diff --git a/gulpfile.js b/gulpfile.js index e6113ba..3628105 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -31,6 +31,13 @@ gulp.task('copy-select2-theme', function () { .pipe(gulp.dest('./assets/css')); }); -gulp.task('copy-assets', gulp.series('copy-bulk', 'copy-jquery', 'copy-select2-theme')); +// Copy favicon(s) +gulp.task('copy-favicon', function () { + return gulp + .src(['./favicon.svg'], { allowEmpty: true }) + .pipe(gulp.dest('./assets')); +}); + +gulp.task('copy-assets', gulp.series('copy-bulk', 'copy-jquery', 'copy-select2-theme', 'copy-favicon')); gulp.task('default', gulp.series('copy-assets')); \ No newline at end of file diff --git a/module.nix b/module.nix index b0250e7..c611ce4 100644 --- a/module.nix +++ b/module.nix @@ -6,69 +6,72 @@ }: let - cfg = config.services.fragify; + cfg = config.services.fragify; in { - options = { - services.fragify = { + options = { + services.fragify = { - enable = lib.mkEnableOption "Fragify web app"; + enable = lib.mkEnableOption "Fragify web app"; - }; - }; + }; + }; - config = lib.mkIf cfg.enable { + config = lib.mkIf cfg.enable { - services.uwsgi = { - enable = true; - user = "fragify"; - group = "fragify"; - plugins = [ "python3" ]; - instances.fragify = { - # Align with upstream module: put uwsgi options under settings - settings = { - "chdir" = "/"; - "wsgi-file" = "${pkgs.fragify}/share/fragify/fragify_wsgi.py"; - module = "fragify:app"; - # Socket - "socket" = "unix:${config.services.uwsgi.runDir}/fragify.sock"; - "chmod-socket" = "660"; - umask = "0077"; - vacuum = true; - master = true; - processes = 2; - threads = 2; - "harakiri" = 60; - "buffer-size" = 65535; - "need-app" = true; - "no-orphans" = true; - # Serve static files directly via uWSGI (optional) - # Map /static to packaged assets directory (if present) - "static-map" = "/static=${pkgs.fragify}/share/fragify/assets"; - }; - # Environment for the WSGI app - env = { - FRAGIFY_TEMPLATES_DIR = "${pkgs.fragify}/share/fragify/templates"; - FRAGIFY_STATIC_DIR = "${pkgs.fragify}/share/fragify/assets"; - }; - # Python packages for uWSGI - pythonPackages = p: with p; [ falcon requests jinja2 ]; - }; - }; + services.uwsgi = { + enable = true; + plugins = [ "python3" ]; - # Ensure fragify user and group exist - users.users.fragify = { - isSystemUser = true; - group = "fragify"; - description = "fragify web application user"; - }; + instance = { + type = "emperor"; + vassals = { + fragify = { + type = "normal"; + chdir = "/"; - users.groups.fragify = {}; - }; + module = "fragify_wsgi:app"; - meta = { - maintainers = with lib.maintainers; [ onny ]; - }; + socket = "${config.services.uwsgi.runDir}/fragify.sock"; + "chmod-socket" = "660"; + + umask = "0077"; + vacuum = true; + master = true; + processes = 2; + threads = 2; + harakiri = 60; + "buffer-size" = 65535; + need-app = true; + "no-orphans" = true; + + env = [ + "PYTHONPATH=${pkgs.fragify}/share/fragify:${pkgs.fragify.pythonPath}" + "FRAGIFY_TEMPLATES_DIR=${pkgs.fragify}/share/fragify/templates" + "FRAGIFY_STATIC_DIR=${pkgs.fragify}/share/fragify/assets" + ]; + + settings = { + "static-map" = "/static=${pkgs.fragify}/share/fragify/assets"; + }; + }; + }; + }; + }; + + # Ensure fragify user and group exist + users.users.fragify = { + isSystemUser = true; + group = "fragify"; + description = "fragify web application user"; + }; + + users.groups.fragify = { }; + }; + + meta = { + maintainers = with lib.maintainers; [ onny ]; + }; } diff --git a/templates/base.html b/templates/base.html index 9121a9a..5c96c5b 100644 --- a/templates/base.html +++ b/templates/base.html @@ -25,7 +25,8 @@ {% if noindex %}{% endif %} - + + {% block meta_extra %}{% endblock %}