User:SigmaSquadron/Template:Evaluate: Difference between revisions

From NixOS Wiki
 
(5 intermediate revisions by the same user not shown)
Line 38: Line 38:
== Potential Issues ==
== 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.
* 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.
* This could be rewritten as an anonymous tag with just <nowiki>{{Evaluate|boot}}</nowiki> by using <nowiki>{{{1}}}</nowiki> instead of <nowiki>{{{action}}}</nowiki>. I personally dislike this alternative syntax, but it may be preferable to editors.


* 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. Also, it can point users on the right path when they begin to build systems remotely.
* 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. Also, it can point users on the right path when they begin to build systems remotely.
Line 59: Line 61:


<pre>
<pre>
<nowiki>{{Evaluate|boot}}</nowiki>
<nowiki>{{Evaluate|action=boot}}</nowiki>
</pre>
</pre>


Line 66: Line 68:


<pre>
<pre>
<nowiki>{{Evaluate|boot}}</nowiki>
<nowiki>{{Evaluate|action=test}}</nowiki>
</pre>
</pre>


Line 81: Line 83:
</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>
== Code (No --use-remote-sudo) ==
<syntaxhighlight lang=html>
<noinclude>{{DISPLAYTITLE:Template:evaluate}}
== 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>
<nowiki>{{Evaluate|action=boot}}</nowiki>
</pre>
== Example ==
Default <code>Evaluate</code> Box:
{{Evaluate}}
Boot <code>Evaluate</code> Box:
{{Evaluate|action=boot}}
Test <code>Evaluate</code> Box:
{{Evaluate|action=test}}
</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}}}}}{{#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>
== Code (Anonymous) ==
<syntaxhighlight lang=html>
<noinclude>{{DISPLAYTITLE:Template:evaluate}}
== About ==
This template is used to remind end-users that they need to rebuild for the changes to take effect. Optionally, you may define the action being suggested.
== Usage ==
Default <code>Evaluate</code> Box:
<pre>
<nowiki>{{Evaluate}}</nowiki>
</pre>
Boot <code>Evaluate</code> Box:
<pre>
<nowiki>{{Evaluate|boot}}</nowiki>
</pre>
Test <code>Evaluate</code> Box:
<pre>
<nowiki>{{Evaluate|test}}</nowiki>
</pre>
== Example ==
Default <code>Evaluate</code> Box:
{{Evaluate}}
Boot <code>Evaluate</code> Box:
{{Evaluate|boot}}
Test <code>Evaluate</code> Box:
{{Evaluate|test}}
</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 {{{1|switch}}} --use-remote-sudo}}{{#ifeq: boot | {{{1}}} | Then, reboot:{{Commands|$ systemctl reboot}}}}{{#ifeq: test | {{{1}}} | '''Remember:''' any changes evaluated through <code>nixos-rebuild test</code> '''will not''' persist upon reboot.}}}}</includeonly>
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 09:36, 4 July 2024

Proposal

Alter the Template:Evaluate to support more commands than just switch by providing the optional attribute action. 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 action can be used to define the subcommand suggested by the tip.

Usage

Default Evaluate Box:

{{Evaluate}}

Boot Evaluate Box:

{{Evaluate|action=boot}}

Test Evaluate Box:

{{Evaluate|action=test}}

Example

Default Evaluate Box: (Called without action)

Boot Evaluate Box:

Test Evaluate Box:

Potential Issues

  • You could call some other {{{action}}}, like so: {{Evaluate|action=list-generations}}, and the message about evaluating your configuration would no longer make any sense. I expect editors to know better than that though.
  • This could be rewritten as an anonymous tag with just {{Evaluate|boot}} by using {{{1}}} instead of {{{action}}}. I personally dislike this alternative syntax, but it may be preferable to editors.
  • The usage of --use-remote-sudo means that the command wouldn't work for those not using sudo. 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. Also, it can point users on the right path when they begin to build systems remotely.

Code

<noinclude>{{DISPLAYTITLE:Template:evaluate}}

== 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>
<nowiki>{{Evaluate|action=test}}</nowiki>
</pre>

== Example ==
Default <code>Evaluate</code> Box:
{{Evaluate}}

Boot <code>Evaluate</code> Box:
{{Evaluate|action=boot}}

Test <code>Evaluate</code> Box:
{{Evaluate|action=test}}

</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>

Code (No --use-remote-sudo)

<noinclude>{{DISPLAYTITLE:Template:evaluate}}

== 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>
<nowiki>{{Evaluate|action=boot}}</nowiki>
</pre>

== Example ==
Default <code>Evaluate</code> Box:
{{Evaluate}}

Boot <code>Evaluate</code> Box:
{{Evaluate|action=boot}}

Test <code>Evaluate</code> Box:
{{Evaluate|action=test}}

</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}}}}}{{#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>

Code (Anonymous)

<noinclude>{{DISPLAYTITLE:Template:evaluate}}

== About ==
This template is used to remind end-users that they need to rebuild for the changes to take effect. Optionally, you may define the action being suggested.

== Usage ==

Default <code>Evaluate</code> Box:

<pre>
<nowiki>{{Evaluate}}</nowiki>
</pre>

Boot <code>Evaluate</code> Box:

<pre>
<nowiki>{{Evaluate|boot}}</nowiki>
</pre>


Test <code>Evaluate</code> Box:

<pre>
<nowiki>{{Evaluate|test}}</nowiki>
</pre>

== Example ==
Default <code>Evaluate</code> Box:
{{Evaluate}}

Boot <code>Evaluate</code> Box:
{{Evaluate|boot}}

Test <code>Evaluate</code> Box:
{{Evaluate|test}}

</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 {{{1|switch}}} --use-remote-sudo}}{{#ifeq: boot | {{{1}}} | Then, reboot:{{Commands|$ systemctl reboot}}}}{{#ifeq: test | {{{1}}} | '''Remember:''' any changes evaluated through <code>nixos-rebuild test</code> '''will not''' persist upon reboot.}}}}</includeonly>