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

service-wrapper: init at 16.04.0 #20423

Merged
merged 1 commit into from Nov 4, 2017
Merged

service-wrapper: init at 16.04.0 #20423

merged 1 commit into from Nov 4, 2017

Conversation

DerTim1
Copy link

@DerTim1 DerTim1 commented Nov 15, 2016

Motivation for this change

Add the service-wrapper script to Nix (mainly to NixOS). If you are familiar with SystemV or Upstart, you are used to do something like
service cron restart
instead of
systemctl restart cron
(arguments transposed). This commit adds a package named service-wrapper. It wraps commands with service to systemctl (compare the same script on Ubuntu, Debian and RedHat).

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 (Nix on Ubuntu 16.04)
  • 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.

name = "service-wrapper-${version}";
version = "16.04.0"; # Ajar to Ubuntu Release

inherit src;
Copy link
Contributor

Choose a reason for hiding this comment

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

Better would be to separate real service-wrapper to separate file and use it in src:

src = ./service-wrapper.sh;

You don't need to pass src as attribute because you can directly override derivation attributes (lib.overrideDerivation) later as you wish.


inherit src;

unpackCmd = ''
Copy link
Contributor

Choose a reason for hiding this comment

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

unpackCmd, dontBuild, installPhase and postFixup can be replaced by single phase - buildCommand

But in that case you probably would find it better to use lib.runCommand or lib.writeScriptBin

@DerTim1
Copy link
Author

DerTim1 commented Nov 15, 2016

@danbst Nice hints. We need these things in documentation.
I have totally rewritten the package description (put mainscript to separate file and use substituteAll and runCommand).

@danbst
Copy link
Contributor

danbst commented Nov 15, 2016

basic stop start restart status work for me on NixOS, so +1 from me

@DerTim1
Copy link
Author

DerTim1 commented Jan 3, 2017

Push/Ping :)

in
runCommand "${name}" {
script = substituteAll {
src = ./service-wrapper.sh;
Copy link
Member

Choose a reason for hiding this comment

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

Is there an URL, where this could be downloaded from?

Copy link
Author

Choose a reason for hiding this comment

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

Unfortunately no :(

@7c6f434c 7c6f434c merged commit d715c08 into NixOS:master Nov 4, 2017
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

5 participants