Skip to content

Commit 539f3db

Browse files
committed
Merge remote-tracking branch 'juan/add-version-to-nix-builds'
2 parents 7044f82 + 49ba18d commit 539f3db

21 files changed

+1300
-359
lines changed

.envrc

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
2-
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
1+
if ! has nix_direnv_version || ! nix_direnv_version 3.0.6; then
2+
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.6/direnvrc" "sha256-RYcUJaRMf8oF5LznDrlCXbkOQrywm0HDv1VjYGaJGdM="
33
fi
44

55
watch_file flake.nix
6-
watch_file flake.lock
7-
watch_file go.lock
86

9-
if ! use flake . --impure
7+
if ! use flake .
108
then
11-
echo "devenv could not be built. The devenv environment was not loaded." >&2
9+
echo "development shell could not be built. The nix environment was not loaded." >&2
1210
fi
13-

.github/workflows/goreleaser.yml

+3-8
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,10 @@ jobs:
2020
uses: actions/checkout@v3
2121
with:
2222
fetch-depth: 0
23-
- name: install nix
23+
- name: install nix
2424
uses: cachix/install-nix-action@v31
2525
with:
2626
github_access_token: ${{ secrets.GITHUB_TOKEN }}
27-
- uses: cachix/cachix-action@v16
28-
with:
29-
name: devenv
30-
- name: Install devenv.sh
31-
run: nix profile install nixpkgs#devenv
3227
- name: Setup go
3328
uses: actions/setup-go@v4
3429
with:
@@ -37,12 +32,12 @@ jobs:
3732
GITHUB_TOKEN: ${{ secrets.GH_PAT_TOKEN }}
3833
- name: Bump version and push tag
3934
run: |
40-
nix develop --no-pure-eval --accept-flake-config --command bash -c 'prepare-release'
35+
nix develop --accept-flake-config --command bash -c 'prepare-release'
4136
- name: Run GoReleaser
4237
uses: goreleaser/goreleaser-action@v4
4338
with:
4439
distribution: goreleaser
4540
version: latest
4641
args: release --clean
4742
env:
48-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
/gomod2nix-template
21
.direnv
3-
.devenv
42
.pre-commit-config.yaml
53
result/
6-
vendor/
7-
ess
4+
/ess

.ignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.direnv
2+
vendor

README.md

+17-18
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ Automatically keep `env.sample` files in sync with `.env`
66

77
---
88

