From e06416f048b99d1b96d7cb2b1990198ce1b5b407 Mon Sep 17 00:00:00 2001 From: Leon Vack Date: Thu, 11 Apr 2024 20:33:06 +0200 Subject: [PATCH] Replace shell.nix with a updated flake.nix --- README.md | 5 +-- flake.lock | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 59 +++++++++++++++++++++++++++++++ shell.nix | 27 --------------- 4 files changed, 162 insertions(+), 29 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix delete mode 100644 shell.nix diff --git a/README.md b/README.md index 2beaf3e..68f4855 100644 --- a/README.md +++ b/README.md @@ -63,8 +63,9 @@ You will need: ```sh sudo apt install libwayland-dev libxkbcommon-dev libudev-dev libinput-dev libgdm-dev libseat-dev xwayland ``` - - NixOS: There is ~~a really old~~ an ancient [`shell.nix`](shell.nix) that ~~may or may~~ absolutely does not work :skull: - If you happen to know some Nix any PRs are welcome! + - NixOS: There is flake [`flake.nix`](flake.nix) with a devShell. It also + includes the other tools needed for the build and sets up the + `LD_LIBRARY_PATH` so the dynamically loaded libraries are found. - [protoc](https://grpc.io/docs/protoc-installation/), the Protocol Buffer Compiler, for configuration - Arch: ```sh diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..9fb6427 --- /dev/null +++ b/flake.lock @@ -0,0 +1,100 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1712816664, + "narHash": "sha256-kPIVs2ATag+gm1CiWCJ+qcVQVR89w2eh/Cg4g1Xph70=", + "owner": "nix-community", + "repo": "fenix", + "rev": "94f8df6a8e52447af72a1a0008eccf4a099b6d25", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1712741485, + "narHash": "sha256-bCs0+MSTra80oXAsnM6Oq62WsirOIaijQ/BbUY59tR4=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b2cf36f43f9ef2ded5711b30b1f393ac423d8f72", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "fenix": "fenix", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1712663608, + "narHash": "sha256-tN9ZL6kGppmHg84lxlpAlaN+kXWNctKK7Yitq/iXDEw=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "a5feb4f05f09adca661c869b1bf2324898cbaa43", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..85320a1 --- /dev/null +++ b/flake.nix @@ -0,0 +1,59 @@ +{ + description = " A WIP Smithay-based Wayland compositor, inspired by AwesomeWM and configured in Lua or Rust"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11"; + + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = + { + nixpkgs, + flake-utils, + fenix, + ... + }: + flake-utils.lib.eachSystem + [ + "x86_64-linux" + "aarch64-linux" + ] + ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + fenixPkgs = fenix.packages.${system}; + toolchain = fenixPkgs.stable; + combinedToolchain = toolchain.completeToolchain; + in + { + devShell = pkgs.mkShell { + buildInputs = [ + # rust devel tools + combinedToolchain + pkgs.rust-analyzer + pkgs.cargo-outdated + + # build time stuff + pkgs.pkg-config + pkgs.protobuf + pkgs.luarocks + + # libs + pkgs.seatd.dev + pkgs.systemdLibs.dev + pkgs.libxkbcommon + pkgs.libinput + pkgs.mesa + ]; + LD_LIBRARY_PATH = "${pkgs.wayland}/lib:${pkgs.libGL}/lib"; + }; + } + ); +} diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 6834c9c..0000000 --- a/shell.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ pkgs ? import {} }: -pkgs.mkShell { - buildInputs = [ - pkgs.gcc - pkgs.pkg-config - pkgs.systemd - pkgs.seatd - pkgs.wayland - pkgs.libxkbcommon - pkgs.mesa - pkgs.libinput - pkgs.xorg.libX11 - pkgs.xorg.libXcursor - pkgs.xorg.libXrandr - pkgs.xorg.libXi - pkgs.libglvnd - pkgs.libGL - pkgs.libGL.dev - pkgs.egl-wayland - pkgs.xwayland - ]; - shellHook = '' - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.wayland}/lib:${pkgs.libxkbcommon}/lib:${pkgs.libGL}/lib - export LUA_PATH="$LUA_PATH" - export LUA_CPATH="$LUA_CPATH" - ''; -}