( ctx context.Context, out io.Writer, // Note: installable is a string instead of a flake.Installable // because flake.Installable does not support store paths yet. It converts // paths into "path" flakes which is not what we want for /nix/store paths. // TODO: Add support for store paths in flake.Installable to, installable string, env []string, )
| 8 | ) |
| 9 | |
| 10 | func CopyInstallableToCache( |
| 11 | ctx context.Context, |
| 12 | out io.Writer, |
| 13 | // Note: installable is a string instead of a flake.Installable |
| 14 | // because flake.Installable does not support store paths yet. It converts |
| 15 | // paths into "path" flakes which is not what we want for /nix/store paths. |
| 16 | // TODO: Add support for store paths in flake.Installable |
| 17 | to, installable string, |
| 18 | env []string, |
| 19 | ) error { |
| 20 | fmt.Fprintf(out, "Copying %s to %s\n", installable, to) |
| 21 | cmd := Command( |
| 22 | "copy", "--to", to, |
| 23 | // --impure makes NIXPKGS_ALLOW_* environment variables work. |
| 24 | "--impure", |
| 25 | // --refresh checks the cache to ensure it is up to date. Otherwise if |
| 26 | // anything has was copied previously from this machine and then purged |
| 27 | // it may not be copied again. It's fairly fast, but not instant. |
| 28 | "--refresh", |
| 29 | installable, |
| 30 | ) |
| 31 | |
| 32 | cmd.Stdin = os.Stdin |
| 33 | cmd.Stdout = out |
| 34 | cmd.Stderr = out |
| 35 | cmd.Env = append(allowUnfreeEnv(allowInsecureEnv(os.Environ())), env...) |
| 36 | |
| 37 | return cmd.Run(ctx) |
| 38 | } |
no test coverage detected