From 4c2c4941cdd3dcf15dc9a9f27f628ef4ce6fd16f Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 19 Mar 2024 03:11:54 +0300 Subject: [PATCH] nix: build with nix; move toolchain out of root --- flake.nix | 6 ++++- nix/package.nix | 45 ++++++++++++++++++++++++++++++++++++++ shell.nix => nix/shell.nix | 0 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 nix/package.nix rename shell.nix => nix/shell.nix (100%) diff --git a/flake.nix b/flake.nix index f142379..981598e 100644 --- a/flake.nix +++ b/flake.nix @@ -8,7 +8,11 @@ pkgsForEach = nixpkgs.legacyPackages; in { devShells = forEachSystem (system: { - default = pkgsForEach.${system}.callPackage ./shell.nix {}; + default = pkgsForEach.${system}.callPackage ./nix/shell.nix {}; + }); + + packages = forEachSystem (system: { + default = pkgsForEach.${system}.callPackage ./nix/package.nix {}; }); }; } diff --git a/nix/package.nix b/nix/package.nix new file mode 100644 index 0000000..5a07b4a --- /dev/null +++ b/nix/package.nix @@ -0,0 +1,45 @@ +{ + lib, + dbus, + python3, + pkg-config, + rustPlatform, + xorg, + rev ? "dirty", +}: let + cargoToml = builtins.fromTOML (builtins.readFile ../Cargo.toml); +in + rustPlatform.buildRustPackage { + pname = "tailray"; + version = "${cargoToml.package.version}-${rev}"; + + src = lib.fileset.toSource { + root = ../.; + fileset = + lib.fileset.intersection + (lib.fileset.fromSource (lib.sources.cleanSource ../.)) + (lib.fileset.unions [ + ../src + ../Cargo.toml + ../Cargo.lock + ]); + }; + + cargoLock.lockFile = ../Cargo.lock; + + strictDeps = true; + + buildInputs = [dbus xorg.libxcb]; + nativeBuildInputs = [ + pkg-config + python3 + ]; + + meta = { + description = "Rust implementation of tailscale-systray"; + homepage = "https://github.com/notashelf/tailray"; + license = lib.licenses.gpl3Plus; + mainProgram = "tailray"; + maintainers = with lib.maintainers; [NotAShelf]; + }; + } diff --git a/shell.nix b/nix/shell.nix similarity index 100% rename from shell.nix rename to nix/shell.nix