9-
`ess` transforms environment files containing secrets (e.g. `.env`, `.envrc`) into sample environment files (e.g.
9+
`ess` transforms environment files containing secrets (e.g. `.env`, `.envrc`) into sample environment files (e.g.
1010
`env.sample`) that may be safely checked into git.
1111

1212
`ess` may be run manually by running the cli executable, or automatically by installing the pre-commit hook with `ess install`
13-
in any git repository. Installing `ess` as a git hook ensures that project environment files are automatically and safely
14-
revision controlled when they change.
13+
in any git repository. Installing `ess` as a git hook ensures that project environment files are automatically and safely
14+
revision controlled when they change.
1515

1616
Doing so allows environment configurations to be shared across teams without leaking secrets.
1717

18-
## How it works
18+
## How it works
1919

2020
By default, `ess` checks the local directory for environment files named `.env`. The env file name is controlled by
21-
the `--env-file` switch. Next, the environment file is parsed for environment variables. Environment variables
21+
the `--env-file` switch. Next, the environment file is parsed for environment variables. Environment variables
2222
may be of the following forms:
2323

2424
```
@@ -35,16 +35,16 @@ export FOO='bar baz'
3535

3636
By default, variable values are replaced with innert values named after the variable, e.g. `FOO=bar` is replaced by `FOO=<FOO>`.
3737

38-
Example values may be provided with the `--example` switch, e.g. `--exmaple=FOO="enter your foo here"` will set `FOO`'s
39-
value as follows `FOO="enter your foo here"` in the sample file.
38+
Example values may be provided with the `--example` switch, e.g. `--exmaple=FOO="enter your foo here"` will set `FOO`'s
39+
value as follows `FOO="enter your foo here"` in the sample file.
4040

41-
Finally, when all variables are replaced, the sample file is written with the sanitized variable values, along with all
41+
Finally, when all variables are replaced, the sample file is written with the sanitized variable values, along with all
4242
non-variable strings from the file. By default the sample file is named `env.sample`, which is controlled by the `--env-sample`
43-
switch.
43+
switch.
4444

45-
Because `ess` permits non-variable strings in environment files, it means that both comments and script code (in the case
46-
of `.envrc` files) is included in environment sample files. This allows environment files to not only be checked into git, but
47-
documented with comments.
45+
Because `ess` permits non-variable strings in environment files, it means that both comments and script code (in the case
46+
of `.envrc` files) is included in environment sample files. This allows environment files to not only be checked into git, but
47+
documented with comments.
4848

4949
# Installation & Usage
5050

@@ -153,10 +153,10 @@ This utility can be used as a [pre-commit plugin](https://pre-commit.com/#instal
153153

154154
## Add configuration
155155
```bash
156-
cat <<EOF > .pre-commit-config.yaml
156+
cat <<EOF >.pre-commit-config.yaml
157157
repos:
158158
- repo: https://github.com/acaloiaro/ess.git
159-
rev: v2.14.1
159+
rev: v2.17.0
160160
hooks:
161161
- id: ess
162162
EOF
@@ -214,7 +214,7 @@ It's even possible to provide default/example values for every environment varia
214214
```yml
215215
repos:
216216
- repo: https://github.com/acaloiaro/ess.git
217-
rev: v2.14.1
217+
rev: v2.17.0
218218
hooks:
219219
- id: ess
220220
```
@@ -224,7 +224,7 @@ repos:
224224
```yml
225225
repos:
226226
- repo: https://github.com/acaloiaro/ess.git
227-
rev: v2.14.1
227+
rev: v2.17.0
228228
hooks:
229229
- id: ess
230230
args: ['--env-file=.env_file', '--sample-file=env_file.sample']
@@ -239,7 +239,7 @@ environment variable name surrounded by `<brackets like this>` in sample files.
239239
```yml
240240
repos:
241241
- repo: https://github.com/acaloiaro/ess.git
242-
rev: v2.14.1
242+
rev: v2.17.0
243243
hooks:
244244
- id: ess
245245
args: [--example=FOO="Provide your foo here", --example=BAR="You can fetch bars from https://example.com/bars"]
@@ -258,4 +258,3 @@ Example sample file output
258258
FOO=Provide your foo here
259259
BAR=You can fetch bars from https://example.com/bars
260260
```
261-

default.nix

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
{
2-
pkgs ? (
3-
let
4-
inherit (builtins) fetchTree fromJSON readFile;
5-
inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs;
6-
in
7-
import (fetchTree nixpkgs.locked) {}
8-
),
9-
buildGoModule ? pkgs.buildGoModule,
2+
self,
3+
pkgs ? import <nixpkgs> {},
4+
...
105
}:
11-
buildGoModule {
6+
pkgs.buildGoModule rec {
7+
env.CGO_ENABLED = 0;
128
pname = "ess";
13-
version = "2.16.4";
14-
pwd = ./.;
9+
version = pkgs.lib.strings.removeSuffix "\n" (builtins.readFile ./version.txt);
1510
src = ./.;
16-
vendorHash = "sha256-ooTP3mS7AEzwJm1JKebL0V2lqVge3WnpFZcbr1f/LIg=";
11+
vendorHash = null;
12+
ldflags = [
13+
"-X 'main.version=${version}-nix'"
14+
"-X 'main.commit=${self.rev or "dev"}'"
15+
];
16+
1717
meta = {
1818
description = "ess (env-sample-sync): automatically and safely synchronize env.sample files with .env";
19+
homepage = "https://github.com/acaloiaro/ess";
1920
license = pkgs.lib.licenses.bsd2;
2021
};
2122
}

0 commit comments

Comments
 (0)