I’m trying to write a nixosModule that creates a sonarr nixos-container.
The problem is that sonarr depends on the buildDotNetModule and this has been marked as EOL.
The module then fails to build and I’m looking for a ergonomic way to avoid this error.
This is the simplified flake.nix
:
{
# no inputs
outputs = {...}: {
nixosModules.default = { config, lib, ... }: {
options.mymodule = {
# ...
};
config = lib.mkIf config.mymodule.enable {
# ...
};
imports = [
./dir/container.nix
];
};
};
}
And in ./dir/container.nix
:
{lib, config, ...}:
{
options.mymodule.sonarr = {
enable = lib.mkEnableOption "sonarr";
# ...
};
config = lib.mkIf config.mymodule.sonarr.enable {
containers."sonarr" = {
config = {...}: {
# ...
nixpkgs.pkgs = (import config.nixpkgs {
system = config.system;
config = config.nixpkgs.config // {
permittedInsecurePackages = [ "aspnetcore-runtime-wrapped-6.0.36" ];
};
}).legacyPackages."${config.system}";
# ...
I though reusing the config
parameter and reimporting nixpkgs would work but this fails with cryptic messages such as:
error:
… while calling the 'derivationStrict' builtin
at <nix/derivation-internal.nix>:34:12:
33|
34| strict = derivationStrict drvAttrs;
| ^
35|
… while evaluating derivation 'nixos-vm'
whose name attribute is located at /nix/store/w66xaybnxjf5zhxapxs3pd3zp7gxk9dw-source/pkgs/stdenv/generic/make-derivation.nix:336:7
… while evaluating attribute 'buildCommand' of derivation 'nixos-vm'
at /nix/store/w66xaybnxjf5zhxapxs3pd3zp7gxk9dw-source/pkgs/build-support/trivial-builders/default.nix:59:17:
58| enableParallelBuilding = true;
59| inherit buildCommand name;
| ^
60| passAsFile = [ "buildCommand" ]
… while evaluating the option `virtualisation.vmVariant.system.build.toplevel':
… while evaluating definitions from `/nix/store/w66xaybnxjf5zhxapxs3pd3zp7gxk9dw-source/nixos/modules/system/activation/top-level.nix':
… while evaluating the option `virtualisation.vmVariant.system.systemBuilderArgs':
… while evaluating definitions from `/nix/store/w66xaybnxjf5zhxapxs3pd3zp7gxk9dw-source/nixos/modules/system/activation/activatable-system.nix':
… while evaluating the option `virtualisation.vmVariant.system.activationScripts.etc.text':
… while evaluating definitions from `/nix/store/w66xaybnxjf5zhxapxs3pd3zp7gxk9dw-source/nixos/modules/system/etc/etc-activation.nix':
… while evaluating definitions from `/nix/store/w66xaybnxjf5zhxapxs3pd3zp7gxk9dw-source/nixos/modules/system/etc/etc.nix':
… while evaluating the option `virtualisation.vmVariant.environment.etc."nixos-containers/sonarr.conf".source':
… while evaluating definitions from `/nix/store/w66xaybnxjf5zhxapxs3pd3zp7gxk9dw-source/nixos/modules/system/etc/etc.nix':
… while evaluating the option `virtualisation.vmVariant.environment.etc."nixos-containers/sonarr.conf".text':
… while evaluating definitions from `/nix/store/w66xaybnxjf5zhxapxs3pd3zp7gxk9dw-source/nixos/modules/virtualisation/nixos-containers.nix':
… while evaluating the option `virtualisation.vmVariant.containers.sonarr.path':
… while evaluating definitions from `/nix/store/w66xaybnxjf5zhxapxs3pd3zp7gxk9dw-source/nixos/modules/virtualisation/nixos-containers.nix':
… while evaluating the option `virtualisation.vmVariant.containers.sonarr.config':
… while evaluating the module argument `pkgs' in "/nix/store/w66xaybnxjf5zhxapxs3pd3zp7gxk9dw-source/nixos/modules/services/hardware/bluetooth.nix":
… while evaluating definitions from `/nix/store/w66xaybnxjf5zhxapxs3pd3zp7gxk9dw-source/nixos/modules/virtualisation/nixos-containers.nix':
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: cannot coerce a set to a string: { buildPlatform = «thunk»; config = { }; crossSystem = null; flake = { setFlakeRegistry = true; setNixPath = true; source = "/nix/store/w66xaybnxjf5zhxapxs3pd3zp7gxk9dw-source"; }; hostPlatform = «thunk»; initialSystem = «thunk»; localSystem = { aesSupport = false; «108 attributes elided» }; «3 attributes elided» }
Maybe I could add a nixpkgs input in the flake and somehow pass it to the ./dir/container.nix
module, but I wouldn’t want to add an input if I don’t have to and I always find the ways of passing parameters in modules hacky.
Any ideas how to solve this?