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

Support for NixOS #206

Open
phanirithvij opened this issue Jun 21, 2024 · 16 comments
Open

Support for NixOS #206

phanirithvij opened this issue Jun 21, 2024 · 16 comments

Comments

@phanirithvij
Copy link

phanirithvij commented Jun 21, 2024

I have tried to get lemurs work using the provided flake and use services.displayManager.execCmd with no luck, couldn't get it working and wasn't seeing any error messages either in journalctl.

I copied this user's config https://discourse.nixos.org/t/lemurs-dm-doesnt-work/45300
I did execCmd = "${lemurs.packages.${system}.default}/bin/lemurs --no-log"; instead. While passing lemurs as a specialArg and using this repo as the flake.

Also saw the recent work done on it previously #177 #199.
@antonmosich @NullCub3 could you share your nixos configs for lemurs if you got it working?

@NullCub3
Copy link

I had tried to get lemurs to work on nixos with the updated flake/module on the nixosmodule branch, and I never actually quite got it to work back then. If I remember correctly I got it to show up and start however it wouldn't display any options for sessions to log in with. Wasn't sure what to do about it, and it was a separate branch that was evidently in progress, so I've just been using SDDM in the meantime. But I've learned a decent bit more about nixos in the recent months, so I would like to take a crack at it again.

As for your issue, I took a scroll through your configs in your profile and don't see anything that jumps out at me as wrong with regard to lemurs. I haven't seen that format for executing the package before though, but I don't know much about flakes/building stuff with flakes so that could just be me lol, I'm assuming you're doing it like this because you're directly referencing the flake instead of adding it like as a module or something?

Anyways, what exactly is going wrong with lemurs for you? Is it just not showing up for you or is it something else like what I was experiencing a while back?

@phanirithvij
Copy link
Author

I'm assuming you're doing it like this because you're directly referencing the flake instead of adding it like as a module or something?

I'm pretty new to this too. Yes I'm trying to use the flake from this repo, instead of pkgs.lemurs from nixpkgs just to see if it builds and left it lying there since I'm not using it (benefit of specialisations).

It builds and when I boot via that specialisation it goes to tty directly, I guess I need to use startx. The thing that needs to be done is to get lemurs into displayManagers in nixpkgs (ofcourse no flakes allowed in nixpkgs), I thought of doing it but I first need to understand what startx etc. are so trying something else.

Can you share you config? It doesn't start at all, lemurs.

@NullCub3
Copy link

Well my current configs aren't going to help you much since I removed the lemurs parts a long time ago, but I can show you what I had done:

flake.nix

  inputs = {
    ..
    # Forked the nixosmodule branch to edit (see below)
    lemurs = { url = "github:NullCub3/lemurs/nixosmodule"; inputs.nixpkgs.follows = "nixpkgs"; };
    # Probably a better way to do this would have been something like this
    # and do all your modifications here, offline
    # not 100% sure if this works though lol:
    # lemurs = { 
    #   url = "git+file:///home/username/clonelocation/lemurs"; 
    #   inputs.nixpkgs.follows = "nixpkgs"; 
    # };
    ..
  };

  outputs =
    { self
    , nixpkgs
    , lemurs
    , ...
    }@inputs:
    { 
      nixosConfigurations = {
        systemName = nixpkgs.lib.nixosSystem {
          specialArgs = { inherit inputs; };
          system = "x86_64-linux";
          modules = [
            lemurs.nixosModules.default
            ./hosts/systemName/configuration.nix
          ];
        };
      };
    };

lemurs.nix (imported from configuration.nix)

{ lib, inputs, ... }:
{
  imports = [
    inputs.lemurs.nixosModules.default
  ];

  services.displayManager.sddm.enable = lib.mkForce false;
  services.displayManager.enable = true;

  services.lemurs = {
    enable = true;
    #x11.enable = true;
    wayland.enable = true;
  };
}

