Skip to content
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

CI configs: add nix flake #1815

Merged
merged 5 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ _testmain.go

*.exe

# Nix
/result
# Project specific
cover
/_*
Expand Down
82 changes: 82 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
description = "elvish";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
gomod2nix = {
url = "github:nix-community/gomod2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, gomod2nix }:
let
allSystems = [
"x86_64-linux" # 64-bit Intel/AMD Linux
"aarch64-linux" # 64-bit ARM Linux
"x86_64-darwin" # 64-bit Intel macOS
"aarch64-darwin" # 64-bit ARM macOS
];
forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
inherit system;
pkgs = import nixpkgs { inherit system; };
});
in
{
packages = forAllSystems ({ system, pkgs, ... }:
let
buildGoApplication = gomod2nix.legacyPackages.${system}.buildGoApplication;
in
rec {
default = elvish;

elvish = buildGoApplication {
name = "elvish";
src = ./.;
go = pkgs.go_1_22;
pwd = ./.;
subPackages = [ "cmd/elvish" ];
CGO_ENABLED = 0;
flags = [
"-trimpath"
];
ldflags = [
"-s"
"-w"
"-extldflags -static"
];
};
});

# "nix develop" provides a shell containing development tools.
#
# "nix develop --command gomod2nix" should be run to update gomod2nix.toml
# after updating Go module dependencies.
devShell = forAllSystems ({ system, pkgs }:
pkgs.mkShell {
buildInputs = with pkgs; [
go_1_22
gomod2nix.legacyPackages.${system}.gomod2nix
gopls
];
});

overlays.default = final: prev: {
elvish = self.packages.${final.stdenv.system}.elvish;
};
};
}

48 changes: 48 additions & 0 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
schema = 3

[mod]
[mod."github.com/BurntSushi/toml"]
version = "v1.4.0"
hash = "sha256-3cr8hfVA4th/AfveHDxigmj8Eiiae0ZBnxAgy+7RYO4="
[mod."github.com/creack/pty"]
version = "v1.1.23"
hash = "sha256-42k7lObS5h99pPoicb6tkRlBvVvSPqsy+aC87PWq2o4="
[mod."github.com/davecgh/go-spew"]
version = "v1.1.1"
hash = "sha256-nhzSUrE1fCkN0+RL04N4h8jWmRFPPPWbCuDc7Ss0akI="
[mod."github.com/google/go-cmp"]
version = "v0.6.0"
hash = "sha256-qgra5jze4iPGP0JSTVeY5qV5AvEnEu39LYAuUCIkMtg="
[mod."github.com/gorilla/websocket"]
version = "v1.4.1"
hash = "sha256-+yo/0+zSqf2/dPZyp/9so21r7cfMx1yhxmmOzy2wwQ4="
[mod."github.com/mattn/go-isatty"]
version = "v0.0.20"
hash = "sha256-qhw9hWtU5wnyFyuMbKx+7RB8ckQaFQ8D+8GKPkN3HHQ="
[mod."github.com/pmezard/go-difflib"]
version = "v1.0.0"
hash = "sha256-/FtmHnaGjdvEIKAJtrUfEhV7EVo5A/eYrtdnUkuxLDA="
[mod."github.com/sourcegraph/jsonrpc2"]
version = "v0.2.0"
hash = "sha256-UPJQN/TSg9CjRj0239EV9dbZTwe7grOCf8lFWMkqo8U="
[mod."github.com/stretchr/testify"]
version = "v1.8.1"
hash = "sha256-3e0vOJLgCMAan+GfaGN8RGZdarh5iCavM6flf6YMNPk="
[mod."go.etcd.io/bbolt"]
version = "v1.3.10"
hash = "sha256-uEnz6jmmgT+hlwdZ8ns5NCJSbZcB4i123FF2cn2CbQA="
[mod."go.etcd.io/gofail"]
version = "v0.1.0"
hash = "sha256-y7524CIGBFYMnqwSv6uzCN726sXqMx3Pupw9z7NBBsU="
[mod."golang.org/x/sync"]
version = "v0.8.0"
hash = "sha256-usvF0z7gq1vsX58p4orX+8WHlv52pdXgaueXlwj2Wss="
[mod."golang.org/x/sys"]
version = "v0.24.0"
hash = "sha256-P0fsA+qy9taYHWPTtCs5XmrJ1i8tWfvkno+PNuc2elw="
[mod."gopkg.in/yaml.v3"]
version = "v3.0.1"
hash = "sha256-FqL9TKYJ0XkNwJFnq9j0VvJ5ZUU1RvH/52h/f5bkYAU="
[mod."pkg.nimblebun.works/go-lsp"]
version = "v1.1.0"
hash = "sha256-mJS7tsR4bPOIcHpvIsdKHQvZxpgFRm3hBSMVBMFcDZI="
Loading