Restructure flake.nix for static compilation (#86)

* Expose bluetui package in legacyPackages

* git ignore result directory for nix build

* Treat result as a file in gitignore
This commit is contained in:
Dalton Caron
2025-10-30 08:55:44 -07:00
committed by GitHub
parent 4138691b5b
commit be97a3a757
3 changed files with 32 additions and 20 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
/target
.direnv/
result

View File

@@ -19,6 +19,7 @@
system: let
overlays = [(import rust-overlay)];
pkgs = import nixpkgs {inherit system overlays;};
bluetui = pkgs.callPackage ./package.nix {};
in {
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
@@ -28,28 +29,13 @@
self.packages.${system}.default
];
};
packages = rec {
packages = {
default = bluetui;
bluetui = let
cargo = (pkgs.lib.importTOML ./Cargo.toml).package;
in
pkgs.rustPlatform.buildRustPackage {
pname = cargo.name;
version = cargo.version;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
buildInputs = with pkgs; [dbus];
nativeBuildInputs = with pkgs; [pkg-config];
meta = {
description = cargo.description;
homepage = cargo.homepage;
license = pkgs.lib.licenses.gpl3Only;
maintainers = with pkgs.lib.maintainers; [samuel-martineau];
};
};
inherit bluetui;
};
legacyPackages = pkgs.extend(final: prev: {
bluetui = final.callPackage ./package.nix {};
});
}
);
}

25
package.nix Normal file
View File

@@ -0,0 +1,25 @@
{
lib,
rustPlatform,
dbus,
pkg-config,
}:
let
cargo = lib.importTOML ./Cargo.toml;
in
rustPlatform.buildRustPackage {
pname = cargo.package.name;
version = cargo.package.version;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
buildInputs = [dbus];
nativeBuildInputs = [pkg-config];
meta = {
description = cargo.package.description;
homepage = cargo.package.homepage;
license = lib.licenses.gpl3Only;
maintainers = with lib.maintainers; [samuel-martineau];
};
}