Trouble with building from source fynedesktop

Hi!

I’m trying to package fynedesktop:

But I’m having some troubles. This is my flake: Kazimierz Krauze / nixos-fynedesk · GitLab

After running nix build ./#fynedesktop I get this error:

user@nixos nixos-fynedesk main > nix build ./#fynedesktop
error: Cannot build '/nix/store/k6nnnrjl0hhkl9qjzgq8zh24mp4zh4p5-fynedesktop-v0.4.0.drv'.
       Reason: builder failed with exit code 2.
       Output paths:
         /nix/store/wdwk1jmq73xccg09ggnw2ak956qchr9a-fynedesktop-v0.4.0
       Last 12 log lines:
       > Running phase: unpackPhase
       > unpacking source archive /nix/store/n7ph195zjj97qlaf397a97rclw4i77x4-source
       > source root is source
       > Running phase: patchPhase
       > Running phase: updateAutotoolsGnuConfigScriptsPhase
       > Running phase: configurePhase
       > no configure script, doing nothing
       > Running phase: buildPhase
       > build flags: SHELL=/nix/store/2hjsch59amjs3nbgh7ahcfzm2bfwl8zi-bash-5.3p9/bin/bash
       > go build ./cmd/fynedesk_runner
       > failed to initialize build cache at /homeless-shelter/.cache/go-build: mkdir /homeless-shelter: permission denied
       > make: *** [Makefile:9: build] Error 1
       For full logs, run:
         nix log /nix/store/k6nnnrjl0hhkl9qjzgq8zh24mp4zh4p5-fynedesktop-v0.4.0.drv
user@nixos nixos-fynedesk main > nix log /nix/store/k6nnnrjl0hhkl9qjzgq8zh24mp4zh4p5-fynedesktop-v0.4.0.drv
Running phase: unpackPhase
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking source archive /nix/store/n7ph195zjj97qlaf397a97rclw4i77x4-source
source root is source
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: configurePhase
@nix { "action": "setPhase", "phase": "configurePhase" }
no configure script, doing nothing
Running phase: buildPhase
@nix { "action": "setPhase", "phase": "buildPhase" }
build flags: SHELL=/nix/store/2hjsch59amjs3nbgh7ahcfzm2bfwl8zi-bash-5.3p9/bin/bash
go build ./cmd/fynedesk_runner
failed to initialize build cache at /homeless-shelter/.cache/go-build: mkdir /homeless-shelter: permission denied
make: *** [Makefile:9: build] Error 1
user@nixos nixos-fynedesk main >

I’m very nooby in packaging with nix, so please don’t yell at me because of stupid question.

Anyway, can you guys help me out?

Best,
Miro

Is there a reason you are not using buildGoModule?

I didn’t know it existed :person_facepalming:

I tried to implement it:

{
  description = "Flake for installing fynedesktop";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
  };

  outputs = { self, nixpkgs }:
  let
    system = "x86_64-linux";
    pkgs = import nixpkgs {inherit system; };
  in
  {
    packages.${system}.fynedesktop = pkgs.buildGoModule (finalAttrs: {
      pname = "fynedesktop";
      version = "0.4.0";
      src = pkgs.fetchFromGitHub {
        owner = "FyshOS";
        repo = "fynedesk";
        tag = "v${finalAttrs.version}";
        sha256 = "sha256-NoVe2ZZqq1bzM2AqxaB9Ubu/iXQVMrpLR5HDBnYKxJU=";
      };
      vendorHash = "sha256-yZ57JqZrYBvQYaEjerfhXUJRy/Av8ZodYcN5RMwK9JA=";
      buildInputs = [
        pkgs.go
      ];
      installPhase = ''
        make
        make install
      '';
      meta = {
        description = "Fynedesktop for NixOS";
        homepage = "https://fyshos.com/desktop/";
      };
    });
  };
}

But I get this error:

user@nixos nixos-fynedesk main > nix build ./#fynedesktop --verbose --show-trace
this derivation will be built:
  /nix/store/9fsnw9nv61nwazljfnjv3cbz3chc5sdk-fynedesktop-0.4.0.drv
building '/nix/store/9fsnw9nv61nwazljfnjv3cbz3chc5sdk-fynedesktop-0.4.0.drv'...
error: Cannot build '/nix/store/9fsnw9nv61nwazljfnjv3cbz3chc5sdk-fynedesktop-0.4.0.drv'.
       Reason: builder failed with exit code 1.
       Output paths:
         /nix/store/sm05fr1g9sgzzxf11mf4fvyjklyaakpz-fynedesktop-0.4.0
       Last 18 log lines:
       > Running phase: unpackPhase
       > unpacking source archive /nix/store/n7ph195zjj97qlaf397a97rclw4i77x4-source
       > source root is source
       > Running phase: patchPhase
       > Running phase: updateAutotoolsGnuConfigScriptsPhase
       > Running phase: configurePhase
       > Running phase: buildPhase
       > Building subPackage .
       > Building subPackage ./cmd/fynedesk
       > github.com/go-gl/gl/v2.1/gl: exec: "pkg-config": executable file not found in $PATH
       > # github.com/go-gl/glfw/v3.3/glfw
       > In file included from ./glfw/src/internal.h:188,
       >                  from ./glfw/src/context.c:30,
       >                  from vendor/github.com/go-gl/glfw/v3.3/glfw/c_glfw.go:4:
       > ./glfw/src/x11_platform.h:33:10: fatal error: X11/Xlib.h: No such file or directory
       >    33 | #include <X11/Xlib.h>
       >       |          ^~~~~~~~~~~~
       > compilation terminated.
       For full logs, run:
         nix log /nix/store/9fsnw9nv61nwazljfnjv3cbz3chc5sdk-fynedesktop-0.4.0.drv
user@nixos nixos-fynedesk main >

I understand that builder can’t find command “pkg-config”. Am I right?

It seem that you need to add:

nativeBuildInputs = [ pkg-config ];

Maybe take a look at:

You might not even need this.

Thank you! It really helped

That’s right, I forgot to delete it:)

I’ve managed to build it using v0.3.0, which is fyne for me now. However, I’m not sure how to run it. I mean, I can, being logged into a plasma session, start it from terminal, but when I try tty3 or whatever I get this error:

Can you please explain to me what am I doing wrong?

This will involve quite some back and forth and troubleshooting as I’m not using it myself. It complains that there is no x11 running. A quick search on the internet tells me it is possible to build it for Wayland as well. You might want to search yourself and try. When there are specific errors, ask them here.

Thank you for your help, I’ll try to.