Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a nix flake #165

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,9 @@ doc/icfp-2012.html
download/*.html
gf-book/index.html
src/www/gf-web-api.html
.devenv
.direnv
result
.vscode
.envrc
.pre-commit-config.yaml
252 changes: 252 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

110 changes: 110 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
systems.url = "github:nix-systems/default";
devenv.url = "github:cachix/devenv";
};

nixConfig = {
extra-trusted-public-keys =
"devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=";
extra-substituters = "https://devenv.cachix.org";
};

outputs = { self, nixpkgs, devenv, systems, ... }@inputs:
let forEachSystem = nixpkgs.lib.genAttrs (import systems);
in {
packages = forEachSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
haskellPackages = pkgs.haskell.packages.ghc925.override {
overrides = self: _super: {
cgi = pkgs.haskell.lib.unmarkBroken (pkgs.haskell.lib.dontCheck
(self.callHackage "cgi" "3001.5.0.1" { }));
};
};

in {
devenv-up = self.devShells.${system}.default.config.procfileScript;
gf = pkgs.haskell.lib.overrideCabal
(haskellPackages.callCabal2nixWithOptions "gf" self "--flag=-server"
{ }) (_old: {
# Fix utf8 encoding problems
patches = [
# Already applied in master
# (
# pkgs.fetchpatch {
# url = "https://github.com/anka-213/gf-core/commit/6f1ca05fddbcbc860898ddf10a557b513dfafc18.patch";
# sha256 = "17vn3hncxm1dwbgpfmrl6gk6wljz3r28j191lpv5zx741pmzgbnm";
# }
# )
./nix/expose-all.patch
./nix/revert-new-cabal-madness.patch
];
jailbreak = true;
# executableSystemDepends = [
# (pkgs.ncurses.override { enableStatic = true; })
# ];
# executableHaskellDepends = [ ];
});
});

devShells = forEachSystem (system:
let pkgs = nixpkgs.legacyPackages.${system};

in with pkgs.darwin.apple_sdk.frameworks;
let
darwinPkgs =

if pkgs.stdenv.isDarwin then [ Cocoa pkgs.clang ] else [ ];
in {

default = devenv.lib.mkShell {
inherit inputs pkgs;
modules = [{
# https://devenv.sh/basics/
env.GREET = "devenv";

# https://devenv.sh/packages/
packages = [ pkgs.git pkgs.llvm ] ++ darwinPkgs;

# https://devenv.sh/scripts/
scripts.hello.exec = "echo hello from $GREET";

enterShell = ''
hello
git --version
'';

languages.haskell = {
enable = true;
# HLS fails to build on darwin and 9.2.5
languageServer = null;
package = pkgs.haskell.compiler.ghc925;
};

# https://devenv.sh/pre-commit-hooks/
pre-commit.hooks = {
# lint shell scripts
shellcheck.enable = true;
markdownlint.enable = true;
# lint nix
nixfmt.enable = true;
deadnix.enable = true;
nil.enable = true;
# statix.enable = true;
# format haskell
# ormolu.enable = true;
# cabal-fmt.enable = true;
# lint haskell
# hlint.enable = true;
};
# https://devenv.sh/processes/
# processes.ping.exec = "ping example.com";

# See full reference at https://devenv.sh/reference/options/
}];
};
});
};
}
2 changes: 1 addition & 1 deletion gf.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ library
build-depends:
-- GHC 8.0.2 to GHC 8.10.4
array >= 0.5.1 && < 0.6,
base >= 4.9.1 && < 4.17,
base >= 4.9.1 && < 4.18,
bytestring >= 0.10.8 && < 0.12,
containers >= 0.5.7 && < 0.7,
exceptions >= 0.8.3 && < 0.11,
Expand Down
12 changes: 12 additions & 0 deletions nix/expose-all.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/gf.cabal b/gf.cabal
index 0076e7638..8d3fe4b49 100644
--- a/gf.cabal
+++ b/gf.cabal
@@ -168,7 +168,6 @@ Library
GF.Text.Lexing
GF.Grammar.Canonical

- other-modules:
GF.Main
GF.Compiler
GF.Interactive
Loading
Loading