aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Sun <billksun@gmail.com>2024-01-10 22:43:46 -0800
committerGitHub <noreply@github.com>2024-01-10 22:43:46 -0800
commit236abd9d9da14d614f9f36f1469ff90f441ba167 (patch)
tree45905d916fec45f683fc1a76975cccf77750ff0d
parentb2df3e104f2375af10c0f891eb82253545b952e1 (diff)
downloadniri-236abd9d9da14d614f9f36f1469ff90f441ba167.tar.gz
niri-236abd9d9da14d614f9f36f1469ff90f441ba167.tar.bz2
niri-236abd9d9da14d614f9f36f1469ff90f441ba167.zip
Add Nix Flake (#77)
* Add Nix Flake Co-authored-by: Bryce Berger <bryce.z.berger@gmail.com> * Describe nix flake in readme * Add `niri-config` to build source list * Add maintainer info Add comment at top to indicate the Nix Flake file is community maintained. * Clarify Nix/NixOS README instructions * Shorten Nix/NixOS build instructions Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com> * Move NixOS installation instruction to "Tip" section --------- Co-authored-by: Bryce Berger <bryce.z.berger@gmail.com> Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
-rw-r--r--.gitignore1
-rw-r--r--README.md12
-rw-r--r--flake.lock138
-rw-r--r--flake.nix104
4 files changed, 254 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index ea8c4bf7..d787b706 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
/target
+/result
diff --git a/README.md b/README.md
index 1f49ae76..77436afb 100644
--- a/README.md
+++ b/README.md
@@ -36,7 +36,7 @@ When a monitor disconnects, its workspaces will move to another monitor, but upo
> [!TIP]
> For Fedora users, there's a COPR with built and packaged niri: https://copr.fedorainfracloud.org/coprs/yalter/niri/
>
-> NixOS users, check out https://github.com/sodiboo/niri-flake
+> For NixOS users, check out https://github.com/sodiboo/niri-flake
First, install the dependencies for your distribution.
@@ -57,6 +57,16 @@ First, install the dependencies for your distribution.
Next, build niri with `cargo build --release`.
+### NixOS/Nix
+
+We have a community-maintained flake which provides a devshell with required dependencies. Use `nix build` to build niri, and then run `./results/bin/niri`.
+
+If you're not on NixOS, you may need [NixGL](https://github.com/nix-community/nixGL) to run the resulting binary:
+
+```
+nix run --impure github:guibou/nixGL -- ./results/bin/niri
+```
+
## Installation
The recommended way to install and run niri is as a standalone desktop session.
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 00000000..bdf52d54
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,138 @@
+{
+ "nodes": {
+ "crane": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1702918879,
+ "narHash": "sha256-tWJqzajIvYcaRWxn+cLUB9L9Pv4dQ3Bfit/YjU5ze3g=",
+ "owner": "ipetkov",
+ "repo": "crane",
+ "rev": "7195c00c272fdd92fc74e7d5a0a2844b9fadb2fb",
+ "type": "github"
+ },
+ "original": {
+ "owner": "ipetkov",
+ "repo": "crane",
+ "type": "github"
+ }
+ },
+ "fenix": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ],
+ "rust-analyzer-src": "rust-analyzer-src"
+ },
+ "locked": {
+ "lastModified": 1701411808,
+ "narHash": "sha256-K8QDx8UgbvGdENuvPvcsCXcd8brd55OkRDFLBT7xUVY=",
+ "owner": "nix-community",
+ "repo": "fenix",
+ "rev": "3776d0e2a30184cc6a0ba20fb86dc6df5b41fccd",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-community",
+ "ref": "monthly",
+ "repo": "fenix",
+ "type": "github"
+ }
+ },
+ "flake-utils": {
+ "inputs": {
+ "systems": "systems"
+ },
+ "locked": {
+ "lastModified": 1701680307,
+ "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "nix-filter": {
+ "locked": {
+ "lastModified": 1701697642,
+ "narHash": "sha256-L217WytWZHSY8GW9Gx1A64OnNctbuDbfslaTEofXXRw=",
+ "owner": "numtide",
+ "repo": "nix-filter",
+ "rev": "c843418ecfd0344ecb85844b082ff5675e02c443",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "nix-filter",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1702900294,
+ "narHash": "sha256-pt7sSoJYNw3n8YtXw0Z/Nnr6/PfY2YrjDvqboErXnRM=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "886c9aee6ca9324e127f9c2c4e6f68c2641c8256",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixpkgs-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "crane": "crane",
+ "fenix": "fenix",
+ "flake-utils": "flake-utils",
+ "nix-filter": "nix-filter",
+ "nixpkgs": "nixpkgs"
+ }
+ },
+ "rust-analyzer-src": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1701372675,
+ "narHash": "sha256-MSHhnAoLjJuoPxzsTzBOzNhjhlCTHPs4nvkPAZVV1eY=",
+ "owner": "rust-lang",
+ "repo": "rust-analyzer",
+ "rev": "c9d189d1375e59a6c9b4d62fdede94ade001f6ee",
+ "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 00000000..3dd31050
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,104 @@
+# This flake file is community maintained
+# Maintainers:
+# Bill Sun (github/billksun)
+{
+ description = "Niri: A scrollable-tiling Wayland compositor.";
+
+ inputs = {
+ nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+ crane = {
+ url = "github:ipetkov/crane";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+ flake-utils.url = "github:numtide/flake-utils";
+ nix-filter.url = "github:numtide/nix-filter";
+ fenix = {
+ url = "github:nix-community/fenix/monthly";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+ };
+
+ outputs = {
+ self,
+ nixpkgs,
+ crane,
+ nix-filter,
+ flake-utils,
+ fenix,
+ ...
+ }: let
+ systems = ["aarch64-linux" "x86_64-linux"];
+ in
+ flake-utils.lib.eachSystem systems (
+ system: let
+ pkgs = nixpkgs.legacyPackages.${system};
+ toolchain = fenix.packages.${system}.complete.toolchain;
+ craneLib = crane.lib.${system}.overrideToolchain toolchain;
+
+ craneArgs = {
+ pname = "niri";
+ version = self.rev or "dirty";
+
+ src = nix-filter.lib.filter {
+ root = ./.;
+ include = [
+ ./src
+ ./niri-config
+ ./Cargo.toml
+ ./Cargo.lock
+ ./resources
+ ];
+ };
+
+ nativeBuildInputs = with pkgs; [
+ pkg-config
+ autoPatchelfHook
+ clang
+ ];
+
+ buildInputs = with pkgs; [
+ wayland
+ systemd # For libudev
+ seatd # For libseat
+ libxkbcommon
+ libinput
+ mesa # For libgbm
+ fontconfig
+ stdenv.cc.cc.lib
+ pipewire
+ ];
+
+ runtimeDependencies = with pkgs; [
+ wayland
+ mesa
+ libglvnd # For libEGL
+ ];
+
+ LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
+ };
+
+ cargoArtifacts = craneLib.buildDepsOnly craneArgs;
+ niri = craneLib.buildPackage (craneArgs // {inherit cargoArtifacts;});
+ in {
+ formatter = pkgs.alejandra;
+
+ checks.niri = niri;
+ packages.default = niri;
+
+ devShells.default = pkgs.mkShell.override {stdenv = pkgs.clangStdenv;} {
+ inherit (niri) nativeBuildInputs buildInputs LIBCLANG_PATH;
+ packages = niri.runtimeDependencies;
+
+ # Force linking to libEGL, which is always dlopen()ed, and to
+ # libwayland-client, which is always dlopen()ed except by the
+ # obscure winit backend.
+ RUSTFLAGS = map (a: "-C link-arg=${a}") [
+ "-Wl,--push-state,--no-as-needed"
+ "-lEGL"
+ "-lwayland-client"
+ "-Wl,--pop-state"
+ ];
+ };
+ }
+ );
+}