Skip to content

Commit cbda539

Browse files
author
V
authored
feat: add Nix / direnv integration (#1)
1 parent 4766de5 commit cbda539

File tree

6 files changed

+142
-0
lines changed

6 files changed

+142
-0
lines changed

.envrc

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

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
11
/target
2+
result
3+
.direnv
4+
.envrc.local
5+
6+
*~
7+
*.bak
8+
*.orig
9+
*.sw[a-z]
10+
*.tmp

default.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(import (
2+
let
3+
fc = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.flake-compat.locked;
4+
in
5+
fetchTarball {
6+
url = fc.url or "https://github.com/edolstra/flake-compat/archive/${fc.rev}.tar.gz";
7+
sha256 = fc.narHash;
8+
}
9+
) { src = ./.; }).defaultNix

flake.lock

Lines changed: 44 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: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
description = "Terminal-based Sefaria query tool";
3+
4+
inputs = {
5+
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
6+
flake-compat = {
7+
url = "github:edolstra/flake-compat";
8+
flake = false;
9+
};
10+
};
11+
12+
outputs =
13+
inputs:
14+
let
15+
forEachSystem =
16+
f:
17+
inputs.nixpkgs.lib.genAttrs [
18+
"x86_64-linux"
19+
"x86_64-darwin"
20+
"aarch64-linux"
21+
"aarch64-darwin"
22+
] (system: f (import inputs.nixpkgs { inherit system; }));
23+
in
24+
{
25+
packages = forEachSystem (pkgs: {
26+
default = pkgs.callPackage (
27+
{
28+
lib,
29+
openssl,
30+
pkg-config,
31+
rustPlatform,
32+
}:
33+
let
34+
manifest = (lib.importTOML ./Cargo.toml).package;
35+
in
36+
rustPlatform.buildRustPackage {
37+
pname = manifest.name;
38+
inherit (manifest) version;
39+
src = lib.cleanSource ./.;
40+
cargoLock.lockFile = ./Cargo.lock;
41+
nativeBuildInputs = [ pkg-config ];
42+
buildInputs = [ openssl ];
43+
}
44+
) { };
45+
});
46+
devShells = forEachSystem (pkgs: {
47+
default = pkgs.callPackage (
48+
{
49+
cargo,
50+
clippy,
51+
mkShellNoCC,
52+
rust-analyzer,
53+
rustc,
54+
rustfmt,
55+
rustPlatform,
56+
}:
57+
mkShellNoCC {
58+
packages = [
59+
cargo
60+
clippy
61+
rust-analyzer
62+
rustc
63+
rustfmt
64+
];
65+
RUST_SRC_PATH = "${rustPlatform.rustLibSrc}";
66+
}
67+
) { };
68+
});
69+
};
70+
}

shell.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(import (
2+
let
3+
fc = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.flake-compat.locked;
4+
in
5+
fetchTarball {
6+
url = fc.url or "https://github.com/edolstra/flake-compat/archive/${fc.rev}.tar.gz";
7+
sha256 = fc.narHash;
8+
}
9+
) { src = ./.; }).shellNix

0 commit comments

Comments
 (0)