repo-clone/module.nix

56 lines
1.4 KiB
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;
inherit (pkgs) writeShellScriptBin 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 07:10:49 +00:00
systemd.user.services.${service} = {
2024-08-01 08:23:57 +00:00
Unit.Description = "${service} service";
2024-07-31 23:12:48 +00:00
Service = {
Type = "exec";
ExecStart =
let
2024-08-01 06:53:14 +00:00
execName = service;
2024-08-01 08:23:57 +00:00
script = writeShellScriptBin execName ''
2024-07-31 23:12:48 +00:00
echo "hello!"
2024-08-01 07:15:17 +00:00
echo "${config.repo-clone.pkg}"
2024-07-31 23:12:48 +00:00
'';
in
"${script}/bin/${execName}";
RemainAfterExit = "yes";
};
2024-08-01 08:23:57 +00:00
Install.WantedBy = [ "multi-user.target" ];
2024-07-31 23:12:48 +00:00
};
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: "${target} ${settings.url}") cfg.repos));
2024-07-31 23:12:48 +00:00
};
}