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

rofi: add theme option #36785

Merged
merged 1 commit into from Apr 4, 2018
Merged

rofi: add theme option #36785

merged 1 commit into from Apr 4, 2018

Conversation

Ma27
Copy link
Member

@Ma27 Ma27 commented Mar 11, 2018

Motivation for this change

This is helpful when defining a *.rasi theme for rofi using
pkgs.writeText rather than messing up the impure ~/.config
directory.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@7c6f434c
Copy link
Member

/cc @mbakke @garbas as maintainers

LGTM implementation-wise, I have some minor doubts whether theme is worth having a wrapper in the base package (but not the default value of normal-window, for example).

@Ma27
Copy link
Member Author

Ma27 commented Mar 11, 2018

I have some minor doubts whether theme is worth having a wrapper in the base package

the makeWrapper will only be added as buildInput if theme != null

but not the default value of normal-window, for example

Just to get your point right: you'd like to see several more options for rofi configurable in the wrapper or am I misunderstanding you?

@7c6f434c
Copy link
Member

I want an opinion from maintainers about desirability of having the wrapper code inside the main package definition, if I were sure I would speak with more confidence.

The goal is to write

rofi.override {
  theme = writeTextFile "rofi.theme" ''
    …
  '';
}

instead of

  writeScriptBin "rofi" ''${rofi}/bin/rofi --theme "${writeTextFile ''
    …
  ''}" "$@"''

right?

@Ma27
Copy link
Member Author

Ma27 commented Mar 11, 2018

that's true. I think that the first option is the simpler and more understandable approach. Furthermore I think that having such configuration options available in a package, so a simple override is sufficient to modify your packages for your own needs.
However you might be right - we should discuss at first if it's worth adding more code to the derivation to achieve this :)

@mbakke
Copy link
Contributor

mbakke commented Mar 11, 2018

Theme is probably the most used rofi tweak, so I think having a special provision for it is OK. This change allow downstreams or even Nixpkgs to ship a default theme with Rofi, and is more "natural" for end users than calling writeScriptBin or similar.

So LGTM.

Copy link
Member

@garbas garbas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we stuck everything in main derivation then every change will require rofi to be recompiled. It would make more sense to split it.

in pkgs/top-level/all-packages.nix we need :

{
  
  wrapRofi = callPackage ./../applications/misc/rofi/wrapper.nix {};
  rofi-unwrapped = callPackage ./../applications/misc/rofi {};
  rofi = wrapRofi rofi-unwrapped {};
  
}

I would look at neovim as an example how to write a wrapper derivation (pkgs/applications/editors/neovim/wrapper.nix)

@Ma27
Copy link
Member Author

Ma27 commented Mar 11, 2018

@garbas ACK. I hope that I have sufficient time to tomorrow to implement this :)

@Ma27 Ma27 force-pushed the configurable-rofi-theme branch 2 times, most recently from e924015 to f48d13d Compare March 12, 2018 13:16
@Ma27
Copy link
Member Author

Ma27 commented Mar 12, 2018

@garbas do you like the change now? %)

Copy link
Member

@garbas garbas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also give rofi-unwrapped the name rofi-unwrapped-${version} as this would be how other wrappers do it.

I hope you don't hate me for this nitpicking.

wrapProgram "$out/bin/rofi" --add-flags "-theme ${theme}"
'';

inherit (rofi_unwrapped) meta;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe do

meta = rofi-unwrapped.meta // {
  # prefer wrapper over the package
  priority = (rofi-unwrapped.meta.priority or 0) -1;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh I didn't know about priority, thanks!

@@ -17335,7 +17335,8 @@ with pkgs;

rkt = callPackage ../applications/virtualization/rkt { };

rofi = callPackage ../applications/misc/rofi { };
rofi_unwrapped = callPackage ../applications/misc/rofi { };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be named rofi-unwrapped to be consistent with how others are naming

@@ -0,0 +1,14 @@
{ symlinkJoin, rofi_unwrapped, makeWrapper, theme ? null, lib }:

