-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathflake.nix
More file actions
129 lines (127 loc) · 4.67 KB
/
Copy pathflake.nix
File metadata and controls
129 lines (127 loc) · 4.67 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
{
description = "DDC/CI display control application for Windows and Linux";
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
, pkg-config, python3
, libiconv
, CoreGraphics ? darwin.apple_sdk.frameworks.CoreGraphics, darwin
, enableRust ? true, cargo
, rustTools ? [ ]
, nativeBuildInputs ? [ ]
}: mkShell {
inherit rustTools;
buildInputs =
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 = "ddc=debug";
};
stable = { rust'stable, outputs'devShells'plain }: outputs'devShells'plain.override {
inherit (rust'stable) mkShell;
enableRust = false;
};
dev = { rust'unstable, rust-w64-overlay, rust-w64, outputs'devShells'plain }: let
channel = rust'unstable.override {
channelOverlays = [ rust-w64-overlay ];
};
in outputs'devShells'plain.override {
inherit (channel) mkShell;
enableRust = false;
rustTools = [ "rust-analyzer" ];
nativeBuildInputs = [ rust-w64.pkgs.stdenv.cc.bintools ];
};
default = { outputs'devShells }: outputs'devShells.plain;
};
packages = {
ddcset = {
__functor = _: import ./derivation.nix;
fl'config.args = {
crate.fallback = self.lib.crate;
};
};
ddcset-w64 = { pkgsCross'mingwW64, rust-w64, source }: pkgsCross'mingwW64.callPackage ./derivation.nix {
inherit (rust-w64.latest) rustPlatform;
inherit source;
};
ddcset-static = { pkgsCross'musl64'pkgsStatic, eudev-musl64, source }: (pkgsCross'musl64'pkgsStatic.callPackage ./derivation.nix {
inherit ((import inputs.rust { pkgs = pkgsCross'musl64'pkgsStatic; }).latest) rustPlatform;
udev = eudev-musl64;
inherit source;
}).overrideAttrs (old: {
# XXX: why is this needed?
NIX_LDFLAGS = old.NIX_LDFLAGS or "" + " -static";
RUSTFLAGS = old.RUSTFLAGS or "" + " -C default-linker-libraries=yes";
});
default = { ddcset }: ddcset;
};
legacyPackages = { callPackageSet }: callPackageSet {
source = { rust'builders }: rust'builders.wrapSource self.lib.crate.src;
rust-w64 = { pkgsCross'mingwW64 }: import inputs.rust { inherit (pkgsCross'mingwW64) pkgs; };
rust-w64-overlay = { rust-w64 }: let
target = rust-w64.lib.rustTargetEnvironment {
inherit (rust-w64) pkgs;
rustcFlags = [ "-L native=${rust-w64.pkgs.windows.pthreads}/lib" ];
};
in cself: csuper: {
sysroot-std = csuper.sysroot-std ++ [ cself.manifest.targets.${target.triple}.rust-std ];
cargo-cc = csuper.cargo-cc // cself.context.rlib.cargoEnv {
inherit target;
};
rustc-cc = csuper.rustc-cc // cself.context.rlib.rustcCcEnv {
inherit target;
};
};
eudev-musl64 = { pkgsCross'musl64'pkgsStatic, gperf }: (pkgsCross'musl64'pkgsStatic.eudev.override {
glib = null; gperf = null; util-linux = null; kmod = null;
}).overrideAttrs (old: {
# XXX: apply hack to fix https://github.com/NixOS/nixpkgs/pull/145819
nativeBuildInputs = old.nativeBuildInputs ++ [ gperf ];
patches = old.patches or [ ] ++ [ ./eudev-gettid.patch ];
});
generate = { rust'builders, outputHashes }: rust'builders.generateFiles {
paths = {
"lock.nix" = outputHashes;
};
};
outputHashes = { rust'builders }: rust'builders.cargoOutputHashes {
inherit (self.lib) crate;
};
} { };
checks = {
rustfmt = { rust'builders, ddcset }: rust'builders.check-rustfmt-unstable {
inherit (ddcset) src;
config = ./.rustfmt.toml;
};
};
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 = "ddcset-rs";
};
};
}