MCPcopy Index your code
hub / github.com/jetify-com/devbox / ProfileInstall

Function ProfileInstall

internal/nix/profiles.go:41–68  ·  view source on GitHub ↗
(ctx context.Context, args *ProfileInstallArgs)

Source from the content-addressed store, hash-verified

39var ErrPriorityConflict = errors.New("priority conflict")
40
41func 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+

Callers 1

Calls 8

FunctionTimerFunction · 0.92
nextPriorityFunction · 0.85
FixInstallableArgsFunction · 0.85
appendArgsFunction · 0.85
allowUnfreeEnvFunction · 0.85
EndMethod · 0.80
CombinedOutputMethod · 0.80
CommandFunction · 0.70

Tested by

no test coverage detected