adi1090x / rofi

A huge collection of Rofi based custom Applets, Launchers & Powermenus.
GNU General Public License v3.0
6.79k stars 316 forks source link

Nixos support #171

Open MyGitHubBlueberry opened 6 months ago

MyGitHubBlueberry commented 6 months ago

Hello there. I'm trying to make this package work with nixos. Here to ask for small script changes to make installation truly effortless. I attach flake.nix and default.nix to this post.

What is the problem, exactly? After running nix build, I should run nix run from the package directory. Here it is:

.
├── default.nix
├── flake.lock
├── flake.nix
└── result -> /nix/store/19h0gfn3wyr7n34iddgyfdxlmpvn0007-rofi-extended

result folder auto-generates after nix build. And nix run (also from the same directory because it relies on flakes) launches the installation process. The problem is that install script in the repo has $pwd varriable in it which represents the current directory. And then the script relies on folders which should be in that directory, namely fonts and files.

As you can see, looking at the tree, there is no such directories (they are in result folder).

Work around is to go to result and then ./bin/rofi-extended and then all installs as should, but i don't like this approach, so here I am, asking for help :)

Btw, I not feel like maintaining this nix package myself, so if there are volunteers or developers themselves, please, feel free to take my code.

default.nix

{
    stdenv,
    fetchFromGitHub,
    ...
}:

stdenv.mkDerivation {
  name = "rofi-extended";
  version = "0.0.1";

  src = fetchFromGitHub {
    owner = "adi1090x";
    repo = "rofi";
    rev = "7e236dd67fd98304e1be9e9adc2bed9106cf895b";
    hash = "sha256-K6WQ+olSy6Rorof/EGi9hP2WQpRONjuGREby+aBlzYg=";
  };
  # "sha256": "126dcnhgkwj68j33ndjfji19dzc4pml11zw7mrla9jsji7x9199b",

  # pwd = toString ./. + "";

  buildPhase = ''
    chmod +x setup.sh
  '';

  installPhase = ''
    mkdir -p $out/bin
    mv setup.sh $out/bin/rofi-extended
    mv files $out/bin
    mv fonts $out/bin
  '';
}

flake.nix

{
  description = "A huge collection of Rofi based custom Applets, Launchers & Powermenus.";

  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} = {
          rofi-extended = pkgs.callPackage ./. {}; #extra inputs
          default = self.packages.${system}.rofi-extended;
      };
  };
}
MyGitHubBlueberry commented 6 months ago

Maybe you could provide script for nixos install? In your start.sh:

...
## Directories ----------------------------
DIR=`pwd/result`
...

This should work, I think.

Please, let me know if you solve the problem :)

olaberglund commented 3 months ago

This is not an appropriate way of creating a nix derivation. Feel free to take inspiration from my package.nix for these launchers and themes.