Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down Expand Up @@ -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" }

Comment on lines -145 to -147

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch seems unnecessary and breaks nix build due to // or duplicate source if remove //.
Set branch = "main" in further up on L24 and update Cargo.lock as well.

This commit could be a separate PR if preferred.

[patch.crates-io]
smithay = { git = "https://github.com/smithay/smithay.git", rev = "e3d461a" }
71 changes: 9 additions & 62 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

208 changes: 129 additions & 79 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
}
Loading