nix-book/source/recipes/build/nixpkg/flake.nix
Amy de Buitléir a23029eb15 initial commit
2025-09-14 19:25:14 +01:00

45 lines
1.1 KiB
Nix

{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
in
{
packages = rec {
hello = pkgs.stdenv.mkDerivation rec {
name = "hello-with-cow";
src = ./.;
unpackPhase = "true";
buildPhase = ":";
installPhase =
''
mkdir -p $out/bin
cp $src/hello-with-cow $out/bin
chmod +x $out/bin/hello-with-cow
# modify the hello-again script so it can find hello-nix
COWSAY=$(type -p cowsay)
sed "s_cowsay_"$COWSAY"_" --in-place $out/bin/hello-with-cow
'';
buildInputs = [ pkgs.cowsay ];
};
default = hello;
};
apps = rec {
hello = flake-utils.lib.mkApp { drv = self.packages.${system}.hello; };
default = hello;
};
}
);
}