Skip to content

Commit

Permalink
base pacakges (#76)
Browse files Browse the repository at this point in the history
Signed-off-by: House <[email protected]>
Co-authored-by: Rakshit Gondwal <[email protected]>
  • Loading branch information
dr-housemd and rakshitgondwal authored Jul 13, 2024
1 parent 6ba6ac0 commit 0002005
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 28 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
}
]
}
47 changes: 29 additions & 18 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) {
fmt.Println("IN GENERATE HCL NIX CONFIG -------------------------------------------")
fmt.Println("NAME: ", pd.Name)
Expand Down Expand Up @@ -41,13 +47,13 @@ func generateEmptyConf(pd *langdetect.ProjectDetails) hcl2nix.Config {
}
return hcl2nix.Config{
Packages: hcl2nix.Packages{
Development: []string{""},
Runtime: []string{"[email protected]"},
Development: commonDevDeps,
Runtime: commonRTDeps,
},
OCIArtifact: []hcl2nix.OCIArtifact{
{
Artifact: "pkgs",
Name: pd.Name,
Name: baseImageName,
Cmd: []string{},
Entrypoint: []string{},
EnvVars: []string{},
Expand Down Expand Up @@ -79,10 +85,12 @@ func genRustCargoConf(pd *langdetect.ProjectDetails) (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 @@ -93,7 +101,7 @@ func genRustCargoConf(pd *langdetect.ProjectDetails) (hcl2nix.Config, error) {
OCIArtifact: []hcl2nix.OCIArtifact{
{
Artifact: "pkgs",
Name: pd.Name,
Name: baseImageName,
Cmd: []string{},
Entrypoint: []string{},
EnvVars: []string{},
Expand All @@ -106,13 +114,11 @@ func genRustCargoConf(pd *langdetect.ProjectDetails) (hcl2nix.Config, error) {

func genPythonPoetryConf(pd *langdetect.ProjectDetails) hcl2nix.Config {
// TODO: maybe we should note down the path of the poetry.lock file and use it here.
if pd.Name == "" {
pd.Name = "expl"
}
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 @@ -125,7 +131,8 @@ func genPythonPoetryConf(pd *langdetect.ProjectDetails) hcl2nix.Config {
OCIArtifact: []hcl2nix.OCIArtifact{
{
Artifact: "pkgs",
Name: pd.Name,

Name: baseImageName,
Cmd: []string{},
Entrypoint: []string{},
EnvVars: []string{},
Expand All @@ -149,11 +156,13 @@ 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,
Expand All @@ -162,7 +171,7 @@ func genGoModuleConf(pd *langdetect.ProjectDetails) hcl2nix.Config {
OCIArtifact: []hcl2nix.OCIArtifact{
{
Artifact: "pkgs",
Name: pd.Name,
Name: baseImageName,
Cmd: []string{},
Entrypoint: []string{},
EnvVars: []string{},
Expand Down Expand Up @@ -192,10 +201,12 @@ func genJsNpmConf(pd *langdetect.ProjectDetails) (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,
Expand All @@ -204,7 +215,7 @@ func genJsNpmConf(pd *langdetect.ProjectDetails) (hcl2nix.Config, error) {
OCIArtifact: []hcl2nix.OCIArtifact{
{
Artifact: "pkgs",
Name: pd.Name,
Name: baseImageName,
Cmd: []string{},
Entrypoint: []string{},
EnvVars: []string{},
Expand Down

0 comments on commit 0002005

Please sign in to comment.