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

illum: init at 0.4 #22175

Merged
merged 1 commit into from Feb 5, 2017
Merged

illum: init at 0.4 #22175

merged 1 commit into from Feb 5, 2017

Conversation

dancek
Copy link
Contributor

@dancek dancek commented Jan 26, 2017

Motivation for this change

There seemed to be no easy/automatic solution in NixOS to get the screen brightness adjustment keys working. At least in the case that BIOS doesn't handle them and you run a simplistic system without KDE/GNOME/XFCE. Illum is a simple daemon that listens to brightness keys and adjusts the screen backlight. Probably useful for other people, too.

Tested by running nix-build -A 'config.systemd.units."illum.service".unit', copying the resulting service definition to /run/systemd/system and running the service.

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
    • Linux
  • 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.

@mention-bot
Copy link

@dancek, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @offlinehacker and @bjornfor to be potential reviewers.

@dancek
Copy link
Contributor Author

dancek commented Jan 26, 2017

Apparently set -eu -o pipefail fails on the shell Travis CI is building with. Looks like my /bin/sh is actually bash (I'm used to having a more lightweight shell for scripts), so probably the build will also fail on my machine after I set nix.useSandbox.

I'll try to make the build use bash explicitly if I can figure out how.

@dancek
Copy link
Contributor Author

dancek commented Jan 26, 2017

Strange. I enabled useSandbox and ran nixos-rebuild switch, but the build still works for me.

@dancek
Copy link
Contributor Author

dancek commented Jan 26, 2017

This version uses bash to build, I think. Not completely sure how buildInputs work.


config = mkIf cfg.enable {

environment.systemPackages = [ pkgs.illum ];
Copy link
Member

Choose a reason for hiding this comment

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

This probably shouldn't be necessary? Or do you have to map your keys to use an "illum client"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought that's needed to mark the dependency on the illum package.

There's no need to map keys or anything like that. Illum just works, but there will probably be some configurable options in the future.

Copy link
Member

Choose a reason for hiding this comment

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

No the serviceConfig.ExecStart = "${pkgs.illum}/bin/illum-d"; is enough for that, this would just add the binaries to the path for all users.

@dancek
Copy link
Contributor Author

dancek commented Feb 4, 2017

It's been a while, but here's yet another version that explicitly uses bash ./configure to avoid the set -o pipefail error with a POSIX shell.

I removed the unnecessary environment.systemPackages definition too.

sha256 = "05v3hz7n6b1mlhc6zqijblh1vpl0ja1y8y0lafw7mjdz03wxhfdb";
};

buildInputs = [ bash pkgconfig ninja libevdev libev ];
Copy link
Contributor

Choose a reason for hiding this comment

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

bash is already part of stdenv

services.illum = {

enable = mkOption {
default = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please specify type = types.bool here; there's no inference right now.

config = mkIf cfg.enable {

systemd.services.illum = {
description = "illum";
Copy link
Contributor

Choose a reason for hiding this comment

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

Please flesh out the description a little bit.


systemd.services.illum = {
description = "illum";
after = [ "basic.target" ];
Copy link
Contributor

Choose a reason for hiding this comment

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

after = [ "basic.target" ] is strictly unnecessary; it is the systemd default.

buildInputs = [ bash pkgconfig ninja libevdev libev ];

configurePhase = ''
bash ./configure
Copy link
Contributor

Choose a reason for hiding this comment

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

stdenv.shell can be safely assumed to be bash.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Earlier Travis builds failed on the line set -eu -o pipefail of the configure script, claiming pipefail is an invalid option. Pipefail is a bash extension, been around since bash 3 (2004). Therefore I assumed Travis builds with a POSIX shell (dash or such).

Is there a way to make Travis builds succeed while not explicitly running with bash?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, I see. Sounds like an impurity issue (if travis runs on ubuntu, /bin/sh is dash, I think). You could either patch the shebang of configure (e.g., using the patchShebangs helper in preConfigure) or leave it as is; bash ought to be available in the build environment without adding it to the build inputs, at any rate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll go with bash ./configure then. The script incorrectly specifies #!/bin/sh when it actually needs bash, so in my understanding patchShebangs might not suffice there.

@dancek
Copy link
Contributor Author

dancek commented Feb 4, 2017

@joachifm thanks for the review. Here's another version with the requested changes implemented.

I assume the Travis CI build will fail again because of set -o pipefail now that I removed the explicit bash call.

@dancek
Copy link
Contributor Author

dancek commented Feb 4, 2017

I changed back to bash ./configure to make the Travis build work. Sorry for clobbering the build queue with my tiny edits!

@dancek
Copy link
Contributor Author

dancek commented Feb 5, 2017

The build was successful and the requested changes have been implemented. Waiting for someone to merge this (or request other changes).

@joachifm joachifm merged commit 4459f26 into NixOS:master Feb 5, 2017
@joachifm
Copy link
Contributor

joachifm commented Feb 5, 2017

Thank you

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

Successfully merging this pull request may close these issues.

None yet

4 participants