make flake generic over platform

This commit is contained in:
778a69cd 2023-11-06 17:56:12 +01:00
parent 4fb5be561f
commit a0b001576b

View file

@ -8,56 +8,69 @@
outputs = { self, nixpkgs, nix-filter }: outputs = { self, nixpkgs, nix-filter }:
let let
system = "x86_64-linux"; forAllSystems = f: nixpkgs.lib.genAttrs
pkgs = import nixpkgs { inherit system; }; [ "x86_64-linux" "aarch64-linux" ]
(system: f system);
nixpkgsFor = forAllSystems (
system:
import nixpkgs { inherit system; }
);
filter = nix-filter.lib; filter = nix-filter.lib;
in in
{ {
packages.x86_64-linux = { packages = forAllSystems (system:
mobilizon = pkgs.callPackage ./. { let
src = filter { pkgs = nixpkgsFor.${system};
root = ./.; in
exclude = [ {
(filter.matchExt "nix") mobilizon = pkgs.callPackage ./. {
"js" src = filter {
]; root = ./.;
exclude = [
(filter.matchExt "nix")
"js"
];
};
src-config = ./config;
mobilizon-js = self.packages.x86_64-linux.mobilizon-frontend;
}; };
src-config = ./config;
mobilizon-js = self.packages.x86_64-linux.mobilizon-frontend;
};
mobilizon-frontend = pkgs.callPackage ./js { inherit filter; }; mobilizon-frontend = pkgs.callPackage ./js { inherit filter; };
default = self.packages.x86_64-linux.mobilizon; default = self.packages.x86_64-linux.mobilizon;
# Update local Mobilizon definition # Update local Mobilizon definition
update = update =
pkgs.writeShellScriptBin "update" '' pkgs.writeShellScriptBin "update" ''
set -eou pipefail set -eou pipefail
${pkgs.mix2nix}/bin/mix2nix ./mix.lock > mix.nix ${pkgs.mix2nix}/bin/mix2nix ./mix.lock > mix.nix
''; '';
}; });
devShells.x86_64-linux.default = devShells = forAllSystems (system:
pkgs.mkShell { let pkgs = nixpkgsFor.${system};
buildInputs = with pkgs; [ in {
elixir default =
mix2nix pkgs.mkShell {
cmake buildInputs = with pkgs; [
imagemagick elixir
(yarn.override { mix2nix
nodejs = nodejs-18_x; cmake
}) imagemagick
yarn2nix (yarn.override {
nodejs-18_x nodejs = nodejs-18_x;
]; })
}; yarn2nix
nodejs-18_x
];
};
});
checks.x86_64-linux = { checks = forAllSystems (system: {
inherit (self.packages.x86_64-linux) mobilizon update; inherit (self.packages.${system}) mobilizon update;
}; });
lib = { lib = {
# Patch the logos in the source tree of a mobilizon-frontend package before building. # Patch the logos in the source tree of a mobilizon-frontend package before building.
@ -67,7 +80,6 @@
inherit (icons) logo favicon; inherit (icons) logo favicon;
in in
old: { old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.imagemagick ];
postPatch = '' postPatch = ''
cp '${logo}' src/assets/logo.svg cp '${logo}' src/assets/logo.svg