Skip to content

Commit 8e88206

Browse files
committed
ci: nix flake
- Keeps track of a certain nushell build that is used for testing out the plugin - Builds the repo using the upstream nixpkgs definition - Check that the plugin builds/loads with `nix flake check` - Formats the tree using nixfmt and rustfmt
1 parent 89865e3 commit 8e88206

3 files changed

Lines changed: 201 additions & 0 deletions

File tree

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ target/
1313
# Added by cargo
1414

1515
/target
16+
17+
# nix-related
18+
/.direnv
19+
/.envrc
20+
/result*
21+
/repl-result*

flake.lock

Lines changed: 98 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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.nushellPlugins.dbus.overrideAttrs (
37+
_final: prev: rec {
38+
version = "0.15.0"; # used by versionCheckHook, keep in sync with Cargo.toml
39+
src = ./.;
40+
cargoHash = "";
41+
cargoDeps = pkgs.rustPlatform.fetchCargoVendor {
42+
inherit src;
43+
hash = "sha256-JIEAbzrcfthYSjnyUWEIgNof5SI+EwO4uYflVDMfVE0=";
44+
};
45+
meta = prev.meta // {
46+
broken = false;
47+
};
48+
}
49+
);
50+
51+
# the nushell build we are currently supporting. Should loosely
52+
# follow the upstream nixpkgs build to ensure compatibility with the
53+
# latest version of nushell. Used for load-check.
54+
packages.nushell = pkgs.nushell.overrideAttrs rec {
55+
version = "0.109.1";
56+
57+
src = pkgs.fetchFromGitHub {
58+
owner = "nushell";
59+
repo = "nushell";
60+
tag = "${version}";
61+
hash = "sha256-XNDEfmvmUNS90PU4e/EWFyJeg428R8nFPJHpF3tgRWo=";
62+
};
63+
64+
checkPhase = "";
65+
doCheck = false;
66+
67+
cargoDepsName = "nushell-${version}";
68+
cargoHash = "";
69+
70+
cargoDeps = pkgs.rustPlatform.fetchCargoVendor {
71+
inherit src;
72+
hash = "sha256-UX0WmvrzrWlrTnvMqaWAxoSie7RzQSC4thEb26LAz+A=";
73+
};
74+
};
75+
76+
checks.default =
77+
pkgs.runCommand "test-load-${self'.packages.default.name}"
78+
{
79+
nativeBuildInputs = [ self'.packages.nushell ];
80+
}
81+
''
82+
touch $out
83+
nu --plugins '[${lib.getExe self'.packages.default}]' --plugin-config $out -c 'dbus --help'
84+
'';
85+
86+
devShells.default = pkgs.mkShell {
87+
packages = with pkgs; [
88+
pkgs.cargo
89+
pkgs.rustc
90+
dbus
91+
pkg-config
92+
self'.packages.nushell
93+
];
94+
};
95+
};
96+
};
97+
}

0 commit comments

Comments
 (0)