Cannot run Docker container as systemd service on RISC-V

I am trying to set up a Docker container as a systemd service on my VisionFive 2 (RISC-V). The GHC compiler is not available on this platform, which is why the shellcheck tool won’t work.

In short: any calls to shellcheck need to be avoided.

However, the container gets set up as a systemd unit, which automatically gets checked with shellcheck, leading to this error:

error:
       … while calling the 'head' builtin
         at /nix/store/n1hshh978rylg6m6p8si83s8vks1xqbc-source/lib/attrsets.nix:1574:11:
         1573|         || pred here (elemAt values 1) (head values) then
         1574|           head values
             |           ^
         1575|         else

       … while evaluating the attribute 'value'
         at /nix/store/n1hshh978rylg6m6p8si83s8vks1xqbc-source/lib/modules.nix:816:9:
          815|     in warnDeprecation opt //
          816|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          817|         inherit (res.defsFinal') highestPrio;

       … while evaluating the option `system.build.toplevel':

       … while evaluating definitions from `/nix/store/n1hshh978rylg6m6p8si83s8vks1xqbc-source/nixos/modules/system/activation/top-level.nix':

       … while evaluating the option `system.systemBuilderArgs':

       … while evaluating definitions from `/nix/store/n1hshh978rylg6m6p8si83s8vks1xqbc-source/nixos/modules/system/activation/activatable-system.nix':

       … while evaluating the option `system.activationScripts.etc.text':

       … while evaluating definitions from `/nix/store/n1hshh978rylg6m6p8si83s8vks1xqbc-source/nixos/modules/system/etc/etc-activation.nix':

       … while evaluating definitions from `/nix/store/n1hshh978rylg6m6p8si83s8vks1xqbc-source/nixos/modules/system/etc/etc.nix':

       … while evaluating the option `environment.etc."systemd/system".source':

       … while evaluating the option `systemd.units."vaultwarden-docker.service".text':

       … while evaluating definitions from `/nix/store/n1hshh978rylg6m6p8si83s8vks1xqbc-source/nixos/modules/system/boot/systemd.nix':

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: cannot bootstrap GHC on this platform ('riscv64-linux' with libc 'defaultLibc')

The container was set up like this:

{ config, ... }:
{
  virtualisation.oci-containers = {
    backend = "docker";
    containers = {
      vaultwarden = {
        image = "vaultwarden:b6mkkak7lsxw5xdh0ykkny4h4r6mams3";
        # ...
      };
    };
  };
}

This is the responsible code block for the check phase I found in the trace: nixpkgs/pkgs/build-support/trivial-builders/default.nix at 4e96537f163fad24ed9eb317798a79afc85b51b7 · NixOS/nixpkgs · GitHub and it looks like the check shouldn’t be running on RISC-V.

nix repl says:

:l <nixpkgs>
nix-repl> stdenv.buildPlatform.config
"riscv64-unknown-linux-gnu"

nix-repl> lib.meta.availableOn stdenv.buildPlatform shellcheck-minimal.compiler
true

Why does nix think the GHC compiler is available on riscv64? How do I fix this?

Have you tried nixos-unstable? See writeShellApplication: fix shellcheck availability check by misuzu · Pull Request #362868 · NixOS/nixpkgs · GitHub

1 Like

Thanks for the fix! Not recently but I guess I’ll have to go back at some point then :eyes:

1 Like