Skip to content

Commit 0f5ca33

Browse files
committed
bitte-cli: make devshell actually useful
Move the package and source under the expected `std` path and replace it with a symlink so that I can reference it from the automation cell allowing me to wire up the `RUST_SRC_PATH` so rust-anaylzer works as expected and the rust toolchain is available. Also move `.envrc` under this directory since it is only useful when working on the cli.
1 parent cf6b88f commit 0f5ca33

File tree

19 files changed

+104
-74
lines changed

19 files changed

+104
-74
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
result*
99

1010
# cargo
11-
cli/target
11+
target
1212

1313
# misc
1414
*.swp

cli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nix/cli/packages/cli

cli/package.nix

Lines changed: 0 additions & 56 deletions
This file was deleted.

flake.nix

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
cellsFrom = ./nix;
6262
organelles = [
6363
(inputs.std.devshells "devshells")
64+
(inputs.std.installables "packages")
6465

6566
# ----------
6667
# NixOS: Modules, Profiles, Aggregates
@@ -112,8 +113,6 @@
112113
inherit (nixpkgs) lib;
113114
inherit inputs;
114115
};
115-
116-
toolchain = "stable";
117116
in
118117
utils.lib.eachSystem [
119118
"aarch64-darwin"
@@ -123,17 +122,10 @@
123122
] (system: let
124123
legacyPackages = pkgsForSystem system;
125124
unstablePackages = unstablePkgsForSystem system;
126-
rustPkg = unstablePackages.fenix."${toolchain}".withComponents [
127-
"cargo"
128-
"clippy"
129-
"rust-src"
130-
"rustc"
131-
"rustfmt"
132-
];
133125
in rec {
134126
inherit legacyPackages;
135127

136-
packages.bitte = unstablePackages.callPackage ./cli/package.nix {inherit toolchain;};
128+
packages = {inherit (self.${system}.cli.packages) bitte;};
137129
defaultPackage = packages.bitte;
138130

139131
hydraJobs = let

nix/automation/devshells.nix

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44
}: let
55
inherit (inputs.std) std;
66
inherit (inputs) capsules nixpkgs;
7+
inherit (inputs.cells.cli.packages) bitte;
8+
inherit (bitte) rustPkg rustPlatform;
79
l = nixpkgs.lib // builtins;
810

911
rust-dev-pkgs =
1012
[
11-
nixpkgs.openssl
1213
nixpkgs.zlib
1314
nixpkgs.pkg-config
14-
# rustPkg
15-
# rust-analyzer-nightly
15+
rustPkg
16+
bitte.rust-analyzer
1617
]
1718
++ l.optionals nixpkgs.stdenv.isDarwin (with nixpkgs.darwin;
1819
with nixpkgs.apple_sdk.frameworks; [
@@ -26,17 +27,26 @@
2627
in {
2728
default = std.lib.mkShell {
2829
packages = rust-dev-pkgs;
30+
language.rust = {
31+
packageSet = rustPlatform;
32+
enableDefaultToolchain = false;
33+
};
2934
env = [
3035
{
3136
name = "RUST_BACKTRACE";
3237
value = "1";
3338
}
34-
# {
35-
# name = "RUST_SRC_PATH";
36-
# value = "${rustPkg}/lib/rustlib/src/rust/library";
37-
# }
39+
{
40+
name = "RUST_SRC_PATH";
41+
value = "${rustPkg}/lib/rustlib/src/rust/library";
42+
}
43+
{
44+
name = "PKG_CONFIG_PATH";
45+
value = l.makeSearchPath "lib/pkgconfig" bitte.buildInputs;
46+
}
3847
];
3948
imports = [
49+
"${inputs.std.inputs.devshell}/extra/language/rust.nix"
4050
capsules.base
4151
capsules.tools
4252
capsules.integrations
File renamed without changes.

nix/cli/packages/cli/default.nix

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
stdenv,
3+
lib,
4+
pkg-config,
5+
openssl,
6+
zlib,
7+
makeRustPlatform,
8+
fenix,
9+
# darwin dependencies
10+
darwin,
11+
toolchain,
12+
}: let
13+
rustPlatform = makeRustPlatform {inherit (fenix.${toolchain}) cargo rustc;};
14+
15+
rustPkg = fenix."${toolchain}".withComponents [
16+
"cargo"
17+
"clippy"
18+
"rust-src"
19+
"rustc"
20+
"rustfmt"
21+
];
22+
in
23+
rustPlatform.buildRustPackage
24+
{
25+
inherit
26+
(with builtins; (fromTOML (readFile ./Cargo.toml)).package)
27+
name
28+
version
29+
;
30+
31+
src = lib.cleanSource ./.;
32+
cargoLock.lockFile = ./Cargo.lock;
33+
cargoLock.outputHashes = {
34+
"deploy-rs-0.1.0" = "sha256-cDFOojpoHdRt2NFM/39GPPjqARoVuy+yVk0/BgYHwv0=";
35+
};
36+
37+
nativeBuildInputs = [pkg-config];
38+
buildInputs =
39+
[openssl zlib]
40+
++ lib.optionals stdenv.isDarwin
41+
(with darwin.apple_sdk.frameworks; [
42+
SystemConfiguration
43+
Security
44+
CoreFoundation
45+
darwin.libiconv
46+
darwin.libresolv
47+
darwin.Libsystem
48+
]);
49+
50+
doCheck = false;
51+
52+
postInstall = ''
53+
export BITTE_CLUSTER=b
54+
export BITTE_PROVIDER=aws
55+
export BITTE_DOMAIN=b.b.b
56+
57+
mkdir -p $out/share/zsh/site-functions
58+
$out/bin/bitte comp zsh > $out/share/zsh/site-functions/_bitte
59+
60+
mkdir -p $out/share/bash-completion/completions
61+
$out/bin/bitte comp bash > $out/share/bash-completion/completions/bitte
62+
'';
63+
64+
passthru = {
65+
inherit rustPlatform rustPkg;
66+
inherit (fenix.${toolchain}) rust-src;
67+
inherit (fenix) rust-analyzer;
68+
};
69+
}
70+
// {
71+
meta.description = "A swiss knife for the bitte cluster";
72+
}

0 commit comments

Comments
 (0)