I have a flake that builds: there’s a file hugo/flake.nix
which does the right thing when I do cd hugo && nix build
.
Now I want another flake that depends on it. (Concretely, hugo
builds my static blog content, and I want a nixops flake that deploys it.)
The obvious attempt, where “obvious” means “fifty blog posts and eight hours later, having written several thousand lines of code and deleted it all again”, is as follows:
{
description = "my site";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
hugo.url = "path:./hugo";
}
outputs = { self, nixpkgs, hugo, ... }:
{
defaultPackage.x86_64-linux = hugo;
};
}
This, of course, does not work (“flake output attribute ‘defaultPackage.x86_64-linux
’ is not a derivation”). For the life of me I don’t know what it is, if it’s not a derivation, because hugo/flake.nix
specifies a perfectly good derivation - its outputs
is a pkgs.stdenv.mkDerivation
and everything.
For completeness, here is an approximation of hugo/flake.nix
:
{
description = "Static site builder for website";
inputs.flake-utils.url = github:numtide/flake-utils;
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let pkgs = nixpkgs.legacyPackages.${system}; in
rec {
packages = flake-utils.lib.flattenTree {
gitAndTools = pkgs.gitAndTools;
};
defaultPackage =
pkgs.stdenv.mkDerivation {
pname = "website";
version = "0.1.0";
src = ./contents;
buildInputs = [
pkgs.hugo
];
buildPhase = ''
echo "big pile o' build script"
'';
installPhase = ''
mv output $out
'';
};
});
}
I have two questions:
- what is
hugo
if not a derivation, and how could I have found that out? (nix repl
is not helping me in the world of flakes, because I can’t get into a flakey context from the repl.) - how do I get my flake to depend on another flake?