Skip to content

Commit de5d494

Browse files
committed
Add devenv support for NixOS
+ Use Devenv to setup a standarized dev environment for NixOS.
1 parent 657e5c4 commit de5d494

File tree

5 files changed

+213
-0
lines changed

5 files changed

+213
-0
lines changed

.envrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
export DIRENV_WARN_TIMEOUT=20s
4+
5+
eval "$(devenv direnvrc)"
6+
7+
# `use devenv` supports the same options as the `devenv shell` command.
8+
#
9+
# To silence all output, use `--quiet`.
10+
#
11+
# Example usage: use devenv --quiet --impure --option services.postgres.enable:bool true
12+
use devenv

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,14 @@ Cargo.lock
33
*.bk
44
.vscode
55
*.sublime-workspace
6+
7+
# Devenv
8+
.devenv*
9+
devenv.local.nix
10+
devenv.local.yaml
11+
12+
# direnv
13+
.direnv
14+
15+
# pre-commit
16+
.pre-commit-config.yaml

devenv.lock

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{
2+
"nodes": {
3+
"devenv": {
4+
"locked": {
5+
"dir": "src/modules",
6+
"lastModified": 1763939584,
7+
"owner": "cachix",
8+
"repo": "devenv",
9+
"rev": "1ebc7baa0726314d24bb5cc34d5fc7927aa57929",
10+
"type": "github"
11+
},
12+
"original": {
13+
"dir": "src/modules",
14+
"owner": "cachix",
15+
"repo": "devenv",
16+
"type": "github"
17+
}
18+
},
19+
"flake-compat": {
20+
"flake": false,
21+
"locked": {
22+
"lastModified": 1761588595,
23+
"owner": "edolstra",
24+
"repo": "flake-compat",
25+
"rev": "f387cd2afec9419c8ee37694406ca490c3f34ee5",
26+
"type": "github"
27+
},
28+
"original": {
29+
"owner": "edolstra",
30+
"repo": "flake-compat",
31+
"type": "github"
32+
}
33+
},
34+
"git-hooks": {
35+
"inputs": {
36+
"flake-compat": "flake-compat",
37+
"gitignore": "gitignore",
38+
"nixpkgs": [
39+
"nixpkgs"
40+
]
41+
},
42+
"locked": {
43+
"lastModified": 1763741496,
44+
"owner": "cachix",
45+
"repo": "git-hooks.nix",
46+
"rev": "20e71a403c5de9ce5bd799031440da9728c1cda1",
47+
"type": "github"
48+
},
49+
"original": {
50+
"owner": "cachix",
51+
"repo": "git-hooks.nix",
52+
"type": "github"
53+
}
54+
},
55+
"gitignore": {
56+
"inputs": {
57+
"nixpkgs": [
58+
"git-hooks",
59+
"nixpkgs"
60+
]
61+
},
62+
"locked": {
63+
"lastModified": 1762808025,
64+
"owner": "hercules-ci",
65+
"repo": "gitignore.nix",
66+
"rev": "cb5e3fdca1de58ccbc3ef53de65bd372b48f567c",
67+
"type": "github"
68+
},
69+
"original": {
70+
"owner": "hercules-ci",
71+
"repo": "gitignore.nix",
72+
"type": "github"
73+
}
74+
},
75+
"nixpkgs": {
76+
"locked": {
77+
"lastModified": 1761313199,
78+
"owner": "cachix",
79+
"repo": "devenv-nixpkgs",
80+
"rev": "d1c30452ebecfc55185ae6d1c983c09da0c274ff",
81+
"type": "github"
82+
},
83+
"original": {
84+
"owner": "cachix",
85+
"ref": "rolling",
86+
"repo": "devenv-nixpkgs",
87+
"type": "github"
88+
}
89+
},
90+
"root": {
91+
"inputs": {
92+
"devenv": "devenv",
93+
"git-hooks": "git-hooks",
94+
"nixpkgs": "nixpkgs",
95+
"pre-commit-hooks": [
96+
"git-hooks"
97+
],
98+
"rust-overlay": "rust-overlay"
99+
}
100+
},
101+
"rust-overlay": {
102+
"inputs": {
103+
"nixpkgs": [
104+
"nixpkgs"
105+
]
106+
},
107+
"locked": {
108+
"lastModified": 1763952169,
109+
"owner": "oxalica",
110+
"repo": "rust-overlay",
111+
"rev": "ab726555a9a72e6dc80649809147823a813fa95b",
112+
"type": "github"
113+
},
114+
"original": {
115+
"owner": "oxalica",
116+
"repo": "rust-overlay",
117+
"type": "github"
118+
}
119+
}
120+
},
121+
"root": "root",
122+
"version": 7
123+
}

devenv.nix

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
pkgs,
3+
lib,
4+
config,
5+
inputs,
6+
...
7+
}: {
8+
# https://devenv.sh/basics/
9+
env.GREET = "devenv";
10+
11+
# https://devenv.sh/packages/
12+
packages = with pkgs; [
13+
git
14+
bacon
15+
cargo-nextest
16+
gitui
17+
helix
18+
];
19+
20+
# https://devenv.sh/languages/
21+
languages.rust = {
22+
enable = true;
23+
channel = "stable";
24+
};
25+
26+
# https://devenv.sh/processes/
27+
# processes.dev.exec = "${lib.getExe pkgs.watchexec} -n -- ls -la";
28+
29+
# https://devenv.sh/services/
30+
# services.postgres.enable = true;
31+
32+
# https://devenv.sh/scripts/
33+
scripts.hello.exec = ''
34+
echo hello from $GREET
35+
'';
36+
37+
# https://devenv.sh/basics/
38+
enterShell = ''
39+
hello # Run scripts directly
40+
git --version # Use packages
41+
'';
42+
43+
# https://devenv.sh/tasks/
44+
# tasks = {
45+
# "myproj:setup".exec = "mytool build";
46+
# "devenv:enterShell".after = [ "myproj:setup" ];
47+
# };
48+
49+
# https://devenv.sh/tests/
50+
enterTest = ''
51+
echo "Running tests"
52+
git --version | grep --color=auto "${pkgs.git.version}"
53+
'';
54+
55+
# https://devenv.sh/git-hooks/
56+
# git-hooks.hooks.shellcheck.enable = true;
57+
58+
# See full reference at https://devenv.sh/reference/options/
59+
}

devenv.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
inputs:
2+
nixpkgs:
3+
url: github:cachix/devenv-nixpkgs/rolling
4+
rust-overlay:
5+
url: github:oxalica/rust-overlay
6+
inputs:
7+
nixpkgs:
8+
follows: nixpkgs

0 commit comments

Comments
 (0)