-
-
Notifications
You must be signed in to change notification settings - Fork 180
Expand file tree
/
Copy pathflake.nix
More file actions
139 lines (123 loc) · 4.14 KB
/
Copy pathflake.nix
File metadata and controls
139 lines (123 loc) · 4.14 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
{
description = "A very fast, portable and hackable fuzzy finder for the terminal";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
crane.url = "github:ipetkov/crane";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs@{
flake-parts,
crane,
...
}:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = inputs.nixpkgs.lib.systems.flakeExposed;
perSystem =
{
self',
pkgs,
lib,
...
}:
let
rustBin = inputs.rust-overlay.lib.mkRustBin { } pkgs;
rustToolchain = rustBin.fromRustupToolchainFile ./rust-toolchain.toml;
tvCargo = builtins.fromTOML (builtins.readFile ./Cargo.toml);
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
unfilteredRoot = ./.;
src = lib.fileset.toSource {
root = unfilteredRoot;
fileset = lib.fileset.unions [
# Default files from crane (Rust and cargo files)
(craneLib.fileset.commonCargoSources unfilteredRoot)
# Include shell completions
(lib.fileset.maybeMissing ./television/utils/shell)
# Pass tests/config/cli_overrides.rs tests
(lib.fileset.maybeMissing ./working-dir-test.txt)
# Pass tests/app.rs tests
(lib.fileset.maybeMissing ./tests/target_dir)
# Pass legacy config file templates
(lib.fileset.maybeMissing ./television/config/legacy_config_templates.json)
];
};
runtimeDeps = with pkgs; [
bat
fd
jq
just
];
pname = "television";
version = tvCargo.package.version + "-nightly";
meta = {
description = "A very fast, portable and hackable fuzzy finder for the terminal";
homepage = "https://github.com/alexpasmantier/television";
license = lib.licenses.mit;
platforms = lib.platforms.unix;
mainProgram = "tv";
maintainers = [
lib.maintainers.doprz
"tukanoidd"
];
};
# Common arguments can be set here to avoid repeating them later
# Note: changes here will rebuild all dependency crates
commonArgs = {
inherit
src
pname
version
meta
;
strictDeps = true;
doCheck = false; # NOTE: tests/common/mod.rs:139 fails
nativeBuildInputs = with pkgs; [
makeWrapper
installShellFiles
];
buildInputs =
[ ]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
# Additional darwin specific inputs can be set here
pkgs.libiconv
];
};
tv = craneLib.buildPackage (
commonArgs
// {
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
# Additional environment variables or build phases/hooks can be set
# here *without* rebuilding all dependency crates
# MY_CUSTOM_VAR = "some value";
# Wrap the binary to include runtime dependencies in PATH
postInstall = ''
wrapProgram $out/bin/tv \
--prefix PATH : ${lib.makeBinPath runtimeDeps} \
'';
}
);
in
{
checks = {
inherit tv;
};
packages.default = tv;
apps.default = {
inherit meta;
type = "app";
program = lib.getExe tv;
};
devShells.default = craneLib.devShell {
name = "tv-dev";
checks = self'.checks;
# cargo and rustc are provided by default
# includes components defined in rust-toolchain.toml
packages = [ ] ++ runtimeDeps;
};
};
};
}