forked from dpc/fs-dir-cache
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
109 lines (93 loc) · 3.54 KB
/
flake.nix
File metadata and controls
109 lines (93 loc) · 3.54 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
{
description = "A CLI tool for CIs and build scripts, making file system based caching easy and correct (locking, eviction, etc.) ";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
flake-utils.url = "github:numtide/flake-utils";
crane = {
url = "github:ipetkov/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;
extLib = import ./nix/lib.nix { inherit lib; };
fenixChannel = fenix.packages.${system}.stable;
fenixChannelNightly = fenix.packages.${system}.latest;
fenixToolchain = (fenixChannel.withComponents [
"rustc"
"cargo"
"clippy"
"rust-analysis"
"rust-src"
]);
fenixToolchainRustfmt = (fenixChannelNightly.withComponents [
"rustfmt"
]);
craneLib = crane.lib.${system}.overrideToolchain fenixToolchain;
commonArgs =
{
src = extLib.cleanSourceWithRel {
src = builtins.path {
name = "fs-dir-cache";
path = ./.;
};
filter = path: type:
(craneLib.filterCargoSources path type)
;
};
buildInputs = [ ] ++ lib.optionals pkgs.stdenv.isDarwin [
pkgs.libiconv
pkgs.darwin.apple_sdk.frameworks.Security
];
nativeBuildInputs = builtins.attrValues
{
inherit (pkgs) lld mold;
} ++ [ ];
};
in
{
packages. default = craneLib.buildPackage ({ } // commonArgs);
devShells = {
default = pkgs.mkShell {
buildInputs = [ ] ++ commonArgs.buildInputs;
nativeBuildInputs = builtins.attrValues
{
inherit (pkgs) cargo-watch;
inherit fenixToolchain fenixToolchainRustfmt;
inherit (pkgs) nixpkgs-fmt shellcheck rnix-lsp just;
inherit (pkgs) lld parallel typos convco;
} ++ [
# 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
(pkgs.hiPrio pkgs.bashInteractive)
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
chmod +x .git/hooks/{pre-commit,commit-msg}
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
# if running in direnv
if [ -n "''${DIRENV_IN_ENVRC:-}" ]; then
# and not set DIRENV_LOG_FORMAT
if [ -n "''${DIRENV_LOG_FORMAT:-}" ]; then
>&2 echo "💡 Set 'DIRENV_LOG_FORMAT=\"\"' in your shell environment variables for a cleaner output of direnv"
fi
fi
>&2 echo "💡 Run 'just' for a list of available 'just ...' helper recipes"
'';
};
};
}
);
}