nix: fix builds and CI
Things done: - migrate from flake-utils to flake-parts for easier composability - use rust-overlay from oxalica since it works well with rust-toolchain.toml files
This commit is contained in:
parent
bdcb803efa
commit
92932e0c3e
3 changed files with 169 additions and 127 deletions
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
|
@ -11,7 +11,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: cachix/install-nix-action@v21
|
- uses: cachix/install-nix-action@v22
|
||||||
with:
|
with:
|
||||||
nix_path: nixpkgs=channel:nixpkgs-unstable
|
nix_path: nixpkgs=channel:nixpkgs-unstable
|
||||||
- run: GIT_LFS_SKIP_SMUDGE=1 nix build
|
- run: GIT_LFS_SKIP_SMUDGE=1 nix build
|
||||||
|
|
|
||||||
163
flake.lock
generated
163
flake.lock
generated
|
|
@ -4,17 +4,15 @@
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-compat": "flake-compat",
|
"flake-compat": "flake-compat",
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": [
|
"nixpkgs": "nixpkgs",
|
||||||
"nixpkgs"
|
|
||||||
],
|
|
||||||
"rust-overlay": "rust-overlay"
|
"rust-overlay": "rust-overlay"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1684981077,
|
"lastModified": 1688425221,
|
||||||
"narHash": "sha256-68X9cFm0RTZm8u0rXPbeBzOVUH5OoUGAfeHHVoxGd9o=",
|
"narHash": "sha256-DhZnju72DuX9GhOnCOBIE94aCGKC2BOaF+kGxbnP/K0=",
|
||||||
"owner": "ipetkov",
|
"owner": "ipetkov",
|
||||||
"repo": "crane",
|
"repo": "crane",
|
||||||
"rev": "35110cccf28823320f4fd697fcafcb5038683982",
|
"rev": "fc6a236548b31aef0be3b0a0377c4459bb39d923",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -23,27 +21,6 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"fenix": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
],
|
|
||||||
"rust-analyzer-src": "rust-analyzer-src"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1685600533,
|
|
||||||
"narHash": "sha256-7oly5/7xJMtFH44I/Bsrnc2VG4M6HyUVhph3WoZrG64=",
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "fenix",
|
|
||||||
"rev": "360c6a0bc9b78b896fdd60c8803ba98298a37f7c",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "fenix",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"flake-compat": {
|
"flake-compat": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
|
@ -65,11 +42,11 @@
|
||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1681202837,
|
"lastModified": 1687709756,
|
||||||
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
"narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
|
"rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -83,11 +60,11 @@
|
||||||
"systems": "systems_2"
|
"systems": "systems_2"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1685518550,
|
"lastModified": 1681202837,
|
||||||
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
|
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
|
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -98,11 +75,11 @@
|
||||||
},
|
},
|
||||||
"nix-filter": {
|
"nix-filter": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1681154353,
|
"lastModified": 1687178632,
|
||||||
"narHash": "sha256-MCJ5FHOlbfQRFwN0brqPbCunLEVw05D/3sRVoNVt2tI=",
|
"narHash": "sha256-HS7YR5erss0JCaUijPeyg2XrisEb959FIct3n2TMGbE=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "nix-filter",
|
"repo": "nix-filter",
|
||||||
"rev": "f529f42792ade8e32c4be274af6b6d60857fbee7",
|
"rev": "d90c75e8319d0dd9be67d933d8eb9d0894ec9174",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -112,6 +89,40 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1688221086,
|
||||||
|
"narHash": "sha256-cdW6qUL71cNWhHCpMPOJjlw0wzSRP0pVlRn2vqX/VVg=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "cd99c2b3c9f160cd004318e0697f90bbd5960825",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixpkgs-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs-lib": {
|
||||||
|
"locked": {
|
||||||
|
"dir": "lib",
|
||||||
|
"lastModified": 1688049487,
|
||||||
|
"narHash": "sha256-100g4iaKC9MalDjUW9iN6Jl/OocTDtXdeAj7pEGIRh4=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "4bc72cae107788bf3f24f30db2e2f685c9298dc9",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"dir": "lib",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1685591878,
|
"lastModified": 1685591878,
|
||||||
"narHash": "sha256-Ib3apaLqIFkZb94q6Q214DXrz0FnJq5C7usywTv63og=",
|
"narHash": "sha256-Ib3apaLqIFkZb94q6Q214DXrz0FnJq5C7usywTv63og=",
|
||||||
|
|
@ -127,29 +138,65 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"nixpkgs_3": {
|
||||||
"inputs": {
|
|
||||||
"crane": "crane",
|
|
||||||
"fenix": "fenix",
|
|
||||||
"flake-utils": "flake-utils_2",
|
|
||||||
"nix-filter": "nix-filter",
|
|
||||||
"nixpkgs": "nixpkgs"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"rust-analyzer-src": {
|
|
||||||
"flake": false,
|
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1685541053,
|
"lastModified": 1681358109,
|
||||||
"narHash": "sha256-ck8hhiuxvy8jLIv2cPsQK8bfc/aYZjrIelmLAv16T4o=",
|
"narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=",
|
||||||
"owner": "rust-lang",
|
"owner": "NixOS",
|
||||||
"repo": "rust-analyzer",
|
"repo": "nixpkgs",
|
||||||
"rev": "bafa6c4ee5d3acdbb62ec289364564270357c6a2",
|
"rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "rust-lang",
|
"owner": "NixOS",
|
||||||
"ref": "nightly",
|
"ref": "nixpkgs-unstable",
|
||||||
"repo": "rust-analyzer",
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"parts": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1688466019,
|
||||||
|
"narHash": "sha256-VeM2akYrBYMsb4W/MmBo1zmaMfgbL4cH3Pu8PGyIwJ0=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"rev": "8e8d955c22df93dbe24f19ea04f47a74adbdc5ec",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"crane": "crane",
|
||||||
|
"nix-filter": "nix-filter",
|
||||||
|
"nixpkgs": "nixpkgs_2",
|
||||||
|
"parts": "parts",
|
||||||
|
"rust": "rust"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils_2",
|
||||||
|
"nixpkgs": "nixpkgs_3"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1688438033,
|
||||||
|
"narHash": "sha256-wOmpZis06pVKTR+5meGwhrW10/buf98lnA26uQLaqek=",
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"rev": "c3e43223dece545cfe06ddd92fd782adc73d56c3",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -165,11 +212,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1683080331,
|
"lastModified": 1688351637,
|
||||||
"narHash": "sha256-nGDvJ1DAxZIwdn6ww8IFwzoHb2rqBP4wv/65Wt5vflk=",
|
"narHash": "sha256-CLTufJ29VxNOIZ8UTg0lepsn3X03AmopmaLTTeHDCL4=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "d59c3fa0cba8336e115b376c2d9e91053aa59e56",
|
"rev": "f9b92316727af9e6c7fee4a761242f7f46880329",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
129
flake.nix
129
flake.nix
|
|
@ -3,78 +3,73 @@
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
parts.url = "github:hercules-ci/flake-parts";
|
||||||
|
crane.url = "github:ipetkov/crane";
|
||||||
|
rust.url = "github:oxalica/rust-overlay";
|
||||||
nix-filter.url = "github:numtide/nix-filter";
|
nix-filter.url = "github:numtide/nix-filter";
|
||||||
crane = {
|
|
||||||
url = "github:ipetkov/crane";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
fenix = {
|
|
||||||
url = "github:nix-community/fenix";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils, nix-filter, crane, fenix }:
|
outputs = inputs@{ self, nixpkgs, parts, crane, rust, nix-filter, ... }:
|
||||||
flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system:
|
parts.lib.mkFlake { inherit inputs; } {
|
||||||
let
|
systems = [ "aarch64-linux" "x86_64-linux" ];
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
|
||||||
craneLib = crane.lib.${system}.overrideToolchain fenix.packages.${system}.stable.toolchain;
|
|
||||||
|
|
||||||
pkgDef = {
|
perSystem = { self', lib, system, ... }:
|
||||||
src = nix-filter.lib.filter {
|
let
|
||||||
root = ./.;
|
pkgs = nixpkgs.legacyPackages.${system}.extend rust.overlays.default;
|
||||||
include = [
|
rust-toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||||
./src
|
craneLib = crane.lib.${system}.overrideToolchain rust-toolchain;
|
||||||
./Cargo.toml
|
craneArgs = {
|
||||||
./Cargo.lock
|
pname = "cosmic-comp";
|
||||||
./resources
|
version = self.rev or "dirty";
|
||||||
|
|
||||||
|
src = nix-filter.lib.filter {
|
||||||
|
root = ./.;
|
||||||
|
include = [
|
||||||
|
./src
|
||||||
|
./Cargo.toml
|
||||||
|
./Cargo.lock
|
||||||
|
./resources
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
pkg-config
|
||||||
|
autoPatchelfHook
|
||||||
|
cmake
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
wayland
|
||||||
|
systemd # For libudev
|
||||||
|
seatd # For libseat
|
||||||
|
libxkbcommon
|
||||||
|
libinput
|
||||||
|
mesa # For libgbm
|
||||||
|
fontconfig
|
||||||
|
stdenv.cc.cc.lib
|
||||||
|
];
|
||||||
|
|
||||||
|
runtimeDependencies = with pkgs; [
|
||||||
|
libglvnd # For libEGL
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
nativeBuildInputs = with pkgs; [
|
|
||||||
pkg-config
|
cargoArtifacts = craneLib.buildDepsOnly craneArgs;
|
||||||
autoPatchelfHook
|
cosmic-comp = craneLib.buildPackage (craneArgs // { inherit cargoArtifacts; });
|
||||||
cmake
|
in
|
||||||
];
|
{
|
||||||
buildInputs = with pkgs; [
|
apps.cosmic-comp = {
|
||||||
wayland
|
type = "app";
|
||||||
systemd # For libudev
|
program = lib.getExe self'.packages.default;
|
||||||
seatd # For libseat
|
};
|
||||||
libxkbcommon
|
|
||||||
libinput
|
checks.cosmic-comp = cosmic-comp;
|
||||||
mesa # For libgbm
|
packages.default = cosmic-comp;
|
||||||
fontconfig
|
|
||||||
stdenv.cc.cc.lib
|
devShells.default = pkgs.mkShell {
|
||||||
];
|
# Should there be packages here or use Nix purely for CI?
|
||||||
runtimeDependencies = with pkgs; [
|
LD_LIBRARY_PATH = lib.makeLibraryPath (__concatMap (d: d.runtimeDependencies) (__attrValues self'.checks));
|
||||||
libglvnd # For libEGL
|
};
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
cargoArtifacts = craneLib.buildDepsOnly pkgDef;
|
|
||||||
cosmic-comp = craneLib.buildPackage (pkgDef // {
|
|
||||||
inherit cargoArtifacts;
|
|
||||||
});
|
|
||||||
in {
|
|
||||||
checks = {
|
|
||||||
inherit cosmic-comp;
|
|
||||||
};
|
|
||||||
|
|
||||||
packages.default = cosmic-comp;
|
|
||||||
|
|
||||||
apps.default = flake-utils.lib.mkApp {
|
|
||||||
drv = cosmic-comp;
|
|
||||||
};
|
|
||||||
|
|
||||||
devShells.default = pkgs.mkShell rec {
|
|
||||||
inputsFrom = builtins.attrValues self.checks.${system};
|
|
||||||
LD_LIBRARY_PATH = pkgs.lib.strings.makeLibraryPath (builtins.concatMap (d: d.runtimeDependencies) inputsFrom);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
nixConfig = {
|
|
||||||
# Cache for the Rust toolchain in fenix
|
|
||||||
extra-substituters = [ "https://nix-community.cachix.org" ];
|
|
||||||
extra-trusted-public-keys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" ];
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue