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

nixos/xautolock: rewrite and add some options #30128

Merged
merged 1 commit into from Oct 10, 2017
Merged

Conversation

WilliButz
Copy link
Member

Things done
  • xautolock is now run as a user service
  • added the killer and killertime options to the module
  • added extraOptions for additional customization
  • 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 via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • 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.

/cc @Ma27 @fpletz

@Ma27
Copy link
Member

Ma27 commented Oct 5, 2017 via email

type = types.nullOr types.string;

description = ''
The script to use when manually locking the computer with `xautolock -locknow`.
Copy link
Member

Choose a reason for hiding this comment

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

I believe

`xautolock -locknow`

here should be

<command>xautolock -locknow</command>

since the description is interpreted as docbook code.

killer = mkOption {
default = null; # default according to `man xautolock` is none
example = "systemctl suspend";
type = types.string;
Copy link
Member

Choose a reason for hiding this comment

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

must be types.nullOr types.string.
I left this one empty and I got error: The option value `services.xserver.xautolock.killer' in `/home/ma27/Projects/nixpkgs/nixos/modules/services/x11/xautolock.nix' is not a string.

@@ -45,28 +55,80 @@ in
};

notifier = mkOption {
default = "notify-send 'Locking in 10 seconds'";
type = types.string;
default = null;
Copy link
Member

Choose a reason for hiding this comment

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

as you added an assertion to ensure that notifier contains a useful script, default = null is not a good idea, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I did this so that you'd have to take care of the script when you set enableNotifier to true, because the previous default notify-send was not mentioned in the manpage and would add another dependency.

@Ma27
Copy link
Member

Ma27 commented Oct 7, 2017

FYI I built a simple test VM using the following expression to confirm this change:

{
  xautolock = { pkgs, ... }: with pkgs; {
    environment.systemPackages = [ pkgs.i3lock ];

    users.extraUsers.vm = {
      password = "vm";
      extraGroups = [ "wheel" ];
      isNormalUser = true;
    };

    services.xserver = {
      enable = true;
      windowManager = {
        i3.enable = true;
        default = "i3";
      };
      desktopManager = {
        xterm.enable = false;
        default = "none";
      };
      xautolock = {
        enable = true;
        enableNotifier = true;
        locker = "i3lock";
        killer = "systemctl suspend";
        notifier = "notify-send 'abc'";
      };
    };
  };
}

@WilliButz WilliButz force-pushed the xautolock branch 2 times, most recently from 760aa18 to 5ed21ee Compare October 7, 2017 11:10
default = "notify-send 'Locking in 10 seconds'";
type = types.string;
default = null;
example = "notify-send 'Locking in 10 seconds'";
Copy link
Member

@Mic92 Mic92 Oct 7, 2017

Choose a reason for hiding this comment

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

Would this example actually work if libnotify is not installed? Should this not be "${pkgs.libnotify}/bin/notify-send" 'Locking in 10 seconds'.

Copy link
Member

Choose a reason for hiding this comment

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

true, but the example is just for documentation purposes and nothing that actually influences the system, right?

Copy link
Member Author

@WilliButz WilliButz Oct 7, 2017

Choose a reason for hiding this comment

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

@Mic92 No it actually won't, but I'm not sure what example should be used there, so I kept the previous one. I'd prefix it as you did if this example with notify-send is acceptable, even though it does not notify me on my own system like that. I'm using i3wm and here it probably would be more fitting to use something like i3-nagbar -m 'locking soon'.
I'm open for suggestions :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I just got it working. I need to have notify-osd running and then notify-send works, which means anyone using notify-send has to enable/run the daemon manually. I think this is not for the xautolock module to handle, right?
If so, I'd just prefix the command in the example :)

Copy link
Member

Choose a reason for hiding this comment

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

Using the following value should do the trick:

example = literalExample ''"${pkgs.libnotify}/bin/notify-send \"Locking in 10 seconds\"''';

@Ma27
Copy link
Member

Ma27 commented Oct 8, 2017

@WilliButz done :-)

@grahamc
Copy link
Member

grahamc commented Oct 10, 2017

@Ma27 can you formalize that in to a proper nixos test that can be run by hydra?

@globin globin merged commit 5e8d175 into NixOS:master Oct 10, 2017
@Ma27
Copy link
Member

Ma27 commented Mar 9, 2018

@grahamc sorry for the delay, I've just seen your comment right now as I talked with @WilliButz about some user services and things like this.
Back in October that wasn't possible since the testing framework didn't support user services properly (see #32845), however I hope that I manage to write a test tonight %)

@WilliButz WilliButz deleted the xautolock branch March 10, 2018 21:22
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

6 participants