And with my fork of the nixosmodule branch all I had done was fix the existing shell issue here and here (although with it just replacing it anyways I don't think it actually matters) and then removing the couple of lines here pointing to the wayland and x sessions because they were causing issues for some reason and then with that lemurs would start up properly and everything but I don't think there was any way for me to log in or anything. Currently my fork of it doesn't actually have all of those changes made though, so you'll have to make your own. Hopefully this helps?

@phanirithvij
Copy link
Author

I completely missed the nixosmodule branch thanks for posting your config

@phanirithvij
Copy link
Author

Yes I see what you mean, It boots to lemurs and I see two options Plasma ( Plasma ( with text cut off. (x11, wayland versions) And I can't boot into either of them, neither does F1 and F2 work (had to press the power button once to shutdown)

@NullCub3
Copy link

Hey there, I've been working on setting up the lemurs module for a while and in my research I came across these couple of repos and I was wondering if they might be able to help you out a bit:

They seem to be mostly identical and I haven't tried out the module configs, but the person who made the second one was the one who added lemurs to nixpkgs

@coastalwhite
Copy link
Owner

Hey, thank you all for your effort. As you have seen, I had tried myself for some time to get lemurs to work on NixOS. I think the problem currently is to do with how lemurs relies on PAM to lower the privilege, but I am not 100% sure.

I feel like I might need to copy something similar to what greetd is doing for it to work properly.

@auvred
Copy link

auvred commented Jun 29, 2024

I'm completely new to Nix & NixOS, but I was able to run lemurs in my NixOS setup. You can see the full config here: https://github.com/auvred/nixos-config/blob/3e3b86a988a25fd0bae13192a5c5e2c107c47de5/nixos-modules/lemurs/default.nix. I hope this helps someone!

The main parts I've struggled with:

  • Properly start the Xorg server with configuration defined in the services.xserver.*
    First of all, I enabled services.xserver.enable = true and disabled lightdm (since it's enabled by default) services.xserver.displayManager.lightdm.enable = false. Then I set x11.xserver_path in lemurs config to the let dm = config.services.xserver.displayManager; in "${dm.xserverBin} ${toString dm.xserverArgs}". This basically starts the Xorg like every other display manager in nixpkgs.

  • Use window manager provided by home-manager
    Since I use home-manager and configure my window manager (i3) with it, I'd like to run it as is (without having to further configure i3 in nixosConfiguration).

    My solution to this problem is far from perfect, but at least it works and looks pretty clean.

    home-manager starts window manager in xsession.scriptPath file (.xsession by default) - https://github.com/nix-community/home-manager/blob/7e68e55d2e16d3a1e92a679430728c35a30fd24e/modules/xsession.nix#L196-L222.
    I've changed xsession.scriptPath to ".xsession-hm" to avoid collisions with default xsetup.sh -

    lemurs/extra/xsetup.sh

    Lines 94 to 96 in 9bc4297

    if [ -f "$USERXSESSION" ]; then
    . "$USERXSESSION"
    fi

    This ~/.xsession-hm is executed in the hm-xsession start script (see code for more details).

  • Issue with PAM
    See Authentication error with PAM: Error writing /proc/self/loginuid #166.
    I haven't had that much time to dig into this more deeply yet, so as a temporary workaround I just set security.pam.services.login.setLoginUid = false.

@NullCub3
Copy link

Oh that's fantastic! Very well documented, thank you for sharing that, that's incredibly useful. If it's okay with you, I'll just roll that into the improved module I'm working on at the moment.

Do the shutdown/reboot keys work for you at all with that config? I haven't yet investigated what exactly lemurs wants to run for those but it clearly isn't finding the right commands.

@auvred
Copy link

auvred commented Jun 29, 2024

Do the shutdown/reboot keys work for you at all with that config?

No, I just haven't tried pressing on them.

After a little straceing, it appears that the lemurs is trying to execute a bash here:

let cmd_status = Command::new("bash")

It's pretty easy to patch. See this commit auvred/nixos-config@e304bf4.

Perhaps this patch should be applied in lemurs itself, because this is the only place in the project that spawns not a system_shell from the config: https://github.com/search?q=repo%3Acoastalwhite%2Flemurs%20%22command%3A%3Anew%22&type=code.

@NullCub3
Copy link

Ah, makes sense. But yeah why don't you just open a pull request with that patch applied? Probably just got missed in fixing the assuming of binary locations if I had to guess.

@Stunkymonkey
Copy link
Contributor

fyi: #208 just got merged. thanks to @coastalwhite 👍

@Stunkymonkey
Copy link
Contributor

my first attempt to have a nixos-module: NixOS/nixpkgs#329496 .

the poweroff and shutdown does not yet work, but the rest seems fine to me. (At least QEMU boots fine)

@NullCub3
Copy link

NullCub3 commented Jul 24, 2024

Okay sweet! I had stepped away from this for a bit as I wasn't sure exactly what config settings to include, and the next major step was to do some extensive testing to find and fix some bugs* but I have a functional module integrated into the flake right now. Power buttons work, login works, config, etc.

The only couple of things I had wanted to do was figure out what the most common config options people wanted and also add some kind of system to add your own init scripts. Both of those would be an easy add I think.

https://github.com/NullCub3/lemurs/tree/nixosmodule-dev

*for example, trying to log back in with a wayland session after having logged out of one doesn't work? Not sure if that's a me issue or not. I also have not tested X11 since I don't have that set up on my system right now.

@coastalwhite coastalwhite changed the title nixos support Support for NixOS Jul 24, 2024
@NullCub3
Copy link

By the way, as I mentioned here, the latest release for lemurs is very old and doesn't include any of the newer configuration for the X server paths, @coastalwhite would you be willing to publish a new release including all the newer changes so that it can be more easily merged into nixpkgs?

@mahyarmirrashed
Copy link

@coastalwhite following up on this! I would like to start using Lemur from the nixpkgs.

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

6 participants