From 0e29326a7c23f091fe51ebf551f7113bccbcf08e Mon Sep 17 00:00:00 2001 From: House Date: Sat, 13 Jul 2024 16:07:51 +0530 Subject: [PATCH] base pacakges Signed-off-by: House --- bsf.lock | 58 ++++++++++++++++++++++++----- cmd/init/config.go | 93 ++++++++++++++++++++++++++-------------------- 2 files changed, 101 insertions(+), 50 deletions(-) diff --git a/bsf.lock b/bsf.lock index 80ae6bd5..aa207196 100644 --- a/bsf.lock +++ b/bsf.lock @@ -89,9 +89,7 @@ "wasm32-wasi", "x86_64-windows", "i686-windows" - ], - "attr_name": "golangci-lint" - + ] }, "runtime": true }, @@ -130,11 +128,8 @@ "riscv64-linux", "s390-linux", "s390x-linux", - "x86_64-linux", - "wasm64-wasi", - "wasm32-wasi" - ], - "attr_name": "go-task" + "x86_64-linux" + ] }, "runtime": false }, @@ -221,6 +216,49 @@ }, "runtime": false }, + { + "package": { + "name": "golangci-lint", + "revision": "7445ccd775d8b892fc56448d17345443a05f7fb4", + "version": "1.59.0", + "description": "Fast linters Runner for Go", + "homepage": "https://golangci-lint.run/", + "free": true, + "spdx_id": "GPL-3.0-or-later", + "epoch_seconds": 1716993062, + "platforms": [ + "x86_64-darwin", + "i686-darwin", + "aarch64-darwin", + "armv7a-darwin", + "aarch64-linux", + "armv5tel-linux", + "armv6l-linux", + "armv7a-linux", + "armv7l-linux", + "i686-linux", + "loongarch64-linux", + "m68k-linux", + "microblaze-linux", + "microblazeel-linux", + "mips-linux", + "mips64-linux", + "mips64el-linux", + "mipsel-linux", + "powerpc64-linux", + "powerpc64le-linux", + "riscv32-linux", + "riscv64-linux", + "s390-linux", + "s390x-linux", + "x86_64-linux", + "wasm64-wasi", + "wasm32-wasi" + ], + "attr_name": "golangci-lint" + }, + "runtime": false + }, { "package": { "name": "gotools", @@ -259,7 +297,7 @@ "x86_64-linux" ] }, - "runtime": true - }, + "runtime": false + } ] } \ No newline at end of file diff --git a/cmd/init/config.go b/cmd/init/config.go index 188706f9..a355e284 100644 --- a/cmd/init/config.go +++ b/cmd/init/config.go @@ -10,6 +10,12 @@ import ( "github.com/buildsafedev/bsf/pkg/langdetect" ) +var ( + commonDevDeps = []string{"coreutils-full@9.5", "bash@5.2.15"} + commonRTDeps = []string{"cacert@3.95"} + baseImageName = "ttl.sh/base" +) + func generatehcl2NixConf(pt langdetect.ProjectType, pd *langdetect.ProjectDetails) (hcl2nix.Config, error) { switch pt { case langdetect.GoModule: @@ -36,17 +42,17 @@ func generatehcl2NixConf(pt langdetect.ProjectType, pd *langdetect.ProjectDetail func generateEmptyConf() hcl2nix.Config { return hcl2nix.Config{ Packages: hcl2nix.Packages{ - Development: []string{""}, - Runtime: []string{"cacert@3.95"}, + Development: commonDevDeps, + Runtime: commonRTDeps, }, OCIArtifact: []hcl2nix.OCIArtifact{ { - Artifact: "pkgs", - Name: "bsf-base-image", - Cmd: []string{}, - Entrypoint: []string{}, - EnvVars: []string{}, - ExposedPorts: []string{}, + Artifact: "pkgs", + Name: baseImageName, + Cmd: []string{}, + Entrypoint: []string{}, + EnvVars: []string{}, + ExposedPorts: []string{}, ImportConfigs: []string{}, }, }, @@ -71,10 +77,12 @@ func genRustCargoConf() (hcl2nix.Config, error) { } else { CrateName = "my-project" } + + rustDevDeps := append(commonDevDeps, "cargo@1.75.0") return hcl2nix.Config{ Packages: hcl2nix.Packages{ - Development: []string{"cargo@1.75.0"}, - Runtime: []string{"cacert@3.95"}, + Development: rustDevDeps, + Runtime: commonRTDeps, }, RustApp: &hcl2nix.RustApp{ WorkspaceSrc: "./.", @@ -84,12 +92,12 @@ func genRustCargoConf() (hcl2nix.Config, error) { }, OCIArtifact: []hcl2nix.OCIArtifact{ { - Artifact: "pkgs", - Name: "bsf-base-image", - Cmd: []string{}, - Entrypoint: []string{}, - EnvVars: []string{}, - ExposedPorts: []string{}, + Artifact: "pkgs", + Name: baseImageName, + Cmd: []string{}, + Entrypoint: []string{}, + EnvVars: []string{}, + ExposedPorts: []string{}, ImportConfigs: []string{}, }, }, @@ -98,10 +106,11 @@ func genRustCargoConf() (hcl2nix.Config, error) { func genPythonPoetryConf() hcl2nix.Config { // TODO: maybe we should note down the path of the poetry.lock file and use it here. + poetryDevDeps := append(commonDevDeps, "python3@3.12.2", "poetry@1.8.2") return hcl2nix.Config{ Packages: hcl2nix.Packages{ - Development: []string{"python3@3.12.2", "poetry@1.8.2"}, - Runtime: []string{"cacert@3.95"}, + Development: poetryDevDeps, + Runtime: commonRTDeps, }, PoetryApp: &hcl2nix.PoetryApp{ ProjectDir: "./.", @@ -113,12 +122,12 @@ func genPythonPoetryConf() hcl2nix.Config { }, OCIArtifact: []hcl2nix.OCIArtifact{ { - Artifact: "pkgs", - Name: "bsf-base-image", - Cmd: []string{}, - Entrypoint: []string{}, - EnvVars: []string{}, - ExposedPorts: []string{}, + Artifact: "pkgs", + Name: baseImageName, + Cmd: []string{}, + Entrypoint: []string{}, + EnvVars: []string{}, + ExposedPorts: []string{}, ImportConfigs: []string{}, }, }, @@ -135,11 +144,13 @@ func genGoModuleConf(pd *langdetect.ProjectDetails) hcl2nix.Config { } } + + goDevDeps := append(commonDevDeps, "go@1.22.3", "gotools@0.18.0", "delve@1.22.1") return hcl2nix.Config{ Packages: hcl2nix.Packages{ - Development: []string{"go@1.22.3", "gotools@0.18.0", "delve@1.22.1"}, + Development: goDevDeps, // todo: maybe we should dynamically inject the latest version of such runtime packages(cacert)? - Runtime: []string{"cacert@3.95"}, + Runtime: commonRTDeps, }, GoModule: &hcl2nix.GoModule{ Name: name, @@ -147,12 +158,12 @@ func genGoModuleConf(pd *langdetect.ProjectDetails) hcl2nix.Config { }, OCIArtifact: []hcl2nix.OCIArtifact{ { - Artifact: "pkgs", - Name: "bsf-base-image", - Cmd: []string{}, - Entrypoint: []string{}, - EnvVars: []string{}, - ExposedPorts: []string{}, + Artifact: "pkgs", + Name: baseImageName, + Cmd: []string{}, + Entrypoint: []string{}, + EnvVars: []string{}, + ExposedPorts: []string{}, ImportConfigs: []string{}, }, }, @@ -175,10 +186,12 @@ func genJsNpmConf() (hcl2nix.Config, error) { if !ok { return hcl2nix.Config{}, fmt.Errorf("error fetching project name: %v", err) } + + nodeDevDeps := append(commonDevDeps, "nodejs@20.11.1") return hcl2nix.Config{ Packages: hcl2nix.Packages{ - Development: []string{"nodejs@20.11.1"}, - Runtime: []string{"cacert@3.95"}, + Development: nodeDevDeps, + Runtime: commonRTDeps, }, JsNpmApp: &hcl2nix.JsNpmApp{ PackageName: name, @@ -186,12 +199,12 @@ func genJsNpmConf() (hcl2nix.Config, error) { }, OCIArtifact: []hcl2nix.OCIArtifact{ { - Artifact: "pkgs", - Name: "bsf-base-image", - Cmd: []string{}, - Entrypoint: []string{}, - EnvVars: []string{}, - ExposedPorts: []string{}, + Artifact: "pkgs", + Name: baseImageName, + Cmd: []string{}, + Entrypoint: []string{}, + EnvVars: []string{}, + ExposedPorts: []string{}, ImportConfigs: []string{}, }, },