headplane_headscale_nix/headplane5.nix.old

81 lines
2.2 KiB
Nix

{ config, lib, pkgs, ... }:
let
domain = "kennys.mom";
headplanePort = 3000;
cookieSecret = "iQ0bUyaFgwaijWaSyZ1ILA9RwfywrbZ3";
# Generate YAML config for headplane
yamlData = {
server = {
host = "0.0.0.0";
port = headplanePort;
cookie_secret = cookieSecret;
cookie_secure = false;
};
headscale = {
url = "https://headscale.${domain}";
config_path = "/var/lib/headscale/config.yaml";
config_strict = true;
};
integration = { proc = { enabled = true; }; };
};
yamlFormat = pkgs.formats.yaml { };
configFile = yamlFormat.generate "headplane.yaml" yamlData;
headplanePkg = pkgs.stdenv.mkDerivation {
pname = "headplane";
version = "0.5.10";
src = pkgs.fetchFromGitHub {
owner = "tale";
repo = "headplane";
rev = "0.5.10";
sha256 = "sha256-Nx4rqH/dV/jg7txvXa40malRPYBeKE+ifd1pUswq/Gg=";
};
buildInputs = [
pkgs.nodejs_22
(pkgs.yarn.override { nodejs = pkgs.nodejs_22; })
];
installPhase = ''
export HOME=$PWD
export PATH=${pkgs.nodejs_22}/bin:$PATH
yarn install --ignore-engines --frozen-lockfile || yarn install --ignore-engines --network-concurrency 1 --frozen-lockfile
yarn build
mkdir -p $out/share/headplane
cp -r build/* $out/share/headplane/
mkdir -p $out/bin
cat > $out/bin/headplane <<EOF
#!${pkgs.runtimeShell}
exec ${pkgs.nodejs_22}/bin/node $out/share/headplane/server/index.js "\$@"
EOF
chmod +x $out/bin/headplane
'';
};
in
{
environment.systemPackages = [ headplanePkg ];
environment.etc."headplane/config.yaml".source = configFile;
users.users.headplane = {
isSystemUser = true;
group = "headplane";
description = "Headplane service user";
};
users.groups.headplane = {};
systemd.services.headplane = {
description = "Headplane Web UI";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${headplanePkg}/bin/headplane --config /etc/headplane/config.yaml";
Restart = "on-failure";
User = "headplane";
Group = "headplane";
DynamicUser = false;
};
};
}