headplane_headscale_nix/headplane4.nix.old

80 lines
2.1 KiB
Nix

{ config, pkgs, ... }:
let
domain = "kennys.mom";
headplanePort = 3000;
cookieSecret = "iQ0bUyaFgwaijWaSyZ1ILA9RwfywrbZ3";
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;
headplane = pkgs.stdenv.mkDerivation {
pname = "headplane";
version = "test";
src = pkgs.fetchFromGitHub {
owner = "dahjah";
repo = "headplane";
rev = "test";
sha256 = "1vs2cdh1w30cfrdf428k066chkh0ag03byrbr8c1i69984jq0jqv";
};
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 = [ headplane ];
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 = "${headplane}/bin/headplane --config /etc/headplane/config.yaml";
Restart = "on-failure";
User = "headplane";
Group = "headplane";
DynamicUser = false;
};
};
}