|
| 1 | +{ |
| 2 | + description = "Flake for building and testing nu_plugin_dbus"; |
| 3 | + |
| 4 | + inputs = { |
| 5 | + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; |
| 6 | + flake-parts.url = "github:hercules-ci/flake-parts"; |
| 7 | + treefmt-nix = { |
| 8 | + url = "github:numtide/treefmt-nix"; |
| 9 | + inputs.nixpkgs.follows = "nixpkgs"; |
| 10 | + }; |
| 11 | + systems.url = "github:nix-systems/default-linux"; |
| 12 | + }; |
| 13 | + |
| 14 | + outputs = |
| 15 | + inputs@{ flake-parts, ... }: |
| 16 | + flake-parts.lib.mkFlake { inherit inputs; } { |
| 17 | + systems = import inputs.systems; |
| 18 | + |
| 19 | + imports = [ |
| 20 | + inputs.treefmt-nix.flakeModule |
| 21 | + ]; |
| 22 | + |
| 23 | + perSystem = |
| 24 | + { |
| 25 | + pkgs, |
| 26 | + lib, |
| 27 | + self', |
| 28 | + ... |
| 29 | + }: |
| 30 | + { |
| 31 | + treefmt = { |
| 32 | + programs.nixfmt.enable = true; |
| 33 | + programs.rustfmt.enable = true; |
| 34 | + }; |
| 35 | + |
| 36 | + packages.default = pkgs.nushell-plugin-dbus.overrideAttrs ( |
| 37 | + final: prev: { |
| 38 | + version = "0.15.0"; # used by versionCheckHook, keep in sync with Cargo.toml |
| 39 | + src = lib.fileset.toSource { |
| 40 | + root = ./.; |
| 41 | + fileset = lib.fileset.unions [ |
| 42 | + ./Cargo.toml |
| 43 | + ./Cargo.lock |
| 44 | + ./src |
| 45 | + ]; |
| 46 | + }; |
| 47 | + cargoHash = ""; |
| 48 | + cargoDeps = pkgs.rustPlatform.fetchCargoVendor { |
| 49 | + inherit (final) src; |
| 50 | + hash = "sha256-C/fuxQgxiuySGvYOPRSKyXvJP6RCFTPG8seqWjjT8fs="; |
| 51 | + }; |
| 52 | + meta = prev.meta // { |
| 53 | + broken = false; |
| 54 | + }; |
| 55 | + } |
| 56 | + ); |
| 57 | + |
| 58 | + # the nushell build we are currently supporting. Should loosely |
| 59 | + # follow the upstream nixpkgs build to ensure compatibility with the |
| 60 | + # latest version of nushell. Used for load-check. |
| 61 | + packages.nushell = pkgs.nushell.overrideAttrs rec { |
| 62 | + version = "0.112.2"; |
| 63 | + |
| 64 | + src = pkgs.fetchFromGitHub { |
| 65 | + owner = "nushell"; |
| 66 | + repo = "nushell"; |
| 67 | + tag = "${version}"; |
| 68 | + hash = "sha256-wc7mfbwkJO5gq9mwsiTVx74+btqU6Ox8tPhnXkfmXRU="; |
| 69 | + }; |
| 70 | + |
| 71 | + checkPhase = ""; |
| 72 | + doCheck = false; |
| 73 | + |
| 74 | + cargoDepsName = "nushell-${version}"; |
| 75 | + cargoHash = ""; |
| 76 | + |
| 77 | + cargoDeps = pkgs.rustPlatform.fetchCargoVendor { |
| 78 | + inherit src; |
| 79 | + hash = "sha256-KBDgICbdYcqgMLtUXWQsMPe1fO7zT4NcavAyS2i0cDc="; |
| 80 | + }; |
| 81 | + }; |
| 82 | + |
| 83 | + checks.default = |
| 84 | + pkgs.runCommand "test-load-${self'.packages.default.name}" |
| 85 | + { |
| 86 | + nativeBuildInputs = [ self'.packages.nushell ]; |
| 87 | + } |
| 88 | + '' |
| 89 | + touch $out |
| 90 | + nu --plugins ${lib.getExe self'.packages.default} --plugin-config $out -c 'dbus --help' |
| 91 | + ''; |
| 92 | + |
| 93 | + devShells.default = pkgs.mkShell { |
| 94 | + packages = with pkgs; [ |
| 95 | + cargo |
| 96 | + rustc |
| 97 | + dbus |
| 98 | + pkg-config |
| 99 | + self'.packages.nushell |
| 100 | + ]; |
| 101 | + }; |
| 102 | + }; |
| 103 | + }; |
| 104 | +} |
0 commit comments