Skip to content

Commit

Permalink
base pacakges
Browse files Browse the repository at this point in the history
Signed-off-by: House <[email protected]>
  • Loading branch information
dr-housemd committed Jul 13, 2024
1 parent ddda3f9 commit 0e29326
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 50 deletions.
58 changes: 48 additions & 10 deletions bsf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@
"wasm32-wasi",
"x86_64-windows",
"i686-windows"
],
"attr_name": "golangci-lint"

]
},
"runtime": true
},
Expand Down Expand Up @@ -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
},
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -259,7 +297,7 @@
"x86_64-linux"
]
},
"runtime": true
},
"runtime": false
}
]
}
93 changes: 53 additions & 40 deletions cmd/init/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import (
"github.com/buildsafedev/bsf/pkg/langdetect"
)

var (
commonDevDeps = []string{"[email protected]", "[email protected]"}
commonRTDeps = []string{"[email protected]"}
baseImageName = "ttl.sh/base"
)

func generatehcl2NixConf(pt langdetect.ProjectType, pd *langdetect.ProjectDetails) (hcl2nix.Config, error) {
switch pt {
case langdetect.GoModule:
Expand All @@ -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{"[email protected]"},
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{},
},
},
Expand All @@ -71,10 +77,12 @@ func genRustCargoConf() (hcl2nix.Config, error) {
} else {
CrateName = "my-project"
}

rustDevDeps := append(commonDevDeps, "[email protected]")
return hcl2nix.Config{
Packages: hcl2nix.Packages{
Development: []string{"[email protected]"},
Runtime: []string{"[email protected]"},
Development: rustDevDeps,
Runtime: commonRTDeps,
},
RustApp: &hcl2nix.RustApp{
WorkspaceSrc: "./.",
Expand All @@ -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{},
},
},
Expand All @@ -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, "[email protected]", "[email protected]")
return hcl2nix.Config{
Packages: hcl2nix.Packages{
Development: []string{"[email protected]", "[email protected]"},
Runtime: []string{"[email protected]"},
Development: poetryDevDeps,
Runtime: commonRTDeps,
},
PoetryApp: &hcl2nix.PoetryApp{
ProjectDir: "./.",
Expand All @@ -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{},
},
},
Expand All @@ -135,24 +144,26 @@ func genGoModuleConf(pd *langdetect.ProjectDetails) hcl2nix.Config {
}

}

goDevDeps := append(commonDevDeps, "[email protected]", "[email protected]", "[email protected]")
return hcl2nix.Config{
Packages: hcl2nix.Packages{
Development: []string{"[email protected]", "[email protected]", "[email protected]"},
Development: goDevDeps,
// todo: maybe we should dynamically inject the latest version of such runtime packages(cacert)?
Runtime: []string{"[email protected]"},
Runtime: commonRTDeps,
},
GoModule: &hcl2nix.GoModule{
Name: name,
SourcePath: entrypoint,
},
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{},
},
},
Expand All @@ -175,23 +186,25 @@ func genJsNpmConf() (hcl2nix.Config, error) {
if !ok {
return hcl2nix.Config{}, fmt.Errorf("error fetching project name: %v", err)
}

nodeDevDeps := append(commonDevDeps, "[email protected]")
return hcl2nix.Config{
Packages: hcl2nix.Packages{
Development: []string{"[email protected]"},
Runtime: []string{"[email protected]"},
Development: nodeDevDeps,
Runtime: commonRTDeps,
},
JsNpmApp: &hcl2nix.JsNpmApp{
PackageName: name,
PackageRoot: "./.",
},
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{},
},
},
Expand Down

0 comments on commit 0e29326

Please sign in to comment.