How to specify a git branch with git+ssh in nixos-rebuild

May I ask how to specify a git branch (I have main) in:

nixos-rebuild switch --flake 'git+ssh://git@example.uk/srv/local/git/nixos-configuration.git'#myconfig --target-host root@87.x.x.x

like if it were github:

"github:NixOS/nixpkgs/nixos-21.11"
                      ^^^^^^^^^^^ - this is the branch

none of these work:

git+ssh://git@example.uk/srv/local/git/nixos-configuration.git#main
git+ssh://git@example.uk/srv/local/git/nixos-configuration.git/main
git+ssh://git@example.uk/srv/local/git/nixos-configuration.git/refs/heads/main

Try with ?ref=main as the suffix.

https://nix.dev/manual/nix/2.32/command-ref/new-cli/nix3-flake.html#types and see the point starting with git.

1 Like