You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
2.3 KiB
Nix
113 lines
2.3 KiB
Nix
1 year ago
|
{
|
||
|
inputs = {
|
||
|
utils.url = "github:numtide/flake-utils";
|
||
|
nixpkgs.url = "github:NixOS/nixpkgs/master";
|
||
|
nix-filter.url = "github:numtide/nix-filter";
|
||
|
};
|
||
|
|
||
|
outputs = {
|
||
|
self,
|
||
|
nixpkgs,
|
||
|
utils,
|
||
|
nix-filter,
|
||
|
}:
|
||
|
utils.lib.eachDefaultSystem
|
||
|
(system: let
|
||
|
pkgs = import nixpkgs {
|
||
|
inherit system;
|
||
|
};
|
||
|
|
||
|
filter = nix-filter.lib;
|
||
|
|
||
|
nodejs = pkgs.nodejs-18_x;
|
||
|
|
||
|
node_modules = pkgs.stdenv.mkDerivation {
|
||
|
name = "node_modules";
|
||
|
|
||
|
src = filter {
|
||
|
root = ./.;
|
||
|
include = [
|
||
|
./package.json
|
||
|
./package-lock.json
|
||
|
];
|
||
|
};
|
||
|
|
||
|
__noChroot = true;
|
||
|
|
||
|
configurePhase = ''
|
||
|
export HOME=$TMP
|
||
|
'';
|
||
|
|
||
|
buildInputs = [ nodejs ];
|
||
|
|
||
|
buildPhase = ''
|
||
|
${nodejs}/bin/npm ci
|
||
|
'';
|
||
|
|
||
|
installPhase = ''
|
||
|
mkdir $out
|
||
|
mv node_modules $out/node_modules
|
||
|
'';
|
||
|
};
|
||
|
in {
|
||
|
packages = {
|
||
|
|
||
|
default = pkgs.stdenv.mkDerivation {
|
||
|
name = "tempest.dev";
|
||
|
|
||
|
src = filter {
|
||
|
root = ./.;
|
||
|
exclude = [
|
||
|
./.next
|
||
|
./node_modules
|
||
|
];
|
||
|
};
|
||
|
|
||
|
nativeBuildInputs = [ nodejs ];
|
||
|
|
||
|
buildPhase = ''
|
||
|
npm run build
|
||
|
npm run export
|
||
|
'';
|
||
|
|
||
|
configurePhase = ''
|
||
|
ln -sf ${node_modules}/node_modules node_modules
|
||
|
export HOME=$TMP
|
||
|
'';
|
||
|
|
||
|
installPhase = ''
|
||
|
# Copy static export
|
||
|
mv out $out
|
||
|
'';
|
||
|
};
|
||
|
};
|
||
|
}) // {
|
||
|
nixosModule = {config, lib, pkgs, ...}:
|
||
|
with lib;
|
||
|
let cfg = config.ashe.services."tempest.dev";
|
||
|
|
||
|
in {
|
||
|
options.ashe.services."ashen.earth" = {
|
||
|
enable = mkEnableOption "Enables the ashen.earth HTTP service";
|
||
|
|
||
|
domain = mkOption rec {
|
||
|
type = types.str;
|
||
|
default = "ashen.earth";
|
||
|
example = default;
|
||
|
description = "The domain name for ashen.earth";
|
||
|
};
|
||
|
};
|
||
|
|
||
|
config = mkIf cfg.enable {
|
||
|
services.nginx.virtualHosts.${cfg.domain} = {
|
||
|
root = "${pkg}"
|
||
|
forceSSL = true;
|
||
|
enableACME = true;
|
||
|
};
|
||
|
};
|
||
|
};
|
||
|
|
||
|
|
||
|
};
|
||
|
}
|