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

Help-wanted: install with configuration.nix #132

Open
godalming123 opened this issue Jul 25, 2022 · 2 comments
Open

Help-wanted: install with configuration.nix #132

godalming123 opened this issue Jul 25, 2022 · 2 comments
Labels
documentation Can be answered by improving documentation

Comments

@godalming123
Copy link

godalming123 commented Jul 25, 2022

How do I install this in my configuration.nix? In hyprland (my previous wm) there's a guide; https://github.com/hyprwm/Hyprland/wiki/Installation#without-flakes is there such a thing for newm?

@jbuchermn jbuchermn added the documentation Can be answered by improving documentation label Jul 25, 2022
@jbuchermn
Copy link
Owner

I have everything set up using flakes (see my repositories). Maybe you can use that as a basis to build sth without flakes.

Unfortunately I have got very little time at the moment and can't provide support, maybe other nix users on here can.

@tewkanz
Copy link

tewkanz commented Sep 12, 2022

I was able to get this working, mostly by copying the contents of the flakes into derivations. Though, I'm pretty new to nix, so my style not be the greatest ;)

For pyWM:

{
  python3Packages,
  fetchgit,
  fetchFromGitHub,
  pkgs,
  ...
}:
python3Packages.buildPythonPackage rec {
  # A released derivation would ask you if you wanted to include xwayland support.
  # I wasn't interested in that, so I statically set it to yes. Basically you would modify your buildInputs and mesonFlags to not include it if you didn't want it.
  pname = "pywm";
  version = "v0.3alpha";
  name = "${pname}-${version}";

  srcs = [
    (fetchgit {
      url = "https://github.com/jbuchermn/pywm.git";
      rev = "02dd26196d0a8cd5390fa22f583f8e5a4ed198e4";
      sha256 = "iCZhb+byXsBIBH7QkfiesOjBM1CHuf0jxF//NPQs3xg=";
    })
    (fetchgit {
      url = "https://gitlab.freedesktop.org/wlroots/wlroots";
      rev = "e279266f714c7122e9ad97d56d047313f78cfdbe";
      sha256 = "8RldE5JsQILUZ2DF1nB6AEz1pZecgnURIjRXK/dCAdI=";
      fetchSubmodules = true;
    })
  ];

  setSourceRoot = ''
    for i in ./*; do
      if [ -f "$i/wlroots.syms" ]; then
        wlrootsDir=$i
      fi
      if [ -f "$i/pywm/pywm.py" ]; then
        sourceRoot=$i
      fi
    done
  '';
  preConfigure = ''
    echo "--- Pre-configure --------------"
    echo "  wlrootsDir=$wlrootsDir"
    echo "  sourceRoot=$sourceRoot"
    echo "--- ls -------------------------"
    ls -al
    echo "--- ls ../wlrootsDir -----------"
    ls -al ../$wlrootsDir
    rm -rf ./subprojects/wlroots 2> /dev/null
    cp -r ../$wlrootsDir ./subprojects/wlroots
    rm -rf ./build
    echo "--- ls ./subprojects/wlroots ---"
    ls -al ./subprojects/wlroots/
    echo "--------------------------------"
  '';
  mesonFlags = ["-Dxwayland=enabled"];

  nativeBuildInputs = with pkgs; [
    meson
    ninja
    pkg-config
    wayland-scanner
    glslang
  ];

  preBuild = "cd ..";

  buildInputs = with pkgs;
    [
      libGL
      wayland
      wayland-protocols
      libinput
      libxkbcommon
      pixman
      vulkan-loader
      mesa
      seatd

      libpng
      ffmpeg
      libcap

      xorg.xcbutilwm
      xorg.xcbutilrenderutil
      xorg.xcbutilerrors
      xorg.xcbutilimage
      xorg.libX11
    ]
    ++ [
      xwayland
    ];

  propagatedBuildInputs = with pkgs.python3Packages; [
    imageio
    numpy
    pycairo
    evdev
  ];
}

The module thefuzz is not currently part of nixpkgs, so you need to create a derivation for that:

{ python3Packages, ... }:

with python3Packages;

buildPythonPackage rec {
    version = "0.19.0";
    pname = "thefuzz";
    name = "${pname}-${version}";

    propagatedBuildInputs = [
      python-Levenshtein
      pycodestyle
    ];

    src = fetchPypi {
      inherit pname version;
      sha256 = "b3Em2y8silQhKwXjp0DkX0KRxJfXXSB1Fyj2Nbt0qj0=";
    };
}

And then finally, import those two derivations into your newm derivation:

{
  pkgs,
  python3Packages,
  fetchFromGitHub,
}:
with python3Packages; let
  thefuzz = pkgs.callPackage (import ./python-thefuzz.nix) {};
  pywm = pkgs.callPackage (import ./pywm.nix) {};
in
  buildPythonApplication rec {
    pname = "newm";
    version = "v0.3alpha";
    src = fetchFromGitHub {
      owner = "jbuchermn";
      repo = "newm";
      rev = "v0.3alpha";
      sha256 = "5mpXPvxfCr7bDdT/zwFAyZUqjgHe5yGK4lE3HuDYJkY=";
    };
    
    setuptoolsCheckPhase = "true";
    propagatedBuildInputs = with python3Packages; 
    [
      pywm
      pycairo
      psutil
      python-pam
      pyfiglet
      dasbus
      thefuzz

      setuptools
    ];
    # newm comes with some desktop environment like helpers that you might want it to have on its PATH. I think you would put those here.
    # buildInputs = with pkgs; [ brightnessctl ];

    # For reasons I don't understand, the desktop file isn't part of my build directory, so I just make it here.
    postInstall = ''
      mkdir -p $out/share/wayland-sessions/
      echo "[Desktop Entry]
Name=newm
Comment=A scrolling Wayland compositor
Exec=$out/bin/start-newm
Type=Application" > $out/share/wayland-sessions/newm.desktop
      chmod u+rw $out/share/wayland-sessions/newm.desktop
      chmod g+r $out/share/wayland-sessions/newm.desktop
      chmod o+r $out/share/wayland-sessions/newm.desktop
    '';
  }

Then you just call this package and add it to your system packages. You'll also want to add it to your display manager's session packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Can be answered by improving documentation
Projects
None yet
Development

No branches or pull requests

3 participants