Mic92 / sops-nix

Atomic secret provisioning for NixOS based on sops
MIT License
1.35k stars 133 forks source link

sops-nix.service not found #581

Open spencer3035 opened 2 weeks ago

spencer3035 commented 2 weeks ago

I am trying to set up sops as a home-manager module. Ive followed the readme mostly, but it seems like it doen't install the sops-nix.service properly. Here are the last few lines after I do home-manager switch --flake /path/to/flake.nix

Activating onFilesChange
Activating reloadSystemd
systemctl --user daemon-reload
Suggested commands:
systemctl --user start sops-nix.service
Activating sops-nix
Failed to restart sops-nix.service: Unit sops-nix.service not found.

Predictably, systemctl status --user sops-nix.service and variations also produce a service not found error.

Trimmed down version of my flake.nix:

{
  description = "My flake";

  inputs = {
    # Source of Home Manager and Nixpkgs.
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    sops-nix.url = "github:Mic92/sops-nix";
    sops-nix.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = { nixpkgs, home-manager, ... }@inputs:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
    in
    {
      homeConfigurations."user@hostname" = home-manager.lib.homeManagerConfiguration {
        inherit pkgs;
        modules = [ ./home.nix ];
        extraSpecialArgs = {
          inherit inputs;
          settings = import ./home-manager/hosts/spencer-laptop/settings.nix;
        };
      };
    };
}

Trimmed down version of my home.nix file

{ inputs, ... }: {

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

  sops = {
    defaultSopsFile = ./secrets/secrets.yaml;
    defaultSopsFormat = "yaml";
    age = {
      keyFile = "/path/to/key.txt";
    };
    secrets = { };
  };
}

From my understanding, the service should be automatically installed? I'm not sure if there is a small detail I missed or there is a bug in the version of sops I am using.

Any help is appreciated.

nasdvoya commented 1 week ago

I'm using home manager on Arch Linux and I have the same issue. The config is pretty much the same, I even tried to remove sops config (in case a path was wrong or something). When I rebuild I get this message:


❯ rebuild

Starting Home Manager activation
Activating checkFilesChanged
Activating checkLinkTargets
Activating writeBoundary
Activating installPackages
replacing old 'home-manager-path'
installing 'home-manager-path'
Activating linkGeneration
Cleaning up orphan links from /home/user
No change so reusing latest profile generation 306
Creating home file links in /home/user
Activating onFilesChange
Activating reloadSystemd
The user systemd session is degraded:
  UNIT             LOAD      ACTIVE SUB    DESCRIPTION
● sops-nix.service not-found failed failed sops-nix.service

Legend: LOAD   → Reflects whether the unit definition was properly loaded.
        ACTIVE → The high-level unit activation state, i.e. generalization of SUB.
        SUB    → The low-level unit activation state, values depend on unit type.

1 loaded units listed.
Attempting to reload services anyway...
Mic92 commented 1 week ago

Maybe @SebTM has an idea. I am not really using the home-manager integration.

SebTM commented 1 week ago

I can't reproduce the issue (built with sops-nix b5974d4331fb6c893e808977a2e1a6d34b3162d6 and home-manager 36317d4d38887f7629876b0e43c8d9593c5cc48d), the major difference to my config I assume is the case in both cases is that I use home-manager as nixosModule not standalone.