For context I think that this is nix language question(all the code I will provide is a short version of my actual files). I have flake.nix that defines nixos(and home manger as nixos module) and home-manger for generic use.
{
description = "Multi machine flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
home-manager = {
url = "github:nix-community/home-manager/release-25.05";
inputs.nixpkgs.follows = "nixpkgs";
};
# implicitly sets programs.command-not-found.enable = false;
nix-index-database = {
url = "github:Mic92/nix-index-database";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ nixpkgs, ... }@inputs:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
lib = nixpkgs.lib;
in
{
nixosConfigurations = {
kvm-nixos-server = lib.nixosSystem {
inherit system;
specialArgs = {
inherit inputs;
machineName = "kvm-nixos-server";
};
modules = [
./machines/kvm-nixos-server/configuration.nix
inputs.home-manager.nixosModules.home-manager
inputs.nix-index-database.nixosModules.nix-index
inputs.sops-nix.nixosModules.sops
inputs.disko.nixosModules.disko
];
};
homeConfigurations = {
kmedrish = inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs;
extraSpecialArgs = {
inherit inputs;
machineName = "generic_linux_distro";
};
modules = [
./machines/generic_linux_distro/home.nix
inputs.sops-nix.homeManagerModules.sops
];
};
};
};
}
And I have a file host-specification.nix with global variables which I use all over my configuration files by importing it.
{ lib, config, ... }:
{
options.hostSpecification = {
syncthing = lib.mkOption {
type = lib.types.submodule {
options = {
syncDir = lib.mkOption {
default = "${config.hostSpecification.primeUserHomeDirectory}/Sync";
type = lib.types.str;
description = "Defines the Syncthing sync directory";
};
};
};
default = {};
description = "Syncthing related configuration";
};
};
}
In case of my nixos + home-manger as nixos module I import host-specification.nix inside of my configuration.nix and then pass its value inside on my home-manger module.
{
inputs,
machineName,
config,
...
}:
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = {
inherit inputs;
inherit machineName;
hostSpecification = config.hostSpecification;
};
users.${config.hostSpecification.primeUsername} =
import config.userDefinedGlobalVariables.homeMangerImportPath;
sharedModules = [
inputs.sops-nix.homeManagerModules.sops
];
};
}
This means that inside my home-manger files I don"t call for config.hostSpecification.syncthing.syncDir I instead use hostSpecification.syncthing.syncDir like in taskwarrior.nix
{ pkgs, hostSpecification, ... }:
{
home.packages = with pkgs; [ taskwarrior-tui ];
programs.taskwarrior = {
enable = true;
package = pkgs.taskwarrior3;
dataLocation = "${hostSpecification.syncthing.syncDir}/taskwarrior_data/task";
};
}
The question is how do I go about this in my “home-manger for generic Linux setup” as there is no
hostSpecification = config.hostSpecification; for it meaning when I try and reuse my taskwarrior.nix it falils as there is no hostSpecification.syncthing.syncDir only config.hostSpecification.syncthing.syncDi