forked from crev-dev/rblake2sum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
76 lines (66 loc) · 2.24 KB
/
flake.nix
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
{
description = "dpc's basic flake template";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.05";
flake-utils.url = "github:numtide/flake-utils";
crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, crane, fenix }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
lib = pkgs.lib;
fenixChannel = fenix.packages.${system}.stable;
fenixToolchain = (fenixChannel.withComponents [
"rustc"
"cargo"
"clippy"
"rust-analysis"
"rust-src"
"rustfmt"
]);
craneLib = crane.lib.${system}.overrideToolchain fenixToolchain;
commonArgs = {
src = craneLib.cleanCargoSource ./.;
buildInputs = with pkgs; [
];
nativeBuildInputs = with pkgs; [
];
};
in
{
packages.default = craneLib.buildPackage ({ } // commonArgs);
devShells = {
default = pkgs.mkShell {
buildInputs = with pkgs; [ ] ++ commonArgs.buildInputs;
nativeBuildInputs = with pkgs; [
fenix.packages.${system}.rust-analyzer
fenixToolchain
cargo-udeps
# This is required to prevent a mangled bash shell in nix develop
# see: https://discourse.nixos.org/t/interactive-bash-with-nix-develop-flake/15486
(hiPrio pkgs.bashInteractive)
# Nix
pkgs.nixpkgs-fmt
pkgs.shellcheck
pkgs.rnix-lsp
pkgs.nodePackages.bash-language-server
] ++ commonArgs.nativeBuildInputs;
shellHook = ''
dot_git="$(git rev-parse --git-common-dir)"
if [[ ! -d "$dot_git/hooks" ]]; then mkdir "$dot_git/hooks"; fi
for hook in misc/git-hooks/* ; do ln -sf "$(pwd)/$hook" "$dot_git/hooks/" ; done
${pkgs.git}/bin/git config commit.template $(pwd)/misc/git-hooks/commit-template.txt
'';
};
};
}
);
}