flake

Francesco Saccone's Nix flake.
git clone git://git.francescosaccone.com/flake
Log | Files | Refs | README | LICENSE

commit 8cb709b6a1580391038518cfbbdc1ba47bda7a30
parent 8348c8b125a4810181ad0e49e3d543b320b50f43
Author: Francesco Saccone <francesco@francescosaccone.com>
Date:   Mon, 24 Mar 2025 19:13:23 +0100

refactor: replace description, owner and baseUrl options with additionalFiles attrset option

Signed-off-by: Francesco Saccone <francesco@francescosaccone.com>

Diffstat:
Mhosts/server/default.nix | 8+++++---
Mmodules/nixos/git/default.nix | 42+++++++++++++++++++-----------------------
2 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/hosts/server/default.nix b/hosts/server/default.nix @@ -153,9 +153,11 @@ rec { name: { description }: { - inherit description; - owner = "Francesco Saccone"; - baseUrl = networking.domain; + additionalFiles = { + inherit description; + owner = "Francesco Saccone"; + url = "git://${networking.domain}/${name}"; + }; } ); daemon = { diff --git a/modules/nixos/git/default.nix b/modules/nixos/git/default.nix @@ -30,20 +30,13 @@ type = lib.types.submodule { options = { - description = lib.mkOption { - description = "The description."; - type = lib.types.uniq lib.types.str; - }; - owner = lib.mkOption { - description = "The owner."; - type = lib.types.uniq lib.types.str; - }; - baseUrl = lib.mkOption { + additionalFiles = lib.mkOption { description = '' - The base URL used to clone the repository through the Git - protocol. + For each additional file to add to the repository directory, + its content. ''; - type = lib.types.uniq lib.types.str; + default = { }; + type = lib.types.attrsOf lib.types.str; }; hooks = { preReceive = lib.mkOption { @@ -103,23 +96,26 @@ |> builtins.mapAttrs ( name: { - description, - owner, - baseUrl, + additionalFiles, hooks, }: '' ${pkgs.git}/bin/git init -q --bare -b master \ ${directory}/${name} - ${pkgs.sbase}/bin/echo "${description}" > \ - ${directory}/${name}/description - - ${pkgs.sbase}/bin/echo "${owner}" > \ - ${directory}/${name}/owner - - ${pkgs.sbase}/bin/echo "git://${baseUrl}/${name}" > \ - ${directory}/${name}/url + ${ + ( + additionalFiles + |> builtins.mapAttrs ( + fileName: content: '' + ${pkgs.sbase}/bin/echo "${content}" > \ + ${directory}/${name}/${fileName} + '' + ) + |> builtins.attrValues + |> builtins.concatStringsSep "\n" + ) + } ${pkgs.sbase}/bin/mkdir -p ${directory}/${name}/hooks