with-inputs icon indicating copy to clipboard operation
with-inputs copied to clipboard

`inputs.self` has no `outPath` attribute

Open acid-bong opened this issue 3 months ago • 5 comments

AFAIU, flakes generate self.outPath by using either "${dirOf ./flake.nix}" or fetch[Git|Mercurial] (dirOf ./flake.nix) (or analogies of such). Would it be possible/make sense for with-inputs to add this?

acid-bong avatar Aug 31 '26 17:08 acid-bong

I don't currently have much access to my laptop, but I'd be surprised if we did not have self.outPath, can you verify and a failing test ? We should have a test that checks self.outPath is present, if that is not currently the case, PR is very welcome :)

vic avatar Aug 31 '26 21:08 vic

wdym surprised? currently with-inputs isn't even supposed to resolve self as a flake, only outputs top-level with separate outputs and inputs: https://github.com/denful/with-inputs/blob/dae6b8126fe613bfe12185d94d593db426a34daa/with-inputs.nix#L146-L150

funnily enough, the workaround is to set a top-level output outPath = ./.;; or, in flake-parts:

          options.flake.outPath = inputs.nixpkgs.lib.mkOption {
            type = inputs.nixpkgs.lib.types.path;
            default = ./.;
          };

acid-bong avatar Sep 01 '26 04:09 acid-bong

Fix (at least for the from.* api cases) in https://github.com/denful/with-inputs/pull/18.

jbgi avatar Sep 01 '26 18:09 jbgi

nix-repl> nixosConfigurations.jetpure.config.home-manager.extraSpecialArgs.self
{
  _type = "flake";
  allSystems = { ... };
  apps = { ... };
  checks = { ... };
  currentSystem = { ... };
  debug = { ... };
  denful = { ... };
  devShells = { ... };
  diskoConfigurations = { ... };
  formatter = { ... };
  inputs = { ... };
  legacyPackages = { ... };
  modules = { ... };
  nixosConfigurations = { ... };
  nixosModules = «repeated»;
  outputs = { ... };
  overlays = «repeated»;
  packages = { ... };
}
{
  self,
  inputs,
  ...
}:

{
  zen.miscellaneous.home-manager = {
    os =
      {
        ...
      }:
      {
        home-manager.extraSpecialArgs = {
          inherit
            self
            inputs
            ;
        };
      };
  };
}

also, how to make self alike in flake?

for this works

nix-repl> "${outputs.inputs.self}"
error:
       … while evaluating a path segment
         at «string»:1:2:
            1| "${outputs.inputs.self}"
             |  ^

       error: cannot coerce a set to a string: { _type = "flake"; allSystems = { x86_64-linux = «thunk»; }; apps = { x86_64-linux = «thunk»; }; checks = { x86_64-linux = «thunk»; }; currentSystem = { _module = «thunk»; allModuleArgs = «thunk»; apps = «thunk»; «9 attributes elided» }; «13 attributes elided» }

unazikx avatar Oct 12 '26 12:10 unazikx

Fixed at #23 please use latest main.

vic avatar Oct 12 '26 17:10 vic