|
| 1 | +{ |
| 2 | + description = "rdf-protect"; |
| 3 | + |
| 4 | + nixConfig = { |
| 5 | + substituters = [ |
| 6 | + # Add here some other mirror if needed. |
| 7 | + "https://cache.nixos.org/" |
| 8 | + ]; |
| 9 | + extra-substituters = [ |
| 10 | + # Nix community's cache server |
| 11 | + "https://nix-community.cachix.org" |
| 12 | + ]; |
| 13 | + extra-trusted-public-keys = [ |
| 14 | + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" |
| 15 | + ]; |
| 16 | + }; |
| 17 | + |
| 18 | + inputs = { |
| 19 | + # Nixpkgs |
| 20 | + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; |
| 21 | + |
| 22 | + # You can access packages and modules from different nixpkgs revs |
| 23 | + # at the same time. Here's an working example: |
| 24 | + nixpkgsStable.url = "github:nixos/nixpkgs/nixos-23.11"; |
| 25 | + # Also see the 'stable-packages' overlay at 'overlays/default.nix'. |
| 26 | + |
| 27 | + flake-utils.url = "github:numtide/flake-utils"; |
| 28 | + |
| 29 | + # The Rust overlay to include the latest toolchain. |
| 30 | + rust-overlay = { |
| 31 | + url = "github:oxalica/rust-overlay"; |
| 32 | + inputs = { |
| 33 | + nixpkgs.follows = "nixpkgs"; |
| 34 | + flake-utils.follows = "flake-utils"; |
| 35 | + }; |
| 36 | + }; |
| 37 | + }; |
| 38 | + |
| 39 | + outputs = { |
| 40 | + self, |
| 41 | + nixpkgs, |
| 42 | + nixpkgsStable, |
| 43 | + flake-utils, |
| 44 | + rust-overlay, |
| 45 | + ... |
| 46 | + } @ inputs: |
| 47 | + flake-utils.lib.eachDefaultSystem |
| 48 | + # Creates an attribute map `{ devShells.<system>.default = ...}` |
| 49 | + # by calling this function: |
| 50 | + ( |
| 51 | + system: let |
| 52 | + overlays = [(import rust-overlay)]; |
| 53 | + |
| 54 | + # Import nixpkgs and load it into pkgs. |
| 55 | + pkgs = import nixpkgs { |
| 56 | + inherit system overlays; |
| 57 | + }; |
| 58 | + |
| 59 | + # Set the rust toolchain from the `rust-toolchain.toml`. |
| 60 | + rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ../rust-toolchain.toml; |
| 61 | + |
| 62 | + # Things needed only at compile-time. |
| 63 | + nativeBuildInputsBasic = with pkgs; [ |
| 64 | + rustToolchain |
| 65 | + cargo-watch |
| 66 | + |
| 67 | + just |
| 68 | + parallel |
| 69 | + podman |
| 70 | + ]; |
| 71 | + |
| 72 | + # Things needed only at compile-time. |
| 73 | + nativeBuildInputsDev = []; |
| 74 | + |
| 75 | + # Things needed at runtime. |
| 76 | + buildInputs = []; |
| 77 | + in |
| 78 | + with pkgs; { |
| 79 | + devShells = { |
| 80 | + default = mkShell { |
| 81 | + inherit buildInputs; |
| 82 | + nativeBuildInputs = nativeBuildInputsBasic ++ nativeBuildInputsDev; |
| 83 | + }; |
| 84 | + |
| 85 | + ci = mkShell { |
| 86 | + inherit buildInputs; |
| 87 | + nativeBuildInputs = nativeBuildInputsBasic; |
| 88 | + }; |
| 89 | + }; |
| 90 | + } |
| 91 | + ); |
| 92 | +} |
0 commit comments