diff --git a/default.nix b/default.nix index 1187144..57fefea 100644 --- a/default.nix +++ b/default.nix @@ -1,32 +1,32 @@ -{ pkgs ? import { } }: -let manifest = (pkgs.lib.importTOML ./Cargo.toml).package; - packages = with pkgs; [ - pkg-config - libGLU - libGL - libxkbcommon - wayland - ]; +{pkgs ? import {}}: let + manifest = (pkgs.lib.importTOML ./Cargo.toml).package; + packages = with pkgs; [ + pkg-config + libGLU + libGL + libxkbcommon + wayland + ]; in -pkgs.rustPlatform.buildRustPackage rec { - pname = manifest.name; - version = manifest.version; - cargoLock.lockFile = ./Cargo.lock; - src = pkgs.lib.cleanSource ./.; + pkgs.rustPlatform.buildRustPackage { + pname = manifest.name; + version = manifest.version; + cargoLock.lockFile = ./Cargo.lock; + src = pkgs.lib.cleanSource ./.; - meta = { - description = manifest.description ? null; - }; - postBuild = '' - patchelf --add-needed libxkbcommon.so target/x86_64-unknown-linux-gnu/release/todoodoo - patchelf --add-needed libwayland-client.so target/x86_64-unknown-linux-gnu/release/todoodoo - patchelf --add-needed libGLU.so target/x86_64-unknown-linux-gnu/release/todoodoo - patchelf --add-needed libEGL.so target/x86_64-unknown-linux-gnu/release/todoodoo - old_rpath=$(patchelf --print-rpath target/x86_64-unknown-linux-gnu/release/todoodoo) - if [[ -z "$old_rpath" ]]; then - patchelf --set-rpath "${pkgs.lib.makeLibraryPath packages}" target/x86_64-unknown-linux-gnu/release/todoodoo - else - patchelf --set-rpath "${pkgs.lib.makeLibraryPath packages}:$old_rpath" target/x86_64-unknown-linux-gnu/release/todoodoo - fi - ''; -} + meta = { + description = manifest.description ? null; + }; + postBuild = '' + patchelf --add-needed libxkbcommon.so target/x86_64-unknown-linux-gnu/release/todoodoo + patchelf --add-needed libwayland-client.so target/x86_64-unknown-linux-gnu/release/todoodoo + patchelf --add-needed libGLU.so target/x86_64-unknown-linux-gnu/release/todoodoo + patchelf --add-needed libEGL.so target/x86_64-unknown-linux-gnu/release/todoodoo + old_rpath=$(patchelf --print-rpath target/x86_64-unknown-linux-gnu/release/todoodoo) + if [[ -z "$old_rpath" ]]; then + patchelf --set-rpath "${pkgs.lib.makeLibraryPath packages}" target/x86_64-unknown-linux-gnu/release/todoodoo + else + patchelf --set-rpath "${pkgs.lib.makeLibraryPath packages}:$old_rpath" target/x86_64-unknown-linux-gnu/release/todoodoo + fi + ''; + } diff --git a/flake.nix b/flake.nix index ee9424b..af890c9 100644 --- a/flake.nix +++ b/flake.nix @@ -3,18 +3,20 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; }; - outputs = { self, nixpkgs }: - let - supportedSystems = [ "x86_64-linux" ]; - forAllSystems = nixpkgs.lib.genAttrs supportedSystems; - pkgsFor = nixpkgs.legacyPackages; - in { - packages = forAllSystems (system: { - default = pkgsFor.${system}.callPackage ./default.nix { }; - }); - devShells = forAllSystems (system: { - default = pkgsFor.${system}.callPackage ./shell.nix { }; - }); - }; + outputs = { + self, + nixpkgs, + }: let + supportedSystems = ["x86_64-linux"]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + pkgsFor = nixpkgs.legacyPackages; + in { + formatter = forAllSystems (system: pkgsFor.${system}.alejandra); + packages = forAllSystems (system: { + default = pkgsFor.${system}.callPackage ./default.nix {}; + }); + devShells = forAllSystems (system: { + default = pkgsFor.${system}.callPackage ./shell.nix {}; + }); + }; } - diff --git a/shell.nix b/shell.nix index 6dbfb37..08cffe6 100644 --- a/shell.nix +++ b/shell.nix @@ -1,5 +1,8 @@ -{ pkgs ? import { }, lib }: -let packages = with pkgs; [ +{ + pkgs ? import {}, + lib, +}: let + packages = with pkgs; [ rust-analyzer rustfmt clippy @@ -12,18 +15,17 @@ let packages = with pkgs; [ libGLU libGL libxkbcommon - + wayland ]; in -pkgs.mkShell { - # Get dependencies from the main package - inputsFrom = [ (pkgs.callPackage ./default.nix { }) ]; - nativeBuildInputs = packages; - buildInputs = packages; - env = { - LIBCLANG_PATH = "${pkgs.libclang.lib}/lib"; - LD_LIBRARY_PATH = "${lib.makeLibraryPath packages}"; - }; -} - + pkgs.mkShell { + # Get dependencies from the main package + inputsFrom = [(pkgs.callPackage ./default.nix {})]; + nativeBuildInputs = packages; + buildInputs = packages; + env = { + LIBCLANG_PATH = "${pkgs.libclang.lib}/lib"; + LD_LIBRARY_PATH = "${lib.makeLibraryPath packages}"; + }; + }