nix icon indicating copy to clipboard operation
nix copied to clipboard

nix flake templates are not evaluated properly

Open EvysGarden opened this issue 6 months ago • 5 comments

Describe the bug derivations in flake templates are not properly evaluated?

Steps To Reproduce Consider the following code:

{
  outputs = { self, nixpkgs }:
    let
      pkgs = import nixpkgs { system = "x86_64-linux"; };
      templatePackage = pkgs.stdenv.mkDerivation {
        name = "foo-template-package";
        src = ./.;
        installPhase = ''
          mkdir -p $out
          echo yo > $out/foo
        '';
      };
    in
    {
      templates = {
        foo = {
          path = "${templatePackage}";
        };
      };
    };
}

Calling nix flake init -t ".#foo" gives me the following error:

error: opening directory '/nix/store/<some-hash>-foo-template-package': No such file or directory

Expected behavior The derivation should be actually build so that the path exists.

nix-env --version output nix-env (Nix) 2.18.5

Priorities

Add :+1: to issues you find important.

EvysGarden avatar Aug 16 '24 09:08 EvysGarden