aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flake.lock90
-rw-r--r--flake.nix184
2 files changed, 108 insertions, 166 deletions
diff --git a/flake.lock b/flake.lock
index f3bf519b..f685c8f4 100644
--- a/flake.lock
+++ b/flake.lock
@@ -1,60 +1,5 @@
{
"nodes": {
- "crane": {
- "locked": {
- "lastModified": 1725409566,
- "narHash": "sha256-PrtLmqhM6UtJP7v7IGyzjBFhbG4eOAHT6LPYOFmYfbk=",
- "owner": "ipetkov",
- "repo": "crane",
- "rev": "7e4586bad4e3f8f97a9271def747cf58c4b68f3c",
- "type": "github"
- },
- "original": {
- "owner": "ipetkov",
- "repo": "crane",
- "type": "github"
- }
- },
- "fenix": {
- "inputs": {
- "nixpkgs": [
- "nixpkgs"
- ],
- "rust-analyzer-src": "rust-analyzer-src"
- },
- "locked": {
- "lastModified": 1725172314,
- "narHash": "sha256-BtLY9lWu/pe6/ImFwuRRRqMwLacY5AZOKA2hUHUQ64k=",
- "owner": "nix-community",
- "repo": "fenix",
- "rev": "28b42d01f549c38bd165296fbcb4fe66d98fc24f",
- "type": "github"
- },
- "original": {
- "owner": "nix-community",
- "ref": "monthly",
- "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"
- }
- },
"nix-filter": {
"locked": {
"lastModified": 1710156097,
@@ -88,44 +33,9 @@
},
"root": {
"inputs": {
- "crane": "crane",
- "fenix": "fenix",
- "flake-utils": "flake-utils",
"nix-filter": "nix-filter",
"nixpkgs": "nixpkgs"
}
- },
- "rust-analyzer-src": {
- "flake": false,
- "locked": {
- "lastModified": 1725094379,
- "narHash": "sha256-TBujPMMIv8RG6BKlsBEpCln1ePmWz79xTcJOQpU2L18=",
- "owner": "rust-lang",
- "repo": "rust-analyzer",
- "rev": "914a1caab54e48a028b2407d0fe6fade89532f67",
- "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",
diff --git a/flake.nix b/flake.nix
index d5380dca..e773a34a 100644
--- a/flake.nix
+++ b/flake.nix
@@ -4,107 +4,139 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
- crane.url = "github:ipetkov/crane";
- 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
+ inherit (nixpkgs) lib;
systems = [
"aarch64-linux"
"x86_64-linux"
];
+
+ forAllSystems = lib.genAttrs systems;
+ nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system});
in
- flake-utils.lib.eachSystem systems (
- system:
- let
- pkgs = nixpkgs.legacyPackages.${system};
- toolchain = fenix.packages.${system}.complete.toolchain;
- craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
+ {
+ checks = forAllSystems (system: {
+ inherit (self.packages.${system}) niri;
+ });
- craneArgs = {
- pname = "niri";
- version = self.rev or "dirty";
+ devShells = forAllSystems (
+ system:
+ let
+ inherit (self.packages.${system}) niri;
+ in
+ {
+ default = nixpkgsFor.${system}.mkShell {
+ inputsFrom = [ niri ];
- src = nixpkgs.lib.cleanSourceWith {
- src = craneLib.path ./.;
- filter =
- path: type:
- (builtins.match "resources" path == null)
- || ((craneLib.filterCargoSources path type) && (builtins.match "niri-visual-tests" path == null));
+ env = {
+ LD_LIBRARY_PATH = lib.makeLibraryPath niri.buildInputs;
+ inherit (niri.env) LIBCLANG_PATH;
+ };
};
+ }
+ );
- nativeBuildInputs = with pkgs; [
- pkg-config
- autoPatchelfHook
- clang
- gdk-pixbuf
- graphene
- gtk4
- libadwaita
- ];
+ formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style);
- buildInputs = with pkgs; [
- wayland
- systemd # For libudev
- seatd # For libseat
- libxkbcommon
- libdisplay-info
- libinput
- mesa # For libgbm
- fontconfig
- stdenv.cc.cc.lib
- pipewire
- pango
- cairo
- glib
- pixman
- ];
+ packages = forAllSystems (system: {
+ niri = nixpkgsFor.${system}.callPackage (
+ {
+ cairo,
+ clang,
+ fontconfig,
+ gdk-pixbuf,
+ glib,
+ graphene,
+ gtk4,
+ libadwaita,
+ libclang,
+ libdisplay-info,
+ libglvnd,
+ libinput,
+ libxkbcommon,
+ mesa,
+ pango,
+ pipewire,
+ pixman,
+ pkg-config,
+ rustPlatform,
+ seatd,
+ stdenv,
+ systemd,
+ wayland,
+ xorg,
+ }:
+ rustPlatform.buildRustPackage rec {
+ pname = "niri";
+ version = self.shortRev or self.dirtyShortRev or "unknown";
- runtimeDependencies = with pkgs; [
- wayland
- mesa
- libglvnd # For libEGL
- xorg.libXcursor
- xorg.libXi
- libxkbcommon
- ];
+ cargoLock = {
+ # NOTE: This is only used for Git dependencies
+ allowBuiltinFetchGit = true;
+ lockFile = ./Cargo.lock;
+ };
- LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
- LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath craneArgs.runtimeDependencies; # Needed for tests to find libxkbcommon
- };
+ src = nix-filter.lib.filter {
+ root = self;
+ include = [
+ "niri-config"
+ "niri-ipc"
+ "resources"
+ "src"
+ ];
+ };
- cargoArtifacts = craneLib.buildDepsOnly craneArgs;
- niri = craneLib.buildPackage (craneArgs // { inherit cargoArtifacts; });
- in
- {
- formatter = pkgs.nixfmt-rfc-style;
+ nativeBuildInputs = [
+ clang
+ gdk-pixbuf
+ graphene
+ gtk4
+ libadwaita
+ pkg-config
+ ];
- checks.niri = niri;
- packages.default = niri;
+ buildInputs = [
+ cairo
+ fontconfig
+ glib
+ libdisplay-info
+ libinput
+ libxkbcommon
+ mesa # For libgbm
+ pango
+ pipewire
+ pixman
+ seatd # For libseat
+ stdenv.cc.cc.lib
+ systemd # For libudev
+ wayland
+ ];
- devShells.default = craneLib.devShell {
- inputsFrom = [ niri ];
+ runtimeDependencies = [
+ libglvnd # For libEGL
+ libxkbcommon
+ mesa
+ wayland
+ xorg.libXcursor
+ xorg.libXi
+ ];
- LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (
- craneArgs.runtimeDependencies ++ craneArgs.nativeBuildInputs ++ craneArgs.buildInputs
- );
- inherit (niri) LIBCLANG_PATH;
- };
- }
- );
+ LD_LIBRARY_PATH = lib.makeLibraryPath runtimeDependencies;
+ LIBCLANG_PATH = lib.getLib libclang + "/lib";
+ }
+ ) { };
+
+ default = self.packages.${system}.niri;
+ });
+ };
}