-
Notifications
You must be signed in to change notification settings - Fork 6
/
flake.nix
122 lines (121 loc) · 3.71 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
112
113
114
115
116
117
118
119
120
121
122
{
description = "A VFIO KVM switch using DDC/CI";
inputs = {
flakelib.url = "github:flakelib/fl";
nixpkgs = { };
rust = {
url = "github:arcnmx/nixexprs-rust";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, flakelib, nixpkgs, rust, ... }@inputs: let
nixlib = nixpkgs.lib;
in flakelib {
inherit inputs;
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
devShells = {
plain = {
mkShell, writeShellScriptBin, hostPlatform
, udev
, libxcb ? xorg.libxcb, xorg ? { }
, pkg-config, python3
, libiconv
, CoreGraphics ? darwin.apple_sdk.frameworks.CoreGraphics, darwin
, enableRust ? true, cargo
, rustTools ? [ ]
, nativeBuildInputs ? [ ]
}: mkShell {
inherit rustTools;
buildInputs = [ libxcb ]
++ nixlib.optional hostPlatform.isLinux udev
++ nixlib.optionals hostPlatform.isDarwin [ libiconv CoreGraphics ];
nativeBuildInputs = [ pkg-config python3 ]
++ nixlib.optional enableRust cargo
++ nativeBuildInputs ++ [
(writeShellScriptBin "generate" ''nix run .#generate "$@"'')
];
RUST_LOG = "debug";
};
stable = { rust'stable, outputs'devShells'plain }: outputs'devShells'plain.override {
inherit (rust'stable) mkShell;
enableRust = false;
};
dev = { rust'unstable, outputs'devShells'plain }: outputs'devShells'plain.override {
inherit (rust'unstable) mkShell;
enableRust = false;
rustTools = [ "rust-analyzer" ];
};
default = { outputs'devShells }: outputs'devShells.plain;
};
packages = {
screenstub = {
__functor = _: import ./derivation.nix;
fl'config.args = {
crate.fallback = self.lib.crate;
};
};
default = { screenstub }: screenstub;
};
legacyPackages = { callPackageSet }: callPackageSet {
source = { rust'builders }: rust'builders.wrapSource self.lib.crate.src;
generate = { rust'builders, outputHashes }: rust'builders.generateFiles {
paths = {
"lock.nix" = outputHashes;
};
};
outputHashes = { rust'builders }: rust'builders.cargoOutputHashes {
inherit (self.lib) crate;
};
} { };
checks = {
${if false then "rustfmt" else null} = { rust'builders, screenstub }: rust'builders.check-rustfmt-unstable {
inherit (screenstub) src;
config = ./.rustfmt.toml;
};
check-config = { screenstub, runCommand }: runCommand "screenstub-check-config" {
nativeBuildInputs = [ screenstub ];
sampleConfig = ./samples/config.yml;
} ''
screenstub --config $sampleConfig check-config > $out
'';
};
lib = with nixlib; {
crate = rust.lib.importCargo {
path = ./Cargo.toml;
inherit (import ./lock.nix) outputHashes;
};
inherit (self.lib.crate) version;
releaseTag = "v${self.lib.version}";
};
config = rec {
name = "screenstub";
};
overlays = {
screenstub = final: prev: {
screenstub = final.callPackage ./derivation.nix {
inherit (self.lib) crate;
};
};
default = self.overlays.screenstub;
};
} // (let
config = {
_module.args.inputs'screenstub = nixlib.mkDefault self;
};
in {
nixosModules = {
screenstub = { lib, ... }: {
imports = [ ./nixos.nix ];
inherit config;
};
default = self.nixosModules.screenstub;
};
homeModules = {
screenstub = { lib, ... }: {
imports = [ ./home.nix ];
inherit config;
};
default = self.homeModules.screenstub;
};
});
}