-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Flake #1502
Open
asymmetric
wants to merge
9
commits into
centrifuge:develop
Choose a base branch
from
asymmetric:flake
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+147
−0
Open
Add Flake #1502
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
58021f0
nix: init flake
asymmetric 06fa318
nix: further work
asymmetric 244065f
nix: fix source cleaning
asymmetric fa4e271
nix: use builtins.any to simplify filtering
asymmetric 26c7608
nix: sort ignoreList
asymmetric 9bc39a1
nix: remove busybox from container
asymmetric c314958
nix: add busybox to image
asymmetric 5ae4cde
nix: add commit hash to Docker image tag
asymmetric 6b13526
nix: add devShell
asymmetric File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,99 @@ | ||
{ | ||
description = "go-centrifuge"; | ||
|
||
inputs = { | ||
nixpkgs.url = github:NixOS/nixpkgs/nixos-21.11; | ||
gitignore = { | ||
url = github:hercules-ci/gitignore.nix; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
}; | ||
|
||
outputs = { self, nixpkgs, gitignore }: | ||
let | ||
name = "go-centrifuge"; | ||
version = "2.0"; | ||
|
||
system = "x86_64-linux"; | ||
|
||
pkgs = nixpkgs.legacyPackages.${system}; | ||
|
||
srcFilter = src: | ||
let | ||
srcIgnored = gitignore.lib.gitignoreFilter src; | ||
ignoreList = [ | ||
".envrc" | ||
".github" | ||
"CODE_OF_CONDUCT.md" | ||
"README.md" | ||
"codecov.yml" | ||
"flake.lock" | ||
"flake.nix" | ||
]; | ||
in | ||
path: type: | ||
srcIgnored path type | ||
&& builtins.all (name: builtins.baseNameOf path != name) ignoreList; | ||
in | ||
{ | ||
packages.${system} = { | ||
go-centrifuge = pkgs.buildGoModule { | ||
pname = name; | ||
inherit version; | ||
|
||
src = pkgs.lib.cleanSourceWith { | ||
src = ./.; | ||
filter = srcFilter ./.; | ||
name = "${name}-source"; | ||
}; | ||
|
||
vendorSha256 = "sha256-Yr1lxkeW9rvOR+tLn9YBE682hgatsLGRqsalhcz+r9Y="; | ||
}; | ||
|
||
dockerImage = | ||
let | ||
# This evaluates to the first 6 digits of the git hash of this repo's HEAD | ||
# commit, or to "dirty" if there are uncommitted changes. | ||
commit-substr = builtins.substring 0 6 (self.rev or "dirty"); | ||
|
||
tag = "${version}-${commit-substr}"; | ||
in | ||
pkgs.dockerTools.buildLayeredImage { | ||
name = "centrifugeio/${name}"; | ||
inherit tag; | ||
created = builtins.substring 0 8 self.lastModifiedDate; | ||
|
||
contents = [ | ||
pkgs.busybox | ||
self.defaultPackage.${system} | ||
]; | ||
|
||
config = { | ||
ExposedPorts = { | ||
# api | ||
"8082/tcp" = { }; | ||
# p2p | ||
"38202/tcp" = { }; | ||
}; | ||
Volumes = { | ||
"/data" = { }; | ||
}; | ||
Entrypoint = [ "centrifuge" ]; | ||
}; | ||
}; | ||
}; | ||
|
||
defaultPackage.${system} = self.packages.${system}.go-centrifuge; | ||
|
||
apps.${system}.centrifuge = { | ||
type = "app"; | ||
program = "${self.defaultPackage.${system}}/bin/centrifuge"; | ||
}; | ||
|
||
defaultApp.${system} = self.apps.${system}.centrifuge; | ||
|
||
devShell.${system} = pkgs.mkShellNoCC { | ||
buildInputs = [ self.defaultPackage.${system} ]; | ||
}; | ||
}; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sort of same question as in the other PR, how to know the go version is used, probably part of the same presentation we have to shedule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most basic way to know that is, is to:
flake.lock
nix run nixpkgs/$commit#go -- version
In this specific case:
But I've also implemented a simpler solution, which works by dropping you in a shell where Go is installed. Since nixpkgs is pinned, this is the same Go used to build the app.
nix develop
go version