nix-book/source/recipes/build/flake/flake.nix
Amy de Buitléir 1ad9b077c4 initial commit
2025-09-15 17:40:48 +01:00

46 lines
1.2 KiB
Nix

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