repo-clone/module.nix

40 lines
972 B
Nix
Raw Normal View History

2024-08-01 06:53:14 +00:00
{ lib, config, pkgs, ... }:
2024-07-31 23:12:48 +00:00
let
2024-08-01 06:53:14 +00:00
service = "repo-clone";
2024-07-31 23:12:48 +00:00
cfg = config.repo-clone;
2024-08-01 08:23:57 +00:00
inherit (lib) mkIf mkOption mkEnableOption types;
inherit (lib.strings) concatStringsSep;
inherit (lib.attrsets) mapAttrsToList;
2024-08-01 08:48:41 +00:00
inherit (pkgs) writeText;
2024-07-31 23:12:48 +00:00
in
{
2024-08-01 06:53:14 +00:00
options.${service} = {
2024-08-01 08:23:57 +00:00
enable = mkEnableOption "${service} service";
2024-08-01 06:08:41 +00:00
2024-08-01 08:23:57 +00:00
repos = mkOption {
2024-08-01 06:08:41 +00:00
type = import ./repo.nix { inherit lib; };
description = ''
2024-08-01 06:26:58 +00:00
attrs of repos to clone
2024-08-01 06:08:41 +00:00
'';
default = { };
};
2024-08-01 06:53:14 +00:00
2024-08-01 08:23:57 +00:00
pkg = mkOption {
type = types.package;
2024-08-01 06:53:14 +00:00
};
2024-07-31 23:12:48 +00:00
};
# /nix/store/pxd7wc8icz577hpl6pmz02b74nhbrj6h-unit-home-manager-ravenshade.service/home-manager-ravenshade.service
2024-08-01 08:23:57 +00:00
config = mkIf cfg.enable {
2024-08-01 08:48:41 +00:00
systemd.user.services.${service} = import ./service.nix { inherit service pkgs config; };
2024-08-01 06:53:14 +00:00
2024-08-01 08:23:57 +00:00
repo-clone.pkg = writeText "${service}.conf"
(concatStringsSep "\n"
(mapAttrsToList (target: settings: "${settings.url} ${target}") cfg.repos));
2024-07-31 23:12:48 +00:00
};
}