# Flake URL mutation on macOS

**URL:** https://discourse.nixos.org/t/flake-url-mutation-on-macos/17231
**Category:** Uncategorized
**Created:** [January 20, 2022, 4:23pm UTC](https://discourse.nixos.org/t/flake-url-mutation-on-macos/17231 "2022-01-20T16:23:10Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![azazel75](https://discourse.nixos.org/user_avatar/discourse.nixos.org/azazel75/32/177_2.png) [@azazel75](https://discourse.nixos.org/u/azazel75)
#### Post date: [January 20, 2022, 4:23pm UTC](https://discourse.nixos.org/t/flake-url-mutation-on-macos/17231/1 "2022-01-20T16:23:11Z")

</div>

Hy guys, I’m trying my flake development environment for the first time on macOS  
(Catalina, x86\_64) and I’m experiencing a strange issue: I have a non flake input  
which has an url like `git+ssh://domain:7999/path_to_repo.git`, activating the  
devShell on macOS it tries to clone the git repo at  
`ssh://domain/port/path_to_repo.git` … why this change from port to path fragment? Maybe I’m doing something in the wrong way?

I’m using nix version 2.4, nixpkgs is set to the “nixpkgs-21.11-darwin” channel  
and git comes from It, not from XCode, whic isn’t installed

I’m compiling `nixUnstable` (2.5-pre2112…) and I’ll try with that

---

<div class="post-metadata">

### Author: ![azazel75](https://discourse.nixos.org/user_avatar/discourse.nixos.org/azazel75/32/177_2.png) [@azazel75](https://discourse.nixos.org/u/azazel75)
#### Post date: [January 21, 2022, 3:33pm UTC](https://discourse.nixos.org/t/flake-url-mutation-on-macos/17231/2 "2022-01-21T15:33:07Z")

</div>

Nada, even with the latest Nix, the port of the URL gets translated into a path fragment, but on linux it works as expected…

---

<div class="post-metadata">

### Author: ![azazel75](https://discourse.nixos.org/user_avatar/discourse.nixos.org/azazel75/32/177_2.png) [@azazel75](https://discourse.nixos.org/u/azazel75)
#### Post date: [January 21, 2022, 3:44pm UTC](https://discourse.nixos.org/t/flake-url-mutation-on-macos/17231/3 "2022-01-21T15:44:36Z")

</div>

To be clear, the input is defined as:

```nix
    myproject = {
      url = "git+ssh://git@foo.bar.com:7999/inter/myproject.git";
      flake = false;
    };

```

but then when I try to activate the `devShell` of that flake:

```auto
alberto@Albertos-MBP test % nix develop edev
fetching Git repository 'ssh://git@foo.bar.com/7999/inter/myproject.git'ssh: connect to host foo.bar.com port 22: Operation timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
error: program 'git' failed with exit code 128
(use '--show-trace' to show detailed location information)

```

… and this happens with both the Xcode git or the nixpkgs one…

---

<div class="post-metadata">

### Author: ![lilyball](https://discourse.nixos.org/user_avatar/discourse.nixos.org/lilyball/32/939_2.png) [@lilyball](https://discourse.nixos.org/u/lilyball)
#### Post date: [January 21, 2022, 6:43pm UTC](https://discourse.nixos.org/t/flake-url-mutation-on-macos/17231/4 "2022-01-21T18:43:08Z")

</div>

This appears to be a bug in Nix, in the code that attempts to detect URLs like `git@github.com:NixOS/nix`. I think the problem is the regex it uses to check for this is not anchored to the start. I will file a bug on this.

---

<div class="post-metadata">

### Author: ![lilyball](https://discourse.nixos.org/user_avatar/discourse.nixos.org/lilyball/32/939_2.png) [@lilyball](https://discourse.nixos.org/u/lilyball)
#### Post date: [January 21, 2022, 6:47pm UTC](https://discourse.nixos.org/t/flake-url-mutation-on-macos/17231/5 "2022-01-21T18:47:29Z")

</div>

[https://github.com/NixOS/nix/issues/5958](https://github.com/NixOS/nix/issues/5958)

---

<div class="post-metadata">

### Author: ![azazel75](https://discourse.nixos.org/user_avatar/discourse.nixos.org/azazel75/32/177_2.png) [@azazel75](https://discourse.nixos.org/u/azazel75)
#### Post date: [January 22, 2022, 12:19am UTC](https://discourse.nixos.org/t/flake-url-mutation-on-macos/17231/6 "2022-01-22T00:19:18Z")

</div>

Thanks Lily, I haven’t yet look up for it in the code, but now I’ve switched the channel to nixos-unstable, upgraded all with nix-env -u and now repeating the command works, nix is now at version 2.5.1
