How to use different nixpkgs url?

Hello. In my company the url https://github.com/NixOS/nixpkgs/archive/13043924aaa7375ce482ebe2494338e058282925.tar.gz and any similar ones are blocked by the firewall because the firewal detects unwanted files. For whatever reason the paloalto firewall detects .mov Apple Quicktime Movies files in the repository and blocks the download.

I could for example setup our company proxy to serve these files. It will be a different url. Or download the file by our company security team and send it to me once in a while.

How can I change the url of the file so that nix profile upgrade will download this repository from a different url?

I could just point it to a git clone and git pull once in a while. Or I could git clone the repository and make the .tar.gz myself.

Can nix profile upgrade use file:// urls to download it?

Can it just use git clone for the repository? Can it use a repository already cloned locally for the url?

Thank you.

1 Like

Have you tried https://channels.nixos.org/<channel>/nixexprs.tar.xz?

2 Likes

How can I change the url of the file so that nix profile upgrade will download this repository from a different url?

You can make use of the nix registry add command to change the URL, for a specific user you would use nix registry add nixpkgs https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz or if you want it system-wide nix registry add --registry /etc/nix/registry.json nixpkgs https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz, I used https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz as an example of a flake ref here, but you can replace it with any other kind of flake ref.

Can nix profile upgrade use file:// urls to download it?

I don’t think it understands it if you use file://, but we do have path: which you can use like this path:/local/location/to/my/nixpkgs/repo, if you use the commands from above.

Can it just use git clone for the repository?

Yes you can use git+https://github.com/NixOS/nixpkgs as the falke ref to load it over git.

Can it use a repository already cloned locally for the url?

Yes, you can use git+file:///home/my-user/some-repo/some-repo as flake ref to use a local git repo.

I would recommend using https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz as the flake ref in most cases

1 Like

How and even if you are easily able to change the files source, massively depends on the context you are facing the issue.

Some things are easier to change than others, though all will be ugly in general, and there will not be a global “use my fork instead of github”.

It might be easier to tell your IT to reconfigure the firewall.

2 Likes

Hello. Thank @thefossguy @jopejoe1 for your kind response.

To clarify: I am using rockylinux and single user nix installation with bwrap –bind ~/.nix /nix to have /nix writable for my user.

I executed after some investigation:

$ nix registry list | grep nixpkgs
global flake:nixpkgs github:NixOS/nixpkgs/nixpkgs-unstable
$ git clone <repo> /apps/home/cukrowsk/work/nixpkgs
$ nix registry add nixpkgs path:/apps/home/cukrowsk/work/nixpkgs
$ nix registry list | grep nixpkgs
user   flake:nixpkgs path:/apps/home/cukrowsk/work/nixpkgs
global flake:nixpkgs github:NixOS/nixpkgs/nixpkgs-unstable

Which seem to have added a “user” entry in in the registry config.

After that, nix profile upgrade correctly upgraded.

Thank you very much for guidance.