nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 89 lines 2.4 kB view raw
1{ 2 lib, 3 python3, 4 fetchFromGitHub, 5 systemd, 6 xrandr, 7 installShellFiles, 8 desktop-file-utils, 9 udevCheckHook, 10}: 11 12python3.pkgs.buildPythonApplication rec { 13 pname = "autorandr"; 14 version = "1.15"; 15 format = "other"; 16 17 src = fetchFromGitHub { 18 owner = "phillipberndt"; 19 repo = "autorandr"; 20 tag = version; 21 hash = "sha256-8FMfy3GCN4z/TnfefU2DbKqV3W35I29/SuGGqeOrjNg"; 22 }; 23 24 nativeBuildInputs = [ 25 installShellFiles 26 desktop-file-utils 27 udevCheckHook 28 ]; 29 propagatedBuildInputs = with python3.pkgs; [ packaging ]; 30 31 buildPhase = '' 32 substituteInPlace autorandr.py \ 33 --replace 'os.popen("xrandr' 'os.popen("${xrandr}/bin/xrandr' \ 34 --replace '["xrandr"]' '["${xrandr}/bin/xrandr"]' 35 ''; 36 37 patches = [ ./0001-don-t-use-sys.executable.patch ]; 38 39 outputs = [ 40 "out" 41 "man" 42 ]; 43 44 installPhase = '' 45 runHook preInstall 46 make install TARGETS='autorandr' PREFIX=$out 47 48 # zsh completions exist but currently have no make target, use 49 # installShellCompletions for both 50 # see https://github.com/phillipberndt/autorandr/issues/197 51 installShellCompletion --cmd autorandr \ 52 --bash contrib/bash_completion/autorandr \ 53 --zsh contrib/zsh_completion/_autorandr \ 54 --fish contrib/fish_completion/autorandr.fish 55 56 make install TARGETS='autostart_config' PREFIX=$out DESTDIR=$out 57 58 make install TARGETS='manpage' PREFIX=$man 59 60 ${ 61 if systemd != null then 62 '' 63 make install TARGETS='systemd udev' PREFIX=$out DESTDIR=$out \ 64 SYSTEMD_UNIT_DIR=/lib/systemd/system \ 65 UDEV_RULES_DIR=/etc/udev/rules.d 66 substituteInPlace $out/etc/udev/rules.d/40-monitor-hotplug.rules \ 67 --replace /bin/systemctl "/run/current-system/systemd/bin/systemctl" 68 '' 69 else 70 '' 71 make install TARGETS='pmutils' DESTDIR=$out \ 72 PM_SLEEPHOOKS_DIR=/lib/pm-utils/sleep.d 73 make install TARGETS='udev' PREFIX=$out DESTDIR=$out \ 74 UDEV_RULES_DIR=/etc/udev/rules.d 75 '' 76 } 77 78 runHook postInstall 79 ''; 80 81 meta = with lib; { 82 homepage = "https://github.com/phillipberndt/autorandr/"; 83 description = "Automatically select a display configuration based on connected devices"; 84 license = licenses.gpl3Plus; 85 maintainers = with maintainers; [ coroa ]; 86 platforms = platforms.unix; 87 mainProgram = "autorandr"; 88 }; 89}