ryantm / agenix

age-encrypted secrets for NixOS and Home manager
https://matrix.to/#/#agenix:nixos.org
Creative Commons Zero v1.0 Universal
1.34k stars 108 forks source link

Disable shellcheck warning about impossible comparison #185

Closed Scrumplex closed 1 year ago

Scrumplex commented 1 year ago

This shellcheck warning occurs when setting a path for a secret using the home-manager module.

I discovered this while moving my agenix secrets to home-manager this morning:

age.secrets."beets-secrets.yaml" = {
  file = ../../secrets/common/beets-secrets.yaml;
  path = "${config.xdg.cacheHome}/beets-secrets.yaml";
};
age.secrets."listenbrainz-token" = {
  file = ../../secrets/common/listenbrainz-token;
  path = "${config.xdg.cacheHome}/listenbrainz-token";
};

produces

In /nix/store/0hslyy6kiffcpvzzh5wy9q77vkihvyan-agenix-home-manager-mount-secrets/bin/agenix-home-manager-mount-secrets line 38:
[ "/home/scrumplex/.cache/beets-secrets.yaml" != "$XDG_RUNTIME_DIR/agenix/beets-secrets.yaml" ] && mkdir -p "$(dirname "/home/scrumplex/.cache/beets-secrets.yaml")"
                                              ^-- SC2193 (warning): The arguments to this comparison can never be equal. Make sure your syntax is correct.

In /nix/store/0hslyy6kiffcpvzzh5wy9q77vkihvyan-agenix-home-manager-mount-secrets/bin/agenix-home-manager-mount-secrets line 48:
[ "/home/scrumplex/.cache/beets-secrets.yaml" != "$XDG_RUNTIME_DIR/agenix/beets-secrets.yaml" ] && ln -sfn "$XDG_RUNTIME_DIR/agenix/beets-secrets.yaml" "/home/scrumplex/.cache/beets-secrets.yaml"
                                              ^-- SC2193 (warning): The arguments to this comparison can never be equal. Make sure your syntax is correct.

In /nix/store/0hslyy6kiffcpvzzh5wy9q77vkihvyan-agenix-home-manager-mount-secrets/bin/agenix-home-manager-mount-secrets line 68:
[ "/home/scrumplex/.cache/listenbrainz-token" != "$XDG_RUNTIME_DIR/agenix/listenbrainz-token" ] && mkdir -p "$(dirname "/home/scrumplex/.cache/listenbrainz-token")"
                                              ^-- SC2193 (warning): The arguments to this comparison can never be equal. Make sure your syntax is correct.

In /nix/store/0hslyy6kiffcpvzzh5wy9q77vkihvyan-agenix-home-manager-mount-secrets/bin/agenix-home-manager-mount-secrets line 78:
[ "/home/scrumplex/.cache/listenbrainz-token" != "$XDG_RUNTIME_DIR/agenix/listenbrainz-token" ] && ln -sfn "$XDG_RUNTIME_DIR/agenix/listenbrainz-token" "/home/scrumplex/.cache/listenbrainz-token"
                                              ^-- SC2193 (warning): The arguments to this comparison can never be equal. Make sure your syntax is correct.

For more information:
  https://www.shellcheck.net/wiki/SC2193 -- The arguments to this comparison ...
Scrumplex commented 1 year ago

CC @ambroisie

P.S. Thanks for your awesome HM module!

ambroisie commented 1 year ago

It might be good to add it to the test to make sure it doesn't regress?

Scrumplex commented 1 year ago

This should include some tests to make sure this doesn't regress now.