Skip to content

Commit c8f1138

Browse files
author
Bloxx12
committed
flake.nix: refactor
1 parent da2d87b commit c8f1138

File tree

2 files changed

+79
-88
lines changed

2 files changed

+79
-88
lines changed

flake.lock

Lines changed: 21 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 58 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,45 @@
22
description = "Compositor for the COSMIC desktop environment";
33

44
inputs = {
5-
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
5+
# <https://github.com/nix-systems/default-linux>
6+
systems.url = "github:nix-systems/default-linux";
67

7-
parts.url = "github:hercules-ci/flake-parts";
8-
parts.inputs.nixpkgs-lib.follows = "nixpkgs";
8+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
99

1010
crane.url = "github:ipetkov/crane";
1111

12-
rust.url = "github:oxalica/rust-overlay";
13-
rust.inputs.nixpkgs.follows = "nixpkgs";
14-
15-
nix-filter.url = "github:numtide/nix-filter";
12+
rust-overlay.url = "github:oxalica/rust-overlay";
13+
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
1614
};
1715

18-
outputs = inputs @ {
16+
outputs = {
1917
self,
20-
nixpkgs,
21-
parts,
2218
crane,
23-
rust,
24-
nix-filter,
19+
nixpkgs,
20+
rust-overlay,
21+
systems,
2522
...
26-
}:
27-
parts.lib.mkFlake {inherit inputs;} {
28-
systems = [
29-
"aarch64-linux"
30-
"x86_64-linux"
31-
];
32-
33-
perSystem = {
34-
self',
35-
lib,
36-
system,
37-
...
38-
}: let
39-
pkgs = nixpkgs.legacyPackages.${system}.extend rust.overlays.default;
40-
rust-toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
41-
craneLib = (crane.mkLib pkgs).overrideToolchain rust-toolchain;
23+
}: let
24+
inherit (nixpkgs) lib;
25+
26+
fs = lib.fileset;
27+
eachSystem = lib.genAttrs (import systems);
28+
pkgsFor = eachSystem (system:
29+
import nixpkgs {
30+
localSystem.system = system;
31+
overlays = [(import rust-overlay)];
32+
});
33+
in {
34+
packages =
35+
lib.mapAttrs (system: pkgs: let
36+
craneLib = crane.mkLib pkgs;
4237
craneArgs = {
4338
pname = "cosmic-comp";
4439
version = self.rev or "dirty";
4540

46-
src = nix-filter.lib.filter {
41+
src = fs.toSource {
4742
root = ./.;
48-
include = [
43+
fileset = fs.unions [
4944
./src
5045
./i18n.toml
5146
./Cargo.toml
@@ -89,24 +84,41 @@
8984
};
9085

9186
cargoArtifacts = craneLib.buildDepsOnly craneArgs;
92-
cosmic-comp = craneLib.buildPackage (craneArgs // {inherit cargoArtifacts;});
9387
in {
94-
apps.cosmic-comp = {
95-
type = "app";
96-
program = lib.getExe self'.packages.default;
97-
};
98-
99-
checks.cosmic-comp = cosmic-comp;
100-
packages.default = cosmic-comp;
88+
cosmic-comp = craneLib.buildPackage (craneArgs // {inherit cargoArtifacts;});
10189

102-
devShells.default = craneLib.devShell {
103-
LD_LIBRARY_PATH = lib.makeLibraryPath (
104-
__concatMap (d: d.runtimeDependencies) (__attrValues self'.checks)
105-
);
90+
default = self.packages.${system}.cosmic-comp;
91+
})
92+
pkgsFor;
10693

107-
# include build inputs
108-
inputsFrom = [cosmic-comp];
109-
};
94+
apps = eachSystem (system: {
95+
cosmic-comp = {
96+
type = "app";
97+
program = lib.getExe self.packages.${system}.default;
11098
};
111-
};
99+
100+
default = self.apps.${system}.cosmic-comp;
101+
});
102+
103+
checks = eachSystem (system: {
104+
inherit (self.packages.${system}) cosmic-comp;
105+
});
106+
107+
devShells =
108+
lib.mapAttrs (
109+
system: pkgs: let
110+
craneLib = crane.mkLib pkgs;
111+
in {
112+
default = craneLib.devShell {
113+
LD_LIBRARY_PATH = lib.makeLibraryPath (
114+
builtins.concatMap (d: d.runtimeDependencies) (builtins.attrValues self.checks.${system})
115+
);
116+
117+
# include build inputs
118+
inputsFrom = [self.packages.${system}.cosmic-comp];
119+
};
120+
}
121+
)
122+
pkgsFor;
123+
};
112124
}

0 commit comments

Comments
 (0)