Derivations: Difference between revisions

DoggoBit (talk | contribs)
Low-level derivations: Fix escaped bash operator
DoggoBit (talk | contribs)
Low-level derivations: Fix escaped nixpkgs reference
Line 22: Line 22:
As mentioned above, writing derivations in this manner can quickly become unwieldy and unfeasible. However, in order to understand why, do check out the main article above to follow the process of writing a derivation while hitting every hurdle that you might hit when building one yourself. Doing so is the best way to understand conceptually how derivations operate. You can see what a well defined low-level derivation might look like, in this case simply creating a script that displays the message ''"Hello, world!"'':
As mentioned above, writing derivations in this manner can quickly become unwieldy and unfeasible. However, in order to understand why, do check out the main article above to follow the process of writing a derivation while hitting every hurdle that you might hit when building one yourself. Doing so is the best way to understand conceptually how derivations operate. You can see what a well defined low-level derivation might look like, in this case simply creating a script that displays the message ''"Hello, world!"'':
{{File|example.nix|nix|<nowiki>let
{{File|example.nix|nix|<nowiki>let
   pkgs = import <nixpkgs> {};
   pkgs = import </nowiki><<nowiki>nixpkgs</nowiki>><nowiki> {};
in
in
derivation {
derivation {
Line 28: Line 28:
   system = builtins.currentSystem;
   system = builtins.currentSystem;
   builder = "${pkgs.bash}/bin/bash";
   builder = "${pkgs.bash}/bin/bash";
   args = [ "-c" ''
   args = [
     echo 'echo "Hello, World!"' </nowiki>><nowiki> $out
    "-c"
   '' ];
     "echo 'echo \"Hello, World!\"' </nowiki>><nowiki> $out"
   ];
}</nowiki>}}
}</nowiki>}}