feat: moved to C# thanks to deepseek
This commit is contained in:
1 parent
ab81a1c4be
commit
29ed46aa7f
34 files changed
+1583
-14
No files matched your search
@@ -1,32 +1,126 @@
|
||||
{
|
||||
description = "Phenix website";
|
||||
description = "Balle Phenix website — ASP.NET + SQLite";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, ... }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
build-static-files = pkgs.stdenv.mkDerivation {
|
||||
name = "phenix-website-static-assets";
|
||||
src = ./static;
|
||||
buildPhase = ''
|
||||
find . -type f -exec ${pkgs.brotli}/bin/brotli -9 -f -k {} \;
|
||||
'';
|
||||
installPhase = ''
|
||||
cp -r . $out
|
||||
dotnet = pkgs.dotnetCorePackages.sdk_9_0;
|
||||
pythonEnv = pkgs.python3.withPackages (ps: [ ps.requests ]);
|
||||
|
||||
phenix-website = pkgs.buildDotnetModule {
|
||||
name = "phenix-website";
|
||||
src = ./.;
|
||||
projectFile = "Phenix.csproj";
|
||||
selfContainedBuild = true;
|
||||
dotnet-sdk = dotnet;
|
||||
dotnet-runtime = pkgs.dotnetCorePackages.runtime_9_0;
|
||||
runtimeIdentifiers = "linux-x64";
|
||||
nugetDeps = ./deps.nix;
|
||||
|
||||
postInstall = ''
|
||||
cp -r static $out/lib/static/
|
||||
cp appsettings.json $out/lib/
|
||||
'';
|
||||
meta.mainProgram = "Phenix";
|
||||
};
|
||||
in {
|
||||
packages = { static = build-static-files; };
|
||||
packages = {
|
||||
default = phenix-website;
|
||||
website = phenix-website;
|
||||
};
|
||||
|
||||
devShell = pkgs.mkShell {
|
||||
name = "Phenix-Website";
|
||||
buildInputs = with pkgs; [ deno ];
|
||||
buildInputs = [ dotnet pkgs.nuget-to-nix pythonEnv ];
|
||||
|
||||
shellHook = ''
|
||||
export PATH="$PWD/dev/populate-db:$PATH"
|
||||
'';
|
||||
};
|
||||
});
|
||||
}) // {
|
||||
|
||||
nixosModules.default = { config, lib, pkgs, ... }:
|
||||
let
|
||||
cfg = config.services.phenix-website;
|
||||
phenix = self.packages.${pkgs.system}.website;
|
||||
pythonEnv = pkgs.python3.withPackages (ps: [ ps.requests ]);
|
||||
in {
|
||||
options.services.phenix-website = {
|
||||
enable = lib.mkEnableOption "Balle Phenix website";
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "ballephenix.com";
|
||||
};
|
||||
port = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
default = 8000;
|
||||
};
|
||||
dataDir = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
default = "/var/lib/phenix";
|
||||
};
|
||||
sessionKey = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
systemd.services.phenix-website = {
|
||||
description = "Balle Phenix website";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
ExecStart = "${phenix}/lib/Phenix";
|
||||
WorkingDirectory = "${phenix}/lib/";
|
||||
Restart = "always";
|
||||
RestartSec = 5;
|
||||
User = "phenix";
|
||||
Group = "phenix";
|
||||
};
|
||||
|
||||
environment = {
|
||||
ASPNETCORE_URLS = "http://0.0.0.0:${toString cfg.port}";
|
||||
ASPNETCORE_ENVIRONMENT = "Production";
|
||||
ConnectionStrings__Default = "Data Source=${cfg.dataDir}/phenix.db";
|
||||
} // lib.optionalAttrs (cfg.sessionKey != "") {
|
||||
SessionKey = cfg.sessionKey;
|
||||
};
|
||||
|
||||
postStart = ''
|
||||
mkdir -p ${cfg.dataDir}
|
||||
'';
|
||||
};
|
||||
|
||||
users.users.phenix = {
|
||||
isSystemUser = true;
|
||||
group = "phenix";
|
||||
home = cfg.dataDir;
|
||||
createHome = true;
|
||||
};
|
||||
|
||||
users.groups.phenix = {};
|
||||
|
||||
services.nginx = lib.mkIf (cfg.domain != "") {
|
||||
enable = true;
|
||||
virtualHosts.${cfg.domain} = {
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
locations."/" = {
|
||||
proxyPass = "http://127.0.0.1:${toString cfg.port}";
|
||||
proxyWebsockets = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user