Skip to content

Commit

Permalink
build: use nix flake (#761)
Browse files Browse the repository at this point in the history
* build: use nix flake

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* docs: fmt

---------

Signed-off-by: Carlos Alexandro Becker <[email protected]>
  • Loading branch information
caarlos0 authored Dec 28, 2023
1 parent 440588e commit a117582
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
use nix
use flake
28 changes: 13 additions & 15 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,25 @@ name: docs
on:
push:
branches:
- 'main'
- "main"
paths:
- '.github/workflows/htmltest.yml'
- 'www/*'
pull_request: {}
- "www/**/*"
- ".github/workflows/docs.yml"
pull_request:
paths:
- "www/**/*"
- ".github/workflows/docs.yml"

permissions: read-all
permissions:
contents: read

jobs:
htmltest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: arduino/setup-task@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-go@v5
with:
go-version: stable
- run: task docs:build
- uses: wjdp/htmltest-action@master
- uses: cachix/install-nix-action@v24
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 ci-docs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ manpages
output.json
!acceptance_test.go
.direnv/
tmp/
6 changes: 6 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ tasks:
- task: docs:generate
- "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
vars:
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
Original file line number Diff line number Diff line change
@@ -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 = "nfpm";
version = "unversioned";
src = ./.;
ldflags = [ "-s" "-w" "-X main.version=dev" "-X main.builtBy=flake" ];
doCheck = false;
vendorHash = "sha256-P9jSQG6EyVGMZKtThy8Q7Y/pV7mbMl2eGrylea0VHRc=";
};

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; [
(pkgs.writeScriptBin "ci-docs" "task docs:test")
go-task
htmltest
mkdocs-material
mkdocs-minify
] ++ mkdocs-material.passthru.optional-dependencies.git;
};
}
);
}



12 changes: 0 additions & 12 deletions shell.nix

This file was deleted.

33 changes: 17 additions & 16 deletions www/docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ brew install nfpm
```

!!! info
The [formula in homebrew-core](https://github.com/Homebrew/homebrew-core/blob/master/Formula/nfpm.rb) might be slightly outdated.

The [formula in homebrew-core](https://github.com/Homebrew/homebrew-core/blob/master/Formula/n/nfpm.rb) might be slightly outdated.
Use our homebrew tap to always get the latest updates.

### scoop
Expand Down Expand Up @@ -73,24 +74,25 @@ All artifacts are checksummed, and the checksum is signed with [cosign][].

1. Download the files you want, the `checksums.txt` and `checksums.txt.sig`
files from the [releases][releases] page:
```bash
wget 'https://github.com/goreleaser/nfpm/releases/download/__VERSION__/checksums.txt'
```

```bash
wget 'https://github.com/goreleaser/nfpm/releases/download/__VERSION__/checksums.txt'
```

1. Verify the signature:
```bash
cosign verify-blob \
--certificate-identity 'https://github.com/goreleaser/nfpm/.github/workflows/release.yml@refs/tags/__VERSION__' \
--certificate-oidc-issuer 'https://token.actions.githubusercontent.com' \
--signature 'https://github.com/goreleaser/nfpm/releases/download/__VERSION__/checksums.txt.sig' \
--cert 'https://github.com/goreleaser/nfpm/releases/download/__VERSION__/checksums.txt.pem' \
checksums.txt
```
```bash
cosign verify-blob \
--certificate-identity 'https://github.com/goreleaser/nfpm/.github/workflows/release.yml@refs/tags/__VERSION__' \
--certificate-oidc-issuer 'https://token.actions.githubusercontent.com' \
--signature 'https://github.com/goreleaser/nfpm/releases/download/__VERSION__/checksums.txt.sig' \
--cert 'https://github.com/goreleaser/nfpm/releases/download/__VERSION__/checksums.txt.pem' \
checksums.txt
```
1. If the signature is valid, you can then verify the SHA256 sums match with the
downloaded binary:
```bash
sha256sum --ignore-missing -c checksums.txt
```
```bash
sha256sum --ignore-missing -c checksums.txt
```

### docker images

Expand Down Expand Up @@ -155,4 +157,3 @@ go build -o nfpm ./cmd/nfpm

[releases]: https://github.com/goreleaser/nfpm/releases
[cosign]: https://github.com/sigstore/cosign

4 changes: 2 additions & 2 deletions www/docs/tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ On upgrade, the scripts are being executed in the following order:

### The `.lintian-overrides` file

It is recommended to run [lintian](https://lintian.debian.org) against your
It is recommended to run [lintian](https://wiki.debian.org/Lintian) against your
deb packages to see if there are any problems.

You can also add a `lintian-overrides` file:
Expand All @@ -215,7 +215,7 @@ contents:
mode: 0644
```

You can read more in [lintian's documentation](https://lintian.debian.org/manual/index.html).
You can read more in [lintian's documentation](https://wiki.debian.org/Lintian).

### The `copyright` file

Expand Down

0 comments on commit a117582

Please sign in to comment.