Skip to content

Commit

Permalink
Eliminate mixed Nixpkgs
Browse files Browse the repository at this point in the history
There were two Nixpkgs inputs, with one being used solely to get a particular version of Stack. This now “compromises”
on the same release of Nixpkgs as used for Stack, but from the haskell.nix project to have a consistent package set.

There are also a few other version bumps here (because once you change an uncached input, you might as well upgrade everything):

- bump LTS to 22.43 (GHC 9.6.6 from 9.6.5)
- bump HLS to 2.9 (this is now transitively included via the haskell.nix input)
- bump hpack to 0.36.0 (this is actually the minimum bound for the
  version of Stack we use, so the previous setting was inconsistent)
  • Loading branch information
sellout committed Dec 7, 2024
1 parent cece289 commit 65af116
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"haskell.toolchain": {
"cabal": "3.10.3.0",
"hls": "2.8.0.0",
"hls": "2.9.0.0",
"stack": "2.15.7"
}
}
90 changes: 54 additions & 36 deletions flake.lock

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

33 changes: 15 additions & 18 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@

inputs = {
haskellNix.url = "github:input-output-hk/haskell.nix";
nixpkgs-haskellNix.follows = "haskellNix/nixpkgs-unstable";
nixpkgs-release.url = "github:NixOS/nixpkgs/release-24.05";
nixpkgs.follows = "haskellNix/nixpkgs-2405";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = {
self,
haskellNix,
nixpkgs-haskellNix,
nixpkgs-release,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachSystem [
Expand All @@ -28,32 +26,32 @@
(system: let
## It’s much easier to read from a JSON file than to have JSON import from some other file, so we extract some
## configuration from the VS Code settings to avoid duplication.
vscodeSettings = nixpkgs-release.lib.importJSON ./.vscode/settings.json;
vscodeSettings = nixpkgs.lib.importJSON ./.vscode/settings.json;
versions =
vscodeSettings."haskell.toolchain"
## There are some things we want to pin that the VS Code Haskell extension doesn’t let us control.
// {
hpack = "0.35.2";
ormolu = "0.7.2.0";
};
pkgs = import nixpkgs-haskellNix {
hpack = "0.36.0";
ormolu = "0.7.2.0";
};
pkgs = import nixpkgs {
inherit system;
inherit (haskellNix) config;
overlays = [
haskellNix.overlay
(import ./nix/dependencies.nix {inherit nixpkgs-release;})
(import ./nix/dependencies.nix)
];
};
unison-project = import ./nix/unison-project.nix {
inherit (nixpkgs-haskellNix) lib;
inherit (nixpkgs) lib;
inherit (pkgs) haskell-nix;
};
haskell-nix-flake = import ./nix/haskell-nix-flake.nix {
inherit pkgs unison-project versions;
inherit (nixpkgs-haskellNix) lib;
inherit (nixpkgs) lib;
};
renameAttrs = fn:
nixpkgs-haskellNix.lib.mapAttrs' (name: value: {
nixpkgs.lib.mapAttrs' (name: value: {
inherit value;
name = fn name;
});
Expand All @@ -71,11 +69,10 @@
all = pkgs.symlinkJoin {
name = "all";
paths = let
all-other-packages =
builtins.attrValues (builtins.removeAttrs self.packages."${system}" [
"all"
"docker-ucm" # this package doesn’t produce a directory
]);
all-other-packages = builtins.attrValues (builtins.removeAttrs self.packages."${system}" [
"all"
"docker-ucm" # this package doesn’t produce a directory
]);
devshell-inputs =
builtins.concatMap
(devShell: devShell.buildInputs ++ devShell.nativeBuildInputs)
Expand Down
22 changes: 7 additions & 15 deletions nix/dependencies.nix
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
{nixpkgs-release}: final: prev: let
pinned-pkgs = import nixpkgs-release {inherit (final) system;};
in {
stack = pinned-pkgs.stack;

final: prev: {
## See https://docs.haskellstack.org/en/stable/nix_integration/#supporting-both-nix-and-non-nix-developers for an
## explanation of this package.
stack-wrapped = final.symlinkJoin {
name = "stack"; # will be available as the usual `stack` in terminal
paths = [final.stack];
## explanation of this derivation.
stack = final.symlinkJoin {
inherit (prev.stack) version;
name = "stack";
paths = [prev.stack];
buildInputs = [final.makeWrapper];
postBuild = ''
wrapProgram $out/bin/stack \
--add-flags "\
--no-nix \
--system-ghc \
--no-install-ghc \
"
wrapProgram $out/bin/stack --add-flags "--no-nix --system-ghc --no-install-ghc"
'';
};
}
4 changes: 2 additions & 2 deletions nix/haskell-nix-flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
pkgs.gettext # for envsubst, used by unison-src/builtin-tests/interpreter-tests.sh
pkgs.hpack
pkgs.pkg-config
pkgs.stack-wrapped
pkgs.stack
];
# workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/11042
shellHook = ''
Expand All @@ -45,7 +45,6 @@
(args.tools or {})
// {
cabal = {version = versions.cabal;};
ormolu = {version = versions.ormolu;};
haskell-language-server = {
version = versions.hls;
modules = [
Expand All @@ -64,6 +63,7 @@
constraints: ormolu == ${versions.ormolu}
'';
};
ormolu = {version = versions.ormolu;};
};
};

Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ packages:
- unison-syntax
- yaks/easytest

resolver: lts-22.26
resolver: lts-22.43

extra-deps:
# This custom Haskeline alters ANSI rendering on Windows.
Expand Down
8 changes: 4 additions & 4 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ packages:
hackage: network-udp-0.0.0@sha256:408d2d4fa1a25e49e95752ee124cca641993404bb133ae10fb81daef22d876ae,1075
snapshots:
- completed:
sha256: 8e7996960d864443a66eb4105338bbdd6830377b9f6f99cd5527ef73c10c01e7
size: 719128
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/26.yaml
original: lts-22.26
sha256: 08bd13ce621b41a8f5e51456b38d5b46d7783ce114a50ab604d6bbab0d002146
size: 720271
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/43.yaml
original: lts-22.43

0 comments on commit 65af116

Please sign in to comment.