diff --git a/nix/git_version.nix b/nix/git_version.nix index 5def7f3f..2b6785d7 100644 --- a/nix/git_version.nix +++ b/nix/git_version.nix @@ -1,12 +1,19 @@ -{ pkgs }: +{ pkgs, default ? "unknown" }: + with builtins; with pkgs; -lib.replaceStrings - ["\n"] - [""] - (lib.readFile - (runCommand - "git-version" - { src = ../.; buildInputs = [ gitMinimal ]; } - "cd $src; git describe --long --tags --dirty --always > $out")) +let + gitVersion = + lib.replaceStrings + ["\n"] + [""] + (lib.readFile + (runCommand + "git-version" + { src = ../.; buildInputs = [ gitMinimal ]; } + "cd $src; git describe --long --tags --dirty --always > $out")); +in + if pathExists ../.git + then gitVersion + else default diff --git a/nix/modules/default.nix b/nix/modules/default.nix index 4a1a39ce..8bd06e7f 100644 --- a/nix/modules/default.nix +++ b/nix/modules/default.nix @@ -71,6 +71,12 @@ in { default = null; }; + staticFiles = mkOption { + internal = true; + type = with types; nullOr path; + default = null; + }; + browserSessionSecretKeyFile = mkOption { type = types.str; description = "Path to file containing the secret key for browser session signing"; @@ -101,6 +107,7 @@ in { config = lib.mkIf cfg.enable { services.ekklesia.portal.configFile = configInput; + services.ekklesia.portal.staticFiles = staticFiles; environment.systemPackages = [ ekklesiaPortalConfig ekklesiaPortalShowConfig ]; @@ -146,6 +153,7 @@ in { Restart = "always"; X-ConfigFile = configInput; X-ServeApp = serveApp; + X-StaticFiles = staticFiles; DeviceAllow = [ "/dev/stderr" diff --git a/nix/static_files.nix b/nix/static_files.nix index 08f32157..11a9e360 100755 --- a/nix/static_files.nix +++ b/nix/static_files.nix @@ -1,8 +1,10 @@ +with builtins; + { sources ? null }: let deps = import ./deps.nix { inherit sources; }; - inherit (deps) lib pkgs sassc javascriptDeps webfontsPath sassPath deform python; - version = import ./git_version.nix { inherit pkgs; }; + inherit (deps) lib pkgs sassc javascriptDeps webfontsPath sassPath deform python pyProject; + version = import ./git_version.nix { inherit pkgs; default = pyProject.tool.poetry.version; }; in pkgs.runCommand "ekklesia-portal-static-${version}" {