Skip to content

Comments

doc/manual/local.mk: use local src/nix/nix instead of /usr/bin/nix#5185

Closed
trofi wants to merge 1 commit intoNixOS:masterfrom
trofi:inplace-nix
Closed

doc/manual/local.mk: use local src/nix/nix instead of /usr/bin/nix#5185
trofi wants to merge 1 commit intoNixOS:masterfrom
trofi:inplace-nix

Conversation

@trofi
Copy link
Contributor

@trofi trofi commented Aug 28, 2021

Build failure happens when one tries to build nix on a linux
system as user with later plan to install as root (typical package
building separation):

$ cd /tmp
$ git clone https://github.com/NixOS/nix.git
$ cd nix
$ ./bootstrap.sh
$ ./configure --prefix=/usr ac_cv_header_aws_s3_S3Client_h=no
$ make
...
$ LANG=C make
  LD     /usr/lib/libnixutil.so
/usr/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot open output file /usr/lib/libnixutil.so: Permission denied
collect2: error: ld returned 1 exit status
make: *** [mk/lib.mk:117: /usr/lib/libnixutil.so] Error 1

Build failure happens because doc/manual/nix.json depends
on installed $(bindir) path instead of local inplace path:

$ make -r -d doc/manual/nix.json
...
Considering target file 'doc/manual/nix.json'.
 File 'doc/manual/nix.json' does not exist.
  Considering target file '/usr/bin/nix'.
    Considering target file 'src/build-remote/build-remote.o'.
     Looking for an implicit rule for 'src/build-remote/build-remote.o'.
...
doc/manual/local.mk:$(d)/nix.json: $(bindir)/nix

The fix is to always use inplace built src/nix/nix binary.

Closes: #5184

Build failure happens when one tries to build `nix` on a linux
system as user with later plan to install as root (typical package
building separation):

```
$ cd /tmp
$ git clone https://github.com/NixOS/nix.git
$ cd nix
$ ./bootstrap.sh
$ ./configure --prefix=/usr ac_cv_header_aws_s3_S3Client_h=no
$ make
...
$ LANG=C make
  LD     /usr/lib/libnixutil.so
/usr/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot open output file /usr/lib/libnixutil.so: Permission denied
collect2: error: ld returned 1 exit status
make: *** [mk/lib.mk:117: /usr/lib/libnixutil.so] Error 1
```

Build failure happens because `doc/manual/nix.json` depends
on installed `$(bindir)` path instead of local inplace path:

```
$ make -r -d doc/manual/nix.json
...
Considering target file 'doc/manual/nix.json'.
 File 'doc/manual/nix.json' does not exist.
  Considering target file '/usr/bin/nix'.
    Considering target file 'src/build-remote/build-remote.o'.
     Looking for an implicit rule for 'src/build-remote/build-remote.o'.
...
doc/manual/local.mk:$(d)/nix.json: $(bindir)/nix
```

The fix is to always use inplace built `src/nix/nix` binary.

Closes: #5184
@edolstra
Copy link
Member

Maybe we should get rid of the default make target, since make install is really the only properly supported way to build.

@edolstra
Copy link
Member

Closing this one in favor of #5145.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nix from git tries to write to system root at build time: cannot open output file /usr/lib/libnixutil.so: Permission denied

2 participants