-
Notifications
You must be signed in to change notification settings - Fork 249
devconfig,shellgen: option to patch ELF binaries with newer glibc #1574
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
Changes from 1 commit
24ef38a
7310612
a146729
e959e04
669597e
7382dc9
e7ad143
4f98bf2
a1910b4
3615957
5a34e26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,28 +47,33 @@ func (f *flakeInput) PkgImportName() string { | |
return f.Name + "-pkgs" | ||
} | ||
|
||
func (f *flakeInput) BuildInputs() ([]string, error) { | ||
var err error | ||
attributePaths := lo.Map(f.Packages, func(pkg *devpkg.Package, _ int) string { | ||
attributePath, attributePathErr := pkg.FullPackageAttributePath() | ||
if attributePathErr != nil { | ||
err = attributePathErr | ||
} | ||
return attributePath | ||
}) | ||
if err != nil { | ||
return nil, err | ||
type buildInput struct { | ||
AttrPath string | ||
PatchGlibc bool | ||
} | ||
|
||
func (f *flakeInput) BuildInputs() ([]buildInput, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should be able to revert this as well once you do the individual flake approach since |
||
inputs := make([]buildInput, len(f.Packages)) | ||
prefix := f.Name | ||
if f.IsNixpkgs() { | ||
prefix = f.PkgImportName() | ||
} | ||
if !f.IsNixpkgs() { | ||
return lo.Map(attributePaths, func(pkg string, _ int) string { | ||
return f.Name + "." + pkg | ||
}), nil | ||
prefix += "." | ||
for i, pkg := range f.Packages { | ||
attrPath, err := pkg.FullPackageAttributePath() | ||
if err != nil { | ||
return nil, err | ||
} | ||
if f.IsNixpkgs() { | ||
// Remove the legacyPackages.<system> prefix. | ||
attrPath = strings.SplitN(attrPath, ".", 3)[2] | ||
} | ||
inputs[i] = buildInput{ | ||
AttrPath: prefix + attrPath, | ||
PatchGlibc: pkg.PatchGlibc, | ||
} | ||
} | ||
return lo.Map(attributePaths, func(pkg string, _ int) string { | ||
parts := strings.Split(pkg, ".") | ||
// Ugh, not sure if this is reliable? | ||
return f.PkgImportName() + "." + strings.Join(parts[2:], ".") | ||
}), nil | ||
return inputs, nil | ||
} | ||
|
||
// flakeInputs returns a list of flake inputs for the top level flake.nix | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,14 @@ | |
|
||
inputs = { | ||
nixpkgs.url = "{{ .NixpkgsInfo.URL }}"; | ||
|
||
{{- range .FlakeInputs }} | ||
{{.Name}}.url = "{{.URLWithCaching}}"; | ||
{{- end }} | ||
|
||
{{- if .PatchGlibc }} | ||
nixpkgs-unstable.url = "nixpkgs"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are the semantics for when the concrete resolution for this changes:
How can we ensure it is locked and reproducible for users? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be locked by the flake.lock file. I'm not as familiar with the updating logic, but I think it should only change when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, generally speaking, I think this could be problematic. My understanding is:
Let me think some more (have to go to a meeting, jsut sharing my prelim. thoughts) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make this a hard coded reference. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed: avoid creating |
||
{{- end }} | ||
}; | ||
|
||
outputs = { | ||
|
@@ -14,6 +19,9 @@ | |
{{- range .FlakeInputs }} | ||
{{.Name}}, | ||
{{- end }} | ||
{{- if .PatchGlibc }} | ||
nixpkgs-unstable, | ||
{{- end }} | ||
}: | ||
let | ||
pkgs = nixpkgs.legacyPackages.{{ .System }}; | ||
|
@@ -29,25 +37,59 @@ | |
{{- end }} | ||
{{- end }} | ||
]; | ||
|
||
overlays = [ | ||
{{- range $flake.Packages }} | ||
{{- if .PatchGlibc }} | ||
(final: prev: { | ||
{{.PackageAttributePath}} = prev.{{.PackageAttributePath}}; | ||
}) | ||
{{- end }} | ||
{{- end }} | ||
]; | ||
gcurtis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{ if .PatchGlibc -}} | ||
patchGlibc = pkg: derivation { | ||
name = "devbox-patched-glibc"; | ||
system = "{{.System}}"; | ||
|
||
# Set these attributes so that glibc-patch.bash has access to their | ||
# paths via environment variables of the same name. | ||
inherit pkg; | ||
glibc = nixpkgs.legacyPackages."{{.System}}".glibc; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I specified There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good point |
||
coreutils = nixpkgs.legacyPackages."{{.System}}".coreutils; | ||
file = nixpkgs.legacyPackages."{{.System}}".file; | ||
findutils = nixpkgs.legacyPackages."{{.System}}".findutils; | ||
patchelf = nixpkgs.legacyPackages."{{.System}}".patchelf; | ||
ripgrep = nixpkgs.legacyPackages."{{.System}}".ripgrep; | ||
|
||
builder = "${nixpkgs-unstable.legacyPackages.{{.System}}.bash}/bin/bash"; | ||
args = [ ./glibc-patch.bash ]; | ||
}; | ||
{{ end }} | ||
in | ||
{ | ||
devShells.{{ .System }}.default = pkgs.mkShell { | ||
buildInputs = [ | ||
{{- range .Packages }} | ||
{{- if .IsInBinaryCache }} | ||
(builtins.fetchClosure{ | ||
{{ if .IsInBinaryCache -}} | ||
{{ if .PatchGlibc -}} (patchGlibc {{ end -}} | ||
(builtins.fetchClosure { | ||
fromStore = "{{ $.BinaryCache }}"; | ||
fromPath = "{{ .InputAddressedPath }}"; | ||
inputAddressed = true; | ||
}) | ||
{{- if .PatchGlibc -}} ) {{- end -}} | ||
{{- end }} | ||
{{- end }} | ||
{{- range .FlakeInputs }} | ||
{{- range .BuildInputs }} | ||
{{.}} | ||
{{ if .PatchGlibc -}} (patchGlibc {{ end -}} | ||
{{.AttrPath}} | ||
{{- if .PatchGlibc -}} ) {{- end -}} | ||
{{- end }} | ||
{{- end }} | ||
]; | ||
|
Uh oh!
There was an error while loading. Please reload this page.