Some of you are probably already aware of flake-parts which helps “modularize” flake.nix. This is especially useful on monorepos where the top-level flake.nix
tends to get complicated and huge over time.
flake-parts can also be used to provide a nixos-module like feel.
For example, if you have a directory of Markdown or org-mode files, you can drop the following flake.nix
to it, and run nix build
to get a statically build website, or nix run
to run a live updating view of those plain-text files.
{
nixConfig.extra-substituters = "https://cache.garnix.io";
nixConfig.extra-trusted-public-keys = "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=";
inputs = {
emanote.url = "github:srid/emanote";
nixpkgs.follows = "emanote/nixpkgs";
flake-parts.follows = "emanote/flake-parts";
};
outputs = inputs@{ self, flake-parts, nixpkgs, ... }:
flake-parts.lib.mkFlake { inherit self; } {
systems = nixpkgs.lib.systems.flakeExposed;
imports = [ inputs.emanote.flakeModule ];
perSystem = { self', ... }: {
emanote.sites."default" = {
path = ./.;
pathString = ".";
};
};
};
}
(This uses https://emanote.srid.ca/ to build/serve the site).