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

Simplify Stack usage in Nix #5486

Draft
wants to merge 6 commits into
base: trunk
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/bundle-ucm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: install stack
uses: unisonweb/actions/stack/install@main
with:
stack-version: 2.15.5
stack-version: 2.15.7

- name: build
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
if: steps.cache-ucm-binaries.outputs.cache-hit != 'true'
uses: unisonweb/actions/stack/install@main
with:
stack-version: 2.15.5
stack-version: 2.15.7

# Build deps, then build local code. Splitting it into two steps just allows us to see how much time each step
# takes.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/haddocks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: install stack
uses: unisonweb/actions/stack/install@main
with:
stack-version: 2.15.5
stack-version: 2.15.7

- name: build with haddocks
working-directory: unison
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-transcripts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: install stack
uses: unisonweb/actions/stack/install@main
with:
stack-version: 2.15.5
stack-version: 2.15.7

# One of the transcripts fails if the user's git name hasn't been set.
- name: set git user info
Expand Down
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"
}
}
92 changes: 57 additions & 35 deletions flake.lock

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

47 changes: 21 additions & 26 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,49 @@
};

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

outputs = {
self,
haskellNix,
nixpkgs-haskellNix,
nixpkgs-release,
flake-utils,
haskellNix,
nixpkgs,
self,
systems,
}:
flake-utils.lib.eachSystem [
"x86_64-linux"
"x86_64-darwin"
"aarch64-darwin"
]
flake-utils.lib.eachSystem (import systems)
(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 +67,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"
'';
};
}
Loading
Loading