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

[BUG] Agenix not creating secrets #247

Open
xqtc161 opened this issue Feb 23, 2024 · 2 comments
Open

[BUG] Agenix not creating secrets #247

xqtc161 opened this issue Feb 23, 2024 · 2 comments

Comments

@xqtc161
Copy link

xqtc161 commented Feb 23, 2024

I added agenix as a home-manager module to my flake-based NixOS configuration.

sudo nixos-rebuild switch builds with no errors. Yet there are no secrets in /run/users/1000/. Not even the agenix folder exists, just agenix.d. I use a similar config like a friend of mine, and everything works for him.

@krad246
Copy link

krad246 commented Mar 9, 2024

Same issue here, I can't seem to get the directories to pop up and home manager activation fails outright

@VTimofeenko
Copy link

The /run/users/1000/agenix gets mounted if and only if there are secrets (logic is in this block) with the actual mounting code here.

Sample flake with agenix imported in home-manager

This flake exposes a test VM that can be run as nix run .\#checks.x86_64-linux.test.driverInteractive.

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
    home-manager.url = "github:nix-community/home-manager";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
    agenix.url = "github:ryantm/agenix";
  };

  outputs =
    inputs@{ self, nixpkgs, ... }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs { inherit system; };
      inherit (pkgs) lib;
    in
    {

      checks.${system}.test = pkgs.testers.runNixOSTest {
        name = "foo";
        nodes.machine1 =
          { config, pkgs, ... }:
          {
            services.getty.autologinUser = "alice";
            imports = [ inputs.home-manager.nixosModules.home-manager ];
            users.users.alice = {
              isNormalUser = true;
              password = "hunter2";
            };
            home-manager.users.alice =
              { config, ... }: # config is home-manager's config, not the OS one
              {
                imports = [ inputs.agenix.homeManagerModules.default ];
                home.stateVersion = "24.05";
                home.file.".ssh/id_ed25519".source = ./id_ed25519; # Don't do this to a real key, it's world-readable in store. For test VM it's OK.

                home.file.".ssh/id_ed25519.pub".source = ./id_ed25519.pub;
                programs.ssh = {
                  enable = true;
                  includes = [
                    (lib.removePrefix ".ssh/" config.age.secrets.ssh-config.path) # This makes the include relative
                  ];
                };
                age.secrets.ssh-config.file = ./ssh-config.age;
                age.secrets.ssh-config.path = ".ssh/includes/ssh-config-agenix";
              };
          };
        testScript = "start_all()";
      };
    };
}

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

3 participants