User:SigmaSquadron/Template:Evaluate: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
== Proposal == | |||
Alter the [[Template:Evaluate]] to support more commands than just <code>switch</code> by providing the optional attribute <code>action</code>. This change is backwards compatible and requires no changes to existing template calls. | |||
== About == | |||
This template is used to remind end-users that they need to rebuild for the changes to take effect. The optional attribute <code>action</code> can be used to define the subcommand suggested by the tip. | |||
== Usage == | |||
Default <code>Evaluate</code> Box: | |||
<pre> | |||
<nowiki>{{Evaluate}}</nowiki> | |||
</pre> | |||
Boot <code>Evaluate</code> Box: | |||
<pre> | |||
<nowiki>{{Evaluate|action=boot}}</nowiki> | |||
</pre> | |||
Test <code>Evaluate</code> Box: | |||
<pre> | <pre> | ||
<nowiki>{{Evaluate|action=test}}</nowiki> | |||
</pre> | |||
== Example == | |||
Default <code>Evaluate</code> Box: (Called without action) | |||
{{Tip|1=In order to '''affect''' your NixOS system by your nix-language-specific changes you must first '''evaluate''' it:{{Commands|$ nixos-rebuild switch --use-remote-sudo}}}} | |||
Boot <code>Evaluate</code> Box: | |||
{{Tip|1=In order to '''affect''' your NixOS system by your nix-language-specific changes you must first '''evaluate''' it:{{Commands|$ nixos-rebuild boot --use-remote-sudo}}Then, reboot:{{Commands|$ systemctl reboot}}}} | |||
Test <code>Evaluate</code> Box: | |||
{{Tip|1=In order to '''affect''' your NixOS system by your nix-language-specific changes you must first '''evaluate''' it:{{Commands|$ nixos-rebuild test --use-remote-sudo}}'''Remember:''' any changes evaluated through <code>nixos-rebuild test</code> '''will not''' persist upon reboot.}} | |||
== Potential Issues == | |||
* You could call some other <nowiki>{{{action}}}</nowiki>, like so: <nowiki>{{Evaluate|action=list-generations}}</nowiki>, and the message about evaluating your configuration would no longer make any sense. I expect editors to know better than that though. | |||
* The usage of <code>--use-remote-sudo</code> means that the command wouldn't work for those not using <code>sudo</code>. However, there is the tiny benefit that the evaluation and build process is no longer called by the root user, which may be helpful for those using flake-based evaluation. | |||
== Code == | |||
<syntaxhighlight lang=html> | |||
<noinclude>{{DISPLAYTITLE:Template:evaluate}} | <noinclude>{{DISPLAYTITLE:Template:evaluate}} | ||
Line 9: | Line 52: | ||
Default <code>Evaluate</code> Box: | Default <code>Evaluate</code> Box: | ||
<pre> | |||
<nowiki>{{Evaluate}}</nowiki> | <nowiki>{{Evaluate}}</nowiki> | ||
</pre> | |||
Boot <code>Evaluate</code> Box: | Boot <code>Evaluate</code> Box: | ||
<pre> | |||
<nowiki>{{Evaluate|boot}}</nowiki> | <nowiki>{{Evaluate|boot}}</nowiki> | ||
</pre> | |||
Test <code>Evaluate</code> Box: | Test <code>Evaluate</code> Box: | ||
<pre> | |||
<nowiki>{{Evaluate|boot}}</nowiki> | <nowiki>{{Evaluate|boot}}</nowiki> | ||
</pre> | |||
== Example == | == Example == | ||
Line 31: | Line 81: | ||
</noinclude><includeonly>{{Tip | </noinclude><includeonly>{{Tip | ||
|1=In order to '''affect''' your NixOS system by your nix-language-specific changes you must first '''evaluate''' it:{{Commands|$ nixos-rebuild {{{action|switch}}} --use-remote-sudo}}{{#ifeq: boot | {{{action}}} | Then, reboot:{{Commands|$ systemctl reboot}}}}{{#ifeq: test | {{{action}}} | '''Remember:''' any changes evaluated through <code>nixos-rebuild test</code> '''will not''' persist upon reboot.}}}}</includeonly> | |1=In order to '''affect''' your NixOS system by your nix-language-specific changes you must first '''evaluate''' it:{{Commands|$ nixos-rebuild {{{action|switch}}} --use-remote-sudo}}{{#ifeq: boot | {{{action}}} | Then, reboot:{{Commands|$ systemctl reboot}}}}{{#ifeq: test | {{{action}}} | '''Remember:''' any changes evaluated through <code>nixos-rebuild test</code> '''will not''' persist upon reboot.}}}}</includeonly> | ||
</ | </syntaxhighlight> |