Hey there good people of NixOS community!
I am a complete newbie and will probably get shunned but I have been trying to get at this issue for quite a while now and seem to be just stuck
I am trying to create a systemd service with a simple script that will copy the /etc/nixos/configuration.nix
file whenever that file changes. The file will be copied into a specific git filder and then commited and pushed.
I already have a script that fullfils the core functionality:
#!/bin/sh
SCRIPT_DIR="$(dirname "$0")"
# Copy configuration.nix to the script's directory
sudo cp /etc/nixos/configuration.nix "$SCRIPT_DIR/"
# Change to the script's directory for git operations
cd "$SCRIPT_DIR" || exit 1
# Update permissions and ownership
sudo chmod 666 ./configuration.nix && \
sudo chown $USER:users ./configuration.nix
# Git operations
git add --all && \
git commit -m "Update configuration.nix" && \
git push
The problem I am having is firstly; how can i get the service to setup properly in the and secondly; how to make it run whenever the /etc/nixos/configuration.nix
gets changed.
Thank you in advance,
Simon