Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: attribute 'placeholder' missing #498

Open
pcboy opened this issue Feb 19, 2024 · 3 comments
Open

error: attribute 'placeholder' missing #498

pcboy opened this issue Feb 19, 2024 · 3 comments

Comments

@pcboy
Copy link

pcboy commented Feb 19, 2024

I'm trying to use the sops-nix placeholders in my nixOS flake and this is strangely failing.

In my home.nix I correctly import the sops-nix home manager module with:

  imports = [
    inputs.sops-nix.homeManagerModules.sops
  ];

  sops = {
    defaultSopsFile = ./secrets/secrets.yaml;
    age.keyFile = "/home/pcboy/.config/sops/age/keys.txt";
    secrets."OPENAPI_KEY" = {};
  };

Then if I'm trying to use the placeholder/template system:

  sops.templates."ollama-config".content = ''
    {
      "models": [
        {
          "title": "OpenAI (gpt 3.5)",
          "provider": "openai",
          "apiKey": "${config.sops.placeholder.OPENAPI_KEY}",
          "model": "gpt-3.5-turbo-0125"
        },
      ]
    }
  '';

I get this:

error:
       … while calling the 'head' builtin

         at /nix/store/818hgwlhx8ygjilaj89za2nyfff6d8aj-source/lib/attrsets.nix:960:11:

          959|         || pred here (elemAt values 1) (head values) then
          960|           head values
             |           ^
          961|         else

       … while evaluating the attribute 'value'

         at /nix/store/818hgwlhx8ygjilaj89za2nyfff6d8aj-source/lib/modules.nix:809:9:

          808|     in warnDeprecation opt //
          809|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          810|         inherit (res.defsFinal') highestPrio;

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

       error: attribute 'placeholder' missing

       at /nix/store/ckarwy9k1k9qz5nz00mihhhr7q8cnq36-source/home.nix:192:24:

          191|           "provider": "openai",
          192|           "apiKey": "${config.sops.placeholder."OPENAPI_KEY"}",
             |                        ^
          193|           "model": "gpt-3.5-turbo-0125"

I also tried to use only the nixOS sops-nix module (instead of the HM one) and use the placeholders, same error.
What am I doing wrong?

I'm on sops-nix from 'github:Mic92/sops-nix/ffed177a9d2c685901781c3c6c9024ae0ffc252b' (2024-02-18)

@anasinnyk
Copy link

I have the same issue. I saw a code and as I understand templates support only for nixOs Modules, not for home-manager modules, I hope yet.

@dixslyf
Copy link

dixslyf commented Mar 2, 2024

Indeed. Templates are only available in the NixOS module. There is an existing issue for template support for the HM module: #423.

@Mic92
Copy link
Owner

Mic92 commented Mar 14, 2024

I think the python script should be moved into the go code than it will be available on all platforms as it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants