Remove dev-commit
This commit is contained in:
parent
6883156cfc
commit
e3a9357deb
4 changed files with 0 additions and 155 deletions
|
|
@ -1,83 +0,0 @@
|
|||
{ lib, ... }:
|
||||
|
||||
{
|
||||
flake.modules.homeManager.base =
|
||||
{ config, pkgs, ... }:
|
||||
{
|
||||
options.programs.dev-commit = {
|
||||
enable = lib.mkEnableOption "Enable dev-commit";
|
||||
|
||||
repoPaths = lib.mkOption {
|
||||
default = [ ];
|
||||
description = "A list of repository paths that should have automated commits";
|
||||
type = lib.types.listOf lib.types.path;
|
||||
};
|
||||
|
||||
schedule = lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
options = {
|
||||
enable = lib.mkEnableOption "Enable automated dev commits with systemd";
|
||||
|
||||
time = lib.mkOption {
|
||||
description = ''
|
||||
Time expression for when to run the dev-commit job.
|
||||
|
||||
This uses systemd's `OnCalendar` syntax.
|
||||
|
||||
Examples:
|
||||
- "hourly" (once every hour)
|
||||
- "daily" (once per day at midnight)
|
||||
- "Mon *-*-01 12:00:00" (every Monday at 12:00 PM)
|
||||
|
||||
See `man systemd.time` for full syntax reference.
|
||||
'';
|
||||
default = "hourly";
|
||||
type = lib.types.str;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
default = {
|
||||
enable = false;
|
||||
time = "hourly";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
cfg = config.programs.dev-commit;
|
||||
repoPaths = lib.concatStringsSep ":" cfg.repoPaths;
|
||||
in
|
||||
{
|
||||
home = lib.mkIf cfg.enable {
|
||||
packages = [ pkgs.dev-commit ];
|
||||
|
||||
sessionVariables.DEV_COMMIT_PATHS = repoPaths;
|
||||
};
|
||||
|
||||
systemd.user = lib.mkIf cfg.schedule.enable {
|
||||
services.dev-commit = {
|
||||
Service = {
|
||||
Environment = [ "DEV_COMMIT_PATHS=${repoPaths}" ];
|
||||
ExecStart = "${lib.getExe pkgs.dev-commit}";
|
||||
Type = "oneshot";
|
||||
};
|
||||
|
||||
Unit.Description = "dev-commit";
|
||||
};
|
||||
|
||||
timers.dev-commit = {
|
||||
Install.WantedBy = [ "timers.target" ];
|
||||
|
||||
Timer = {
|
||||
OnCalendar = cfg.schedule.time;
|
||||
Unit = "dev-commit.service";
|
||||
};
|
||||
|
||||
Unit.Description = "Runs automated development commits in select project repositories.";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
{ config, ... }:
|
||||
|
||||
{
|
||||
flake.modules.nixos."nixosConfigurations/t480".home-manager.users.${config.flake.meta.owner.username} =
|
||||
hmArgs: {
|
||||
programs.dev-commit.enable = true;
|
||||
|
||||
programs.dev-commit.schedule.enable = true;
|
||||
programs.dev-commit.schedule.time = "daily";
|
||||
|
||||
programs.dev-commit.repoPaths =
|
||||
let
|
||||
repos = "${hmArgs.config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/forgejo/opdavies";
|
||||
in
|
||||
map (name: "${repos}/${name}") [
|
||||
"email-filters"
|
||||
"git-repo-updater"
|
||||
"nix-config"
|
||||
"oliverdavies.uk"
|
||||
"opentofu-dns"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
@ -16,7 +16,6 @@ in
|
|||
build-glove80 = callPackage ./build-glove80.nix { };
|
||||
count-tags = callPackage ./count-tags.nix { };
|
||||
create-script = callPackage ./create-script.nix { };
|
||||
dev-commit = callPackage ./dev-commit.nix { };
|
||||
get-tags = callPackage ./get-tags.nix { };
|
||||
git-exclude = callPackage ./git-exclude.nix { };
|
||||
git-graph = callPackage ./git-graph.nix { };
|
||||
|
|
|
|||
|
|
@ -1,48 +0,0 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "dev-commit";
|
||||
|
||||
runtimeInputs = with pkgs; [
|
||||
coreutils
|
||||
git
|
||||
logger
|
||||
openssh
|
||||
];
|
||||
|
||||
text = ''
|
||||
IFS=':' read -ra repos <<< "$DEV_COMMIT_PATHS"
|
||||
|
||||
for repo in "''${repos[@]}"; do
|
||||
logger "Processing repository: $repo"
|
||||
|
||||
pushd "$repo" > /dev/null 2>&1
|
||||
|
||||
if [[ -n $(git status --porcelain) ]]; then
|
||||
logger "Changes detected in $repo"
|
||||
|
||||
git status --short | while read -r line; do
|
||||
logger "Changed file: $line"
|
||||
done
|
||||
|
||||
git add .
|
||||
|
||||
if git commit -m "Automated dev commit"; then
|
||||
logger "Commit successful in $repo"
|
||||
|
||||
if git push; then
|
||||
logger "Push successful in $repo"
|
||||
else
|
||||
logger "Push failed in $repo"
|
||||
fi
|
||||
else
|
||||
logger "No changes to commit in $repo"
|
||||
fi
|
||||
else
|
||||
logger "No changes in $repo"
|
||||
fi
|
||||
|
||||
popd > /dev/null 2>&1
|
||||
done
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue