I haven’t been too involved in nix development but I couldn’t help but get pulled into some thoughts about flake schema in this thread: Custom flake outputs for checks - #20 by rehno
If you modify the flake schema with top-level attributes that look like this:
{
inputs = {
nixos.url = "github:nixos/nixpkgs";
home-manager.url = "github:nix-community/home-manager";
nixops.url = "github:nixos/nixops";
templates.url = "github:nixos/templates";
};
outputs = { self, ... }: {
nixos = {
modules = ...;
configurations = ...;
packages = ...;
overlays = ...;
};
homeManager = {
modules = ...;
configurations = ...;
templates = ...;
overlays = ...;
};
nixops = {
modules = ...;
resources = ...;
deployments = ...;
};
templates = {
nixos-example = ...;
nixops-example = ...;
home-manager-example = ...;
};
};
}
Then you could imagine a world where those input flakes look like this:
nixpkgs/flake.nix:
{
inputs.lib.url = "github:nixos/lib";
options = { lib }: {
nixos = {
modules = lib.mkOption { ... };
configurations = lib.mkOption { ... };
templates = lib.mkOption { ... };
overlays = lib.mkOption { ... };
packages = lib.mkOption { ... };
};
};
outputs = { ... };
}
home-manager/flake.nix:
{
inputs.lib.url = "github:nixos/lib";
options = { lib }: {
homeManager = {
modules = lib.mkOption { ... };
configurations = lib.mkOption { ... };
templates = lib.mkOption { ... };
overlays = lib.mkOption { ... };
};
};
outputs = { ... };
}
nixops/flake.nix:
{
inputs.lib.url = "github:nixos/lib";
options = { lib }: {
nixops = {
modules = lib.mkOption { ... };
resources = lib.mkOption { ... };
deployments = lib.mkOption { ... }; # deployment targets (aka "machines")
};
};
outputs = { ... };
}
templates/flake.nix:
{
inputs.lib.url = "github:nixos/lib";
options = { lib }: {
templates = lib.mkOption { ... };
};
outputs = { ... };
}
Then this starts to resemble the existing module system a great deal.
-
inputs = { ... };
resemblesimports = [ ... ];
-
outputs = { ... };
resembleconfig = [ ... ];
-
options = { ... };
obviously resembles the attribute with the same name
Is this a new observation, or am I just re-treading a well-trodden design landscape? I know flakes have been discussed to death and I could imagine that there’s been many other people drawing comparison to the module system. (Apologies if that’s the case!)
I’m curious if it breaks any desirable properties of flakes. Thanks