nix-book/source/modify-hello-flake/flake.nix.new.2
Amy de Buitléir fc5b0d86d7 initial commit
2025-09-14 19:22:32 +01:00

53 lines
1.3 KiB
Groff

{
description = "a very simple and friendly flake";
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
{
devShells = rec {
default = pkgs.mkShell {
packages = [ pkgs.cowsay ];
};
};
packages = rec {
hello = pkgs.stdenv.mkDerivation rec {
name = "hello-flake";
src = ./.;
unpackPhase = "true";
buildPhase = ":";
installPhase =
''
mkdir -p $out/bin
cp $src/hello-flake $out/bin/hello-flake
chmod +x $out/bin/hello-flake
# modify the hello-flake script so it can find cowsay
COWSAY=$(type -p cowsay)
sed "s_cowsay_"$COWSAY"_" --in-place $out/bin/hello-flake
'';
buildInputs = [ pkgs.cowsay ];
};
default = hello;
};
apps = rec {
hello = flake-utils.lib.mkApp { drv = self.packages.${system}.hello; };
default = hello;
};
}
);
}