|
2 | 2 | description = "Compositor for the COSMIC desktop environment";
|
3 | 3 |
|
4 | 4 | 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"; |
6 | 7 |
|
7 |
| - parts.url = "github:hercules-ci/flake-parts"; |
8 |
| - parts.inputs.nixpkgs-lib.follows = "nixpkgs"; |
| 8 | + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; |
9 | 9 |
|
10 | 10 | crane.url = "github:ipetkov/crane";
|
11 | 11 |
|
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"; |
16 | 14 | };
|
17 | 15 |
|
18 | 16 | outputs = inputs @ {
|
19 | 17 | self,
|
20 |
| - nixpkgs, |
21 |
| - parts, |
22 | 18 | crane,
|
23 |
| - rust, |
24 |
| - nix-filter, |
25 | 19 | ...
|
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; |
| 20 | + }: let |
| 21 | + inherit (inputs.nixpkgs) lib; |
| 22 | + |
| 23 | + fs = lib.fileset; |
| 24 | + eachSystem = lib.genAttrs (import inputs.systems); |
| 25 | + pkgsFor = eachSystem (system: |
| 26 | + import inputs.nixpkgs { |
| 27 | + localSystem.system = system; |
| 28 | + overlays = [(import inputs.rust-overlay)]; |
| 29 | + }); |
| 30 | + in { |
| 31 | + packages = |
| 32 | + lib.mapAttrs (system: pkgs: let |
| 33 | + craneLib = crane.mkLib pkgs; |
42 | 34 | craneArgs = {
|
43 | 35 | pname = "cosmic-comp";
|
44 | 36 | version = self.rev or "dirty";
|
45 | 37 |
|
46 |
| - src = nix-filter.lib.filter { |
| 38 | + src = fs.toSource { |
47 | 39 | root = ./.;
|
48 |
| - include = [ |
| 40 | + fileset = fs.unions [ |
49 | 41 | ./src
|
50 | 42 | ./i18n.toml
|
51 | 43 | ./Cargo.toml
|
|
89 | 81 | };
|
90 | 82 |
|
91 | 83 | cargoArtifacts = craneLib.buildDepsOnly craneArgs;
|
92 |
| - cosmic-comp = craneLib.buildPackage (craneArgs // {inherit cargoArtifacts;}); |
93 | 84 | 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; |
| 85 | + cosmic-comp = craneLib.buildPackage (craneArgs // {inherit cargoArtifacts;}); |
101 | 86 |
|
102 |
| - devShells.default = craneLib.devShell { |
103 |
| - LD_LIBRARY_PATH = lib.makeLibraryPath ( |
104 |
| - __concatMap (d: d.runtimeDependencies) (__attrValues self'.checks) |
105 |
| - ); |
| 87 | + default = self.packages.${system}.cosmic-comp; |
| 88 | + }) |
| 89 | + pkgsFor; |
106 | 90 |
|
107 |
| - # include build inputs |
108 |
| - inputsFrom = [cosmic-comp]; |
109 |
| - }; |
| 91 | + apps = eachSystem (system: { |
| 92 | + cosmic-comp = { |
| 93 | + type = "app"; |
| 94 | + program = lib.getExe self.packages.${system}.default; |
110 | 95 | };
|
111 |
| - }; |
| 96 | + |
| 97 | + default = self.apps.${system}.cosmic-comp; |
| 98 | + }); |
| 99 | + |
| 100 | + checks = eachSystem (system: { |
| 101 | + inherit (self.packages.${system}) cosmic-comp; |
| 102 | + }); |
| 103 | + |
| 104 | + devShells = |
| 105 | + lib.mapAttrs ( |
| 106 | + system: pkgs: let |
| 107 | + craneLib = crane.mkLib pkgs; |
| 108 | + in { |
| 109 | + default = craneLib.devShell { |
| 110 | + LD_LIBRARY_PATH = lib.makeLibraryPath ( |
| 111 | + builtins.concatMap (d: d.runtimeDependencies) (builtins.attrValues self.checks.${system}) |
| 112 | + ); |
| 113 | + |
| 114 | + # include build inputs |
| 115 | + inputsFrom = [self.packages.${system}.cosmic-comp]; |
| 116 | + }; |
| 117 | + } |
| 118 | + ) |
| 119 | + pkgsFor; |
| 120 | + }; |
112 | 121 | }
|
0 commit comments