Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

nix-build expects git to be around, it's not in the image #33

Closed
Jackbennett opened this issue Apr 7, 2021 · 10 comments · Fixed by #37
Closed

nix-build expects git to be around, it's not in the image #33

Jackbennett opened this issue Apr 7, 2021 · 10 comments · Fixed by #37
Labels
question Further information is requested

Comments

@Jackbennett
Copy link

2.3.10 doesn't include git in the image, seem odd given the nix-build might assume it's ready to use.

@peti
Copy link
Member

peti commented Apr 30, 2021

Could you please be more specific? Under which circumstances would nix-build assume git to be installed and ready to use? Could you please provide a command that you'd expect to succeed but that fails?

@peti peti added the question Further information is requested label Apr 30, 2021
@thufschmitt
Copy link
Member

Under which circumstances would nix-build assume git to be installed and ready to use?

builtins.fetchGit (as well as git flake inputs) calls the “ambiant” git binary

$ env -u PATH $(which nix-instantiate) --eval -E 'builtins.fetchGit "https://github.com/nixos/nixpkgs"'
error: error: executing 'git': No such file or directory
error: program 'git' failed with exit code 1
(use '--show-trace' to show detailed location information)

@Jackbennett
Copy link
Author

{ stdenv, cmake, gcc, gcc-arm-embedded-8, which, git }:

stdenv.mkDerivation rec 
{
 
  src = ./.;

  cmakefiles = builtins.fetchGit {
    url = "http://.../libs/cmakefiles";
    ref = "master";

  };

We have pkg.nix like this and they need git around to work.

Fuuzetsu added a commit to Fuuzetsu/docker that referenced this issue May 5, 2021
This is a pre-requisite for builtins.fetchGit to work. This is
especially painful to deal with if we're using flakes and
flake-compat: we have this nice self-contained set of inputs
but to use them in presence of any git dependencies, we have to first
install git separately.

Fixes NixOS#33
@Fuuzetsu
Copy link
Member

Fuuzetsu commented May 5, 2021

I made #37 that adds git. I think it's reasonable. A work-around is to use apk to install git manually.

I was also surprised by lack of bash which is kind of inconvenient but if we have git and sh, we can at least use nix to get bash.

@peti
Copy link
Member

peti commented May 5, 2021

I am not particularly fond of catering to undeclared, implicit dependencies. Also, adding git increases the size of the image for everyone, and I'm not sure whether many people need it in the boot image. I reckon that those who need it will simply install it via nix inside of the image. I dunno, I think it would be better to use fetchgit from Nixpkgs instead of the impure builtin.

@Fuuzetsu
Copy link
Member

Fuuzetsu commented May 5, 2021

You can't use fetchgit from nixpkgs if you don't have nixpkgs. If you get your pinned nixpkgs via git such as in a flake, you're stuck in a catch 22.

If you tried to install git via nix in the image itself, you'll notice how much time and space it takes to do so. It's also not any better to use "git from whatever version of nixpkgs the container happens to point at" vs "git at whatever version the container has".

Making the image a pain to use in name of few compressed MBs just seems anti-user: any start-up time you may save is going to be ruined by having to install git yourself. It's all outweighed by any trivial eval anyway.

It's an impure dependency of commonly used built-in function commonly used to bootstrap nixpkgs itself: it doesn't seem that reasonable to include.

I'll keep using forked image from #37 or invoke apk myself at start but it's going to waste more time (machine and human) to keep updated than it will probably ever save...

@thufschmitt
Copy link
Member

adding git increases the size of the image for everyone, and I'm not sure whether many people need it in the boot image. I reckon that those who need it will simply install it via nix inside of the image

I think it would be fair to consider git as a dependency of Nix (as indeed some Nix features rely on it). In which case having it in the image is totally warranted (regardless the ~10MB that it adds)

@peti
Copy link
Member

peti commented May 5, 2021

You can't use fetchgit from nixpkgs if you don't have nixpkgs.

You have nixpkgs, though. It's in the docker image.

@Fuuzetsu
Copy link
Member

Fuuzetsu commented May 5, 2021

You have nixpkgs, though. It's in the docker image.

I already mentioned this:

If you tried to install git via nix in the image itself, you'll notice how much time and space it takes to do so. It's also not any better to use "git from whatever version of nixpkgs the container happens to point at" vs "git at whatever version the container has".

62a906fe6539:/# time nix-env -iA nixpkgs.gitMinimal
installing 'git-minimal-2.30.1'
these paths will be fetched (37.36 MiB download, 199.74 MiB unpacked):
  <snip>
created 51 symlinks in user environment
real	0m 27.06s
user	0m 5.68s
sys	0m 1.02s

30 seconds extra for every run in CI is pretty annoying.

If you want to save space, why not delete nixpkgs from the image? nix-unstable images do this.

Anyway if we're not going to put git in the image, please close as won't fix along with the MR and I'll just use a fork.

@ocharles
Copy link

I am not particularly fond of catering to undeclared, implicit dependencies.

I'm not sure it is - it's a hard runtime dependency of Nix. Unless you build Nix without Git support (I'm not sure it's possible), this is just an incomplete image imo.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants