1
0
Fork 0

Add branch name option to nixos-upgrade with defaults to main

This commit is contained in:
Aires 2024-06-02 13:41:18 -04:00
parent cc4ae56ea3
commit ca40bc1151
2 changed files with 11 additions and 2 deletions

View file

@ -31,6 +31,15 @@ in
type = lib.types.bool;
description = "Enables automatic system updates.";
};
branches = lib.mkOption {
type = lib.types.attrs;
description = "Which local and remote branches to compare.";
default = {
local = "main";
remote = "main";
remoteName = "origin";
};
};
configDir = lib.mkOption {
type = lib.types.str;
description = "Path where your NixOS configuration files are stored.";
@ -70,7 +79,7 @@ in
# Check if there are changes from Git.
echo "Pulling latest version..."
sudo -u ${cfg.user} git fetch
sudo -u ${cfg.user} git diff --quiet --exit-code || true
sudo -u ${cfg.user} git diff --quiet --exit-code ${cfg.branches.local} ${cfg.branches.remoteName}/${cfg.branches.remote} || true
# If we have changes (git diff returns 1), pull changes and run the update
if [ $? -eq 1 ]; then
echo "Updates found, running nixos-rebuild..."

View file

@ -8,7 +8,7 @@ in
host.services.ssh = {
enable = lib.mkEnableOption (lib.mdDoc "Enables SSH server.");
ports = lib.mkOption {
default = [ ];
default = [ 22 ];
type = lib.types.listOf lib.types.int;
description = "Ports for SSH to listen on.";
};