Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notes from a NixOS install #95

Open
tecosaur opened this issue Jan 23, 2025 · 6 comments
Open

Notes from a NixOS install #95

tecosaur opened this issue Jan 23, 2025 · 6 comments

Comments

@tecosaur
Copy link

tecosaur commented Jan 23, 2025

As I mentioned in the other issue I just opened, I've managed to get this working on my NixOS server (in case it's of interest: https://code.tecosaur.net/tec/golgi/commit/53f3218c28168c7f619a1fd8de2093fe823d2f83)

Packaging was rather straightforward, except for these two hacks I seemed to need to do:

  • sed -i 's;/build/source/node_modules/react-router/dist/development/index.mjs;react-router;' $out/share/headplane/build/headplane/server.js because the build path was hardcoded into some of the bundled code
  • sed -i 's;define_process_env_default.PORT;process.env.PORT;' $out/share/headplane/build/headplane/server.js because the PORT envvar wasn't being loaded correctly

To work around the read-only config file issue mentioned in #48, I run cp ${headscale-config-copy} /tmp/headscale.yaml; chmod u+w /tmp/headscale.yaml' as a ExecStartPre step in the service. I figure it will just get overwritten every time the service is started, but that's fine as a stop-gap.

I thought I'd mention this here in case there's anything that can be done to remove the need for the packaging hacks I mention, and in case it helps anyone else :)

@StealthBadger747
Copy link

Thanks for sharing! Probably saved me from a long debugging session.

On 3.6 I was getting away with my-headplane-3.6.nix
In 3.9 I had to introduce a new patchPhase, but I forgot to commit that to git... But now thanks to your config you actually taught me a couple things as well like lib.getExe and I liked your /share/headplane. And now my config is this: my-headplane-4.1.nix

@StealthBadger747
Copy link

StealthBadger747 commented Feb 4, 2025

Also @tecosaur regarding that issue you mentioned (48) I'm not clear as to what the issue is there, but if you are talking about sharing the generated yaml that headscale generates, to headplane I solved it like this:

Note specifically this part

let
  ....
  settingsFormat = pkgs.formats.yaml {};
  headscaleConfig = settingsFormat.generate "headscale-settings.yaml" config.services.headscale.settings;
in {
  environment.etc."headscale/config.yaml".source = 
    lib.mkForce (settingsFormat.generate "headscale-config.yaml" config.services.headscale.settings);

This is a more fleshed out config, but still severely trimmed down.

{ config, pkgs, pkgs-unstable, lib, ... }:
let
  # .....
  headscale_fqdn = "${headscale_host}.${headscale_tld}";
  headplane_port = "3000";
  headplanePkg = pkgs.callPackage ../packages/headplane.nix {};

  settingsFormat = pkgs.formats.yaml {};
  headscaleConfig = settingsFormat.generate "headscale-settings.yaml" config.services.headscale.settings;
in {
  environment.etc."headscale/config.yaml".source = 
    lib.mkForce (settingsFormat.generate "headscale-config.yaml" config.services.headscale.settings);

  services = {
    headscale = {
      enable = true;
      address = "127.0.0.1";
      port = 8080;
      package = pkgs-unstable.headscale;
      settings = {
        server_url = "https://${headscale_fqdn}";
        dns.base_domain = "internal-${headscale_fqdn}";
        oidc = {
          # .....
        };
      };
    };
  };

  systemd.services.headplane = {
    description = "Headplane Service";
    after = [ "network.target" ];
    wantedBy = [ "multi-user.target" ];
    serviceConfig = {
      ExecStart = "${headplanePkg}/bin/headplane";
      WorkingDirectory = "${headplanePkg}";
      Restart = "always";
      User = "headplane";
      Group = "headplane";
      EnvironmentFile = config.sops.secrets.headplane.path;
      Environment = [
        "HOST=127.0.0.1"
        "PORT=${headplane_port}"
        "HEADSCALE_INTEGRATION=proc"
        "HEADSCALE_URL=https://${headscale_fqdn}"
        "DEBUG=true"
        "HEADSCALE_CONFIG_UNSTRICT=true"
      ];
    };
  };
}

Hope that helps!

@tecosaur
Copy link
Author

tecosaur commented Feb 4, 2025

Thanks for sharing, seems like a pretty similar solution, just writing the copy somewhere else.

Along the lines of #48, it would be good if headplane might recognise read-only Configs and make the settings web page present itself as read-only to reflect that.

@tale
Copy link
Owner

tale commented Feb 4, 2025

Still WIP, I have a very big update coming out as Headplane 0.5 and that's planned with it.

@StealthBadger747
Copy link

@tale that's awesome! Thanks.

As a side note. If I made a PR with a Nix CI pipeline to test new builds would you be interested in adopting it? It seems we have a small community of people who want to use your project on Nix.

@tale
Copy link
Owner

tale commented Feb 4, 2025

@StealthBadger747 @tecosaur I believe Headplane should already support read-only config files, do you have debug logs that could indicate what is happening on startup. Also is the DNS/Settings tabs just completely hidden?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants