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

add plotinus and module #34919

Merged
merged 2 commits into from Feb 14, 2018
Merged

add plotinus and module #34919

merged 2 commits into from Feb 14, 2018

Conversation

samdroid-apps
Copy link
Contributor

@samdroid-apps samdroid-apps commented Feb 13, 2018

Motivation for this change

Plotinus add a menu search feature to all Gtk+3 applications. Packaging the app is quite simple. However, users of plotinus usually want to enable it for all applications; and add it to the environment in some way.

This PR is marked as WIP because I'm not sure if this is the best/correct way to add something to the environment.

Currently, the approach is to add the required variables (eg. GTK3_MODULES) to the environment when starting session via the display manager. This was chosen as it would not affect other packages (eg. conditionally compiling it into GTK3 would cause mass rebuilds).

Looking for an opinion on if this is the correct way to do it.

Testing

vm.nix:

{ pkgs, config, ... }:
{
  services.xserver = {
    autorun = true;
    enable = true;

    windowManager.openbox.enable = true;
    displayManager.auto = {
      enable = true;
      user = "test";
    };
  };

  programs.plotinus.enable = true;

  users.extraUsers.test = {
    isNormalUser = true;
    uid = 1000;
    extraGroups = [ "wheel" ];
    password = "";
  };

  environment.systemPackages = with pkgs; [
    xterm
    gnome3.gnome-calculator
  ];
}

Then run:

nixos-rebuild build-vm -I nixpkgs=$HOME/nixpkgs -I nixos-config=vm.nix
./result/bin/run-nixos-vm

Inside the VM, open gnome-calculator. Press Ctrl-Shift-P to open the menu searcher.

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/) -- N/A
  • Fits CONTRIBUTING.md.

@jtojnar
Copy link
Contributor

jtojnar commented Feb 13, 2018

Another option is setting environment.variables.GTK3_MODULES, see for example

config = mkIf (cfg.profiles != {} || cfg.enable) {
environment.etc = optionals (cfg.profiles != {})
(mapAttrsToList mkDconfProfile cfg.profiles);
environment.variables.GIO_EXTRA_MODULES = optional cfg.enable
"${pkgs.gnome3.dconf.lib}/lib/gio/modules";
# https://github.com/NixOS/nixpkgs/pull/31891
#environment.variables.XDG_DATA_DIRS = optional cfg.enable
# "$(echo ${pkgs.gnome3.gsettings_desktop_schemas}/share/gsettings-schemas/gsettings-desktop-schemas-*)";
};

@jtojnar jtojnar added the 6.topic: GNOME GNOME desktop environment and its underlying platform label Feb 13, 2018
@jtojnar jtojnar added this to In Progress in GNOME Feb 13, 2018
@samdroid-apps samdroid-apps changed the title WIP/requesting-comment: add plotinus and module add plotinus and module Feb 13, 2018
@samdroid-apps
Copy link
Contributor Author

Thanks for the suggestion @jtojnar - I've changed to to use something like that and update the vm.nix template.

@GrahamcOfBorg GrahamcOfBorg removed the 6.topic: GNOME GNOME desktop environment and its underlying platform label Feb 13, 2018

