1
0
Fork 0
mirror of https://github.com/hercules-ci/flake-parts.git synced 2025-03-30 19:54:47 +00:00

partitions: allow overriding the flake-compat src

This is useful when flake-compat is already available, e.g. as a flake
input.

By allowing consumers to specify the flake-compat to use, we can avoid
fetching multiple redundant copies.
This commit is contained in:
Matt Sturgeon 2025-02-24 12:30:44 +00:00
parent 32ea77a067
commit ebfbd32548
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299

View file

@ -8,6 +8,10 @@ let
types
;
inherit (lib.generators)
toPretty
;
partitionModule = { config, options, name, ... }: {
options = {
extraInputsFlake = mkOption {
@ -85,15 +89,36 @@ let
# addressed store path is a pure input, so we have to fetch and wire it
# manually with flake-compat.
get-flake = src: (flake-compat { inherit src; system = throw "operating flake-compat in pure mode; system not allowed to be used"; }).outputs;
flake-compat = import config.flakeCompatSrc;
# TODO: update
flake-compat = import (builtins.fetchTarball {
flake-compat-src = {
url = "https://github.com/edolstra/flake-compat/archive/9ed2ac151eada2306ca8c418ebd97807bb08f6ac.tar.gz";
sha256 = "sha256:063slk1np1g1dkh21a82x655kpja7p4pc74rb3lqankyrbbpy4hx";
});
};
in
{
options = {
flakeCompatSrc = mkOption {
type = types.path;
default = builtins.fetchTarball flake-compat-src;
defaultText = lib.literalExpression ''
fetchTarball ${toPretty { multiline = true; } flake-compat-src}
'';
description = ''
Nix does not recognize that a flake like `"''${./dev}"`
(a content addressed store path) is a pure input, so we have to fetch
and wire it manually with [flake-compat].
If a copy of flake-compat is already available, this option can be
used to avoid fetching a second copy.
This option is only used for partitions that have a path-type
[`extraInputsFlake`](#opt-partitions._name_.extraInputsFlake).
[flake-compat]: https://github.com/edolstra/flake-compat
'';
internal = true;
};
partitionedAttrs = mkOption {
type = types.attrsOf types.str;
default = { };