symlinkJoin {
Copy link
Member

@garbas garbas Mar 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would use simple mkDerivation since we only want to link $out/bin/rofi in our wrapper and also make it overridable.

{ stdenv, lib, rofi-unwrapped, makeWrapper, theme ? null }:
let
  wrapper = stdenv.mkDerivation {
    name = "rofi-${version}";
    buildInputs = [ makeWrapper ];
    preferLocalBuild = true;
    passthru = { unwrapped = rofi-unwrapped; };
    buildCommand = ''
      ln -s ${rofi-unwrapped}/bin/rofi
      wrapProgram $out/bin/rofi --add-flags "-theme ${theme}"
    '';
    meta = rofi-unwrapped.meta // {
      # prefer wrapper over the package
      priority = (rofi-unwrapped.meta.priority or 0) -1;
    };
  };
in lib.makeOverridable wrapper

@Ma27
Copy link
Member Author

Ma27 commented Mar 12, 2018

I hope you don't hate me for this nitpicking.

In fact I don't, I'm always glad to learn new things (see my comment) and it keeps the codebase clean :D

@Ma27
Copy link
Member Author

Ma27 commented Mar 12, 2018

@garbas done, I have just one (possibly stupid) question: what exactly do you want to achieve with makeOverridable? I requires to args (func, args), but only one is given, so we return a partially applied function to callPackage. Now callPackage expects a function to return the derivation, however we have a nested partial function, so the end evaluation won't work.

{ lib }:
let
   wrapper = { stdenv, ... }: stdenv.mkDerivation {};
in lib.makeOverridable wrapper

The solution you proposed wouldn't work either as makeOverridable expects a function at first and not a derivation.
Could you please specify more detailed what you'd love to see in wrapper.nix (what's your concrete use-case?), then I might be able to find a suitable solution :)

@Ma27
Copy link
Member Author

Ma27 commented Mar 17, 2018

ping @garbas

@Ma27
Copy link
Member Author

Ma27 commented Apr 4, 2018

@garbas is there anything to add? I'd love to see this merged %)

@7c6f434c
Copy link
Member

7c6f434c commented Apr 4, 2018

@Ma27 OK, I can compare the requests to the current state: the idea of making rofi-unwrapped attribute have name rofi-unwrapped-${version} has been neither implemented nor rejected.

@Ma27 Ma27 force-pushed the configurable-rofi-theme branch 2 times, most recently from 5d35eb8 to 7dceaf1 Compare April 4, 2018 11:58
@Ma27
Copy link
Member Author

Ma27 commented Apr 4, 2018

@7c6f434c ahh you're right, thank you! %)

@GrahamcOfBorg
Copy link

Failure on x86_64-linux (full log)

Attempted: rofi

Partial log (click to expand)

- --:--:-- --:--:--
     0

  0     0    0     0    0     0      0      0 --:--:-
- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404 Not Found
error: cannot download rofi-unwrapped-1.5.1.tar.gz from any mirror
builder for ‘/nix/store/ixlc30aixlyshc75x52i0q9cnvs24gmq-rofi-unwrapped-1.5.1.tar.gz.drv’ failed with exit code 1
cannot build derivation ‘/nix/store/qmpa38911ld7jhas5w3ai0rfvn86ix9j-rofi-unwrapped-1.5.1.drv’: 1 dependencies couldn't be built
cannot build derivation ‘/nix/store/p8sc720ka47hcwb8w6x2afd79s0103wg-rofi-1.5.1.drv’: 1 dependencies couldn't be built
error: build of ‘/nix/store/p8sc720ka47hcwb8w6x2afd79s0103wg-rofi-1.5.1.drv’ failed

@7c6f434c
Copy link
Member

7c6f434c commented Apr 4, 2018

@Ma27 I don't think the URL should use the name with -unwrapped, though…

This is helpful when defining a `*.rasi` theme for rofi using
`pkgs.writeText` rather than messing up the impure `~/.config`
directory.
@GrahamcOfBorg
Copy link

Failure on aarch64-linux (full log)

Attempted: rofi

