aboutsummaryrefslogtreecommitdiff
path: root/nix/builder/symlink/symlink.go
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2022-07-24 10:07:41 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2022-07-24 10:08:21 +0200
commit11574aeb19cd971b20d37353111c4f37ffdfb7f5 (patch)
tree5d9939a08ec11986eff360f41684ec53a35ac7e0 /nix/builder/symlink/symlink.go
parentba8042a21a8552f132cac6d0a45cf8e08d885f08 (diff)
downloadguichet-nix.tar.gz
guichet-nix.zip
Remove vendoring of gomod2nixnix
Diffstat (limited to 'nix/builder/symlink/symlink.go')
-rw-r--r--nix/builder/symlink/symlink.go110
1 files changed, 0 insertions, 110 deletions
diff --git a/nix/builder/symlink/symlink.go b/nix/builder/symlink/symlink.go
deleted file mode 100644
index 3dbb383..0000000
--- a/nix/builder/symlink/symlink.go
+++ /dev/null
@@ -1,110 +0,0 @@
-package main
-
-import (
- "encoding/json"
- "fmt"
- "io/ioutil"
- "os"
- "path/filepath"
- "sort"
-)
-
-type Package struct {
- GoPackagePath string `json:"-"`
- Version string `json:"version"`
- Hash string `json:"hash"`
- ReplacedPath string `json:"replaced,omitempty"`
-}
-
-// type Output struct {
-// SchemaVersion int `json:"schema"`
-// Mod map[string]*Package `json:"mod"`
-// }
-
-func main() {
-
- // var output Output
- sources := make(map[string]string)
- pkgs := make(map[string]*Package)
-
- {
- b, err := ioutil.ReadFile(os.Getenv("sourcesPath"))
- if err != nil {
- panic(err)
- }
-
- err = json.Unmarshal(b, &sources)
- if err != nil {
- panic(err)
- }
- }
-
- {
- b, err := ioutil.ReadFile(os.Getenv("jsonPath"))
- if err != nil {
- panic(err)
- }
-
- err = json.Unmarshal(b, &pkgs)
- if err != nil {
- panic(err)
- }
- }
-
- keys := make([]string, 0, len(pkgs))
- for key := range pkgs {
- keys = append(keys, key)
- }
- sort.Strings(keys)
-
- // Iterate, in reverse order
- for i := len(keys) - 1; i >= 0; i-- {
- key := keys[i]
- src := sources[key]
-
- paths := []string{key}
-
- for _, path := range paths {
-
- vendorDir := filepath.Join("vendor", filepath.Dir(path))
- if err := os.MkdirAll(vendorDir, 0755); err != nil {
- panic(err)
- }
-
- if _, err := os.Stat(filepath.Join("vendor", path)); err == nil {
- files, err := ioutil.ReadDir(src)
- if err != nil {
- panic(err)
- }
-
- for _, f := range files {
- innerSrc := filepath.Join(src, f.Name())
- dst := filepath.Join("vendor", path, f.Name())
- if err := os.Symlink(innerSrc, dst); err != nil {
- // assume it's an existing directory, try to link the directory content instead.
- // TODO should we do this recursively
- files, err := ioutil.ReadDir(innerSrc)
- if err != nil {
- panic(err)
- }
- for _, f := range files {
- if err := os.Symlink(filepath.Join(innerSrc, f.Name()), filepath.Join(dst, f.Name())); err != nil {
- fmt.Println("ignore symlink error", filepath.Join(innerSrc, f.Name()), filepath.Join(dst, f.Name()))
- }
- }
- }
- }
-
- continue
- }
-
- // If the file doesn't already exist, just create a simple symlink
- err := os.Symlink(src, filepath.Join("vendor", path))
- if err != nil {
- panic(err)
- }
-
- }
- }
-
-}