(ctx context.Context, args *ProfileInstallArgs)
| 39 | var ErrPriorityConflict = errors.New("priority conflict") |
| 40 | |
| 41 | func ProfileInstall(ctx context.Context, args *ProfileInstallArgs) error { |
| 42 | defer debug.FunctionTimer().End() |
| 43 | |
| 44 | cmd := Command( |
| 45 | "profile", "install", |
| 46 | "--profile", args.ProfilePath, |
| 47 | "--offline", // makes it faster. Package is already in store |
| 48 | "--impure", // for NIXPKGS_ALLOW_UNFREE |
| 49 | // Using an arbitrary priority to avoid conflicts with other packages. |
| 50 | // Note that this is not really the priority we care about, since we |
| 51 | // use the flake.nix to specify the priority. |
| 52 | "--priority", nextPriority(args.ProfilePath), |
| 53 | ) |
| 54 | |
| 55 | FixInstallableArgs(args.Installables) |
| 56 | cmd.Args = appendArgs(cmd.Args, args.Installables) |
| 57 | cmd.Env = allowUnfreeEnv(os.Environ()) |
| 58 | |
| 59 | // We used to attach this function to stdout and in in order to get the more interactive output. |
| 60 | // However, now we do the building in nix.Build, by the time we install in profile everything |
| 61 | // should already be in the store. We need to capture the output so we can decide if a conflict |
| 62 | // happened. |
| 63 | out, err := cmd.CombinedOutput(ctx) |
| 64 | if bytes.Contains(out, []byte("error: An existing package already provides the following file")) { |
| 65 | return ErrPriorityConflict |
| 66 | } |
| 67 | return err |
| 68 | } |
| 69 | |
| 70 | // ProfileRemove removes packages from a profile. |
| 71 | // WARNING, don't use indexes, they are not supported by nix 2.20+ |
no test coverage detected