TheAlexDev23 / power-options

Linux GUI application for blazingly fast and simple power-management.
MIT License
240 stars 1 forks source link

Package for nix #10

Open IceDBorn opened 2 months ago

TheAlexDev23 commented 2 months ago

I've never used the nix package manager nor NixOS, so I've got 0 experience packaging for nix. If anyone does I'll be happy to accept any PRs but otherwise I don't think this will be a priority.

mark-boute commented 1 month ago

I'll give it a try, @TheAlexDev23 could you provide the Cargo.lock with releases?

TheAlexDev23 commented 1 month ago

@mark-boute yeah sorry, I don't know why I had it excluded from vcs

mark-boute commented 1 month ago

Alright, I got stuck at setting up the systemctl service as it is not available. Leaving my attempt here for someone else to use:


{ lib,    
  libadwaita,
    # yad
  dbus,
  pkg-config,
  atk,
  xdotool,
  gtk3, 
  gtk4, 
  webkitgtk_4_1,
  fetchFromGitHub,
  rustPlatform,
  zsh
}:

rustPlatform.buildRustPackage rec {
  pname = "power-options-gtk";
  version = "591afd6f49ce79cfb5d2d2d1d43e10e64bf44a86";
  # use commit that added Cargo.lock instead of release

  src = fetchFromGitHub {
    owner = "TheAlexDev23";
    repo = "power-options";
    rev = version;
    hash = "sha256-gXSJej3Bl2ZnMl3vlSwaknR1yhlaEsRlGctR8abd+GY=";
  };

  cargoHash = "sha256-QCFtj+zcNJ5AvGq3tpi0BqUSjvDo8o/HA4Bs/3VrTZY=";

  buildInputs = [ 
    libadwaita
    # yad
    dbus
    xdotool
    atk 
    gtk3 
    gtk4 
    webkitgtk_4_1
  ];

  nativeBuildInputs = [ 
    zsh
    pkg-config
   ];

  cargoInstallHook = ''
    mkdir -p $out/bin
    cp target/release/power-daemon-mgr $out/bin/
    cp target/release/frontend-gtk $out/bin/power-options-gtk
    cp icon.png $out/share/icons/power-options.png
    cp install/power-options-gtk.desktop $out/share/applications/
  '';

  meta = {
    description = "A gtk frontend for Power Options, a blazingly fast power management solution.";
    homepage = "https://github.com/TheAlexDev23/power-options";
    license = lib.licenses.mit;
  };
}```

Only the `power-daemon-mgr` seems to be available in `/run/current-system/sw/bin/power-daemon-mgr`
TheAlexDev23 commented 1 month ago

@mark-boute The installation process requires the call to power-daemon-mgr generate-base-files to generate the files for systemd, acpi, dbus, etc. They are not available as files in the repo, mostly because they require some form of string interpolation to be properly generated.

Take a look at the AUR PKGBUILD, https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=power-options-daemon.

Tell me if this is not suitable for nix, and if I should think on alternative installation methods.

mark-boute commented 1 month ago

I figured and tried to run this imperatively. Where does it write to? I think the main limiting factor is me not knowing how I turn this derivation into a systemd service.

TheAlexDev23 commented 1 month ago

The generate-base-files command takes 2 parameters:

It will generate the following files relative to --path

Is this what you were asking?

mark-boute commented 1 month ago

Right, thanks. I am currently looking into this again. giving one root for those files may not work in Nix, see: https://discourse.nixos.org/t/after-the-derivation-is-built-what-happens-to-files-in-out/24711 I am still pretty new to Nix so it's a learning experience for me too :)