-
Notifications
You must be signed in to change notification settings - Fork 248
[remove nixpkgs] add toPath, and edit devbox.lock only on update command #1256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
internal/impl/update.go
Outdated
// we'll need to progressively add it to a project's lockfile. | ||
needsLocalStorePath = userSysInfo.LocalStorePath == "" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 119 to line 128 the logic is a bit hard to follow, since you have if !needsSysInfo, needsLocalStorePath, if needsSysInfo...
Can we flatten this a bit? Something like:
var userSysInfo
var localStorePath
if featureflag.RemoveNixpkgs.Enabled() {
userSysInfo = d.lockfile.Packages[pkg.Raw].Systems[userSystem]
if userSysInfo != nil {
localStorePath = userSysInfo.LocalStorePath
}
}
if userSysInfo == nil { ... }
if localStorePath == "" { ... }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm finding some of the new terms a bit confusing. Could we make them match what Nix calls them?
BinaryStorePath
- this can just beStorePath
. There isn't any difference between a path in a remote binary cache and a local store.LocalStorePath
- it looks like this is just the content-addressed version of the store path. Could we call itCAStorePath
(orContentAddressedStorePath
if CA sounds like certificate)?BinaryStore
→BinaryCache
internal/nix/store.go
Outdated
// Example: | ||
// > nix store make-content-addressed /nix/store/r2jd6ygnmirm2g803mksqqjm4y39yi6i-git-2.33.1 | ||
// rewrote '/nix/store/r2jd6ygnmirm2g803mksqqjm4y39yi6i-git-2.33.1' to '/nix/store/ldbhlwhh39wha58rm61bkiiwm6j7211j-git-2.33.1' | ||
var contentAddressedRegex = regexp.MustCompile(`rewrote\s'[\/a-z0-9-\.]+'\sto\s'([a-z0-9-\/\.]+)'`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does nix store make-content-addressed --json
work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah, good call. Will try that...
"/nix/store/r2jd6ygnmirm2g803mksqqjm4y39yi6i-git-2.33.1", | ||
"/nix/store/ldbhlwhh39wha58rm61bkiiwm6j7211j-git-2.33.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does Nix automatically download these if they're not in the store yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep
"testing" | ||
) | ||
|
||
func TestContentAddressedPath(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
Sounds good to me. Don't feel strongly about the current names (except I didn't want it to be "fromPath" and "toPath", since those don't make sense outside the context of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All CICD has passed. Going to make a small "rename" I missed out and then land...
internal/lock/lockfile.go
Outdated
StorePath string `json:"store_path,omitempty"` | ||
// CAStorePath is the content-addressed path for the nix package in /nix/store | ||
// It is of the form <hash>-<name>-<version> | ||
CAStorePath string `json:"local_store_path,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, forgot to rename the key to ca_store_path
// Check if the system info is missing for the user's system. | ||
sysInfo := d.lockfile.Packages[pkg.Raw].Systems[userSystem] | ||
if sysInfo == nil { | ||
d.lockfile.Packages[pkg.Raw] = newEntry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, could this override an existing (different) system that already has a CA path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right! Much obliged 🙏🏾
sending fix: #1259
} | ||
|
||
// Check if the package's system info is missing, or not complete. | ||
if featureflag.RemoveNixpkgs.Enabled() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the logic in this block could be encapsulated in lock file. Maybe:
if existing.CanBeUpdated(newEntry) {
d.lockfile.Update(existing, newEntry)
}
or something like that. It could deal with version changes and also missing system stuff.
That way we could make Package.Systems
semi-private. (It still needs to be exported because it is part of the JSON)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, is this logic block missing profile install/uninstall? e.g. if a package previously required nixpkgs and we replace it with one that does not require it, do we want to update the profile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I agree this could likely be moved into the lock
package. In general, I think quite a bit of the update code (beyond this block) could be better encapsulated. I may not have time to get to it though...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, is this logic block missing profile install/uninstall? e.g. if a package previously required nixpkgs and we replace it with one that does not require it, do we want to update the profile?
🤔 yeah, this one I am unsure about. In theory, the package's binary should be the exact same.
Its also why I think it was okay and/or put a question mark after using InputAddressedPath
in the Package.Installable
here.
@gcurtis would you have an opinion?
… and ContentAddressedPath, and s/BinaryStore/BinaryCache (#1257) ## Summary This PR is a follow up to this request from @gcurtis: #1256 (review) BUT having `NixStorePath` and `ContentAddressedPath` seemed odd since content-addressed paths are also nix store paths. So, in this PR, I'm explicit about `NixStorePath` being `InputAddressedPath`. Also - changed `BinaryStore` to `BinaryCache`. **RFC**: I didn't change the `lock.SystemInfo` struct, I've left it as: ``` type SystemInfo struct { // StorePath is the input-addressed path for the nix package in /nix/store // It is the cache key in the Binary Cache Store (cache.nixos.org) // It is of the form <hash>-<name>-<version> // <name> may be different from the canonicalName so we store the full store path. StorePath string `json:"store_path,omitempty"` // CAStorePath is the content-addressed path for the nix package in /nix/store // It is of the form <hash>-<name>-<version> CAStorePath string `json:"ca_store_path,omitempty"` } ``` I think this could be okay, because the default `store_path` for nix is input-addressed, for now at least. If you'd like I can change `StorePath` to be explicitly: ``` InputAddrStorePath string `json:"input_addr_path, omitempty" ContentAddrStorePath string `json:"content_addr_path, omitempty" ``` Let me know! ## How was it tested? compiles
Summary
This PR rolls in a few fixes:
toPath
tobuiltins.fetchClosure
--impure
flag innix print-dev-env
ca_store_path
todevbox.lock
devbox update
will only update the user's system'sca_store_path
.nix store make-content-addressed <path>
call on eachdevbox shell/run/shellenv
.devbox.lock
duringdevbox update
.devbox shell/run/shellenv
.devbox.lock
schema'sSystemInfo
to haveStorePath
andCAStorePath
. These are used asfromPath
andtoPath
inbuiltins.fetchClosure
.Miscellaneous changes:
actionlint
from thedevbox.json
. It is not core to our workflows, and I am working with very minimal space on devbox cloud VM. This reduces "out of space errors" marginally.How was it tested?
In
examples/development/go/hello-world
:devbox update
anddevbox shell
The
devbox.lock
diff is now