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