Nix Cookbook: Difference between revisions

imported>Zie
add error The option has conflicting definitions
imported>Hmenke
writeScriptBin -> writeShellScriptBin
Line 3: Line 3:


=== Creating Shell Scripts ===
=== Creating Shell Scripts ===
Arbitrary system shell scripts can be created with [https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/trivial-builders.nix#L58 pkgs.writeScriptBin]. It creates a derivation which you add to [https://nixos.org/nixos/manual/#sec-declarative-package-mgmt environment.systemPackages].
Arbitrary system shell scripts can be created with [https://github.com/NixOS/nixpkgs/blob/808125fff694e4eb4c73952d501e975778ffdacd/pkgs/build-support/trivial-builders.nix#L225-L250 pkgs.writeShellScriptBin]. It creates a derivation which you add to [https://nixos.org/nixos/manual/#sec-declarative-package-mgmt environment.systemPackages].
<syntaxHighlight lang="nix">
<syntaxHighlight lang="nix">
{ pkgs, ... }:
{ pkgs, ... }:


let
let
   helloWorld = pkgs.writeScriptBin "helloWorld" ''
   helloWorld = pkgs.writeShellScriptBin "helloWorld" ''
    #!${pkgs.stdenv.shell}
     echo Hello World
     echo Hello World
   '';
   '';
Line 44: Line 43:


<syntaxHighlight lang="nix">
<syntaxHighlight lang="nix">
pkgs.writeScriptBin "hello" ''
pkgs.writeShellScriptBin "hello" ''
  #!${pkgs.stdenv.shell}
   # Call hello with a traditional greeting  
   # Call hello with a traditional greeting  
   exec ${pkgs.hello}/bin/hello -t
   exec ${pkgs.hello}/bin/hello -t
Line 55: Line 53:
<syntaxHighlight lang="nix">
<syntaxHighlight lang="nix">
let
let
   wrapped = pkgs.writeScriptBin "hello" ''
   wrapped = pkgs.writeShellScriptBin "hello" ''
    #!${pkgs.stdenv.shell}
     exec ${pkgs.hello}/bin/hello -t
     exec ${pkgs.hello}/bin/hello -t
   '';
   '';