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