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

autorandr: 59f6aec0b -> 53d29f9 #20744

Merged
merged 1 commit into from Dec 14, 2016
Merged

autorandr: 59f6aec0b -> 53d29f9 #20744

merged 1 commit into from Dec 14, 2016

Conversation

kampka
Copy link
Contributor

@kampka kampka commented Nov 26, 2016

Motivation for this change

This PR changes autorandr to the python branch of phillipberndt's for of autorandr.

The main reason for this is that the legacy branch seems to no longer work with a current version of xrandr, resulting in an failed to parse 'x' as a position error when trying to apply a profile.

In addition, disper support, the reason I believe for using the legacy branch, is no longer valid as disper itself does not support nvidia drivers of version >= 300 as of version 0.3.1 with the reasoning that those drivers support xrandr. Xrandr support however in incomplete in disper, making it effectively defunct on non-legacy hardware.

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

@kampka, thanks for your PR! By analyzing the history of the files in this pull request, we identified @coroa, @grahamc and @rycee to be potential reviewers.

@grahamc
Copy link
Member

grahamc commented Nov 26, 2016 via email

@rycee
Copy link
Member

rycee commented Nov 26, 2016

Haven't had time to look at this but at some point I used the Python branch myself and this was the expression I used:

{ stdenv, fetchFromGitHub, python3Packages, xrandr }:

stdenv.mkDerivation rec {
  name = "autorandr-${version}";
  version = "20160509";

  src = fetchFromGitHub {
    owner = "phillipberndt";
    repo = "autorandr";
    rev = "6cd92b657027423721a29dfe0c7080483cdfc81e";
    sha256 = "01m8q8jqz8jmvsfpw1jb13yc11wrfim9hj7c496advp21krj7ynz";
  };

  buildInputs = [ python3Packages.python python3Packages.wrapPython ];

  patchPhase = ''
    substituteInPlace autorandr.py \
      --replace "popen(\"xrandr" "popen(\"${xrandr}/bin/xrandr" \
      --replace "\"xrandr\"" "\"${xrandr}/bin/xrandr\""
  '';

  installPhase = ''
    mkdir -p $out/bin $out/etc/bash_completion.d
    cp -v contrib/bash_completion/autorandr $out/etc/bash_completion.d
    cp -v autorandr.py $out/bin/autorandr

    wrapPythonPrograms
  '';

  meta = with stdenv.lib; {
    description = "Automatic display configuration selector based on connected devices";
    homepage = https://github.com/phillipberndt/autorandr/;
    maintainers = [ maintainers.coroa ];
    license = licenses.gpl3Plus;
  };
}

I don't know how relevant it is now but maybe there is something of interest to have there? I notice, for example, that the bash completion is not installed in this proposed PR.

Also, since the package is built from a git revision and not a formal release I believe the name should include "unstable" , i.e., name = "autorandr-unstable-${date}";. See https://nixos.org/nixpkgs/manual/#sec-package-naming

'';

src = fetchgit {
Copy link
Member

@Mic92 Mic92 Nov 27, 2016

Choose a reason for hiding this comment

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

fetchFromGitHub is preferred here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

mkdir -p $out/bin $out/libexec
cp autorandr.py $out/libexec
makeWrapper "${python.interpreter} $out/libexec/autorandr.py" $out/bin/autorandr \
--prefix PYTHONPATH : "$PYTHONPATH"
Copy link
Member

Choose a reason for hiding this comment

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

Looks like a job for wrapPythonProgramsIn.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to wrapPythonProgramsIn.

@kampka
Copy link
Contributor Author

kampka commented Nov 27, 2016

@rycee Thanks for sharing your expression, it was very useful.

I am aware of the naming policy, but I am unsure how renaming the derivation will impact the upgrade path.
Can you maybe shed some light on that?

@Mic92
Copy link
Member

Mic92 commented Nov 27, 2016

@kampka if you mean the unstable prefix. you can change it without breaking anything.

@kampka
Copy link
Contributor Author

kampka commented Nov 27, 2016

@Mic92 Alright, done.

@Mic92
Copy link
Member

Mic92 commented Nov 27, 2016

@kampka you have not uploaded any updates so far.

@kampka
Copy link
Contributor Author

kampka commented Nov 27, 2016

@Mic92 I have squashed the commits, sorry if that confuses the process.

Anyways, I noticed there is still an issue with the python version that I am having trouble fixing.
When using the batch mode, autorandr tryies to figure out its own binary [1], which fails if called from udev or systemd.
If someone has a good idea on how to patch / fix that, I'd be glad to hear it.

[1] https://github.com/phillipberndt/autorandr/blob/master/autorandr.py#L791

@Mic92
Copy link
Member

Mic92 commented Nov 27, 2016

@kampka ok usually github rendered such changes differently.

@FRidh
Copy link
Member

FRidh commented Nov 29, 2016

@kampka if you mean the unstable prefix. you can change it without breaking anything.

Upgrading of imperatively installed programs (nix-env -i) uses the name of derivations to find the upgrade. So if I am correct add unstable might break that. We should document this behavior.

Anyways, I noticed there is still an issue with the python version that I am having trouble fixing.
When using the batch mode, autorandr tryies to figure out its own binary [1], which fails if called from udev or systemd.
If someone has a good idea on how to patch / fix that, I'd be glad to hear it.

Use substituteInplace ?

@vcunat
Copy link
Member

vcunat commented Dec 13, 2016

Ping?

@Mic92 Mic92 merged commit ce31c6b into NixOS:master Dec 14, 2016
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

8 participants