mirror of
https://gitlab.com/d3tn/ud3tn.git
synced 2026-08-13 12:33:27 +02:00
nix: Add forAllSystems function to build multiple architectures
Instead of defining everything repeatedly by hand, the function forAllSystems function is introduced to build for several architectures at once. Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
This commit is contained in:
parent
507a056ca2
commit
2991a5cfcb
1 changed files with 35 additions and 23 deletions
58
flake.nix
58
flake.nix
|
|
@ -3,29 +3,41 @@
|
|||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs }: {
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
systems = [
|
||||
"aarch64-darwin"
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"x86_64-linux"
|
||||
];
|
||||
|
||||
apps.x86_64-linux.default = {
|
||||
type = "app";
|
||||
program = "${self.packages.x86_64-linux.ud3tn}/bin/ud3tn";
|
||||
forAllSystems = fn: nixpkgs.lib.genAttrs systems (
|
||||
system: fn rec {
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
}
|
||||
);
|
||||
in
|
||||
{
|
||||
apps = forAllSystems ({ pkgs, ... }: {
|
||||
default = {
|
||||
type = "app";
|
||||
program = "${self.packages.${pkgs.system}.ud3tn}/bin/ud3tn";
|
||||
};
|
||||
});
|
||||
|
||||
packages = forAllSystems ({ pkgs, ... }:
|
||||
import ./nix/packages.nix { inherit pkgs; }
|
||||
);
|
||||
|
||||
devShells = forAllSystems ({ pkgs, ... }: {
|
||||
default = import ./nix/shell.nix { pkgs = pkgs.extend self.overlays.default; };
|
||||
});
|
||||
|
||||
formatter = forAllSystems ({ pkgs, ... }: pkgs.nixpkgs-fmt);
|
||||
|
||||
overlays.default = final: prev: {
|
||||
inherit (self.packages.${final.system}) ud3tn pyd3tn python-ud3tn-utils;
|
||||
};
|
||||
};
|
||||
|
||||
packages.x86_64-linux =
|
||||
let
|
||||
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||
in
|
||||
import ./nix/packages.nix { inherit pkgs; };
|
||||
|
||||
devShells.x86_64-linux.default =
|
||||
let
|
||||
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||
in
|
||||
import ./nix/shell.nix { pkgs = pkgs.extend self.overlays.default; };
|
||||
|
||||
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt;
|
||||
|
||||
overlays.default = final: prev: {
|
||||
inherit (self.packages.${final.system}) ud3tn pyd3tn python-ud3tn-utils;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue