Nix flake setup to run ghcs from ghcs.nix
The snippet can be accessed without any authentication.
Authored by
Douglas Wilson
Edited
snippetfile1.txt 1.01 KiB
{
nixConfig = {
extra-substituters = [
"https://ghc.cachix.org"
];
extra-trusted-public-keys = [
"ghc.cachix.org-1:a751hwq9ydeP3Nr6h84iA9zSjxg9Z3uznqi4YBGjsiw="
];
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
ghcs-nix = {
url = "gitlab:bgamari/ghcs-nix?host=gitlab.haskell.org";
flake = false;
};
flake-utils = {
url = "github:numtide/flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{
self,
nixpkgs, ghcs-nix, flake-utils,
...
}: with builtins; let
ghcs = import ghcs-nix;
in {
lib = nixpkgs.lib // flake-utils.lib;
apps.x86_64-linux = self.lib.mapAttrs' (n: drv: {
name = replaceStrings ["."] ["_"] "ghc-${n}"; # dots don't work well when using nix run in bash
value = self.lib.mkApp {
inherit drv;
exePath = "/bin/ghc";
};
}) ghcs.ghcs_hadrian;
};
}
# example:
# nix run --impure .#ghc-9.2.2 -- -e 'putStrLn "hello world"' +RTS -s
Please register or sign in to comment