Hello community, this is my first post here and I’d really appreciate your help.
My goal is to use sops-nix
secrets with home-manager’s programs.ssh
so I’m trying to use inputs.sops-nix.nixosModules.sops
inside of homeConfigurations
but I’m getting the following error when building with home-manager switch --flake .
error: cannot coerce null to a string
at /nix/store/jamgsam32gs76c2h5wz97sxfw0kcsyqz-source/modules/sops/default.nix:344:23:
343| generate-age-key = mkIf (cfg.age.generateKey) (stringAfter [] ''
344| if [[ ! -f '${cfg.age.keyFile}' ]]; then
| ^
345| echo generating machine-specific age key...
(use '--show-trace' to show detailed location information
I guess that it’s not getting config
but I’m clueless as to why, cause I can use inputs.sops-nix.nixosModules.sops
inside of nixosConfigurations
just fine. Here are my relevant files.
# flake.nix
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-22.05";
nvim.url = "/home/nixos/system/home/nvim";
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
home-manager = {
url = "github:nix-community/home-manager/release-22.05";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{ self, nixos-hardware, nixpkgs, nvim, home-manager, sops-nix, ... }: let
hostnames = builtins.attrNames (builtins.readDir ./hosts);
system = "x86_64-linux";
in {
nixosConfigurations = builtins.listToAttrs (builtins.map (host: {
name = host;
value = inputs.nixpkgs.lib.nixosSystem {
inherit system;
modules = [
{ _module.args = inputs; }
./hosts/${host}/configuration.nix
];
};
}) hostnames);
homeConfigurations.nixos = home-manager.lib.homeManagerConfiguration {
inherit system;
pkgs = nixpkgs.legacyPackages.${system};
configuration = ./home/home.nix;
homeDirectory = "/home/nixos";
username = "nixos";
stateVersion = "22.05";
extraSpecialArgs = { inherit inputs; };
};
};
}
# home/home.nix
{ inputs, lib, config, pkgs, ... }:
{
imports = [
inputs.sops-nix.nixosModules.sops
];
programs.home-manager.enable = true;
}
I’ve been looking at other peoples configs and reading at the NixOS manual but I can’t find the solution. Been using NixOS for about 2 months on my own and this is my first dead end, so I thought it would be a good opportunity to get in touch with the community.
I would really appreciate any help, cheers.