flake: add `overlay` output
Browse files at this commit1b44e0cd20b532a440bb571e4b823c95ac3e31fdParent: b3d4d4e1 changed file +128 -124
- flake.nix +128 -124
flake.nixmodified+128 -124
| @@ -81,132 +81,10 @@ | |||
| 81 | packages = forAllSystems ( | 81 | packages = forAllSystems ( |
| 82 | system: | 82 | system: |
| 83 | let | 83 | let |
| 84 | - inherit (self.packages.${system}) niri; | 84 | + inherit (self.overlays.default nixpkgsFor.${system} null) niri; |
| 85 | in | 85 | in |
| 86 | { | 86 | { |
| 87 | - niri = nixpkgsFor.${system}.callPackage ( | 87 | + inherit niri; |
| 88 | - { | ||
| 89 | - cairo, | ||
| 90 | - clang, | ||
| 91 | - dbus, | ||
| 92 | - libGL, | ||
| 93 | - libclang, | ||
| 94 | - libdisplay-info, | ||
| 95 | - libinput, | ||
| 96 | - libseat, | ||
| 97 | - libxkbcommon, | ||
| 98 | - mesa, | ||
| 99 | - pango, | ||
| 100 | - pipewire, | ||
| 101 | - pkg-config, | ||
| 102 | - rustPlatform, | ||
| 103 | - systemd, | ||
| 104 | - wayland, | ||
| 105 | - withDbus ? true, | ||
| 106 | - withSystemd ? true, | ||
| 107 | - withScreencastSupport ? true, | ||
| 108 | - withDinit ? false, | ||
| 109 | - }: | ||
| 110 | - | ||
| 111 | - rustPlatform.buildRustPackage { | ||
| 112 | - pname = "niri"; | ||
| 113 | - version = self.shortRev or self.dirtyShortRev or "unknown"; | ||
| 114 | - | ||
| 115 | - src = nix-filter.lib.filter { | ||
| 116 | - root = self; | ||
| 117 | - include = [ | ||
| 118 | - "niri-config" | ||
| 119 | - "niri-ipc" | ||
| 120 | - "niri-visual-tests" | ||
| 121 | - "resources" | ||
| 122 | - "src" | ||
| 123 | - ./Cargo.lock | ||
| 124 | - ./Cargo.toml | ||
| 125 | - ]; | ||
| 126 | - }; | ||
| 127 | - | ||
| 128 | - postPatch = '' | ||
| 129 | - patchShebangs resources/niri-session | ||
| 130 | - substituteInPlace resources/niri.service \ | ||
| 131 | - --replace-fail '/usr/bin' "$out/bin" | ||
| 132 | - ''; | ||
| 133 | - | ||
| 134 | - cargoLock = { | ||
| 135 | - # NOTE: This is only used for Git dependencies | ||
| 136 | - allowBuiltinFetchGit = true; | ||
| 137 | - lockFile = ./Cargo.lock; | ||
| 138 | - }; | ||
| 139 | - | ||
| 140 | - strictDeps = true; | ||
| 141 | - | ||
| 142 | - nativeBuildInputs = [ | ||
| 143 | - clang | ||
| 144 | - pkg-config | ||
| 145 | - ]; | ||
| 146 | - | ||
| 147 | - buildInputs = | ||
| 148 | - [ | ||
| 149 | - cairo | ||
| 150 | - dbus | ||
| 151 | - libGL | ||
| 152 | - libdisplay-info | ||
| 153 | - libinput | ||
| 154 | - libseat | ||
| 155 | - libxkbcommon | ||
| 156 | - mesa # libgbm | ||
| 157 | - pango | ||
| 158 | - wayland | ||
| 159 | - ] | ||
| 160 | - ++ lib.optional (withDbus || withScreencastSupport || withSystemd) dbus | ||
| 161 | - ++ lib.optional withScreencastSupport pipewire | ||
| 162 | - # Also includes libudev | ||
| 163 | - ++ lib.optional withSystemd systemd; | ||
| 164 | - | ||
| 165 | - buildFeatures = | ||
| 166 | - lib.optional withDbus "dbus" | ||
| 167 | - ++ lib.optional withDinit "dinit" | ||
| 168 | - ++ lib.optional withScreencastSupport "xdp-gnome-screencast" | ||
| 169 | - ++ lib.optional withSystemd "systemd"; | ||
| 170 | - buildNoDefaultFeatures = true; | ||
| 171 | - | ||
| 172 | - postInstall = | ||
| 173 | - '' | ||
| 174 | - install -Dm644 resources/niri.desktop -t $out/share/wayland-sessions | ||
| 175 | - install -Dm644 resources/niri-portals.conf -t $out/share/xdg-desktop-portal | ||
| 176 | - '' | ||
| 177 | - + lib.optionalString withSystemd '' | ||
| 178 | - install -Dm755 resources/niri-session $out/bin/niri-session | ||
| 179 | - install -Dm644 resources/niri{.service,-shutdown.target} -t $out/share/systemd/user | ||
| 180 | - ''; | ||
| 181 | - | ||
| 182 | - env = { | ||
| 183 | - LIBCLANG_PATH = lib.getLib libclang + "/lib"; | ||
| 184 | - | ||
| 185 | - # Force linking with libEGL and libwayland-client | ||
| 186 | - # so they can be discovered by `dlopen()` | ||
| 187 | - CARGO_BUILD_RUSTFLAGS = toString ( | ||
| 188 | - map (arg: "-C link-arg=" + arg) [ | ||
| 189 | - "-Wl,--push-state,--no-as-needed" | ||
| 190 | - "-lEGL" | ||
| 191 | - "-lwayland-client" | ||
| 192 | - "-Wl,--pop-state" | ||
| 193 | - ] | ||
| 194 | - ); | ||
| 195 | - }; | ||
| 196 | - | ||
| 197 | - passthru = { | ||
| 198 | - providedSessions = [ "niri" ]; | ||
| 199 | - }; | ||
| 200 | - | ||
| 201 | - meta = { | ||
| 202 | - description = "Scrollable-tiling Wayland compositor"; | ||
| 203 | - homepage = "https://github.com/YaLTeR/niri"; | ||
| 204 | - license = lib.licenses.gpl3Only; | ||
| 205 | - mainProgram = "niri"; | ||
| 206 | - platforms = lib.platforms.linux; | ||
| 207 | - }; | ||
| 208 | - } | ||
| 209 | - ) { }; | ||
| 210 | 88 | ||
| 211 | # NOTE: This is for development purposes only | 89 | # NOTE: This is for development purposes only |
| 212 | # | 90 | # |
| @@ -227,5 +105,131 @@ | |||
| 227 | default = niri; | 105 | default = niri; |
| 228 | } | 106 | } |
| 229 | ); | 107 | ); |
| 108 | + | ||
| 109 | + overlays.default = final: _: { | ||
| 110 | + niri = final.callPackage ( | ||
| 111 | + { | ||
| 112 | + cairo, | ||
| 113 | + clang, | ||
| 114 | + dbus, | ||
| 115 | + libGL, | ||
| 116 | + libclang, | ||
| 117 | + libdisplay-info, | ||
| 118 | + libinput, | ||
| 119 | + libseat, | ||
| 120 | + libxkbcommon, | ||
| 121 | + mesa, | ||
| 122 | + pango, | ||
| 123 | + pipewire, | ||
| 124 | + pkg-config, | ||
| 125 | + rustPlatform, | ||
| 126 | + systemd, | ||
| 127 | + wayland, | ||
| 128 | + withDbus ? true, | ||
| 129 | + withSystemd ? true, | ||
| 130 | + withScreencastSupport ? true, | ||
| 131 | + withDinit ? false, | ||
| 132 | + }: | ||
| 133 | + | ||
| 134 | + rustPlatform.buildRustPackage { | ||
| 135 | + pname = "niri"; | ||
| 136 | + version = self.shortRev or self.dirtyShortRev or "unknown"; | ||
| 137 | + | ||
| 138 | + src = nix-filter.lib.filter { | ||
| 139 | + root = self; | ||
| 140 | + include = [ | ||
| 141 | + "niri-config" | ||
| 142 | + "niri-ipc" | ||
| 143 | + "niri-visual-tests" | ||
| 144 | + "resources" | ||
| 145 | + "src" | ||
| 146 | + ./Cargo.lock | ||
| 147 | + ./Cargo.toml | ||
| 148 | + ]; | ||
| 149 | + }; | ||
| 150 | + | ||
| 151 | + postPatch = '' | ||
| 152 | + patchShebangs resources/niri-session | ||
| 153 | + substituteInPlace resources/niri.service \ | ||
| 154 | + --replace-fail '/usr/bin' "$out/bin" | ||
| 155 | + ''; | ||
| 156 | + | ||
| 157 | + cargoLock = { | ||
| 158 | + # NOTE: This is only used for Git dependencies | ||
| 159 | + allowBuiltinFetchGit = true; | ||
| 160 | + lockFile = ./Cargo.lock; | ||
| 161 | + }; | ||
| 162 | + | ||
| 163 | + strictDeps = true; | ||
| 164 | + | ||
| 165 | + nativeBuildInputs = [ | ||
| 166 | + clang | ||
| 167 | + pkg-config | ||
| 168 | + ]; | ||
| 169 | + | ||
| 170 | + buildInputs = | ||
| 171 | + [ | ||
| 172 | + cairo | ||
| 173 | + dbus | ||
| 174 | + libGL | ||
| 175 | + libdisplay-info | ||
| 176 | + libinput | ||
| 177 | + libseat | ||
| 178 | + libxkbcommon | ||
| 179 | + mesa # libgbm | ||
| 180 | + pango | ||
| 181 | + wayland | ||
| 182 | + ] | ||
| 183 | + ++ lib.optional (withDbus || withScreencastSupport || withSystemd) dbus | ||
| 184 | + ++ lib.optional withScreencastSupport pipewire | ||
| 185 | + # Also includes libudev | ||
| 186 | + ++ lib.optional withSystemd systemd; | ||
| 187 | + | ||
| 188 | + buildFeatures = | ||
| 189 | + lib.optional withDbus "dbus" | ||
| 190 | + ++ lib.optional withDinit "dinit" | ||
| 191 | + ++ lib.optional withScreencastSupport "xdp-gnome-screencast" | ||
| 192 | + ++ lib.optional withSystemd "systemd"; | ||
| 193 | + buildNoDefaultFeatures = true; | ||
| 194 | + | ||
| 195 | + postInstall = | ||
| 196 | + '' | ||
| 197 | + install -Dm644 resources/niri.desktop -t $out/share/wayland-sessions | ||
| 198 | + install -Dm644 resources/niri-portals.conf -t $out/share/xdg-desktop-portal | ||
| 199 | + '' | ||
| 200 | + + lib.optionalString withSystemd '' | ||
| 201 | + install -Dm755 resources/niri-session $out/bin/niri-session | ||
| 202 | + install -Dm644 resources/niri{.service,-shutdown.target} -t $out/share/systemd/user | ||
| 203 | + ''; | ||
| 204 | + | ||
| 205 | + env = { | ||
| 206 | + LIBCLANG_PATH = lib.getLib libclang + "/lib"; | ||
| 207 | + | ||
| 208 | + # Force linking with libEGL and libwayland-client | ||
| 209 | + # so they can be discovered by `dlopen()` | ||
| 210 | + CARGO_BUILD_RUSTFLAGS = toString ( | ||
| 211 | + map (arg: "-C link-arg=" + arg) [ | ||
| 212 | + "-Wl,--push-state,--no-as-needed" | ||
| 213 | + "-lEGL" | ||
| 214 | + "-lwayland-client" | ||
| 215 | + "-Wl,--pop-state" | ||
| 216 | + ] | ||
| 217 | + ); | ||
| 218 | + }; | ||
| 219 | + | ||
| 220 | + passthru = { | ||
| 221 | + providedSessions = [ "niri" ]; | ||
| 222 | + }; | ||
| 223 | + | ||
| 224 | + meta = { | ||
| 225 | + description = "Scrollable-tiling Wayland compositor"; | ||
| 226 | + homepage = "https://github.com/YaLTeR/niri"; | ||
| 227 | + license = lib.licenses.gpl3Only; | ||
| 228 | + mainProgram = "niri"; | ||
| 229 | + platforms = lib.platforms.linux; | ||
| 230 | + }; | ||
| 231 | + } | ||
| 232 | + ) { }; | ||
| 233 | + }; | ||
| 230 | }; | 234 | }; |
| 231 | } | 235 | } |