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

Add nix support #519

Closed
wants to merge 4 commits into from
Closed
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
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@ tmp/
.idea

# build output
air
air

# Dev evnrionment files
.devenv
.direnv
.envrc
.pre-commit-config.yaml
result
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@ this will replace `$PWD` with the current directory, `$AIR_PORT` is the port whe

</details>


### Nix flake input

Add air as a Nix flake input in `flake.nix`

```nix
inputs.air.url = "github:cosmtrek/air";
```

## Usage

For less typing, you could add `alias air='~/.air'` to your `.bashrc` or `.zshrc`.
Expand Down Expand Up @@ -298,6 +307,14 @@ make install

Pull requests are welcome.

### Nix users

Start a development shell with all `air`'s dependencies present.

```bash
nix develop --impure
```

### Release

```shell
Expand Down
31 changes: 31 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
pkgs ? (
let
inherit (builtins) fetchTree fromJSON readFile;
inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix;
in
import (fetchTree nixpkgs.locked) {
overlays = [
(import "${fetchTree gomod2nix.locked}/overlay.nix")
];
}
),
buildGoApplication ? pkgs.buildGoApplication,
}:
buildGoApplication rec {
pname = "air";
version = "dev";
src = ./.;
pwd = ./.;
subPackages = ["runner"];
checkPhase = false;
modules = ./gomod2nix.toml;

buildPhase = ''
LDFLAGS=" -X main.BuildTimestamp=$(date -u "+%Y-%m-%d-%H:%M:%S")"
LDFLAGS+=" -X main.airVersion=${version}"
LDFLAGS+=" -X main.goVersion=$(go version | sed -r 's/go version go(.*)\ .*/\1/')"

go build -o $out/bin/air -ldflags "$LDFLAGS"
'';
}
291 changes: 291 additions & 0 deletions flake.lock

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

Loading
Loading