Nix flake
parent
8ca1ca0588
commit
29b6e1a96e
@ -0,0 +1,112 @@
|
|||||||
|
{
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue