Skip to content

Nix GC collects derivations used for IFD #719

@wizeman

Description

@wizeman

I have a NixOS configuration with the following contents:

{ config, pkgs
, ... }:

let

  kodiOff_src = pkgs.srcOnly {
    name = "kodiOff-src";
    src = /home/tarballs/autogen/kodi-off.tar.gz;
  };

  kodiOff_pkg = import "${kodiOff_src}/default.nix" {};

in {
# (...)
  systemd.services.kodi-off = {
#   (...)
    serviceConfig = {
      Type = "simple";
      ExecStart = "${kodiOff_pkg}/bin/kodi-off";
    };
  };
# (...)
}

Now, even though I have the following options in the /etc/nix/nix.conf of my private Hydra server:

gc-keep-outputs = true
gc-keep-derivations = true

... and even though the configuration root hasn't been gc'ed, a Nix garbage collection still appears to delete the output of the pkgs.srcOnly derivation.

The above configuration is built by my private Hydra server, but if a garbage collection runs after the configuration is built, then my laptop (which is configured to use my Hydra server as a binary cache) fails to download the package during nixops deploy, reporting a 410 Gone error instead:

building all machine configurations...
fetching path ‘/nix/store/cvz1fpbsvqqq36xwyzc33cp7jy4r7lg3-kodiOff-src’...

*** Downloading ‘http://homeserv:3000/nar/cvz1fpbsvqqq36xwyzc33cp7jy4r7lg3-kodiOff-src’ to ‘/nix/store/cvz1fpbsvqqq36xwyzc33cp7jy4r7lg3-kodiOff-src’...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (22) The requested URL returned error: 410 Gone

bzip2: Compressed file ends unexpectedly;
        perhaps it is corrupted?  *Possible* reason follows.
bzip2: Inappropriate ioctl for device
        Input file = (stdin), output file = (stdout)

It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.

error: unexpected end-of-file
download of ‘http://homeserv:3000/nar/cvz1fpbsvqqq36xwyzc33cp7jy4r7lg3-kodiOff-src’ failed: No such file or directory
could not download ‘/nix/store/cvz1fpbsvqqq36xwyzc33cp7jy4r7lg3-kodiOff-src’ from any binary cache
fetching path ‘/nix/store/cvz1fpbsvqqq36xwyzc33cp7jy4r7lg3-kodiOff-src’ failed with exit code 1
error: some substitutes for the outputs of derivation ‘/nix/store/miwpgzvgqw4nn90mggvra3sjlymz10q2-kodiOff-src.drv’ failed (usually happens due to networking issues); try ‘--fallback’ to build derivation from source 
(use ‘--show-trace’ to show detailed location information)
error: unable to build all machine configurations

This happens to me all the time.

If I add the --fallback option, the nixops deploy command successfully completes (and most other packages are correctly downloaded instead of being rebuilt), but then I can't be sure that there won't be spurious rebuilds (say, because my Hydra server hasn't finished rebuilding packages).

But in any case, correct me if I'm wrong, but I think that according to the documentation, the garbage collection was not supposed to delete that derivation.

Metadata

Metadata

Assignees

Labels

UXThe way in which users interact with Nix. Higher level than UI.bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions