Skip to content

Commit c23f85d

Browse files
committed
build: add nix flake
1 parent 4e4a3dc commit c23f85d

File tree

2 files changed

+148
-0
lines changed

2 files changed

+148
-0
lines changed

flake.lock

+62
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
description = "oxidizr";
3+
4+
inputs = {
5+
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
6+
rust-overlay.url = "github:oxalica/rust-overlay";
7+
};
8+
9+
outputs =
10+
{
11+
self,
12+
nixpkgs,
13+
rust-overlay,
14+
}:
15+
let
16+
supportedSystems = [
17+
"x86_64-linux"
18+
"aarch64-linux"
19+
];
20+
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
21+
22+
pkgsForSystem =
23+
system:
24+
(import nixpkgs {
25+
inherit system;
26+
overlays = [ (import rust-overlay) ];
27+
});
28+
in
29+
{
30+
packages = forAllSystems (
31+
system:
32+
let
33+
inherit (pkgsForSystem system)
34+
lib
35+
rustPlatform
36+
;
37+
38+
cargoToml = lib.trivial.importTOML ./Cargo.toml;
39+
version = cargoToml.package.version;
40+
in
41+
rec {
42+
default = oxidizr;
43+
44+
oxidizr = rustPlatform.buildRustPackage {
45+
pname = "oxidizr";
46+
version = version;
47+
src = lib.cleanSource ./.;
48+
cargoLock.lockFile = ./Cargo.lock;
49+
50+
meta = {
51+
description = "Replace system utilities with Rust alternatives on Ubuntu";
52+
homepage = "https://github.com/jnsgruk/oxidizr";
53+
license = lib.licenses.asl20;
54+
mainProgram = "oxidizr";
55+
platforms = lib.platforms.unix;
56+
maintainers = with lib.maintainers; [ jnsgruk ];
57+
};
58+
};
59+
}
60+
);
61+
62+
devShells = forAllSystems (
63+
system:
64+
let
65+
pkgs = pkgsForSystem system;
66+
rust = pkgs.rust-bin.stable.latest.default.override {
67+
extensions = [ "rust-src" ];
68+
};
69+
in
70+
{
71+
default = pkgs.mkShell {
72+
name = "oxidizr";
73+
74+
NIX_CONFIG = "experimental-features = nix-command flakes";
75+
RUST_SRC_PATH = "${rust}/lib/rustlib/src/rust/library";
76+
77+
inputsFrom = [ self.packages.${system}.oxidizr ];
78+
buildInputs = with pkgs; [
79+
clippy
80+
rust
81+
];
82+
};
83+
}
84+
);
85+
};
86+
}

0 commit comments

Comments
 (0)