-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
170 lines (154 loc) · 5.24 KB
/
flake.nix
File metadata and controls
170 lines (154 loc) · 5.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# SPDX-License-Identifier: PMPL-1.0-or-later
# Copyright (c) {{CURRENT_YEAR}} {{AUTHOR}} ({{OWNER}}) <{{AUTHOR_EMAIL}}>
#
# Nix flake for {{PROJECT_NAME}}
#
# NOTE: guix.scm is the PRIMARY development environment. This flake is provided
# as a FALLBACK for contributors who use Nix instead of Guix. The .envrc checks
# for Guix first, then falls back to Nix.
#
# Usage:
# nix develop # Enter development shell
# nix build # Build the project
# nix flake check # Run checks
# nix flake show # Show flake outputs
#
# With direnv (.envrc already configured):
# direnv allow # Auto-enters shell on cd
#
# TODO: Replace {{PROJECT_NAME}} and {{PROJECT_DESCRIPTION}} with actual values.
{
description = "{{PROJECT_NAME}} — RSR-compliant project";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system:
let
pkgs = import nixpkgs { inherit system; };
# Common development tools present in every RSR project.
commonTools = with pkgs; [
git
just
nickel
curl
bash
coreutils
];
# ---------------------------------------------------------------
# Language-specific packages: uncomment the stacks you need.
# ---------------------------------------------------------------
#
# Rust:
# rustc cargo clippy rustfmt rust-analyzer
#
# Elixir:
# elixir erlang
#
# Gleam:
# gleam erlang
#
# Zig:
# zig zls
#
# Haskell:
# ghc cabal-install haskell-language-server
#
# Idris2:
# idris2
#
# OCaml:
# ocaml dune_3 ocaml-lsp
#
# ReScript (via Deno):
# deno
#
# Julia:
# julia
#
# Ada/SPARK:
# gnat gprbuild
#
# ---------------------------------------------------------------
languageTools = with pkgs; [
# TODO: Uncomment or add packages for your stack.
# Example for a Rust project:
# rustc
# cargo
# clippy
# rustfmt
# rust-analyzer
];
in
{
# ---------------------------------------------------------------
# Development shell — `nix develop`
# ---------------------------------------------------------------
devShells.default = pkgs.mkShell {
name = "{{PROJECT_NAME}}-dev";
buildInputs = commonTools ++ languageTools;
# Environment variables available inside the shell.
env = {
PROJECT_NAME = "{{PROJECT_NAME}}";
RSR_TIER = "infrastructure";
};
shellHook = ''
echo ""
echo " {{PROJECT_NAME}} — development shell"
echo " Nix: $(nix --version 2>/dev/null || echo 'unknown')"
echo " Just: $(just --version 2>/dev/null || echo 'not found')"
echo ""
echo " Run 'just' to see available recipes."
echo ""
# Source .envrc manually when direnv is not managing the shell.
# This keeps project env vars (PROJECT_NAME, DATABASE_URL, etc.)
# consistent whether you enter via 'nix develop' or 'direnv allow'.
if [ -z "''${DIRENV_IN_ENVRC:-}" ] && [ -f .envrc ]; then
# Only source the non-nix parts to avoid recursion.
export PROJECT_NAME="{{PROJECT_NAME}}"
export RSR_TIER="infrastructure"
if [ -f .env ]; then
set -a
. .env
set +a
fi
fi
'';
};
# ---------------------------------------------------------------
# Package — `nix build`
# ---------------------------------------------------------------
packages.default = pkgs.stdenv.mkDerivation {
pname = "{{PROJECT_NAME}}";
version = "0.1.0";
src = self;
# TODO: Replace with real build instructions.
# Examples:
#
# Rust (use rustPlatform.buildRustPackage instead of stdenv):
# packages.default = pkgs.rustPlatform.buildRustPackage { ... };
#
# Elixir (use mixRelease):
# packages.default = pkgs.beamPackages.mixRelease { ... };
#
# Zig:
# buildPhase = "zig build -Doptimize=ReleaseSafe";
buildPhase = ''
echo "TODO: Add build commands for {{PROJECT_NAME}}"
'';
installPhase = ''
mkdir -p $out/share/doc
cp README.adoc $out/share/doc/ 2>/dev/null || true
'';
meta = with pkgs.lib; {
description = "{{PROJECT_DESCRIPTION}}";
homepage = "https://github.com/{{OWNER}}/{{PROJECT_NAME}}";
license = licenses.mpl20; # PMPL-1.0-or-later extends MPL-2.0
maintainers = [];
platforms = [ "x86_64-linux" "aarch64-linux" ];
};
};
}
);
}