mirror of
https://codeberg.org/mhwombat/nix-book.git
synced 2025-12-27 00:34:58 +08:00
45 lines
1.1 KiB
Nix
45 lines
1.1 KiB
Nix
{
|
|
description = "what does the cow say";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs";
|
|
};
|
|
|
|
outputs = { self, nixpkgs }: {
|
|
|
|
devShells = {
|
|
x86_64-linux.default =
|
|
let
|
|
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
|
in
|
|
pkgs.mkShell {
|
|
packages = [ pkgs.cowsay ];
|
|
};
|
|
}; # devShells
|
|
|
|
packages = {
|
|
x86_64-linux.default =
|
|
let
|
|
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
|
in
|
|
pkgs.stdenv.mkDerivation {
|
|
name = "cow-hello.sh";
|
|
src = ./.;
|
|
unpackPhase = "true";
|
|
buildPhase = ":";
|
|
installPhase =
|
|
''
|
|
mkdir -p $out/bin
|
|
cp $src/cow-hello.sh $out/bin
|
|
chmod +x $out/bin/cow-hello.sh
|
|
|
|
# modify the cow-hello.sh script so it can find cowsay
|
|
COWSAY=$(type -p cowsay)
|
|
sed "s_cowsay_"$COWSAY"_" --in-place $out/bin/cow-hello.sh
|
|
'';
|
|
buildInputs = [ pkgs.cowsay ];
|
|
}; # mkDerivation
|
|
}; # packages
|
|
|
|
}; # outputs
|
|
}
|