I have a Flake with a custom home-manager module that looks something like this:
{ config, lib, ... }:
with lib;
{
options.my.module.icon = mkOption {
type = types.pathInStore;
description = "Image to use for this thing";
};
}
Elsewhere in the Flake, I use the module in my config referencing a file in the flake:
my.module.icon = ./my-icon.png
I have been happily using this with nixos-rebuild --flake for some time. But today I’m setting up a new machine and it’s suddenly causing problems. nixos-install fails, complaining that the value for the option is invalid.
# (running on the installer image)
> nixos-install --flake .#myNewMachine
<snip>
error: A definition for option `home-manager.users.me.my.module.icon` is not of type `path in the Nix store'. Definition values:
- In `/mnt/nix/store/<snip>-source/my-config.nix': /mnt/nix/store/<snip>-source/my-icon.png
I’m doubtful that this is specific to home-manager in any way, and pretty confident that it’s getting thrown off by the /mnt/nix/store prefix. Is there any way to get around this, or a smarter way to refer to files within my flake? Wrapping it in a derivation perhaps?
pathInStore uses builtins.storeDir to determine the store. nixos-install uses Nix’ --store flag to build in the store at /mnt/ but that doesn’t change the storeDir.
For whatever reason though, the files you reference are interpreted as absolute paths rather than as store paths.
Same problem here though I’m not using custom home-manager module rather 3rd party flake.parts module: ez-configs - flake-parts
error: A definition for option `ezConfigs.root' is not of type `null or path in the Nix store'. Definition values:
- In `/mnt/nix/store/pr08xgx825h10pyrbw8czrvgszylr5s3-source/flake.nix': /mnt/nix/store/pr08xgx825h10pyrbw8czrvgszylr5s3-source
I’m afraid that there may be many more such modules that I’m using. After a few yeas using nixos-rebuild with flakes I’m in a need of doing nixos-install and failing hard.
I’ve tried nix 2.18.4 and 2.22.2 to no avail. And I’m trying to run the build command manually so there’s no change nixos-install is picking a different version.