We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://discourse.nixos.org/t/how-pkgs-substituteall-chmod-x-buildenv/8167/2
Turns out pkgs.substituteAll has some extra functionality so pkgs.writeScript* isn’t needed even. So after some tinkering, this works: let pkgs = import <nixpkgs> {}; inherit (pkgs) lib; options = { foo = "foo"; bar = "bar"; }; scripts = lib.mapAttrs (name: type: pkgs.substituteAll ({ src = ./scripts + "/${name}"; dir = "bin"; isExecutable = true; } // options)) (builtins.readDir ./scripts); joined = pkgs.symlinkJoin { name = "scripts"; paths = lib.attrValues scripts; }; in joined
Turns out pkgs.substituteAll has some extra functionality so pkgs.writeScript* isn’t needed even. So after some tinkering, this works:
pkgs.substituteAll
pkgs.writeScript*
let pkgs = import <nixpkgs> {}; inherit (pkgs) lib; options = { foo = "foo"; bar = "bar"; }; scripts = lib.mapAttrs (name: type: pkgs.substituteAll ({ src = ./scripts + "/${name}"; dir = "bin"; isExecutable = true; } // options)) (builtins.readDir ./scripts); joined = pkgs.symlinkJoin { name = "scripts"; paths = lib.attrValues scripts; }; in joined
cowsay-hello.nix
{ lib , substituteAll , runtimeShell , cowsay }: substituteAll { name = "cowsay-hello"; src = ./cowsay-hello.sh; dir = "bin"; isExecutable = true; inherit runtimeShell; path = lib.makeBinPath [ cowsay ]; postInstall = '' # ... ''; }
cowsay-hello.sh
#! @runtimeShell@ if [ -x "@runtimeShell@" ]; then export SHELL="@runtimeShell@"; fi; export PATH=@path@:$PATH exec cowsay hello
see also nixpkgs/pkgs/os-specific/linux/nixos-rebuild/default.nix nixpkgs/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh ... and many other examples in nixpkgs
https://ryantm.github.io/nixpkgs/builders/trivial-builders/
The text was updated successfully, but these errors were encountered:
No branches or pull requests
substituteAll
https://discourse.nixos.org/t/how-pkgs-substituteall-chmod-x-buildenv/8167/2
simple example
cowsay-hello.nix
cowsay-hello.sh
see also
nixpkgs/pkgs/os-specific/linux/nixos-rebuild/default.nix
nixpkgs/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh
... and many other examples in nixpkgs
trivial builders docs
https://ryantm.github.io/nixpkgs/builders/trivial-builders/
The text was updated successfully, but these errors were encountered: