Initial nix config
parent
aed95398e4
commit
a2451e4184
@ -0,0 +1,77 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nix-filter": {
|
||||
"locked": {
|
||||
"lastModified": 1681154353,
|
||||
"narHash": "sha256-MCJ5FHOlbfQRFwN0brqPbCunLEVw05D/3sRVoNVt2tI=",
|
||||
"owner": "numtide",
|
||||
"repo": "nix-filter",
|
||||
"rev": "f529f42792ade8e32c4be274af6b6d60857fbee7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "nix-filter",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1686547151,
|
||||
"narHash": "sha256-lnu+ziAXNa3iiPtFVg9Ex7ZUcsYCb7zZVpv9OiB1iac=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "4e3d46a3ea37d09c3d6dda557a0623c18ed58afe",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "master",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nix-filter": "nix-filter",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"utils": "utils"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1685518550,
|
||||
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
{
|
||||
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";
|
||||
__noChroot = true;
|
||||
|
||||
src = filter {
|
||||
root = ./.;
|
||||
include = [
|
||||
./package.json
|
||||
./package-lock.json
|
||||
];
|
||||
};
|
||||
|
||||
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 = "drowning";
|
||||
|
||||
src = filter {
|
||||
root = ./.;
|
||||
exclude = [
|
||||
./node_modules
|
||||
];
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ nodejs ];
|
||||
|
||||
configurePhase = ''
|
||||
ln -sf ${node_modules}/node_modules node_modules
|
||||
export HOME=$TMP
|
||||
'';
|
||||
|
||||
buildPhase = ''npm run build'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
mv dist/index.html $out/
|
||||
mv dist/assets $out/
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
}) // {
|
||||
nixosModule = {config, lib, pkgs, ...}:
|
||||
with lib;
|
||||
let cfg = config.ashe.services.drowning;
|
||||
pkg = self.packages.${pkgs.system}.default;
|
||||
|
||||
in {
|
||||
options.ashe.services.drowning = {
|
||||
enable = mkEnableOption "Enables the drowning site";
|
||||
|
||||
domain = mkOption rec {
|
||||
type = types.str;
|
||||
default = "drowning.ashen.earth";
|
||||
example = default;
|
||||
description = "The domain name to serve the Drowning Among Stars game at";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services.nginx.virtualHosts.${cfg.domain} = {
|
||||
locations."/" = {
|
||||
root = "${pkg}";
|
||||
};
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue