5

with derivation

let
  pkgs = import <nixpkgs> {};
in

with pkgs;

stdenv.mkDerivation {
  name = "asdfasdf";

  version = "0.1";

  src = /home/srghma/opt/foxitsoftware/foxitreader/FoxitReader; # this is executeable file

  dontUnpack = true; # not fu**** working

  installPhase = ''
    echo "not even executed"
  '';
}

I have an error

nix-build tmp.nix
these derivations will be built:
  /nix/store/x75gi70i1i57y8d3k4hhx0r3z5kjn6h6-asdfasdf.drv
building '/nix/store/x75gi70i1i57y8d3k4hhx0r3z5kjn6h6-asdfasdf.drv'...
unpacking sources
unpacking source archive /nix/store/3hnf69pky6mqaxv4jxly9fyywqpq6iml-FoxitReader
do not know how to unpack source archive /nix/store/3hnf69pky6mqaxv4jxly9fyywqpq6iml-FoxitReader
builder for '/nix/store/x75gi70i1i57y8d3k4hhx0r3z5kjn6h6-asdfasdf.drv' failed with exit code 1
error: build of '/nix/store/x75gi70i1i57y8d3k4hhx0r3z5kjn6h6-asdfasdf.drv' failed

why dontUnpack not working?


Update: created bug issue at nixpkgs https://github.com/NixOS/nixpkgs/issues/65434

Ente
  • 2,301
  • 1
  • 16
  • 34
srghma
  • 4,770
  • 2
  • 38
  • 54
  • 1
    Aside: Personally, I wouldn't use `stdenv.mkDerivation` for this. It's intended for software where the unpack process is, well, *fairly standard*; there are other constructs that give you more fine-grained control in other cases. – Charles Duffy Jul 26 '19 at 20:16
  • 1
    Also, passing `/home/srghma/opt/foxitsoftware/foxitreader/FoxitReader` is not very helpful to us, because obviously, nobody but you has a `/home/srghma`. Could you make this a [mcve], where other people can run the code and thus test proposed fixes? – Charles Duffy Jul 26 '19 at 20:17
  • 1
    ...and after trying to create a sample executable and inserting its path, I can't reproduce your bug. Which specific version of Nix (and nixpkgs) did you test with? – Charles Duffy Jul 26 '19 at 20:18
  • 1
    See https://gist.github.com/charles-dyfis-net/0b7d04e5b47961658f586fa4ebbf549f with the transcript of the attempt to reproduce, and the much more reasonable error I get instead. – Charles Duffy Jul 26 '19 at 20:20
  • 1
    To be clear, the specific failure to repro is with Nix 2.2.2, and stdenv /nix/store/7pwc81j56n5jcbj2bg6j6rf3wz410mdv-stdenv-darwin from current nixpkgs-unstable. – Charles Duffy Jul 26 '19 at 20:25
  • 1
    Maybe you could post the output from `nix show-derivation -r /nix/store/x75gi70i1i57y8d3k4hhx0r3z5kjn6h6-asdfasdf.drv` somewhere, to give others the information needed to reproduce? (Well, we'd still need our own copy of the FoxitReader file, so maybe replace that with a well-known stub or something you can include a copy of, and *then* generate a new derivation and post it). – Charles Duffy Jul 26 '19 at 20:27
  • 1
    @CharlesDuffy , same here can't reporduce – Ente Jul 26 '19 at 20:35
  • with nix 2.2.2 and `/nix/store/3d547md672sl43r4rg1x7g20vcagwqa0-stdenv-linux.drv` – Ente Jul 26 '19 at 20:43
  • replied to an issue on github – srghma Jul 27 '19 at 07:06

2 Answers2

6

Try this:

let
  pkgs = import <nixpkgs> {};
in

with pkgs;

stdenv.mkDerivation {
  name = "asdfasdf";

  version = "0.1";

  # Renamed to imply that 'src' functionality is not being used.
  executable = /home/srghma/opt/foxitsoftware/foxitreader/FoxitReader; # this is executeable file

  phases = [ "installPhase" ]; # Removes all phases except installPhase

  installPhase = ''
    mkdir -p $out/bin
    cp ${executable} $out/bin
  '';
}
Emmanuel Rosa
  • 9,697
  • 2
  • 14
  • 20
  • 2
    Were you able to reproduce the problem, or is this solution suggested in absence of a reproducer. – Charles Duffy Jul 27 '19 at 02:44
  • this is working, but I would avoid using phases because they disable pre phases (like preInstallPhase and postInstallPhase) , which could be used by hooks – srghma Jul 27 '19 at 07:06
  • there is even an proposal to remove phases at all – srghma Jul 27 '19 at 07:06
  • [phases](https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L1269) is just a string, for example `phases = "checkPhase installPhase installCheckPhase distPhase";` – milahu Apr 25 '21 at 14:29
  • With 18.03 release, I get `attribute 'src' missing` error. So instead I overrode `unpackPhase` and just use that to do the same steps that above `installPhase` attribute does. Seems to work. – LB2 Aug 27 '21 at 02:26
0

@FRidh wrote

Many of the dont attributes were not yet implemented in the current and past stable releases. So, if you intend to use it with the current stable or older stables, use instead unpackPhase = ":".

srghma
  • 4,770
  • 2
  • 38
  • 54