diff --git a/Cargo.lock b/Cargo.lock index 859203e4a..f1885b48e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -902,7 +902,7 @@ dependencies = [ [[package]] name = "cosmic-protocols" version = "0.2.0" -source = "git+https://github.com/pop-os//cosmic-protocols?branch=main#32283d76a8d0342da74c4cc022a533c52dcf378f" +source = "git+https://github.com/pop-os/cosmic-protocols?branch=main#32283d76a8d0342da74c4cc022a533c52dcf378f" dependencies = [ "bitflags 2.11.0", "wayland-backend", diff --git a/Cargo.toml b/Cargo.toml index 23fe2775a..5b25d0425 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ cosmic-config = { git = "https://github.com/pop-os/libcosmic", features = [ "calloop", "macro", ] } -cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", rev = "160b086", default-features = false, features = [ +cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", branch = "main", default-features = false, features = [ "server", ] } cosmic-settings-config = { git = "https://github.com/pop-os/cosmic-settings-daemon" } @@ -142,8 +142,5 @@ inherits = "release" [profile.release] lto = "fat" -[patch."https://github.com/pop-os/cosmic-protocols"] -cosmic-protocols = { git = "https://github.com/pop-os//cosmic-protocols", branch = "main" } - [patch.crates-io] smithay = { git = "https://github.com/smithay/smithay.git", rev = "e3d461a" } diff --git a/flake.lock b/flake.lock index 6152e20c8..aa198f3a7 100644 --- a/flake.lock +++ b/flake.lock @@ -1,92 +1,39 @@ { "nodes": { - "crane": { - "locked": { - "lastModified": 1724974107, - "narHash": "sha256-69+1W0Ao5K9su569YUfUPANeN/Ea7aKu7xIZP1MSl9o=", - "owner": "ipetkov", - "repo": "crane", - "rev": "63396562b8e08efda3b3c66e32661b8a513055de", - "type": "github" - }, - "original": { - "owner": "ipetkov", - "repo": "crane", - "type": "github" - } - }, - "nix-filter": { - "locked": { - "lastModified": 1710156097, - "narHash": "sha256-1Wvk8UP7PXdf8bCCaEoMnOT1qe5/Duqgj+rL8sRQsSM=", - "owner": "numtide", - "repo": "nix-filter", - "rev": "3342559a24e85fc164b295c3444e8a139924675b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "nix-filter", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1725067332, - "narHash": "sha256-bMi5zhDwR6jdmN5mBHEu9gQQf9CibIEasA/6mc34Iek=", + "lastModified": 1774386573, + "narHash": "sha256-4hAV26quOxdC6iyG7kYaZcM3VOskcPUrdCQd/nx8obc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "192e7407cc66e2eccc3a6c5ad3834dd62fae3800", + "rev": "46db2e09e1d3f113a13c0d7b81e2f221c63b8ce9", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixpkgs-unstable", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, - "parts": { - "inputs": { - "nixpkgs-lib": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1725024810, - "narHash": "sha256-ODYRm8zHfLTH3soTFWE452ydPYz2iTvr9T8ftDMUQ3E=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "af510d4a62d071ea13925ce41c95e3dec816c01d", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, "root": { "inputs": { - "crane": "crane", - "nix-filter": "nix-filter", "nixpkgs": "nixpkgs", - "parts": "parts", - "rust": "rust" + "rust-overlay": "rust-overlay" } }, - "rust": { + "rust-overlay": { "inputs": { "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1724984647, - "narHash": "sha256-BC6MUq0CTdmAu/cueVcdWTI+S95s0mJcn19SoEgd7gU=", + "lastModified": 1772775058, + "narHash": "sha256-i+I9RYN8kYb9/9kibkxd0avkkislD1tyWojSVgIy160=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "87b6cffc276795b46ef544d7ed8d7fed6ad9c8e4", + "rev": "629bbb7f9d02787a54e28398b411da849246253b", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 1fe2c57c3..35cc9bc90 100644 --- a/flake.nix +++ b/flake.nix @@ -2,115 +2,165 @@ description = "Compositor for the COSMIC desktop environment"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - - parts.url = "github:hercules-ci/flake-parts"; - parts.inputs.nixpkgs-lib.follows = "nixpkgs"; - - crane.url = "github:ipetkov/crane"; - - rust.url = "github:oxalica/rust-overlay"; - rust.inputs.nixpkgs.follows = "nixpkgs"; - - nix-filter.url = "github:numtide/nix-filter"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = - inputs@{ + { self, nixpkgs, - parts, - crane, - rust, - nix-filter, - ... + rust-overlay, }: - parts.lib.mkFlake { inherit inputs; } { - systems = [ - "aarch64-linux" + let + supportedSystems = [ "x86_64-linux" + "aarch64-linux" ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; - perSystem = + pkgsForSystem = + system: + import nixpkgs { + inherit system; + overlays = [ (import rust-overlay) ]; + }; + + commonFor = + system: + let + pkgs = pkgsForSystem system; + rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + in { - self', - lib, - system, - ... - }: + inherit pkgs rustToolchain; + + buildInputs = with pkgs; [ + libdisplay-info + libinput + libgbm + libxkbcommon + fontconfig + pixman + stdenv.cc.cc.lib + seatd + systemd + udev + wayland + xrdb + ]; + + nativeBuildInputs = with pkgs; [ + autoPatchelfHook + cmake + pkg-config + ]; + + runtimeDependencies = with pkgs; [ + libglvnd + wayland + libx11 + libxcb + libxcursor + libxi + libxkbcommon + xrdb + vulkan-loader + ]; + }; + in + { + packages = forAllSystems ( + system: let - pkgs = nixpkgs.legacyPackages.${system}.extend rust.overlays.default; - rust-toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; - craneLib = (crane.mkLib pkgs).overrideToolchain rust-toolchain; - craneArgs = { + common = commonFor system; + rustPlatform = common.pkgs.makeRustPlatform { + cargo = common.rustToolchain; + rustc = common.rustToolchain; + }; + in + { + default = self.packages.${system}.cosmic-comp; + + cosmic-comp = rustPlatform.buildRustPackage { pname = "cosmic-comp"; - version = self.rev or "dirty"; + version = "1.m.M-dev"; - src = nix-filter.lib.filter { + src = common.pkgs.lib.fileset.toSource { root = ./.; - include = [ + fileset = common.pkgs.lib.fileset.unions [ + ./cosmic-comp-config + ./data + ./resources ./src - ./i18n.toml ./Cargo.toml ./Cargo.lock - ./resources - ./cosmic-comp-config + ./Makefile + ./build.rs + ./i18n.toml ]; }; - nativeBuildInputs = with pkgs; [ - pkg-config - autoPatchelfHook - cmake - ]; + cargoLock = { + lockFile = ./Cargo.lock; + allowBuiltinFetchGit = true; + }; - buildInputs = with pkgs; [ - wayland - systemd # For libudev - seatd # For libseat - libxkbcommon - libinput - mesa # For libgbm - fontconfig - stdenv.cc.cc.lib - pixman - libdisplay-info - ]; + dontCargoInstall = true; + + inherit (common) buildInputs nativeBuildInputs runtimeDependencies; - runtimeDependencies = with pkgs; [ - libglvnd # For libEGL - wayland # winit->wayland-sys wants to dlopen libwayland-egl.so - # for running in X11 - xorg.libX11 - xorg.libXcursor - xorg.libxcb - xorg.libXi - libxkbcommon - # for vulkan backend - vulkan-loader + separateDebugInfo = true; + + makeFlags = [ + "prefix=${placeholder "out"}" + "CARGO_TARGET_DIR=target/${common.pkgs.stdenv.hostPlatform.rust.cargoShortTarget}" ]; + + meta = with common.pkgs.lib; { + description = "Compositor for the COSMIC desktop environment"; + homepage = "https://github.com/pop-os/cosmic-comp"; + license = licenses.gpl3Only; + platforms = platforms.linux; + mainProgram = "cosmic-comp"; + }; }; + } + ); - cargoArtifacts = craneLib.buildDepsOnly craneArgs; - cosmic-comp = craneLib.buildPackage (craneArgs // { inherit cargoArtifacts; }); + devShells = forAllSystems ( + system: + let + common = commonFor system; in { - apps.cosmic-comp = { - type = "app"; - program = lib.getExe self'.packages.default; - }; + default = common.pkgs.mkShell { + inputsFrom = [ self.packages.${system}.cosmic-comp ]; - checks.cosmic-comp = cosmic-comp; - packages.default = cosmic-comp; + packages = with common.pkgs; [ + common.rustToolchain + rust-analyzer + ]; - devShells.default = craneLib.devShell { - LD_LIBRARY_PATH = lib.makeLibraryPath ( - __concatMap (d: d.runtimeDependencies) (__attrValues self'.checks) - ); + LD_LIBRARY_PATH = common.pkgs.lib.makeLibraryPath common.runtimeDependencies; - # include build inputs - inputsFrom = [ cosmic-comp ]; + shellHook = '' + echo "COSMIC Compositor development environment" + echo "Run 'cargo build' to build, 'cargo test' to test" + ''; }; - }; + } + ); + + # Formatter for 'nix fmt' + formatter = forAllSystems (system: (pkgsForSystem system).nixfmt-rfc-style); + + # Overlay for use in other flakes + overlays.default = final: prev: { + cosmic-comp = self.packages.${prev.system}.cosmic-comp; + }; }; }