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
nixos/autorandr: make default target in systemd service configurable #42398
nixos/autorandr: make default target in systemd service configurable #42398
Conversation
@@ -28,7 +38,15 @@ in { | |||
wantedBy = [ "sleep.target" ]; | |||
}; | |||
|
|||
nixpkgs.overlays = mkIf (cfg.defaultTarget != null) [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why an overlay and not a local package override?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're actually right, I thought that it might sense to override the package when the option is set in the module system, but it's actually not needed as it only alters the .service
file :)
fcd72ba
to
f4f47e5
Compare
It would be possible to not have to rebuild autorandr on |
@infinisil ack, goodpoint. I just hacked it together to see if it works (and |
f4f47e5
to
2bda8a3
Compare
@infinisil done, would you mind having another look at it? 😄 |
2bda8a3
to
c223475
Compare
The `.service` file defining the `systemd` unit for `autorandr.service` which is bundled with the package itself uses `--default default` in the `ExecStart` section. This can be an issue when having multiple layouts (e.g. `default` as workstation layout I mostly work on and `mobile` when I go somewhere else). When the service gets restarted and `--default` can't be applied, however the current layout can't be detected (e.g. when working with an unknown beamer) the service silently fails with a message like this: ``` Jun 22 18:44:46 hauptshuhle autorandr[3168]: /nix/store/h83b72ffm68nm8fyjnppljchp456a94r-xrandr-1.5.0/bin/xrandr: ca> Jun 22 18:44:46 hauptshuhle autorandr[3168]: Failed to apply profile 'default' (line 718): Jun 22 18:44:46 hauptshuhle autorandr[3168]: Command failed: /nix/store/h83b72ffm68nm8fyjnppljchp456a94r-xrandr-1.> ``` As discussed in the IRC (see https://botbot.me/freenode/nixos/2018-07-05/?msg=101791455&page=6) it's a bad long-term solution in terms of maintenance to manually patch the service file bundled with the derivation, instead the service shall be configured declaratively. Additionally this makes possible overrides from the user-space way easier. The `udev` rule (in `$out/etc/udev/rules.d`) won't' be affected, it simply runs `systemctl start autorandr.service` when e.g. a new display is added, so now `udev` communicates with the NixOS systemd unit.
c223475
to
8325996
Compare
@infinisil @gramahc I modified the patch as discussed and linked the relevant parts of the IRC logs in the commit message %) |
Awesome, looks much better, have you tested it? |
@infinisil yes I did, checked the resulting |
Nice! |
Motivation for this change
The
.service
file defining thesystemd
unit forautorandr.service
which is bundled with the package itself uses
--default default
in theExecStart
section. This can be an issue when having multiple layouts(e.g.
default
as workstation layout I mostly work on andmobile
whenI go somewhere else).
When the service gets restarted and
--default
can't be applied,however the current layout can't be detected (e.g. when working with an
unknown beamer) the service silently fails with a message like this:
As discussed in the IRC (see https://botbot.me/freenode/nixos/2018-07-05/?msg=101791455&page=6)
it's a bad long-term solution in terms of maintenance to manually patch
the service file bundled with the derivation, instead the service shall
be configured declaratively. Additionally this makes possible overrides
from the user-space way easier.
The
udev
rule (in$out/etc/udev/rules.d
) won't' be affected, itsimply runs
systemctl start autorandr.service
when e.g. a new displayis added, so now
udev
communicates with the NixOS systemd unit.Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)