config = mkIf cfg.enable {
environment.variables.GSETTINGS_SCHEMA_DIR = "${pkgs.plotinus}/share/gsettings-schemas/plotinus-0.2.0/glib-2.0/schemas";
environment.variables.GTK3_MODULES = "${pkgs.plotinus}/lib/libplotinus.so";
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be in array brackets, in order to be merged correctly.

###### implementation

config = mkIf cfg.enable {
environment.variables.GSETTINGS_SCHEMA_DIR = "${pkgs.plotinus}/share/gsettings-schemas/plotinus-0.2.0/glib-2.0/schemas";
Copy link
Contributor

Choose a reason for hiding this comment

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

And here, XDG_DATA_DIRS is probably better since GSETTINGS_SCHEMA_DIR cannot be used more than once.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds like a good idea. But I don't know how to use XDG_DATA_DIRS in this context as it gives me an error that it is specified by another module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, got ya - using a list fixes it.

Copy link
Contributor

Choose a reason for hiding this comment

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

environment.variables.XDG_DATA_DIRS = [ "${pkgs.plotinus}/share/gsettings-schemas/plotinus-0.2.0" ]; should work. What module is that?

$machine->waitForX;
$machine->execute("xterm -e 'gnome-calculator' &");
$machine->waitForWindow(qr/Calculator/);
# $machine->sleep(40); # wait until Firefox has finished loading the page
Copy link
Contributor

Choose a reason for hiding this comment

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

This not needed?

@samdroid-apps
Copy link
Contributor Author

Thanks for the review @jtojnar - I've amended and pushed again.

@jtojnar
Copy link
Contributor

jtojnar commented Feb 13, 2018

@GrahamcOfBorg test plotinus

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Partial log (click to expand)

machine: exit status 1
syncing
machine: running command: sync
machine: exit status 0
test script finished in 18.28s
cleaning up
killing machine (pid 593)
vde_switch: EOF on stdin, cleaning up and exiting
vde_switch: Could not remove ctl dir '/build/vde1.ctl': Directory not empty
/nix/store/qf858hp711sml13av9amgmz593nw0bc3-vm-test-run-plotinus

###### implementation

config = mkIf cfg.enable {

Copy link
Contributor

Choose a reason for hiding this comment

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

This space bugs me :)


config = mkIf cfg.enable {

environment.variables.XDG_DATA_DIRS = [ "${pkgs.plotinus}/share/gsettings-schemas/plotinus-0.2.0" ];
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use ${pkgs.plotinus.name} instead of plotinus-0.2.0 to be more forward compatible.

import ./make-test.nix ({ pkgs, ... }: {
name = "plotinus";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ samdroid-apps ];
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe use pkgs.plotinus.meta.maintainers?


environment.variables.XDG_DATA_DIRS = [ "${pkgs.plotinus}/share/gsettings-schemas/plotinus-0.2.0" ];
environment.variables.GTK3_MODULES = [ "${pkgs.plotinus}/lib/libplotinus.so" ];
};
Copy link
Contributor

@jtojnar jtojnar Feb 13, 2018

Choose a reason for hiding this comment

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

The module itself is missing meta.maintainers. https://nixos.org/nixpkgs/manual/#idm140737316978672

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That link doesn't seem to take me to any specific section. I assume you meant the "14.4. New modules" section?

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, apparently the manual anchors are not stable.

@GrahamcOfBorg
Copy link

Failure on aarch64-linux (full log)

Partial log (click to expand)

cannot build derivation '/nix/store/dydjbzki6lcy4wwf6j9y0888d59xkny5-system-units.drv': 3 dependencies couldn't be built
cannot build derivation '/nix/store/js0vzg10aqwc4fsbbw8vma757m3x1qpm-user-units.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/agc6x6y3a3caxavkjskpdxjdf9p98i4s-etc.drv': 5 dependencies couldn't be built
cannot build derivation '/nix/store/4yha9rm09f3isry7mazv9ip141gbb41l-nixos-system-machine-18.03.git.8972d18.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/4x3bind93i6fvl56hvrnmkf257magk2m-closure-info.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/2b5v25dk2c8d25cq9gyxpjisf68ryx5q-run-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/afx7q3wdgia4k1npzc9w0mybhmc7xv1w-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/axxmfsqxjys8nbkkaza8zlw6yk1iz833-nixos-test-driver-plotinus.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/8xy3cag29chnh1sdyaw340c7kzfbh022-vm-test-run-plotinus.drv': 1 dependencies couldn't be built
error: build of '/nix/store/8xy3cag29chnh1sdyaw340c7kzfbh022-vm-test-run-plotinus.drv' failed

@samdroid-apps
Copy link
Contributor Author

Thanks @jtojnar - I've updated to add the "meta", fix other comments, and add the required documentation.

@jtojnar
Copy link
Contributor

jtojnar commented Feb 14, 2018

Great work, thanks.

@jtojnar jtojnar merged commit 16fa6f5 into NixOS:master Feb 14, 2018
GNOME automation moved this from In Progress to Done Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
GNOME
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants