reCoreD-UI/flake.nix

77 lines
2.2 KiB
Nix
Raw Normal View History

2024-04-02 13:23:28 +00:00
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
};
2024-04-19 01:44:37 +00:00
outputs = { self, nixpkgs, utils }:
2024-04-02 13:23:28 +00:00
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
in
{
2024-04-19 07:10:08 +00:00
packages = rec {
recored-ui = with pkgs; stdenv.mkDerivation rec {
name = "recored-ui";
src = self;
buildInputs = [
go
nodejs
];
buildPhase = ''
cd web && npm i && npm run build && cd ..
go get . && go generate ./... && go build . -o recored-ui -ldflags "-s -w"
'';
installPhase = ''
mkdir -p $out/bin
cp recored-ui $out/bin
'';
};
default = recored-ui;
};
2024-04-02 13:23:28 +00:00
devShell = with pkgs; mkShell {
buildInputs = [
go
2024-04-02 13:26:57 +00:00
nodejs
2024-04-19 01:44:37 +00:00
dig
2024-04-10 03:00:38 +00:00
tokei
2024-04-02 13:23:28 +00:00
];
2024-04-03 09:05:12 +00:00
GOPATH = "/home/coder/.cache/go";
2024-04-11 02:51:33 +00:00
RECORED_MYSQL_DSN = "recoredui:A123456a-@tcp(mysql.dev:3306)/recoredui?charset=utf8mb4";
2024-04-02 13:23:28 +00:00
};
nixosModule = { config, pkgs, lib, ... }: with lib;
let
cfg = config.services.recored-ui;
in
{
options.services.hangitbot = {
enable = mkEnableOption "reCoreD-UI service";
2024-04-19 07:10:08 +00:00
mysql-dsn = mkOption {
2024-04-02 13:23:28 +00:00
type = types.str;
2024-04-19 07:10:08 +00:00
example = "recoredui:A123456a-@tcp(mysql.dev:3306)/recoredui?charset=utf8mb4";
description = lib.mdDoc "mysql connection DSN";
2024-04-02 13:23:28 +00:00
};
extraOptions = mkOption {
type = types.str;
2024-04-19 07:10:08 +00:00
description = lib.mdDoc "Extra options";
2024-04-02 13:23:28 +00:00
default = "";
};
};
2024-04-19 07:10:08 +00:00
config = mkIf cfg.enable {
systemd.services.recored-ui = {
wantedBy = [ "multi-uesr.target" ];
environment = {
RECORED_MYSQL_DSN = cfg.mysql-dsn;
2024-04-02 13:23:28 +00:00
};
2024-04-19 07:10:08 +00:00
serviceconfig.ExecStart = "${pkgs.recored-ui}/bin/recored-ui server";
2024-04-02 13:23:28 +00:00
};
2024-04-19 07:10:08 +00:00
};
2024-04-02 13:23:28 +00:00
};
});
}