Skip to content

Commit 0ed2f53

Browse files
committed
[Nix Support] Adds nix flake support for bifrost
1 parent e0d915d commit 0ed2f53

File tree

5 files changed

+139
-4
lines changed

5 files changed

+139
-4
lines changed

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,8 @@ test-reports
5353

5454

5555
# Cursor specific
56-
.cursor/
56+
.cursor/
57+
58+
# Nix specific
59+
.direnv
60+
.nix-store

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ build: build-ui ## Build bifrost-http binary
151151
echo "$(YELLOW)Note: This will create a dynamically linked build.$(NC)"; \
152152
echo "$(YELLOW)To build with dynamic plugin support.$(NC)"; \
153153
else \
154-
echo "$(YELLOW)Note: This will create a statically linked build.$(NC)"; \
155-
echo "$(YELLOW)To build with dynamic plugin support.$(NC)"; \
154+
echo "$(YELLOW)Note: This will create a statically linked build,$(NC)"; \
155+
echo "$(YELLOW)to build with dynamic plugin support.$(NC)"; \
156156
fi
157157
@mkdir -p ./tmp
158158
@TARGET_OS="$(GOOS)"; \
@@ -758,4 +758,4 @@ mod-tidy: ## Run go mod tidy on modules (Usage: make mod-tidy [MODULE=all|core|p
758758
done; \
759759
fi
760760
@echo ""
761-
@echo "$(GREEN)✓ go mod tidy complete$(NC)"
761+
@echo "$(GREEN)✓ go mod tidy complete$(NC)"

flake.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{
2+
description = "Bifrost's Nix Flake";
3+
4+
# Flake inputs
5+
inputs = {
6+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
7+
};
8+
9+
# Flake outputs
10+
outputs = {self, ...} @ inputs: let
11+
# The systems supported for this flake's outputs
12+
supportedSystems = [
13+
"x86_64-linux" # 64-bit Intel/AMD Linux
14+
"aarch64-linux" # 64-bit ARM Linux
15+
"aarch64-darwin" # 64-bit ARM macOS
16+
];
17+
18+
# Helper for providing system-specific attributes
19+
forEachSupportedSystem = f:
20+
inputs.nixpkgs.lib.genAttrs supportedSystems (
21+
system:
22+
f {
23+
inherit system;
24+
# Provides a system-specific, configured Nixpkgs
25+
pkgs = import inputs.nixpkgs {
26+
inherit system;
27+
# Enable using unfree packages
28+
config.allowUnfree = true;
29+
};
30+
}
31+
);
32+
in {
33+
# To activate the default environment:
34+
# nix develop
35+
# Or if you use direnv:
36+
# direnv allow
37+
devShells = forEachSupportedSystem (
38+
{
39+
pkgs,
40+
system,
41+
}: {
42+
# Run `nix develop` to activate this environment or `direnv allow` if you have direnv installed
43+
default = pkgs.mkShellNoCC {
44+
# The name of the environment
45+
name = "bifrost-nix-dev-shell";
46+
47+
# The Nix packages provided in the environment
48+
packages = with pkgs; [
49+
go
50+
nodejs_24
51+
];
52+
53+
# Set any environment variables for your development environment
54+
env = {};
55+
56+
# Add any shell logic you want executed when the environment is activated
57+
shellHook = ''
58+
##
59+
## Go: project-local GOPATH/GOBIN
60+
##
61+
export GOPATH="$PWD/.nix-store/go"
62+
export GOBIN="$GOPATH/bin"
63+
export GOMODCACHE="$GOPATH/pkg/mod"
64+
export GOCACHE="$PWD/.nix-store/gocache"
65+
66+
mkdir -p "$GOBIN" "$GOMODCACHE" "$GOCACHE"
67+
68+
export PATH="$PATH:$GOBIN"
69+
70+
# Install gopls into this project's Go bin if missing
71+
if ! command -v gopls >/dev/null 2>&1; then
72+
go install golang.org/x/tools/gopls@latest
73+
fi
74+
# Install air into this project's Go bin if missing
75+
if ! command -v air >/dev/null 2>&1; then
76+
go install github.com/air-verse/air@latest
77+
fi
78+
# Install dlv into this project's Go bin if missing
79+
if ! command -v dlv >/dev/null 2>&1; then
80+
go install github.com/go-delve/delve/cmd/dlv@latest
81+
fi
82+
# Install staticcheck into this project's Go bin if missing
83+
if ! command -v staticcheck >/dev/null 2>&1; then
84+
go install honnef.co/go/tools/cmd/staticcheck@latest
85+
fi
86+
87+
##
88+
## Node: project-local "global" npm prefix
89+
##
90+
# npm reads npm_config_prefix (or NPM_CONFIG_PREFIX) as the "prefix" config,
91+
# which is where `npm i -g` installs to.
92+
export npm_config_prefix="$PWD/.nix-store/npm-global"
93+
94+
mkdir -p "$npm_config_prefix/bin"
95+
96+
# Ensure "global" npm bin is on PATH for this shell only
97+
export PATH="$PATH:$npm_config_prefix/bin"
98+
'';
99+
};
100+
}
101+
);
102+
};
103+
}

0 commit comments

Comments
 (0)