78
flake.nix
78
flake.nix
@@ -1,42 +1,82 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
haskellNix.url = "github:input-output-hk/haskell.nix";
|
||||
# nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
nixpkgs.follows = "haskellNix/nixpkgs-unstable";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, ... }@inputs:
|
||||
outputs = { self, nixpkgs, haskellNix, ... }@inputs:
|
||||
let
|
||||
supportedSystems = [
|
||||
"aarch64-darwin" "aarch64-linux"
|
||||
"x86_64-darwin" "x86_64-linux"
|
||||
];
|
||||
|
||||
overlays = [
|
||||
haskellNix.overlay
|
||||
(final: _prev: {
|
||||
# This overlay adds our project to pkgs
|
||||
qbe-hs = final.haskell-nix.project' {
|
||||
src = ./.;
|
||||
compiler-nix-name = "ghc912";
|
||||
# This is used by `nix develop .` to open a shell for use with
|
||||
# `cabal`, `hlint` and `haskell-language-server`
|
||||
shell.tools = {
|
||||
cabal = {};
|
||||
# hlint = {};
|
||||
# haskell-language-server = {};
|
||||
};
|
||||
# Non-Haskell shell tools go here
|
||||
shell.buildInputs = with final; [
|
||||
gcc
|
||||
qbe
|
||||
];
|
||||
# passthru = { inherit (final) qbe; };
|
||||
# This adds `js-unknown-ghcjs-cabal` to the shell.
|
||||
# shell.crossPlatforms = p: [p.ghcjs];
|
||||
};
|
||||
})
|
||||
];
|
||||
|
||||
each-system = f: nixpkgs.lib.genAttrs supportedSystems (system: f rec {
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
inherit system overlays;
|
||||
};
|
||||
inherit (pkgs) lib;
|
||||
inherit system;
|
||||
});
|
||||
|
||||
# haskell-flake
|
||||
hf =
|
||||
let
|
||||
keys = [
|
||||
"packages" "apps" "devShells"
|
||||
"hydraJobs" "ciJobs" "checks"
|
||||
];
|
||||
in nixpkgs.lib.genAttrs keys
|
||||
(k: each-system ({ pkgs, ... }: (pkgs.qbe-hs.flake {}).${k}));
|
||||
in {
|
||||
# Exposed as a REPL convenience.
|
||||
_pkgs = each-system ({ pkgs, ... }: pkgs);
|
||||
|
||||
packages = each-system ({ pkgs, ... }: {
|
||||
# default = pkgs.callPackage ./default.nix {};
|
||||
});
|
||||
packages = each-system ({ pkgs, system, ... }:
|
||||
hf.packages.${system} // {
|
||||
default = hf.packages.${system}."qbe:lib:qbe";
|
||||
});
|
||||
|
||||
devShells = each-system ({ pkgs, system, ... }: {
|
||||
default = pkgs.haskellPackages.developPackage {
|
||||
root = ./.;
|
||||
modifier = drv:
|
||||
pkgs.haskell.lib.addBuildTools
|
||||
drv
|
||||
(with pkgs; [
|
||||
cabal-install
|
||||
qbe
|
||||
gcc
|
||||
]);
|
||||
};
|
||||
});
|
||||
devShells = each-system
|
||||
({ pkgs, system, ... }: hf.devShells.${system});
|
||||
};
|
||||
|
||||
nixConfig = {
|
||||
extra-substituters = [
|
||||
"https://cache.iog.io"
|
||||
"https://cache.zw3rk.com"
|
||||
];
|
||||
extra-trusted-public-keys = [
|
||||
"hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="
|
||||
"loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk="
|
||||
];
|
||||
allow-import-from-derivation = "true";
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user