-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
125 lines (114 loc) · 3.34 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
123
124
125
{
description = "justshow";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
pre-commit-hooks-nix = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs-stable.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
};
};
outputs = inputs @ {self, ...}:
inputs.flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
inputs.pre-commit-hooks-nix.flakeModule
];
# `nix flake show --impure` hack
systems =
if builtins.hasAttr "currentSystem" builtins
then [builtins.currentSystem]
else inputs.nixpkgs.lib.systems.flakeExposed;
flake = {
nixosConfigurations = {
wm = self.inputs.nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
modules = [
(import ./nix/wm-vm.nix {
inherit (self.packages.${system}) justwindows;
})
];
};
};
};
perSystem = {
config,
self',
inputs',
pkgs,
lib,
system,
...
}: let
rustToolchain = pkgs.rust-bin.fromRustupToolchain {
channel = "stable";
components = ["rust-analyzer" "rust-src" "rustfmt" "rustc" "cargo"];
targets = ["x86_64-unknown-linux-gnu" "x86_64-unknown-linux-musl"];
};
in {
_module.args.pkgs = import self.inputs.nixpkgs {
inherit system;
overlays = [
inputs.rust-overlay.overlays.rust-overlay
];
};
pre-commit.settings = {
src = ./.;
hooks = {
alejandra.enable = true;
rustfmt.enable = true;
clippy.enable = true;
};
tools = {
rustfmt = lib.mkForce rustToolchain;
clippy = lib.mkForce rustToolchain;
};
};
apps = {
vm-wm.program = "${self.nixosConfigurations.wm.config.system.build.vm}/bin/run-nixos-vm";
};
packages = {
justwindows = pkgs.rustPlatform.buildRustPackage {
name = "justwindows";
src = builtins.filterSource (path: type: !(lib.hasSuffix ".nix" path)) ./.;
buildAndTestSubdir = "crates/just_windows";
cargoLock.lockFile = ./Cargo.lock;
};
};
devShells.default = pkgs.mkShell {
shellHook = ''
${config.pre-commit.installationScript}
PATH=$PATH:$(pwd)/target/release
'';
env = {
LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib";
};
nativeBuildInputs = [
pkgs.alejandra
pkgs.cargo-expand
pkgs.cargo-flamegraph
pkgs.cargo-leptos
pkgs.cargo-machete
pkgs.cargo-modules
pkgs.cargo-nextest
pkgs.cargo-semver-checks
pkgs.cargo-tarpaulin
pkgs.cargo-udeps
pkgs.fd
pkgs.heaptrack
pkgs.hyperfine
pkgs.linuxKernel.packages.linux_6_1.perf
rustToolchain
pkgs.xlsfonts
];
};
formatter = pkgs.alejandra;
};
};
}