Skip to content

Commit 5a8b0f5

Browse files
committed
Remove require from lock
1 parent d1f394d commit 5a8b0f5

3 files changed

Lines changed: 31 additions & 18 deletions

File tree

go/gobuild-nix-generate/main.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ type lockFile struct {
3838
Schema int `toml:"schema"`
3939
Cycles map[string]int `toml:"cycles,omitempty"`
4040
Locked map[string]*goPackageLock `toml:"locked"`
41-
Require []string `toml:"require"`
4241
}
4342

4443
//go:embed fetcher.nix
@@ -132,19 +131,8 @@ func createLock(directory string, workers int, pkgsFlag string, attrFlag string)
132131
}
133132
}
134133

135-
log.Println("Downloading initial dependencies")
136-
modDownloads, err := downloadModules(directory, []string{})
137-
if err != nil {
138-
return nil, err
139-
}
140-
for _, download := range modDownloads {
141-
lock.Require = append(lock.Require, download.Path)
142-
}
143-
144-
log.Println("Done downloading initial dependencies")
145-
146134
log.Println("Discovering dependencies")
147-
modDownloads, err = discoverDependencies(directory, workers, sumVersions)
135+
modDownloads, err := discoverDependencies(directory, workers, sumVersions)
148136
if err != nil {
149137
return nil, err
150138
}

lib.nix

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ in
6262
let
6363
locked = lockFile.locked.${goPackagePath};
6464
in
65-
concatMap (req: if elem req cycle then [ ] else if ! final ? ${req} then (builtins.trace req [ ]) else [ final.${req} ]) (locked.require or [ ])
65+
concatMap (req: if elem req cycle then [ ] else [ final.${req} ]) (locked.require or [ ])
6666
) cycle;
6767

6868
}
@@ -79,8 +79,6 @@ in
7979
in
8080
{
8181
inherit cycles;
82-
83-
require = map (packagePath: final.${packagePath}) lockFile.require;
8482
}
8583
// mapAttrs (
8684
goPackagePath: locked:

nix/default.nix

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
let
2+
wellKnown = builtins.listToAttrs (
3+
map
4+
(name: {
5+
inherit name;
6+
value = null;
7+
})
8+
[
9+
"go"
10+
"require"
11+
"goPackages"
12+
"gobuild-nix-gocacheprog"
13+
"fetchers"
14+
"hooks"
15+
"callPackage"
16+
]
17+
);
18+
in
119
{
220
go,
321
newScope,
@@ -12,8 +30,17 @@ lib.makeScope newScope (
1230
# Tooling
1331
inherit go;
1432

15-
# Empty initial list of require's until overriden by generated overlay
16-
require = [ ];
33+
# List all non-known attributes in the require list
34+
require = builtins.concatMap (
35+
attr:
36+
if wellKnown ? ${attr} then
37+
[ ]
38+
else
39+
let
40+
value = final.${attr};
41+
in
42+
if !lib.isDerivation value then [ ] else [ value ]
43+
) (builtins.attrNames final);
1744

1845
goPackages = final;
1946

0 commit comments

Comments
 (0)