Skip to content

Commit

Permalink
chore: add local development environment using nix
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
  • Loading branch information
sagikazarmark committed Jun 29, 2023
1 parent a362607 commit 351365d
Show file tree
Hide file tree
Showing 8 changed files with 361 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ indent_style = tab

[{Makefile,*.mk}]
indent_style = tab

[*.nix]
indent_size = 2
4 changes: 4 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8="
fi
use flake . --impure
32 changes: 32 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,35 @@ jobs:
uses: golangci/golangci-lint-action@v3
with:
version: v1.52.2

dev:
name: Developer environment
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- name: Set up Nix
uses: cachix/install-nix-action@4b933aa7ebcc94a6174cf1364864e957b4910265 # v21
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Check
run: nix flake check --impure

- name: Dev shell
run: nix develop --impure

dependency-review:
name: Dependency review
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'

steps:
- name: Checkout repository
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- name: Dependency Review
uses: actions/dependency-review-action@1360a344ccb0ab6e9475edef90ad2f46bf8003b1 # v3.0.6
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/.devenv/
/.direnv/
/.idea/
/.pre-commit-config.yaml
/bin/
/build/
/var/
Expand Down
2 changes: 2 additions & 0 deletions .yamlignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# TODO: FIXME
/.github/
6 changes: 6 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ignore-from-file: [.gitignore, .yamlignore]

extends: default

rules:
line-length: disable
255 changes: 255 additions & 0 deletions flake.lock

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

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

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
devenv.url = "github:cachix/devenv";
};

outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.devenv.flakeModule
];

systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ];

perSystem = { config, self', inputs', pkgs, system, ... }: rec {
devenv.shells = {
default = {
languages = {
go.enable = true;
};

pre-commit.hooks = {
nixpkgs-fmt.enable = true;
yamllint.enable = true;
};

packages = with pkgs; [
gnumake

golangci-lint
yamllint
];

scripts = {
versions.exec = ''
go version
golangci-lint version
'';
};

enterShell = ''
versions
'';

# https://github.com/cachix/devenv/issues/528#issuecomment-1556108767
containers = pkgs.lib.mkForce { };
};

ci = devenv.shells.default;
};
};
};
}

0 comments on commit 351365d

Please sign in to comment.