-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
122 lines (107 loc) · 3 KB
/
Copy pathflake.nix
File metadata and controls
122 lines (107 loc) · 3 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
{
description = "A TUI program for movies";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = {
self,
nixpkgs,
}: let
systems = nixpkgs.lib.systems.flakeExposed;
forAllsystems = nixpkgs.lib.genAttrs systems;
name = "cineteca";
mkInputs = pkgs: {
nativeBuildInputs = with pkgs; [
pkg-config
clang
rustPlatform.bindgenHook
clippy
];
buildInputs = with pkgs; [
ffmpeg
];
};
in {
packages = forAllsystems (
system: let
pkgs = nixpkgs.legacyPackages.${system};
inputs = mkInputs pkgs;
cineteca = pkgs.rustPlatform.buildRustPackage {
inherit (inputs) nativeBuildInputs buildInputs;
inherit name;
version = "0.1.0";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
meta = with pkgs.lib; {
inherit systems;
description = "TUI application for movies";
maintainers = ["cch000"];
license = licenses.gpl3Plus;
};
};
in {
inherit cineteca;
default = cineteca;
}
);
formatter = forAllsystems (
system: let
pkgs = nixpkgs.legacyPackages.${system};
in
pkgs.writeShellApplication {
name = "format";
text = ''
echo "Formatting Nix files..."
find . -name "*.nix" -exec alejandra {} + > /dev/null 2>&1
echo "Formatting Rust files..."
find . -name "*.rs" -exec rustfmt {} +
'';
}
);
checks = forAllsystems (
system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
formatting-nix = pkgs.runCommand "check-nix-formatting" {} ''
echo "Checking Nix file formatting..."
cd ${self}
find . -name "*.nix" -exec ${pkgs.lib.getExe pkgs.alejandra} --check {} + > /dev/null 2>&1
touch $out
'';
formatting-rust = pkgs.runCommand "check-rust-formatting" {} ''
echo "Checking Rust file formatting..."
cd ${self}
find . -name "*.rs" -exec ${pkgs.lib.getExe pkgs.rustfmt} --check {} +
touch $out
'';
linting-rust = self.packages.${system}.default.overrideAttrs (
old: {
name = "check-rust-linting";
doCheck = true;
checkPhase = ''
echo "Running Rust linting checks..."
cargo clippy -- -D warnings
'';
installPhase = "mkdir -p $out";
}
);
}
);
devShells = forAllsystems (
system: let
pkgs = nixpkgs.legacyPackages.${system};
inputs = mkInputs pkgs;
in {
default = pkgs.mkShell {
inherit (inputs) nativeBuildInputs buildInputs;
inputsFrom = [self.packages.${system}.default];
packages = with pkgs; [
nixd
rustfmt
alejandra
];
};
}
);
};
}