Skip to content

Commit

Permalink
Use static-haskell-nix to generate static executables
Browse files Browse the repository at this point in the history
  • Loading branch information
FPtje committed Jun 30, 2024
1 parent 2338565 commit 9ff0259
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 14 deletions.
28 changes: 23 additions & 5 deletions flake.lock

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

27 changes: 23 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
{
description = "glualint - Linter and pretty printer for Garry's Mod's variant of Lua.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixpkgs = {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
flake = true;
# This is specifically pinned to be the same as the nixpkgs used by static-haskell-nix. That
# ensures that the caches from nh2 can be reused.
rev = "ede5282c487a1fd2de64303ba59adad6726f1225";
};
flake-utils.url = "github:numtide/flake-utils";
static-haskell-nix = {
url = "github:nh2/static-haskell-nix/fp/fix-callPackage-dynamic-executables";
flake = false;
};
};

nixConfig = {
Expand All @@ -11,13 +23,20 @@
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= glualint.cachix.org-1:wHSvobqyCtsGg5tvumXl2SKi998JKhEZbbQeupxHHeY=";
};

outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system:
outputs = { self, nixpkgs, flake-utils, static-haskell-nix}: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.${system}.glualint ];
overlays = [ (import ./nix/overlay.nix) ];
};

# Use the default.nix in static-haskell-nix/survey to build a statically linked glualint
survey = import (static-haskell-nix + "/survey") {
normalPkgs = pkgs;
compiler = "ghc965";
};
staticHaskellPackages = survey.haskellPackages.extend (pkgs.callPackage nix/haskell-overlay.nix {});

# Function to build a devshell for glualint
mkDevShell = mkBuildInputs: pkgs.glualintPkgs.haskellPackages.shellFor {
packages = p: [ p.glualint ];
Expand All @@ -29,7 +48,7 @@

packages = {
glualint = pkgs.glualintPkgs.haskellPackages.glualint;
glualint-static = pkgs.glualintPkgs.staticHaskellPackages.glualint;
glualint-static = staticHaskellPackages.glualint;
default = self.packages.${system}.glualint-static;
};

Expand Down
6 changes: 3 additions & 3 deletions nix/haskell-overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ let
# https://github.com/UU-ComputerScience/uuagc/pull/11
uuagc-source = fetchFromGitHub
{
owner = "FPtje";
owner = "UU-ComputerScience";
repo = "uuagc";
rev = "93783365b8e0771b092b9d99264227ca7c5d0823";
sha256 = "sha256-hvJ/GShwR1AvSofPmmR4FJMPUwUaCMiL1l1CKcKvQw0=";
rev = "7d1dcacb18846820f9f56bbf94209fd1c630fb97";
sha256 = "sha256-TbJbSRvGG/U5SCLgVICx82d5g2m42rZGFwuT4pX6a30=";
};
in
{
Expand Down
4 changes: 2 additions & 2 deletions nix/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ final: previous:
haskellOverlay = final.callPackage ./haskell-overlay.nix {};

haskellPackages =
previous.haskell.packages.ghc94.extend final.glualintPkgs.haskellOverlay;
previous.haskell.packages.ghc965.extend final.glualintPkgs.haskellOverlay;

staticHaskellPackages =
previous.pkgsStatic.haskell.packages.ghc94.extend final.glualintPkgs.haskellOverlay;
previous.pkgsStatic.haskell.packages.ghc965.extend final.glualintPkgs.haskellOverlay;
};
}

0 comments on commit 9ff0259

Please sign in to comment.