aciceri / agenix-shell

https://flake.parts/options/agenix-shell
35 stars 3 forks source link

installation script has no effect? #2

Open MangoIV opened 12 months ago

MangoIV commented 12 months ago

for me it says /nix/store/1pp7al3i0pxwdf30fhhxb2nr9rws2mr8-install-agenix-shell in the shellHook which is just some directory; I think ideally it should be inlined, i.e. have the store path be directly a the text and not a storepath/bin/exe

MangoIV commented 12 months ago

alright I looked at the flake template, makes sense! I think I would put the installationScript attribute as

source ${config.agenix-shell/bin/install-agenix-shell}

such that you can just concat it with the rest of your shellHook

MangoIV commented 11 months ago

For some reason that breaks my entire devShell 😞

aciceri commented 10 months ago

Hey sorry but I missed this issue, have you figured it out in the end?

Yeah probably including the source part is in the installationScript is not a bad idea. Probably I will create another option (internal) which contains just the installationScript as now and a new installationCommand with default value is "source ${installationScript}", so we leave more customizability if someone for some reason doesn't need to source it.

Also notice that my initial idea was providing this raw installationScript for a "vanilla" experience but then add a module that extends devshell's options and use it myself (I tend to use devshell whenever I can).

MrFoxPro commented 10 months ago

Running ${lib.getExe config.agenix-shell.installationScript} in devenv enterShell still has no effect, and sourcing it breaks other shell variables

aciceri commented 10 months ago

@MrFoxPro How does it break them? If you give me a repro that uses devenv I will try to fix it (and we could also add it to templates/checks).

MrFoxPro commented 10 months ago

@MrFoxPro How does it break them? If you give me a repro that uses devenv I will try to fix it (and we could also add it to templates/checks).

Okay I will try. What I mean by breaking is all binaries provided by packages = [] are gone (I guess because PATH overriden)

aciceri commented 6 months ago

@MrFoxPro In the past few weeks I tidied up a bit the repository (there were things that didn't make sense) and after I tried to replicate your problem but it doesn't seem to appear.

This is the flake I'm using:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    devenv.url = "github:cachix/devenv";
    agenix-shell.url = "github:aciceri/agenix-shell";
  };

  outputs = inputs: let
    system = "x86_64-linux";
    pkgs = inputs.nixpkgs.legacyPackages.${system};
    lib = pkgs.lib;
    installationScript = inputs.agenix-shell.packages.${system}.installationScript.override {
      agenixShellConfig.secrets = {
        foo.file = ./secrets/foo.age;
      };
    };

    in {
      devShell.x86_64-linux = inputs.devenv.lib.mkShell {
        inherit inputs pkgs;
        modules = [
          ({ pkgs, config, ... }: {
        packages = [ pkgs.hello ];

            enterShell = ''
          source ${lib.getExe installationScript}
        '';
          })
        ];
      };
    };
}

2024-04-18T14:10:15+02:00

I also just added this example to templates.

MrFoxPro commented 6 months ago

@MrFoxPro In the past few weeks I tidied up a bit the repository (there were things that didn't make sense) and after I tried to replicate your problem but it doesn't seem to appear.

This is the flake I'm using:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    devenv.url = "github:cachix/devenv";
    agenix-shell.url = "github:aciceri/agenix-shell";
  };

  outputs = inputs: let
    system = "x86_64-linux";
    pkgs = inputs.nixpkgs.legacyPackages.${system};
    lib = pkgs.lib;
    installationScript = inputs.agenix-shell.packages.${system}.installationScript.override {
      agenixShellConfig.secrets = {
        foo.file = ./secrets/foo.age;
      };
    };

    in {
      devShell.x86_64-linux = inputs.devenv.lib.mkShell {
        inherit inputs pkgs;
        modules = [
          ({ pkgs, config, ... }: {
      packages = [ pkgs.hello ];

            enterShell = ''
        source ${lib.getExe installationScript}
      '';
          })
        ];
      };
    };
}

2024-04-18T14:10:15+02:00

I also just added this example to templates.

Okay thanks I will try a bit later