Partial log (click to expand)

   Compiling backtrace v0.3.4
   Compiling rustc_const_math v0.0.0 (file:///build/rustc-1.24.0-src/src/librustc_const_math)
   Compiling proc_macro v0.0.0 (file:///build/rustc-1.24.0-src/src/libproc_macro)
   Compiling syntax_ext v0.0.0 (file:///build/rustc-1.24.0-src/src/libsyntax_ext)
building of '/nix/store/whsyh46wr0zfkw420xcc8ffgahszsd80-rustc-1.24.0.drv' timed out after 3600 seconds
cannot build derivation '/nix/store/nfjkyviyyy9ly6hq1pj5wzy6qxmd491n-cargo-0.24.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/bbqaq71xj30lggbbbf6calm3g7g56c02-librsvg-2.42.2.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/wmpykl7jd0kpks3sja70vxcszkvv6vr7-rofi-unwrapped-1.5.1.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/4phknv692asnjxaprlplwxs0if4xw59h-rofi-1.5.1.drv': 1 dependencies couldn't be built
�[31;1merror:�[0m build of '/nix/store/4phknv692asnjxaprlplwxs0if4xw59h-rofi-1.5.1.drv' failed

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: rofi

Partial log (click to expand)

post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/fl2bvqz8py85ii97ihmxp1kk2hsw5p9d-rofi-unwrapped-1.5.1
shrinking /nix/store/fl2bvqz8py85ii97ihmxp1kk2hsw5p9d-rofi-unwrapped-1.5.1/bin/rofi
gzipping man pages under /nix/store/fl2bvqz8py85ii97ihmxp1kk2hsw5p9d-rofi-unwrapped-1.5.1/share/man/
strip is /nix/store/fzcs0fn6bb04m82frhlb78nc03ny3w55-binutils-2.28.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/fl2bvqz8py85ii97ihmxp1kk2hsw5p9d-rofi-unwrapped-1.5.1/lib  /nix/store/fl2bvqz8py85ii97ihmxp1kk2hsw5p9d-rofi-unwrapped-1.5.1/bin
patching script interpreter paths in /nix/store/fl2bvqz8py85ii97ihmxp1kk2hsw5p9d-rofi-unwrapped-1.5.1
checking for references to /tmp/nix-build-rofi-unwrapped-1.5.1.drv-0 in /nix/store/fl2bvqz8py85ii97ihmxp1kk2hsw5p9d-rofi-unwrapped-1.5.1...
building path(s) ‘/nix/store/qfa2jadqqbqvqafcnsaf13nn4588rjl9-rofi-1.5.1’
/nix/store/qfa2jadqqbqvqafcnsaf13nn4588rjl9-rofi-1.5.1

@7c6f434c 7c6f434c merged commit 63c6c2d into NixOS:master Apr 4, 2018
@Ma27 Ma27 deleted the configurable-rofi-theme branch April 4, 2018 13:46
@GrahamcOfBorg
Copy link

Failure on aarch64-linux (full log)

Attempted: rofi

Partial log (click to expand)

   Compiling backtrace v0.3.4
   Compiling proc_macro v0.0.0 (file:///build/rustc-1.24.0-src/src/libproc_macro)
   Compiling rustc_const_math v0.0.0 (file:///build/rustc-1.24.0-src/src/librustc_const_math)
   Compiling syntax_ext v0.0.0 (file:///build/rustc-1.24.0-src/src/libsyntax_ext)
building of '/nix/store/whsyh46wr0zfkw420xcc8ffgahszsd80-rustc-1.24.0.drv' timed out after 3600 seconds
cannot build derivation '/nix/store/nfjkyviyyy9ly6hq1pj5wzy6qxmd491n-cargo-0.24.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/bbqaq71xj30lggbbbf6calm3g7g56c02-librsvg-2.42.2.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/jrlr62lh4c7cm7kdahs46y0r6nlisdvw-rofi-unwrapped-1.5.1.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/vj9gls5719r6xbdnr7xh3qfvsjk1bj7z-rofi-1.5.1.drv': 1 dependencies couldn't be built
�[31;1merror:�[0m build of '/nix/store/vj9gls5719r6xbdnr7xh3qfvsjk1bj7z-rofi-1.5.1.drv' failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants