3 ms·
Thanks for the example - I’ve been looking for how to make mix packaging easy. How do you add files to this build? For example, if I have this program.rb that
by jeofken 6y ago
Thanks for the example - I’ve been looking for how to make mix packaging easy.
How do you add files to this build? For example, if I have this program.rb that depends on ruby:
puts “Hello World”
And then you add a file called package.nix
let pkgs = import <nixpkgs> {}; in
pkgs.runCommand "my-app"
{
buildInputs = [pkgs.ruby];
}
''
pwd && ls;
ruby ./program.rb
''
How do you get your files in there - like “ADD” in a Dockerfile?
- xfer 6y agoexample in the manual: https://nixos.org/manual/nixpkgs/stable/#chap-trivial-builders https://nixos.org/manual/nixpkgs/stable/#chap-trivial-builde... shows how it creates a file `$out/message`. If you want to write to nix store with stdenv use $out.
- chriswarbo 6y agoYou can splice file paths directly into the script, like this: let pkgs = import <nixpkgs> {}; in pkgs.runCommand "my-app" { buildInputs = [pkgs.ruby]; } '' pwd && ls ruby ${./program.rb} '' Or you could add it as an env var: let pkgs = import <nixpkgs> {}; in pkgs.runCommand "my-app" { buildInputs = [pkgs.ruby]; program = ./program.rb; } '' pwd && ls; ruby "$program" ''