-
Notifications
You must be signed in to change notification settings - Fork 98
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
goimports: nix flake check no longer works #318
Comments
Thanks for the nice bug report. Its pretty strange, apparently goimports needs a go executable and didnt before or might it be a packaging problem maybe in |
What is weird to me is that |
@jaredmontoya : I checked ou current The treefmt file which is generated contains (I hope its the same as in [formatter.deadnix]
command = "/nix/store/h7jllc8dsyfy1bfhqr3bq1cdxms8ncdn-deadnix-1.2.1/bin/deadnix"
excludes = []
includes = ["*.nix"]
options = ["--edit"]
[formatter.gofmt]
command = "/nix/store/8zgc91q1igzgmg36mglxrk8qa1r2dvsd-go-1.23.6/bin/gofmt"
excludes = ["vendor/*"]
includes = ["*.go"]
options = ["-w"]
[formatter.goimports]
command = "/nix/store/8m595m24h551sa46h60mcbgmz1rqp3j4-gotools-0.30.0/bin/goimports"
excludes = ["vendor/*"]
includes = ["*.go"]
options = ["-w"]
[formatter.nixfmt]
command = "/nix/store/jh6h8md8zl2vsvr6bd3hgldm5p3kcfsl-nixfmt-unstable-2024-12-04/bin/nixfmt"
excludes = []
includes = ["*.nix"]
options = []
[formatter.statix]
command = "/nix/store/xpa3m7f826cmksbxlf5mymwn30zn7wkw-statix-fix/bin/statix-fix"
excludes = []
includes = ["*.nix"]
options = []
[global]
excludes = [
"*.lock",
"*.patch",
"package-lock.json",
"go.mod",
"go.sum",
".gitignore",
".gitmodules",
".hgignore",
".svnignore",
]
on-unmatched = "warn" When i executre |
Try running |
@jaredmontoya : Still trying to figure out whats wrong. Apparently somehow the |
@zimbatm: Do you have a solution for this. We could hack the |
I came up with this: {
lib,
pkgs,
config,
mkFormatterModule,
...
}:
let
cfg = config.programs.goimports;
command = pkgs.writeShellApplication {
name = "goimports-with-go";
runtimeInputs = [ cfg.goPackage ];
text = ''
"${cfg.package}/bin/goimports"
'';
};
in
{
meta.maintainers = [ "gabyx" ];
imports = [
(mkFormatterModule {
name = "goimports";
package = "gotools";
args = [ "-w" ];
includes = [ "*.go" ];
excludes = [ "vendor/*" ];
})
(
{
pkgs,
lib,
...
}:
{
options = {
programs.goimports.goPackage = lib.mkPackageOption pkgs "goPackage" {
default = "go_1_23";
extraDescription = "The `go` package to use since `goimports` depends on a `go` compiler in the `PATH`.";
};
};
}
)
];
config = lib.mkIf cfg.enable {
settings.formatter.goimports = {
command = "${command}/bin/goimports-with-go";
};
};
} What do you think? (the module system is pretty cool, I think the above might work?) But the example.sh does not generate the additional option right? # Example generated by ../examples.sh
[formatter.goimports]
command = "goimports-with-go"
excludes = ["vendor/*"]
includes = ["*.go"]
options = ["-w"] |
I think that if goimports indeed depends on go, then it has to be fixed in nixpkgs. I am not sure if I implemented it in the best way possible but here is my nixpkgs PR that should fix this: NixOS/nixpkgs#390770 |
PR merged |
Describe the bug
With the new release of GO and goimports in nixpkgs the goimports formatter in treefmt-nix now fails to execute
nix flake check
To Reproduce
Steps to reproduce the behavior:
nix flake check
and it will worknix flake update
to update inputsnix flake check
and you should get an output similar to this:Instead of setting up a project from scratch you can also just perform
nix flake check
test before and afternix flake update
on a real life example: https://github.com/danielmiessler/fabricExpected behavior
It should work as it worked before
System information
NixOS unstable
Additional context
Maintainer ping
@gabyx
The text was updated successfully, but these errors were encountered: