-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
v2raya: add cliPackage option #319526
v2raya: add cliPackage option #319526
Conversation
traling whitespace check fails |
253a550
to
4730889
Compare
fixed |
@@ -6,11 +6,22 @@ with lib; | |||
options = { | |||
services.v2raya = { | |||
enable = options.mkEnableOption "the v2rayA service"; | |||
|
|||
cliPackage = mkOption { |
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.
cliPackage = mkOption { | |
package = mkOption { |
Please use mkPackageOption
}; | ||
}; | ||
|
||
config = mkIf config.services.v2raya.enable { | ||
environment.systemPackages = [ pkgs.v2raya ]; | ||
environment.systemPackages = [ (pkgs.v2raya.override { v2ray = config.services.v2raya.cliPackage; }) ]; |
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.
This seems unnecessary complex and inflexible.
environment.systemPackages = [ (pkgs.v2raya.override { v2ray = config.services.v2raya.cliPackage; }) ]; | |
environment.systemPackages = [ cfg.package ]; |
This makes the configuration more straight forward and flexible, and people can also just overwrite the cli package or the entire package
@@ -33,7 +44,7 @@ with lib; | |||
|
|||
serviceConfig = { | |||
User = "root"; | |||
ExecStart = "${getExe pkgs.v2raya} --log-disable-timestamp"; | |||
ExecStart = "${getExe (pkgs.v2raya.override { v2ray = config.services.v2raya.cliPackage; })} --log-disable-timestamp"; |
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.
ExecStart = "${getExe (pkgs.v2raya.override { v2ray = config.services.v2raya.cliPackage; })} --log-disable-timestamp"; | |
ExecStart = "${getExe cfg.package; })} --log-disable-timestamp"; |
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.
this doesn't do what you think it does, since the package is v2raya, not xray so this change will break the execstart
cliPackage = mkOption { | ||
type = types.package; | ||
default = pkgs.v2ray; | ||
defaultText = literalExpression "pkgs.v2ray"; | ||
example = literalExpression "pkgs.xray"; | ||
description = '' | ||
The package used for the cli binary. | ||
''; | ||
relatedPackages = [ "xray" "v2ray" ]; | ||
}; |
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.
cliPackage = mkOption { | |
type = types.package; | |
default = pkgs.v2ray; | |
defaultText = literalExpression "pkgs.v2ray"; | |
example = literalExpression "pkgs.xray"; | |
description = '' | |
The package used for the cli binary. | |
''; | |
relatedPackages = [ "xray" "v2ray" ]; | |
}; | |
package = options.mkPackageOption pkgs "v2raya" { } | |
cliPackage = options.mkOption { | |
type = types.package; | |
default = pkgs.v2ray; | |
defaultText = literalExpression "pkgs.v2ray"; | |
example = literalExpression "pkgs.xray"; | |
description = '' | |
The package used for the cli binary. | |
''; | |
relatedPackages = [ "xray" "v2ray" ]; | |
}; |
package
almost always refers to the main package used. Since you also need cliPackage
, use a separate option for it.
To avoid rebuilds, make sure the package's default v2ray
attribute is set to the default for cliPackage
.
}; | ||
}; | ||
|
||
config = mkIf config.services.v2raya.enable { | ||
environment.systemPackages = [ pkgs.v2raya ]; | ||
environment.systemPackages = [ (pkgs.v2raya.override { v2ray = config.services.v2raya.cliPackage; }) ]; |
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.
environment.systemPackages = [ (pkgs.v2raya.override { v2ray = config.services.v2raya.cliPackage; }) ]; | |
environment.systemPackages = [ (cfg.package.override { v2ray = cfg.cliPackage; }) ]; |
Ditto for the other instance of the 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.
error: undefined variable 'cfg'
after I added
let
cfg = config.services.v2raya;
in
at the top the next error is
error: function 'anonymous lambda' called with unexpected argument 'v2ray'
the one that works is pkgs.v2raya.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.
Please push your changes, even if they're broken, so we can find the error.
I pushed a version where I already fixed the errors |
v2raya can now be run using the xray cli package as well
It looks like you accidentally mass-pinged a bunch of people by accidentally requesting Please open a new pull request with your changes, link back to this one and ping the In order to avoid this in the future, there are instructions for how to properly |
v2raya can now be run using the xray cli package as well
Description of changes
fixes #271818
Things done
added a cliPackage option
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.