Skip to content

Commit

Permalink
build: nix devShell (#4507)
Browse files Browse the repository at this point in the history
<!--

Hi, thanks for contributing!

Please make sure you read our CONTRIBUTING guide.

Also, add tests and the respective documentation changes as well.

-->


<!-- If applied, this commit will... -->

...

<!-- Why is this change being made? -->

...

<!-- # Provide links to any relevant tickets, URLs or other resources
-->

...

---------

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
  • Loading branch information
caarlos0 committed Dec 28, 2023
1 parent e91a0f5 commit 48f036b
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 19 deletions.
1 change: 1 addition & 0 deletions .envrc
@@ -0,0 +1 @@
use flake
14 changes: 4 additions & 10 deletions .github/workflows/docs.yml
Expand Up @@ -20,14 +20,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v3
- uses: arduino/setup-task@e26d8975574116b0097a1161e0fe16ba75d84c1c # v1
- uses: cachix/install-nix-action@v24
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v4
with:
go-version: stable
- run: task docs:build
- uses: wjdp/htmltest-action@09118714cd26bef56bd3d0819e4f9b1dce6f60a9 # master
with:
path: www/site
config: www/htmltest.yml
nix_path: nixpkgs=channel:nixos-unstable
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- run: nix develop .#docs --command task docs:test
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -14,3 +14,4 @@ completions/
.idea/
manpages
output.json
.direnv
15 changes: 8 additions & 7 deletions Taskfile.yml
Expand Up @@ -6,9 +6,6 @@ env:
GO111MODULE: on
GOPROXY: https://proxy.golang.org,direct

vars:
DOCKER: '{{default "docker" .DOCKER}}'

tasks:
dev:
desc: Setup git hooks
Expand Down Expand Up @@ -124,15 +121,19 @@ tasks:
desc: Start documentation server
cmds:
- task: docs:generate
- "{{.DOCKER}} build -t mkdocs -f www/docker/Dockerfile www/docker"
- "{{.DOCKER}} run --rm -p 8000:8000 -v ${PWD}/www:/docs mkdocs"
- "mkdocs serve -f www/mkdocs.yml -a 0.0.0.0:8000"

docs:build:
desc: Build docs
cmds:
- task: docs:generate
- "{{.DOCKER}} build -t mkdocs -f www/docker/Dockerfile www/docker"
- "{{.DOCKER}} run --rm -v ${PWD}/www:/docs mkdocs build"
- "mkdocs build -f www/mkdocs.yml"

docs:test:
desc: Test docs with htmltest
cmds:
- task: docs:build
- "htmltest www/site -c www/htmltest.yml"

release:
desc: Create a new tag
Expand Down
78 changes: 78 additions & 0 deletions flake.lock

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

46 changes: 46 additions & 0 deletions flake.nix
@@ -0,0 +1,46 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
staging.url = "github:caarlos0/nixpkgs/wip";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { nixpkgs, staging, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
staging-pkgs = staging.legacyPackages.${system};
in
{
packages.default = pkgs.buildGoModule {
pname = "goreleaser";
version = "unversioned";
src = ./.;
ldflags = [ "-s" "-w" "-X main.version=dev" "-X main.builtBy=flake" ];
doCheck = false;
vendorHash = "sha256-wY3kIhNIqTaK9MT1VeePERNhqvbtf6bsyRTjG8nrqxU=";
};

devShells.default = pkgs.mkShell {
packages = with pkgs; with staging-pkgs.python311Packages; [
go
go-task
gofumpt
];
shellHook = "go mod tidy";
};

devShells.docs = pkgs.mkShell {
packages = with pkgs; with staging-pkgs.python311Packages; [
go-task
htmltest
mkdocs-material
mkdocs-redirects
mkdocs-minify
mkdocs-rss-plugin
mkdocs-include-markdown-plugin
] ++ mkdocs-material.passthru.optional-dependencies.git;
};
}
);
}

2 changes: 0 additions & 2 deletions www/docker/Dockerfile

This file was deleted.

0 comments on commit 48f036b

Please sign in to comment.