Add Nix Flake (#77)
Browse files at this commit4 changed files +254 -1
- .gitignore +1 -0
- README.md +11 -1
- flake.lock +138 -0
- flake.nix +104 -0
.gitignoremodified+1 -0
| @@ -1 +1,2 @@ | ||
| 1 | 1 | /target |
| 2 | +/result |
README.mdmodified+11 -1
| @@ -36,7 +36,7 @@ When a monitor disconnects, its workspaces will move to another monitor, but upo | ||
| 36 | 36 | > [!TIP] |
| 37 | 37 | > For Fedora users, there's a COPR with built and packaged niri: https://copr.fedorainfracloud.org/coprs/yalter/niri/ |
| 38 | 38 | > |
| 39 | -> NixOS users, check out https://github.com/sodiboo/niri-flake | |
| 39 | +> For NixOS users, check out https://github.com/sodiboo/niri-flake | |
| 40 | 40 | |
| 41 | 41 | First, install the dependencies for your distribution. |
| 42 | 42 | |
| @@ -57,6 +57,16 @@ First, install the dependencies for your distribution. | ||
| 57 | 57 | |
| 58 | 58 | Next, build niri with `cargo build --release`. |
| 59 | 59 | |
| 60 | +### NixOS/Nix | |
| 61 | + | |
| 62 | +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`. | |
| 63 | + | |
| 64 | +If you're not on NixOS, you may need [NixGL](https://github.com/nix-community/nixGL) to run the resulting binary: | |
| 65 | + | |
| 66 | +``` | |
| 67 | +nix run --impure github:guibou/nixGL -- ./results/bin/niri | |
| 68 | +``` | |
| 69 | + | |
| 60 | 70 | ## Installation |
| 61 | 71 | |
| 62 | 72 | The recommended way to install and run niri is as a standalone desktop session. |
flake.lockadded+138 -0
| @@ -0,0 +1,138 @@ | ||
| 1 | +{ | |
| 2 | + "nodes": { | |
| 3 | + "crane": { | |
| 4 | + "inputs": { | |
| 5 | + "nixpkgs": [ | |
| 6 | + "nixpkgs" | |
| 7 | + ] | |
| 8 | + }, | |
| 9 | + "locked": { | |
| 10 | + "lastModified": 1702918879, | |
| 11 | + "narHash": "sha256-tWJqzajIvYcaRWxn+cLUB9L9Pv4dQ3Bfit/YjU5ze3g=", | |
| 12 | + "owner": "ipetkov", | |
| 13 | + "repo": "crane", | |
| 14 | + "rev": "7195c00c272fdd92fc74e7d5a0a2844b9fadb2fb", | |
| 15 | + "type": "github" | |
| 16 | + }, | |
| 17 | + "original": { | |
| 18 | + "owner": "ipetkov", | |
| 19 | + "repo": "crane", | |
| 20 | + "type": "github" | |
| 21 | + } | |
| 22 | + }, | |
| 23 | + "fenix": { | |
| 24 | + "inputs": { | |
| 25 | + "nixpkgs": [ | |
| 26 | + "nixpkgs" | |
| 27 | + ], | |
| 28 | + "rust-analyzer-src": "rust-analyzer-src" | |
| 29 | + }, | |
| 30 | + "locked": { | |
| 31 | + "lastModified": 1701411808, | |
| 32 | + "narHash": "sha256-K8QDx8UgbvGdENuvPvcsCXcd8brd55OkRDFLBT7xUVY=", | |
| 33 | + "owner": "nix-community", | |
| 34 | + "repo": "fenix", | |
| 35 | + "rev": "3776d0e2a30184cc6a0ba20fb86dc6df5b41fccd", | |
| 36 | + "type": "github" | |
| 37 | + }, | |
| 38 | + "original": { | |
| 39 | + "owner": "nix-community", | |
| 40 | + "ref": "monthly", | |
| 41 | + "repo": "fenix", | |
| 42 | + "type": "github" | |
| 43 | + } | |
| 44 | + }, | |
| 45 | + "flake-utils": { | |
| 46 | + "inputs": { | |
| 47 | + "systems": "systems" | |
| 48 | + }, | |
| 49 | + "locked": { | |
| 50 | + "lastModified": 1701680307, | |
| 51 | + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", | |
| 52 | + "owner": "numtide", | |
| 53 | + "repo": "flake-utils", | |
| 54 | + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", | |
| 55 | + "type": "github" | |
| 56 | + }, | |
| 57 | + "original": { | |
| 58 | + "owner": "numtide", | |
| 59 | + "repo": "flake-utils", | |
| 60 | + "type": "github" | |
| 61 | + } | |
| 62 | + }, | |
| 63 | + "nix-filter": { | |
| 64 | + "locked": { | |
| 65 | + "lastModified": 1701697642, | |
| 66 | + "narHash": "sha256-L217WytWZHSY8GW9Gx1A64OnNctbuDbfslaTEofXXRw=", | |
| 67 | + "owner": "numtide", | |
| 68 | + "repo": "nix-filter", | |
| 69 | + "rev": "c843418ecfd0344ecb85844b082ff5675e02c443", | |
| 70 | + "type": "github" | |
| 71 | + }, | |
| 72 | + "original": { | |
| 73 | + "owner": "numtide", | |
| 74 | + "repo": "nix-filter", | |
| 75 | + "type": "github" | |
| 76 | + } | |
| 77 | + }, | |
| 78 | + "nixpkgs": { | |
| 79 | + "locked": { | |
| 80 | + "lastModified": 1702900294, | |
| 81 | + "narHash": "sha256-pt7sSoJYNw3n8YtXw0Z/Nnr6/PfY2YrjDvqboErXnRM=", | |
| 82 | + "owner": "NixOS", | |
| 83 | + "repo": "nixpkgs", | |
| 84 | + "rev": "886c9aee6ca9324e127f9c2c4e6f68c2641c8256", | |
| 85 | + "type": "github" | |
| 86 | + }, | |
| 87 | + "original": { | |
| 88 | + "owner": "NixOS", | |
| 89 | + "ref": "nixpkgs-unstable", | |
| 90 | + "repo": "nixpkgs", | |
| 91 | + "type": "github" | |
| 92 | + } | |
| 93 | + }, | |
| 94 | + "root": { | |
| 95 | + "inputs": { | |
| 96 | + "crane": "crane", | |
| 97 | + "fenix": "fenix", | |
| 98 | + "flake-utils": "flake-utils", | |
| 99 | + "nix-filter": "nix-filter", | |
| 100 | + "nixpkgs": "nixpkgs" | |
| 101 | + } | |
| 102 | + }, | |
| 103 | + "rust-analyzer-src": { | |
| 104 | + "flake": false, | |
| 105 | + "locked": { | |
| 106 | + "lastModified": 1701372675, | |
| 107 | + "narHash": "sha256-MSHhnAoLjJuoPxzsTzBOzNhjhlCTHPs4nvkPAZVV1eY=", | |
| 108 | + "owner": "rust-lang", | |
| 109 | + "repo": "rust-analyzer", | |
| 110 | + "rev": "c9d189d1375e59a6c9b4d62fdede94ade001f6ee", | |
| 111 | + "type": "github" | |
| 112 | + }, | |
| 113 | + "original": { | |
| 114 | + "owner": "rust-lang", | |
| 115 | + "ref": "nightly", | |
| 116 | + "repo": "rust-analyzer", | |
| 117 | + "type": "github" | |
| 118 | + } | |
| 119 | + }, | |
| 120 | + "systems": { | |
| 121 | + "locked": { | |
| 122 | + "lastModified": 1681028828, | |
| 123 | + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", | |
| 124 | + "owner": "nix-systems", | |
| 125 | + "repo": "default", | |
| 126 | + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", | |
| 127 | + "type": "github" | |
| 128 | + }, | |
| 129 | + "original": { | |
| 130 | + "owner": "nix-systems", | |
| 131 | + "repo": "default", | |
| 132 | + "type": "github" | |
| 133 | + } | |
| 134 | + } | |
| 135 | + }, | |
| 136 | + "root": "root", | |
| 137 | + "version": 7 | |
| 138 | +} |
flake.nixadded+104 -0
| @@ -0,0 +1,104 @@ | ||
| 1 | +# This flake file is community maintained | |
| 2 | +# Maintainers: | |
| 3 | +# Bill Sun (github/billksun) | |
| 4 | +{ | |
| 5 | + description = "Niri: A scrollable-tiling Wayland compositor."; | |
| 6 | + | |
| 7 | + inputs = { | |
| 8 | + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | |
| 9 | + crane = { | |
| 10 | + url = "github:ipetkov/crane"; | |
| 11 | + inputs.nixpkgs.follows = "nixpkgs"; | |
| 12 | + }; | |
| 13 | + flake-utils.url = "github:numtide/flake-utils"; | |
| 14 | + nix-filter.url = "github:numtide/nix-filter"; | |
| 15 | + fenix = { | |
| 16 | + url = "github:nix-community/fenix/monthly"; | |
| 17 | + inputs.nixpkgs.follows = "nixpkgs"; | |
| 18 | + }; | |
| 19 | + }; | |
| 20 | + | |
| 21 | + outputs = { | |
| 22 | + self, | |
| 23 | + nixpkgs, | |
| 24 | + crane, | |
| 25 | + nix-filter, | |
| 26 | + flake-utils, | |
| 27 | + fenix, | |
| 28 | + ... | |
| 29 | + }: let | |
| 30 | + systems = ["aarch64-linux" "x86_64-linux"]; | |
| 31 | + in | |
| 32 | + flake-utils.lib.eachSystem systems ( | |
| 33 | + system: let | |
| 34 | + pkgs = nixpkgs.legacyPackages.${system}; | |
| 35 | + toolchain = fenix.packages.${system}.complete.toolchain; | |
| 36 | + craneLib = crane.lib.${system}.overrideToolchain toolchain; | |
| 37 | + | |
| 38 | + craneArgs = { | |
| 39 | + pname = "niri"; | |
| 40 | + version = self.rev or "dirty"; | |
| 41 | + | |
| 42 | + src = nix-filter.lib.filter { | |
| 43 | + root = ./.; | |
| 44 | + include = [ | |
| 45 | + ./src | |
| 46 | + ./niri-config | |
| 47 | + ./Cargo.toml | |
| 48 | + ./Cargo.lock | |
| 49 | + ./resources | |
| 50 | + ]; | |
| 51 | + }; | |
| 52 | + | |
| 53 | + nativeBuildInputs = with pkgs; [ | |
| 54 | + pkg-config | |
| 55 | + autoPatchelfHook | |
| 56 | + clang | |
| 57 | + ]; | |
| 58 | + | |
| 59 | + buildInputs = with pkgs; [ | |
| 60 | + wayland | |
| 61 | + systemd # For libudev | |
| 62 | + seatd # For libseat | |
| 63 | + libxkbcommon | |
| 64 | + libinput | |
| 65 | + mesa # For libgbm | |
| 66 | + fontconfig | |
| 67 | + stdenv.cc.cc.lib | |
| 68 | + pipewire | |
| 69 | + ]; | |
| 70 | + | |
| 71 | + runtimeDependencies = with pkgs; [ | |
| 72 | + wayland | |
| 73 | + mesa | |
| 74 | + libglvnd # For libEGL | |
| 75 | + ]; | |
| 76 | + | |
| 77 | + LIBCLANG_PATH = "${pkgs.libclang.lib}/lib"; | |
| 78 | + }; | |
| 79 | + | |
| 80 | + cargoArtifacts = craneLib.buildDepsOnly craneArgs; | |
| 81 | + niri = craneLib.buildPackage (craneArgs // {inherit cargoArtifacts;}); | |
| 82 | + in { | |
| 83 | + formatter = pkgs.alejandra; | |
| 84 | + | |
| 85 | + checks.niri = niri; | |
| 86 | + packages.default = niri; | |
| 87 | + | |
| 88 | + devShells.default = pkgs.mkShell.override {stdenv = pkgs.clangStdenv;} { | |
| 89 | + inherit (niri) nativeBuildInputs buildInputs LIBCLANG_PATH; | |
| 90 | + packages = niri.runtimeDependencies; | |
| 91 | + | |
| 92 | + # Force linking to libEGL, which is always dlopen()ed, and to | |
| 93 | + # libwayland-client, which is always dlopen()ed except by the | |
| 94 | + # obscure winit backend. | |
| 95 | + RUSTFLAGS = map (a: "-C link-arg=${a}") [ | |
| 96 | + "-Wl,--push-state,--no-as-needed" | |
| 97 | + "-lEGL" | |
| 98 | + "-lwayland-client" | |
| 99 | + "-Wl,--pop-state" | |
| 100 | + ]; | |
| 101 | + }; | |
| 102 | + } | |
| 103 | + ); | |
| 104 | +} |