yep, more dotfiles
1{
2 inputs = {
3 nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
4
5 rust-overlay.url = "github:oxalica/rust-overlay";
6 rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
7
8 gitignore.url = "github:hercules-ci/gitignore.nix";
9 gitignore.inputs.nixpkgs.follows = "nixpkgs";
10 };
11
12 outputs =
13 {
14 self,
15 nixpkgs,
16 rust-overlay,
17 gitignore,
18 }:
19 let
20 inherit (nixpkgs.lib) genAttrs getExe;
21
22 forAllSystems = genAttrs [
23 "x86_64-linux"
24 "aarch64-linux"
25 "aarch64-darwin"
26 ];
27 forAllPkgs = function: forAllSystems (system: function pkgs.${system});
28
29 mkApp = (
30 program: {
31 type = "app";
32 inherit program;
33 }
34 );
35
36 pkgs = forAllSystems (
37 system:
38 import nixpkgs {
39 inherit system;
40 overlays = [ (import rust-overlay) ];
41 }
42 );
43 in
44 {
45 formatter = forAllPkgs (pkgs: pkgs.nixfmt-tree);
46
47 packages = forAllPkgs (pkgs: rec {
48 default = app;
49 app = pkgs.callPackage ./package.nix { inherit gitignore; };
50 });
51 apps = forAllSystems (system: rec {
52 default = app;
53 app = mkApp (getExe self.packages.${system}.app);
54 });
55
56 devShells = forAllPkgs (
57 pkgs:
58 let
59 file-rust-toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
60 rust-toolchain = file-rust-toolchain.override { extensions = [ "rust-analyzer" ]; };
61 in
62 {
63 default = pkgs.mkShell {
64 packages = with pkgs; [
65 pkg-config
66 rust-toolchain
67 ];
68
69 RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc;
70 };
71 }
72 );
73 };
74}