-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move build to support, extract version from go.mod
- Loading branch information
1 parent
cb33f90
commit c2c0917
Showing
4 changed files
with
57 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ pkgs, ... }: | ||
let | ||
gomod = builtins.readFile ../go.mod; | ||
gomod-lines = pkgs.lib.strings.splitString "\n" gomod; | ||
in | ||
{ | ||
version = "0.0.1"; | ||
src = pkgs.lib.fileset.toSource { | ||
root=../.; | ||
fileset = pkgs.lib.fileset.unions [ | ||
../src | ||
../go.mod | ||
../go.sum | ||
]; | ||
}; | ||
# Extract repository name from go.mod | ||
repo = let | ||
module-line = pkgs.lib.lists.findFirst | ||
(line: pkgs.lib.strings.hasPrefix "module " line) | ||
null | ||
gomod-lines; | ||
in pkgs.lib.lists.last | ||
(pkgs.lib.strings.splitString " " module-line); | ||
# Extract coredns version from go.mod | ||
coredns-version = let | ||
coredns-line = pkgs.lib.lists.findFirst | ||
(line: pkgs.lib.strings.hasInfix "github.com/coredns/coredns " line) | ||
null | ||
gomod-lines; | ||
# github.com/... vX.X.X -> vX.X.X | ||
raw-version = pkgs.lib.lists.last | ||
(pkgs.lib.strings.splitString " " coredns-line); | ||
in if (pkgs.lib.strings.hasPrefix "v" raw-version) | ||
then (builtins.substring 1 (-1) raw-version) | ||
else raw-version; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 5 additions & 9 deletions
14
buildFirewallController.nix → support/buildFirewallController.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,11 @@ | ||
{ pkgs, ... }: | ||
let | ||
common = import ./buildCommon.nix { inherit pkgs; }; | ||
in | ||
pkgs.buildGoModule { | ||
pname = "firewall-controller"; | ||
version = "0.0.1"; | ||
src = pkgs.lib.fileset.toSource { | ||
root=./.; | ||
fileset = pkgs.lib.fileset.unions [ | ||
./src | ||
./go.mod | ||
./go.sum | ||
]; | ||
}; | ||
version = common.version; | ||
src = common.src; | ||
vendorHash = "sha256-sF8RFUEIy3mip/EyJDn0+mRfFbeBbn18rqsWtfsAOqo="; | ||
# vendorHash = pkgs.lib.fakeHash; | ||
} |