Skip to content

nix flake templates are not evaluated properlyΒ #11309

Open
@EvysGarden

Description

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 πŸ‘ to issues you find important.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions