-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: update build configurations and flake.nix for Go module
- Removed `goPackage` and `buildGoModule` parameters from `build-configs.yaml`. - Updated `flake.nix` to use `buildGoModule` instead of `buildGo122Module`. - Added `version` and `CgoEnabled` fields to `GoCobraCliConfig` in `go_cobra_cli.go`. - Updated `internal/templates/templates/go-cobra-cli/flake.nix` to include `version` and `CgoEnabled` fields.
- Loading branch information
1 parent
18e0491
commit a85aa33
Showing
4 changed files
with
59 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,33 @@ | ||
{ | ||
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; | ||
|
||
outputs = inputs@{ flake-parts, ... }: | ||
flake-parts.lib.mkFlake { inherit inputs; } { | ||
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; | ||
outputs = inputs @ {flake-parts, ...}: | ||
flake-parts.lib.mkFlake {inherit inputs;} { | ||
systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"]; | ||
|
||
perSystem = { config, pkgs, ... }: | ||
let | ||
inherit (pkgs) | ||
go_1_22 | ||
just; | ||
|
||
name = "build-configs"; | ||
CGO_ENABLED = "0"; | ||
in | ||
{ | ||
devShells.default = pkgs.mkShell { | ||
buildInputs = [ just ]; | ||
inputsFrom = [ config.packages.default ]; | ||
}; | ||
|
||
packages = { | ||
default = pkgs.buildGo122Module { | ||
inherit name; | ||
src = ./.; | ||
vendorHash = "sha256-6B9O6ho4COpJy4HlkzQ0lk+ieezRO3xg9LyLHzoxYzc="; | ||
buildModules = [ "cmd/${name}" ]; | ||
}; | ||
perSystem = { | ||
config, | ||
pkgs, | ||
... | ||
}: let | ||
inherit (pkgs) just; | ||
name = "build-configs"; | ||
version = "0.1.0"; | ||
CGO_ENABLED = "0"; | ||
in { | ||
devShells.default = pkgs.mkShell { | ||
buildInputs = [just]; | ||
inputsFrom = [config.packages.default]; | ||
}; | ||
|
||
docker = pkgs.dockerTools.buildImage { | ||
inherit name; | ||
tag = "latest"; | ||
config = { | ||
Entrypoint = [ "${config.packages.default}/bin/${name}" ]; | ||
Env = [ | ||
"SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" | ||
]; | ||
}; | ||
}; | ||
packages = { | ||
default = pkgs.buildGoModule { | ||
inherit CGO_ENABLED name version; | ||
src = ./.; | ||
subPackages = ["cmd/${name}"]; | ||
vendorHash = "sha256-6B9O6ho4COpJy4HlkzQ0lk+ieezRO3xg9LyLHzoxYzc="; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,33 @@ | ||
{ | ||
inputs.nixpkgs.url = "github:nixos/nixpkgs/{{ .Nix.NixpkgsBranch }}"; | ||
|
||
outputs = inputs@{ flake-parts, ... }: | ||
flake-parts.lib.mkFlake { inherit inputs; } { | ||
systems = [ {{range .Nix.Systems}}"{{.}}" {{end}}]; | ||
outputs = inputs @ {flake-parts, ...}: | ||
flake-parts.lib.mkFlake {inherit inputs;} { | ||
systems = [{{range .Nix.Systems}}"{{.}}" {{end}}]; | ||
|
||
perSystem = { config, pkgs, ... }: | ||
let | ||
inherit (pkgs) | ||
{{ .Nix.GoPackage }} | ||
just; | ||
|
||
name = "{{ .Name }}"; | ||
CGO_ENABLED = "0"; | ||
in | ||
{ | ||
devShells.default = pkgs.mkShell { | ||
buildInputs = [ just ]; | ||
inputsFrom = [ config.packages.default ]; | ||
}; | ||
|
||
packages = { | ||
default = pkgs.{{ .Nix.BuildGoModule }} { | ||
inherit name; | ||
src = ./.; | ||
vendorHash = "{{ .Nix.VendorHash }}"; | ||
buildModules = [ "cmd/${name}" ]; | ||
}; | ||
perSystem = { | ||
config, | ||
pkgs, | ||
... | ||
}: let | ||
inherit (pkgs) just; | ||
name = "{{ .Name }}"; | ||
version = "{{ .Version }}"; | ||
{{ if .CgoEnabled }}CGO_ENABLED = "1";{{ else }}CGO_ENABLED = "0";{{ end }} | ||
in { | ||
devShells.default = pkgs.mkShell { | ||
buildInputs = [just]; | ||
inputsFrom = [config.packages.default]; | ||
}; | ||
|
||
docker = pkgs.dockerTools.buildImage { | ||
inherit name; | ||
tag = "latest"; | ||
config = { | ||
Entrypoint = [ "${config.packages.default}/bin/${name}" ]; | ||
Env = [ | ||
"SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" | ||
]; | ||
}; | ||
}; | ||
packages = { | ||
default = pkgs.{{ .Nix.BuildGoModule }} { | ||
inherit CGO_ENABLED name version; | ||
src = ./.; | ||
subPackages = ["cmd/${name}"]; | ||
vendorHash = "{{ .Nix.VendorHash }}"; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
} |