-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
111 lines (102 loc) · 2.79 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
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
{
description = "Flash utility for the Qoob Pro modchip";
inputs = {
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs: let
inherit (inputs.nixpkgs) lib;
defaultSystems = lib.systems.flakeExposed;
argsForSystem = system: {
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
(import inputs.rust-overlay)
];
config = {};
};
};
allArgs = lib.genAttrs defaultSystems argsForSystem;
eachSystem = fn: lib.genAttrs defaultSystems (system: fn allArgs."${system}");
rqoobPkg = {
lib,
callPackage,
stdenv,
pkg-config,
installShellFiles,
udev,
}: let
naersk = callPackage inputs.naersk {};
in
naersk.buildPackage {
src = ./.;
nativeBuildInputs = [pkg-config installShellFiles];
buildInputs = [udev];
postInstall =
(lib.optionalString stdenv.isLinux ''
install -D "$src/70-qoob.rules" "$out/lib/udev/rules.d/70-qoob.rules"
'')
+ ''
installShellCompletion --cmd rqoob \
--bash <("$out/bin/rqoob" gen-completions bash) \
--fish <("$out/bin/rqoob" gen-completions fish) \
--zsh <("$out/bin/rqoob" gen-completions zsh)
'';
};
in {
formatter = eachSystem ({pkgs, ...}:
pkgs.writeShellScriptBin "formatter" ''
${pkgs.alejandra}/bin/alejandra flake.nix
'');
devShells = eachSystem ({pkgs, ...}: {
default = pkgs.mkShell {
name = "rqoob";
inputsFrom = [inputs.self.packages."${pkgs.system}".default];
nativeBuildInputs = [
(pkgs.rust-bin.stable.latest.default.override {
extensions = [
"rust-analyzer"
"rust-src"
];
})
];
};
});
packages = eachSystem ({pkgs, ...}: {
default = pkgs.callPackage rqoobPkg {};
});
nixosModules.default = {
config,
lib,
pkgs,
...
}: let
cfg = config.programs.rqoob;
rqoob = pkgs.callPackage rqoobPkg {};
in {
options = {
programs.rqoob = {
enable = lib.mkEnableOption "Enable rqoob, a Qoob flash utility";
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [rqoob];
services.udev.packages = [rqoob];
};
};
overlays.default = final: prev: {
rqoob = final.callPackage rqoobPkg {};
};
};
}